summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2012-02-07 10:54:22 -0500
committerDan Winship <danw@gnome.org>2012-02-07 13:32:22 -0500
commitf049262a6105ecad71e5515300cbb0239800b10d (patch)
tree34d126dc0f8f94678b8bea5e47ee4eb9c3059d84
parent808346c6abd1af04221308a1ef3abe98b7f062f4 (diff)
downloadglib-f049262a6105ecad71e5515300cbb0239800b10d.tar.gz
glib-mkenums: fix handling of forward enum declarations
Given typedef enum MyFoo MyFoo; glib-mkenums would get confused, not notice the ";", and then keep skipping lines until it found one that started with a "{", possibly even going into the next file. Fix it to just ignore those lines instead (and also, to error out if it hits eof while parsing an enum). https://bugzilla.gnome.org/show_bug.cgi?id=669595
-rwxr-xr-xgobject/glib-mkenums.in6
1 files changed, 6 insertions, 0 deletions
diff --git a/gobject/glib-mkenums.in b/gobject/glib-mkenums.in
index 34440aa04..b776e1f41 100755
--- a/gobject/glib-mkenums.in
+++ b/gobject/glib-mkenums.in
@@ -290,6 +290,9 @@ while (<>) {
([^*]+|\*(?!/))*
\*/@@gx;
+ # ignore forward declarations
+ next if /^\s*typedef\s+enum.*;/;
+
if (m@^\s*typedef\s+enum\s*
({)?\s*
(?:/\*<
@@ -321,6 +324,9 @@ while (<>) {
# Didn't have trailing '{' look on next lines
if (!defined $1 && !defined $4) {
while (<>) {
+ if (eof) {
+ die "Hit end of file while parsing enum in $ARGV";
+ }
if (s/^\s*\{//) {
last;
}