Index: tree-pretty-print.c =================================================================== --- tree-pretty-print.c (revision 135494) +++ tree-pretty-print.c (working copy) @@ -40,7 +40,7 @@ along with GCC; see the file COPYING3. /* Local functions, macros and variables. */ static int op_prio (const_tree); static const char *op_symbol (const_tree); -static void pretty_print_string (pretty_printer *, const char*); +static void pretty_print_string (pretty_printer *, const char *, int len); static void print_call_name (pretty_printer *, const_tree); static void newline_and_indent (pretty_printer *, int); static void maybe_init_pretty_print (FILE *); @@ -841,7 +841,8 @@ dump_generic_node (pretty_printer *buffe case STRING_CST: pp_string (buffer, "\""); - pretty_print_string (buffer, TREE_STRING_POINTER (node)); + pretty_print_string (buffer, TREE_STRING_POINTER (node), + TREE_STRING_LENGTH (node)); pp_string (buffer, "\""); break; @@ -2740,15 +2741,19 @@ print_call_name (pretty_printer *buffer, /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */ static void -pretty_print_string (pretty_printer *buffer, const char *str) +pretty_print_string (pretty_printer *buffer, const char *str, int len) { if (str == NULL) return; - while (*str) + while ((len--) > 0) { switch (str[0]) { + case '\0': + pp_string (buffer, "\\0"); + break; + case '\b': pp_string (buffer, "\\b"); break; @@ -2785,8 +2790,6 @@ pretty_print_string (pretty_printer *buf pp_string (buffer, "\\'"); break; - /* No need to handle \0; the loop terminates on \0. */ - case '\1': pp_string (buffer, "\\1"); break; @@ -2816,7 +2819,14 @@ pretty_print_string (pretty_printer *buf break; default: - pp_character (buffer, str[0]); + if (ISPRINT (str[0])) + pp_character (buffer, str[0]); + else + { + char s[5]; + sprintf (s, "\\x%02x", (unsigned)(unsigned char)str[0]); + pp_string (buffer, s); + } break; } str++;