[glibmm] Strip directory from filenames in enum.pl output
- From: Daniel Elstner <daniel src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glibmm] Strip directory from filenames in enum.pl output
- Date: Mon, 24 Aug 2009 10:03:47 +0000 (UTC)
commit 57ef81981096c378643c09ac6f1baf0a0fce6506
Author: Daniel Elstner <danielk openismus com>
Date: Mon Aug 24 12:02:52 2009 +0200
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.
ChangeLog | 11 +++++++++++
tools/enum.pl | 21 ++++++++++-----------
2 files changed, 21 insertions(+), 11 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 228d7b1..d7414f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2009-08-24 Daniel Elstner <danielk openismus com>
+
+ 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.
+
2009-08-21 Daniel Elstner <danielk openismus com>
Deprecate wrapper methods of deprecated functions
diff --git a/tools/enum.pl b/tools/enum.pl
index f1b6cbe..357931d 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=();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]