Author: leo
Date: Tue Nov 15 14:46:23 2005
New Revision: 10004
Modified:
trunk/src/string.c
trunk/t/op/string_cs.t
Log:
strings - string_escape minor changes to r10003
* escape del char (0x7f) too
* s/{%02x}/{%x}/ i.e. create variable-sized w/o leading zeroes
needed for codepoints > 0xffff
* test del & codepoints > 0xffff
All tests are still passing including streams_13 (ppc/darwin).
Modified: trunk/src/string.c
==============================================================================
--- trunk/src/string.c (original)
+++ trunk/src/string.c Tue Nov 15 14:46:23 2005
@@ -2423,7 +2423,7 @@ string_escape_string_delimited(Interp *
dp = result->strstart;
for (i = 0; len > 0; --len) {
c = iter.get_and_advance(interpreter, &iter);
- if (c < 0x80) {
+ if (c < 0x7f) {
/* process ASCII chars */
if (i >= charlen - 2) {
/* resize - still len codepoints to go */
@@ -2478,7 +2478,7 @@ string_escape_string_delimited(Interp *
/* escape by appending either \uhhhh or \x{hh...} */
result->bufused = result->strlen = i;
if (c < 0x0100 || c >= 0x10000)
- hex = Parrot_sprintf_c(interpreter, "\\x{%02x}", c);
+ hex = Parrot_sprintf_c(interpreter, "\\x{%x}", c);
else
hex = Parrot_sprintf_c(interpreter, "\\u%04x", c);
result = string_append(interpreter, result, hex, 0);
Modified: trunk/t/op/string_cs.t
==============================================================================
--- trunk/t/op/string_cs.t (original)
+++ trunk/t/op/string_cs.t Tue Nov 15 14:46:23 2005
@@ -745,13 +745,13 @@ abcdefghi\n
OUTPUT
output_is( <<'CODE', <<'OUTPUT', "escape ctrl" );
- set S0, "\x00\x01\x1f"
+ set S0, "\x00\x01\x1f\x7f"
escape S1, S0
print S1
print "\n"
end
CODE
-\x{00}\x{01}\x{1f}
+\x{0}\x{1}\x{1f}\x{7f}
OUTPUT
output_is( <<'CODE', <<'OUTPUT', "escape latin1");
@@ -765,11 +765,11 @@ t\x{f6}tsch leo
OUTPUT
output_is( <<'CODE', <<'OUTPUT', "escape unicode" );
- set S0, unicode:"\u2001\u2002\u2003\u2004"
+ set S0, unicode:"\u2001\u2002\u2003\u2004\x{e01ef}\u0114"
escape S1, S0
print S1
print "\n"
end
CODE
-\u2001\u2002\u2003\u2004
+\u2001\u2002\u2003\u2004\x{e01ef}\u0114
OUTPUT