Re: segfault in glib-mkenums
- From: Max Horn <max quendi de>
- To: Owen Taylor <otaylor redhat com>
- Cc: timj gtk org, Gtk Developers <gtk-devel-list gnome org>
- Subject: Re: segfault in glib-mkenums
- Date: Sun, 16 Sep 2001 01:06:22 +0200
At 18:35 Uhr -0400 15.09.2001, Owen Taylor wrote:
Max Horn <max quendi de> writes:
A work around for the crash in glib-mkenums, that I believe should
work on other OSes, too, and will even speed up glib-mkenums a bit is
to change the three occurences of
while (m@/\*([^*]|\*[^/*])*\**$ x) {
my $new;
defined ($new = <>) || die "Unmatched comment in $ARGV";
$_ .= $new;
}
Hmmm, this got "deimproved" from the original version in
gtk+/gtk/makeenums.pl in GTK+-1.2:
while (m@/\*
([^*]|\*(?!/))*$
@x) {
my $new;
defined ($new = <$file>) || die "Unmatched comment";
$_ .= $new;
}
Ah I already wondered why the "x" option was specified if no
comments/formatting are added to the regexp :)
I believe the difference in efficiency here is that Perl can be
smarter with fixed length repeating expression of the form:
(a|b)*
Than one with a variable length repeating expression of the
form:
(a|bb)*
Yeah; and I suspect the heavy recursion that kills me is at least
partly due to this.
[...]
>
while (m@/\*([^*]|\*[^/*])*\**$ x) {
my $new;
defined ($new = <>) || die "Unmatched comment in $ARGV";
next unless ($new =~ m \*/$@);
$_ .= $new;
}
This will skip intermediate lines in multi-line comments. Unless there
is a flaw with this that I overlooked, it would be cool if it could be
added to glib-mkenums in CVS! Thanks.
This doesn't quite work, because we actually need the complete
comment to handle multi-line pseudocomments.
typedef enum {
foo_blah_abcd, /<*
nick=blah_abcd
*>/
foo_blah_efgh
} Foo;
AAAhh! OK, I was not aware of these pseudo comments, I only took a
quick look at the code. That of course explains the current code.
You could write something like:
while (m@/\*([^*]|\*[^/*])*\**$ x) {
my $new;
defined ($new = <>) || die "Unmatched comment in $ARGV";
next unless ($new =~ m \*/$@);
$_ .= $new;
}
if ([$_ ends in an open comment]) {
while (1) {
my $new;
defined ($new = <$file>) || die "Unmatched comment in $ARGV";
$_ .= $new;
break if ([$new closes comment] && ![$new ends in an open comment]);
}
}
But the simpler n^2 algorithm with the makeenums.pl regex's should
work fine for comments up to a few hundred lines anyways.
Sadly, not at all for me :/. I know I know it is not your fault :) It
is Perl who uses excessivly recursion.
Getting Perl to compile is not that easy, I will have to reformat one
partition to UFS file system, since Perl won't build on a HFS+
filesystem, which apple machines usually use ... <sigh>
Anyway, for now I can workaround this problem, there are more
pressing issues I need to look into :)
Thanks fo ryour help,
Max
--
-----------------------------------------------
Max Horn
Software Developer
email: <mailto:max quendi de>
phone: (+49) 6151-494890
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]