diff options
author | Tom de Vries <tom@codesourcery.com> | 2016-04-17 05:22:45 +0000 |
---|---|---|
committer | Tom de Vries <vries@gcc.gnu.org> | 2016-04-17 05:22:45 +0000 |
commit | da3ebf2ddefe30d18110c6f73ca8abe644c46b5d (patch) | |
tree | 2650aaaf6a4a08998177636ea3795ff236f74b51 | |
parent | 182c78687e6cf481c4d8e8fce99a0f293510adb7 (diff) | |
download | gcc-da3ebf2ddefe30d18110c6f73ca8abe644c46b5d.zip gcc-da3ebf2ddefe30d18110c6f73ca8abe644c46b5d.tar.gz gcc-da3ebf2ddefe30d18110c6f73ca8abe644c46b5d.tar.bz2 |
Simplify loop in pp_write_text_as_dot_label_to_stream
2016-04-17 Tom de Vries <tom@codesourcery.com>
* pretty-print.c (pp_write_text_as_dot_label_to_stream): Simplify loop
structure.
From-SVN: r235075
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/pretty-print.c | 23 |
2 files changed, 19 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2a20cee..2bd0d6f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2016-04-17 Tom de Vries <tom@codesourcery.com> + * pretty-print.c (pp_write_text_as_dot_label_to_stream): Simplify loop + structure. + +2016-04-17 Tom de Vries <tom@codesourcery.com> + PR other/70185 * tree-pass.h (class opt_pass): Remove graph_dump_initialized member. * dumpfile.h (struct dump_file_info): Add graph_dump_initialized field. diff --git a/gcc/pretty-print.c b/gcc/pretty-print.c index acb89e6..f6e4b43 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); |