Author: leo
Date: Tue Nov 15 09:18:34 2005
New Revision: 9990

Modified:
   trunk/src/string.c
   trunk/t/op/string_cs.t
Log:
escape other control chars to hex

Modified: trunk/src/string.c
==============================================================================
--- trunk/src/string.c  (original)
+++ trunk/src/string.c  Tue Nov 15 09:18:34 2005
@@ -2442,7 +2442,8 @@ string_escape_string_delimited(Interp * 
             result = string_append(interpreter, result, hex, 0);
             i += hex->strlen;
         }
-        else if (c >= 0x80) {
+        else if (c >= 0x7f) {
+esc_hex:
             result->bufused = result->strlen = i;
             hex = Parrot_sprintf_c(interpreter, "\\x%02x", c);
             result = string_append(interpreter, result, hex, 0);
@@ -2482,6 +2483,9 @@ string_escape_string_delimited(Interp * 
                     dp[i++] = '\\';
                     c = '"';
                     break;
+                default:
+                    if (c < 32)
+                        goto esc_hex;
             }
             dp[i++] = c;
         }

Modified: trunk/t/op/string_cs.t
==============================================================================
--- trunk/t/op/string_cs.t      (original)
+++ trunk/t/op/string_cs.t      Tue Nov 15 09:18:34 2005
@@ -745,13 +745,13 @@ abcdefghi\n
 OUTPUT
 
 output_is( <<'CODE', <<'OUTPUT', "escape ctrl" );
-    set S0, "\a\b\t\n\v"
+    set S0, "\x00\x01\x1f"
     escape S1, S0
     print S1
     print "\n"
     end
 CODE
-\a\b\t\n\v
+\x00\x01\x1f
 OUTPUT
 
 output_is( <<'CODE', <<'OUTPUT', "escape latin1");

Reply via email to