Author: chromatic
Date: Fri Nov  7 19:44:37 2008
New Revision: 32444

Modified:
   trunk/src/string.c
   trunk/t/op/string_cs.t

Log:
[src] When escaping non-ASCII characters in a string, increment the length of
the result string for each ASCII character encountered (fixes RT #60396,
reported by Patrick Michaud, and RT #58820, reported by ihrd).

Modified: trunk/src/string.c
==============================================================================
--- trunk/src/string.c  (original)
+++ trunk/src/string.c  Fri Nov  7 19:44:37 2008
@@ -2394,8 +2394,8 @@
                     break;
             }
             if (c >= 0x20) {
-                dp[i++] = (unsigned char)c;
-                PARROT_ASSERT(i < charlen);
+                dp[i++]         = (unsigned char)c;
+                result->bufused = result->strlen = i;
                 continue;
             }
         }

Modified: trunk/t/op/string_cs.t
==============================================================================
--- trunk/t/op/string_cs.t      (original)
+++ trunk/t/op/string_cs.t      Fri Nov  7 19:44:37 2008
@@ -1,12 +1,12 @@
 #!perl
-# Copyright (C) 2001-2007, The Perl Foundation.
+# Copyright (C) 2001-2008, The Perl Foundation.
 # $Id$
 
 use strict;
 use warnings;
 use lib qw( . lib ../lib ../../lib );
 use Test::More;
-use Parrot::Test tests => 50;
+use Parrot::Test tests => 51;
 use Parrot::Config;
 
 =head1 NAME
@@ -827,6 +827,16 @@
 \u2001\u2002\u2003\u2004\x{e01ef}\u0114
 OUTPUT
 
+pir_output_is(<<'CODE', <<'OUTPUT', 'escape unicode w/ literal 0, RT #60396' );
+.sub 'main'
+    $S0 = unicode:"x/\u0445\u0440\u0435\u043d\u044c_09-10.txt"
+    $S1 = escape $S0
+    say $S1
+.end
+CODE
+x/\u0445\u0440\u0435\u043d\u044c_09-10.txt
+OUTPUT
+
 # Local Variables:
 #   mode: cperl
 #   cperl-indent-level: 4

Reply via email to