public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, trivial, 3/3, PR70433] Handle backslash in pp_write_text_as_dot_label_to_stream
@ 2016-04-04 12:27 Tom de Vries
  0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2016-04-04 12:27 UTC (permalink / raw)
  To: GCC Patches; +Cc: t.w.lefering

[-- Attachment #1: Type: text/plain, Size: 917 bytes --]

Hi,

this patch fixes PR70433.

Consider test.c:
...
#include <stdio.h>

void
test (void)
{
   printf ("\"%s\"",__FUNCTION__);
}
...

In the dump file we find the backslashes in the string:
...
   printf ("\"%s\"", &__FUNCTION__);
...

But the dot file contains:
...
printf\ (\"\\"%s\\"\",\ &__FUNCTION__);
...

Which translates to this string in the pdf file, without the backslashes:
...
printf (""%s"", &__FUNCTION__);
...

The patch classifies the backslash as always-escape in 
pp_write_text_as_dot_label_to_stream, and that fixes the PR.
[ Also, the patch adds an assert to prevent running into a known graphiz 
PR related to backslashes. ]

Bootstrapped and reg-tested on x86_64.

Will commit to stage1 trunk as trivial.

[ I'd add a testcase, but that is blocked on the 
lib/scandump.exp/dump-suffix bit of 
https://gcc.gnu.org/ml/gcc-patches/2016-03/msg01077.html which is 
awaiting review. ]

Thanks,
- Tom

[-- Attachment #2: 0003-Handle-backslash-in-pp_write_text_as_dot_label_to_stream.patch --]
[-- Type: text/x-patch, Size: 923 bytes --]

Handle backslash in pp_write_text_as_dot_label_to_stream

2016-04-04  Tom de Vries  <tom@codesourcery.com>

	PR other/70433
	* pretty-print.c (pp_write_text_as_dot_label_to_stream): Escape
	backslash in label.

---
 gcc/pretty-print.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gcc/pretty-print.c b/gcc/pretty-print.c
index c3a90a7..8ac3d34 100644
--- a/gcc/pretty-print.c
+++ b/gcc/pretty-print.c
@@ -182,6 +182,12 @@ pp_write_text_as_dot_label_to_stream (pretty_printer *pp, bool for_record)
 
 	/* The following characters always have to be escaped
 	   for use in labels.  */
+	case '\\':
+	  /* There is a bug in some (f.i. 2.36.0) versions of graphiz
+	     ( http://www.graphviz.org/mantisbt/view.php?id=2524 ) related to
+	     backslash as last char in label.  Let's avoid triggering it.  */
+	  gcc_assert (*(p + 1) != '\0');
+	  /* Fall through.  */
 	case '"':
 	  escape_char = true;
 	  break;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-04-04 12:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-04 12:27 [PATCH, trivial, 3/3, PR70433] Handle backslash in pp_write_text_as_dot_label_to_stream Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).