summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Elstner <daniel@src.gnome.org>2006-11-28 22:20:28 +0000
committerDaniel Elstner <daniel@src.gnome.org>2006-11-28 22:20:28 +0000
commiteb8612047832e32122ea4b06954cace14cb345db (patch)
treeb4d33970e03208897b60256c382f43ce322a6258
parent6a6999e9a3d903f4c8c10b4dcc0d58ea40e187bd (diff)
downloadglibmm-eb8612047832e32122ea4b06954cace14cb345db.tar.gz
Ignore whitespace in front of an enum typedef. This fixes parsing of
* tools/enum.pl (parse): Ignore whitespace in front of an enum typedef. This fixes parsing of HildonTelephoneEditorFormat in hildon-libs. * tools/pm/Enum.pm (parse_values): Check whether the enumeration constants actually have a common module prefix before attempting to remove it. This fixes the incorrect parsing of inconsistently named enums in hildon-libs.
-rw-r--r--ChangeLog10
-rw-r--r--tools/enum.pl2
-rw-r--r--tools/pm/Enum.pm30
3 files changed, 37 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index a443c9be..12606a81 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2006-11-27 Daniel Elstner <danielk@openismus.com>
+ * tools/enum.pl (parse): Ignore whitespace in front of an enum
+ typedef. This fixes parsing of HildonTelephoneEditorFormat in
+ hildon-libs.
+ * tools/pm/Enum.pm (parse_values): Check whether the enumeration
+ constants actually have a common module prefix before attempting
+ to remove it. This fixes the incorrect parsing of inconsistently
+ named enums in hildon-libs.
+
+2006-11-27 Daniel Elstner <danielk@openismus.com>
+
* tools/enum.pl (form_names): Break the loop if the length of the
common prefix reaches zero. This fixes the infinite loop when
processing the inconsistently named enumeration constants of the
diff --git a/tools/enum.pl b/tools/enum.pl
index dd35dc3c..8cc6ff90 100644
--- a/tools/enum.pl
+++ b/tools/enum.pl
@@ -69,7 +69,7 @@ sub parse
s/','/\%\%COMMA\%\%/;
s/'}'/\%\%RBRACE\%\%/;
- if (/^typedef enum/ )
+ if (/^\s*typedef enum/ )
{
print ";; From $file\n\n" if (!$from);
$from=1;
diff --git a/tools/pm/Enum.pm b/tools/pm/Enum.pm
index e928bead..47485e15 100644
--- a/tools/pm/Enum.pm
+++ b/tools/pm/Enum.pm
@@ -79,6 +79,10 @@ sub parse_values($$)
{
my ($self, $value) = @_;
+ my $elem_names = [];
+ my $elem_values = [];
+ my $common_prefix = undef;
+
# break up the value statements
foreach(split(/\s*'*[()]\s*/, $value))
{
@@ -88,17 +92,35 @@ sub parse_values($$)
{
my ($name, $value) = ($1, $2);
- # cut off the module prefix, e.g. GTK_
- $name =~ s/^[^_]+_//;
+ # detect whether there is module prefix common to all names, e.g. GTK_
+ my $prefix = $1 if ($name =~ /^([^_]+_)/);
+
+ if (not defined($common_prefix))
+ {
+ $common_prefix = $prefix;
+ }
+ elsif ($prefix ne $common_prefix)
+ {
+ $common_prefix = "";
+ }
- push(@{$$self{elem_names}}, $name);
- push(@{$$self{elem_values}}, $value);
+ push(@$elem_names, $name);
+ push(@$elem_values, $value);
}
else
{
GtkDefs::error("Unknown value statement ($_) in $$self{c_type}\n");
}
}
+
+ if ($common_prefix)
+ {
+ # cut off the module prefix, e.g. GTK_
+ s/^$common_prefix// foreach (@$elem_names);
+ }
+
+ $$self{elem_names} = $elem_names;
+ $$self{elem_values} = $elem_values;
}
sub beautify_values($)