regcomp.c: Use hex instead of octal for debug ords
authorKarl Williamson <public@khwilliamson.com>
Sun, 28 Nov 2010 03:51:54 +0000 (20:51 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 28 Nov 2010 12:49:16 +0000 (04:49 -0800)
The ordinals that are output in the debugging output have been in octal,
which is ok for the low controls, but for above Latin1, the standard is
hex, so this changes them all to correspond.  If desired the low
controls could be changed back to be in octal.

regcomp.c

index 72afd06..9c013af 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -10365,8 +10365,14 @@ S_put_byte(pTHX_ SV *sv, int c)
        ones (binary 1111 1111, hexadecimal FF). It is similar, but not
        identical, to the ASCII delete (DEL) or rubout control character.
        ) So the old condition can be simplified to !isPRINT(c)  */
-    if (!isPRINT(c))
-       Perl_sv_catpvf(aTHX_ sv, "\\%o", c);
+    if (!isPRINT(c)) {
+       if (c < 256) {
+           Perl_sv_catpvf(aTHX_ sv, "\\x%02x", c);
+       }
+       else {
+           Perl_sv_catpvf(aTHX_ sv, "\\x{%x}", c);
+       }
+    }
     else {
        const char string = c;
        if (c == '-' || c == ']' || c == '\\' || c == '^')