fix off-by-one that resulted in misparse of C</[\x{80}-\x{81}]/>
Gurusamy Sarathy [Wed, 24 Mar 1999 02:26:38 +0000 (02:26 +0000)]
p4raw-id: //depot/perl@3136

regcomp.c
t/pragma/utf8.t [new file with mode: 0755]

index a325b42..bacf2ca 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -2498,7 +2498,7 @@ regclassutf8(void)
                    e = strchr(PL_regcomp_parse++, '}');
                     if (!e)
                         FAIL("Missing right brace on \\x{}");
-                   value = scan_hex(PL_regcomp_parse + 1, e - PL_regcomp_parse, &numlen);
+                   value = scan_hex(PL_regcomp_parse, e - PL_regcomp_parse, &numlen);
                    PL_regcomp_parse = e + 1;
                }
                else {
diff --git a/t/pragma/utf8.t b/t/pragma/utf8.t
new file mode 100755 (executable)
index 0000000..e5b3bb5
--- /dev/null
@@ -0,0 +1,37 @@
+#!./perl 
+
+BEGIN {
+    chdir 't' if -d 't';
+    unshift @INC, '../lib';
+    $ENV{PERL5LIB} = '../lib';
+}
+
+print "1..3\n";
+
+my $test = 1;
+
+sub ok {
+    my ($got,$expect) = @_;
+    print "# expected [$expect], got [$got]\nnot " if $got ne $expect;
+    print "ok $test\n";
+}
+
+{
+    use utf8;
+    $_ = ">\x{263A}<"; 
+    s/([\x{80}-\x{10ffff}])/"&#".ord($1).";"/eg; 
+    ok $_, '>&#9786;<';
+    $test++;
+
+    $_ = ">\x{263A}<"; 
+    my $rx = "\x{80}-\x{10ffff}";
+    s/([$rx])/"&#".ord($1).";"/eg; 
+    ok $_, '>&#9786;<';
+    $test++;
+
+    $_ = ">\x{263A}<"; 
+    my $rx = "\\x{80}-\\x{10ffff}";
+    s/([$rx])/"&#".ord($1).";"/eg; 
+    ok $_, '>&#9786;<';
+    $test++;
+}