From 648204c8bc6a2cd0c345cc6cbf4dbaf6f400917e Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Mon, 25 Mar 2002 23:23:35 +0000 Subject: [PATCH] Fix various bugs and excessive stack usage that crept in the conversion Mon Mar 25 17:51:05 2002 Owen Taylor * glib-mkenums.in (parse_entries): Fix various bugs and excessive stack usage that crept in the conversion from gtk-mkenums. (#74431) --- gobject/ChangeLog | 6 ++++++ gobject/glib-mkenums.in | 40 ++++++++++++++-------------------------- 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/gobject/ChangeLog b/gobject/ChangeLog index 0c0044ec6..26ecc8a9a 100644 --- a/gobject/ChangeLog +++ b/gobject/ChangeLog @@ -1,3 +1,9 @@ +Mon Mar 25 17:51:05 2002 Owen Taylor + + * glib-mkenums.in (parse_entries): Fix various bugs and + excessive stack usage that crept in the conversion from + gtk-mkenums. (#74431) + Mon Mar 25 17:25:57 2002 Owen Taylor * gtype.c (g_type_free_instance): Wrap setting freed instance diff --git a/gobject/glib-mkenums.in b/gobject/glib-mkenums.in index c0e31ca0d..2f8bb0559 100755 --- a/gobject/glib-mkenums.in +++ b/gobject/glib-mkenums.in @@ -30,24 +30,23 @@ sub parse_entries { my $looking_for_name = 0; while (<$file>) { - - # read lines until comment end is matched - while (m@/\*([^*]|\*[^/*])*\**$@x) { + # read lines until we have no open comments + while (m@/\*([^*]|\*(?!/))*$@) { my $new; - defined ($new = <>) || die "Unmatched comment in $ARGV"; + defined ($new = <$file>) || die "Unmatched comment in $ARGV"; $_ .= $new; } # strip comments w/o options - s@/\*[^<]([^*]|\*[^/*])*\**\*/@@gx; - + s@/\*(?!<) + ([^*]+|\*(?!/))* + \*/@@gx; + # strip newlines - s/\n//; + s@\n@ @; # skip empty lines next if m@^\s*$@; -# print STDERR "xxx $_\n"; - if ($looking_for_name) { if (/^\s*(\w+)/) { $enumname = $1; @@ -60,15 +59,6 @@ sub parse_entries { my $file= "../$1"; open NEWFILE, $file or die "Cannot open include file $file: $!\n"; - # read lines until comment end is matched - while (m@/\*([^*]|\*[^/*])*\**$@x) { - my $new; - defined ($new = <>) || die "Unmatched comment in $file_name"; - $_ .= $new; - } - # strip comments w/o options - s@/\*[^<]([^*]|\*[^/*])*\**\*/@@gx; - if (parse_entries (\*NEWFILE, $NEWFILE)) { return 1; } else { @@ -100,8 +90,6 @@ sub parse_entries { @x) { my ($name, $value, $options) = ($1,$2,$3); -# print STDERR "xxx \"$name\" \"$value\" \"$otions\"\n"; - if (!defined $flags && defined $value && $value =~ /<) { $firstenum = 1; # Flag to print filename at next enum } - # read lines until comment end is matched - while (m@/\*([^*]|\*[^/*])*\**$@x) { + # read lines until we have no open comments + while (m@/\*([^*]|\*(?!/))*$@) { my $new; defined ($new = <>) || die "Unmatched comment in $ARGV"; $_ .= $new; } # strip comments w/o options - s@/\*[^<]([^*]|\*[^/*])*\**\*/@@gx; - -# print STDERR "xxx $_\n"; - + s@/\*(?!<) + ([^*]+|\*(?!/))* + \*/@@gx; + if (m@^\s*typedef\s+enum\s* ({)?\s* (?:/\*<