develooper Front page | perl.perl5.porters | Postings from October 2003

[PATCH] Off-by-one error in regcomp.c

Thread Next
From:
Slaven Rezic
Date:
October 31, 2003 04:24
Subject:
[PATCH] Off-by-one error in regcomp.c
Message ID:
1067602571.12768@devpc01.iconmobile.de
In regexp error messages, file and line are not printed due to
an off-by-one error in regcomp.c. This patch fixes the problem and
changes the regmesg.t test.

Regards,
    Slaven

--- regcomp.c.orig	2003-10-31 13:07:52.000000000 +0100
+++ regcomp.c	2003-10-31 13:08:07.000000000 +0100
@@ -5045,7 +5045,7 @@ S_re_croak2(pTHX_ const char* pat1,const
     if (l1 > 512)
 	l1 = 512;
     Copy(message, buf, l1 , char);
-    buf[l1] = '\0';			/* Overwrite \n */
+    buf[l1-1] = '\0';			/* Overwrite \n */
     Perl_croak(aTHX_ "%s", buf);
 }
 
--- t/op/regmesg.t.orig	2003-10-31 13:12:15.000000000 +0100
+++ t/op/regmesg.t	2003-10-31 13:15:06.000000000 +0100
@@ -131,6 +131,7 @@ while (@death)
     chomp $@;
     $result =~ s/{\#}/$marker1/;
     $result =~ s/{\#}/$marker2/;
+    $result .= " at ";
     if ($@ !~ /^\Q$result/) {
 	print "# For $regex, expected:\n#  $result\n# Got:\n#  $@\n#\nnot ";
     }
@@ -164,6 +165,7 @@ while (@warning)
     }
     $result =~ s/{\#}/$marker1/;
     $result =~ s/{\#}/$marker2/;
+    $result .= " at ";
     if ($warning !~ /^\Q$result/)
     {
 	print <<"EOM";

-- 
Slaven Rezic - slaven <at> rezic <dot> de

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About