cvsuser 02/08/12 14:12:45
Modified: . assemble.pl
Log:
Redo comment stripping regexp to a match and substr to run in finite time
on 5.005_03. (Was taking forever, presumably due to backtracking through
(?:) constructions)
Revision Changes Path
1.86 +11 -1 parrot/assemble.pl
Index: assemble.pl
===================================================================
RCS file: /cvs/public/parrot/assemble.pl,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -w -r1.85 -r1.86
--- assemble.pl 10 Aug 2002 23:12:32 -0000 1.85
+++ assemble.pl 12 Aug 2002 21:12:45 -0000 1.86
@@ -463,7 +463,17 @@
$self->{pc}++;
return if $line=~/^\s*$/ or $line=~/^\s*#/; # Filter out the comments and blank
lines
$line=~s/^\s+//; # Remove leading whitespace
- $line=~s/^((?:[^'"]+|$str_re)*)#.*$/$1/o; # Remove trailing comments
+ # Doing it this way chews infinite CPU on 5.005_03. I suspect 5.6.1
+ # introduces some cunning optimisation in the regexp engine to avoid
+ # backtracking through the brackets with the multiple levels of *s
+ #
+ # $line=~s/^((?:[^'"]+|$str_re)*)#.*$/$1/; # Remove trailing comments
+ #
+ # This is 5.005_03 friendly:
+ if ($line=~ /^(?:[^'"]+|$str_re)#/g) {
+ # pos will point to the character after the #
+ substr ($line, (pos $line) - 1) = '';
+ }
$line=~s/\s+\z//; # Remove trailing whitespace
#
# Accumulate lines that only have labels until an instruction is found.