OSDN Git Service

* print-tree.c (print_node): In a STRING_CST, escape non-ascii
authorbothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 10 Sep 2002 07:02:28 +0000 (07:02 +0000)
committerbothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 10 Sep 2002 07:02:28 +0000 (07:02 +0000)
characters, and only print TREE_STRING_LENGTH chars.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@56994 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/print-tree.c

index 3daf742..fb214bd 100644 (file)
@@ -1,3 +1,8 @@
+2002-09-09  Per Bothner  <per@bothner.com>
+
+       * print-tree.c (print_node):  In a STRING_CST, escape non-ascii
+       characters, and only print TREE_STRING_LENGTH chars.
+
 2002-09-09  Steve Ellcey  <sje@cup.hp.com>
 
        * config/ia64/hpux.h (TARGET_HPUX_LD): New, define true.
index 949b7f5..bb03d81 100644 (file)
@@ -711,7 +711,20 @@ print_node (file, prefix, node, indent)
          break;
 
        case STRING_CST:
-         fprintf (file, " \"%s\"", TREE_STRING_POINTER (node));
+         {
+           const char *p = TREE_STRING_POINTER (node);
+           int i = TREE_STRING_LENGTH (node);
+           fputs (" \"", file);
+           while (--i >= 0)
+             {
+               char ch = *p++;
+               if (ch >= ' ' && ch < 127)
+                 putc (ch, file);
+               else
+                 fprintf(file, "\\%03o", ch & 0xFF);
+             }
+           fputc ('\"', file);
+         }
          /* Print the chain at second level.  */
          if (indent == 4)
            print_node (file, "chain", TREE_CHAIN (node), indent + 4);