summaryrefslogtreecommitdiff
path: root/tools/enum.pl
diff options
context:
space:
mode:
authorDaniel Elstner <danielk@openismus.com>2009-08-24 12:02:52 +0200
committerDaniel Elstner <danielk@openismus.com>2009-08-24 12:02:52 +0200
commit57ef81981096c378643c09ac6f1baf0a0fce6506 (patch)
tree00194fef02c0647eb55d6260b4f0ff24267be11a /tools/enum.pl
parent28a59be69b37e2de2e6edf9e09d6ed6287911a14 (diff)
downloadglibmm-57ef81981096c378643c09ac6f1baf0a0fce6506.tar.gz
Strip directory from filenames in enum.pl output
* tools/enum.pl: Use File::Spec module. Reduce the backslashitis in a number of regular expressions by replacing the slash used as the delimiter with a less troublesome character. (parse): Only print the basename component of the filename. (process): Put \Q...\E quoting escapes around a variable reference within a regular expression to protect meta-characters.
Diffstat (limited to 'tools/enum.pl')
-rwxr-xr-xtools/enum.pl21
1 files changed, 10 insertions, 11 deletions
diff --git a/tools/enum.pl b/tools/enum.pl
index f1b6cbee..357931dd 100755
--- a/tools/enum.pl
+++ b/tools/enum.pl
@@ -5,6 +5,7 @@
# Usage: ./enum.pl /gnome/head/cvs/gconf/gconf/*.h > gconf_enums.defs
use warnings;
+use File::Spec;
my %token;
$module="none";
@@ -27,10 +28,8 @@ foreach $file (@ARGV)
exit;
-
-
# parse enums from C
-sub parse
+sub parse ($)
{
my ($file)=@_;
@@ -46,7 +45,7 @@ sub parse
if($comment)
{
# end of multiline comment
- $comment = 0 if(/\*\//);
+ $comment = 0 if(m!\*/!);
next;
}
@@ -58,10 +57,10 @@ sub parse
next if($deprecated > 0);
# filter single-line comments
- s/\/\*.*\*\///g;
+ s!/\*.*?\*/!!g;
# begin of multiline comment
- if(/\/\*/)
+ if(m!/\*!)
{
$comment = 1;
next;
@@ -71,7 +70,8 @@ sub parse
s/'}'/\%\%RBRACE\%\%/;
if (/^\s*typedef enum/ )
{
- print ";; From $file\n\n" if (!$from);
+ my $basename = File::Spec->splitpath($file);
+ print(';; From ', $basename, "\n\n") if (!$from);
$from=1;
$enum=1;
next;
@@ -87,9 +87,8 @@ sub parse
}
}
-
# convert enums to lisp
-sub process
+sub process ($$)
{
my ($line,$def)=@_;
@@ -98,13 +97,13 @@ sub process
my $c_name=$def;
$line=~s/\s+/ /g;
- $line=~s/\/\*.*\*\///g;
+ $line=~s!/\*.*\*/!!g;
$line=~s/\s*{\s*//;
my $entity = "enum";
$c_name =~ /^([A-Z][a-z]*)/;
$module = $1 if ($module eq "none");
- $def =~ s/$module//;
+ $def =~ s/\Q$module\E//;
@c_name=();
@name=();