summaryrefslogtreecommitdiff
path: root/gcc/pretty-print.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/pretty-print.c')
-rw-r--r--gcc/pretty-print.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/gcc/pretty-print.c b/gcc/pretty-print.c
index acb89e6c8b9..f6e4b43d9fb 100644
--- a/gcc/pretty-print.c
+++ b/gcc/pretty-print.c
@@ -159,20 +159,20 @@ pp_write_text_as_dot_label_to_stream (pretty_printer *pp, bool for_record)
const char *p = text;
FILE *fp = pp_buffer (pp)->stream;
- while (*p)
+ for (;*p; p++)
{
+ bool escape_char;
switch (*p)
{
/* Print newlines as a left-aligned newline. */
case '\n':
- fputs ("\\l\\\n", fp);
+ fputs ("\\l", fp);
+ escape_char = true;
break;
/* A pipe is only special for record-shape nodes. */
case '|':
- if (for_record)
- fputc ('\\', fp);
- fputc (*p, fp);
+ escape_char = for_record;
break;
/* The following characters always have to be escaped
@@ -183,13 +183,18 @@ pp_write_text_as_dot_label_to_stream (pretty_printer *pp, bool for_record)
case '>':
case '"':
case ' ':
- fputc ('\\', fp);
- /* fall through */
+ escape_char = true;
+ break;
+
default:
- fputc (*p, fp);
+ escape_char = false;
break;
}
- p++;
+
+ if (escape_char)
+ fputc ('\\', fp);
+
+ fputc (*p, fp);
}
pp_clear_output_area (pp);