You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by jm...@apache.org on 2006/08/13 23:56:02 UTC
svn commit: r431252 - /spamassassin/branches/jm_re2c_hacks/rule2xs/re2xs
Author: jm
Date: Sun Aug 13 14:56:02 2006
New Revision: 431252
URL: http://svn.apache.org/viewvc?rev=431252&view=rev
Log:
more bug fixes for (nest(ed) alternations) in re2xs
Modified:
spamassassin/branches/jm_re2c_hacks/rule2xs/re2xs
Modified: spamassassin/branches/jm_re2c_hacks/rule2xs/re2xs
URL: http://svn.apache.org/viewvc/spamassassin/branches/jm_re2c_hacks/rule2xs/re2xs?rev=431252&r1=431251&r2=431252&view=diff
==============================================================================
--- spamassassin/branches/jm_re2c_hacks/rule2xs/re2xs (original)
+++ spamassassin/branches/jm_re2c_hacks/rule2xs/re2xs Sun Aug 13 14:56:02 2006
@@ -8,7 +8,7 @@
use File::Path;
use Getopt::Long;
-use constant MAX_RULES => 100;
+use constant MAX_RULES => 60;
our $NAME;
our $FORCE;
@@ -374,16 +374,17 @@
# print "FIXUP: $re\n";
my $output = "";
- my $TOK = qr([\{\^\$\"\(\[\|\\\)\.\+\*]);
+ my $TOK = qr([\{\^\$\"\(\)\[\|\\\.\+\*]);
my $STATE;
while ($re =~ /\G(.*?)($TOK)/gc) {
my $pre = $1;
my $tok = $2;
-
+
if (length($pre)) {
$output .= "\"$pre\"";
}
+
if ($tok eq "(") {
# Grouping
my $origpos = pos $re;
@@ -403,6 +404,9 @@
elsif ($tok eq "|") {
$output .= " | ";
}
+ elsif ($tok eq ")") {
+ $output .= " ) ";
+ }
elsif ($tok eq "[") {
# chars
if ($re =~ /\G(.*?)\]/gc) {
@@ -530,9 +534,12 @@
if (!defined(pos($re))) {
$output .= $re;
}
+ elsif (pos($re) <= length($re)) {
+ $output .= substr($re, pos($re));
+ }
# we hit end-of-string; in other words, it was a balanced re anyway
- # warn "JMD balanced $re => $output";
- return $output;
+ # warn "JMD fully balanced $re";
+ return $re;
}