Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* RFA: c-lang.c -vs- \0
@ 2002-09-14 14:29 Tom Tromey
  2002-09-16 22:29 ` Andrew Cagney
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2002-09-14 14:29 UTC (permalink / raw)
  To: gdb-patches

This is an updated version of my \0-printing patch.

In double-quoted strings we now print \0 as "\000" to avoid ambiguity.
In single-quoted output we still print '\0'.

There is also a test suite patch enclosed.  I didn't add a new test,
as this functionality is already adequately tested.  However, I did
update the existing tests to reflect the new output.

Tested with no regressions on x86 Red Hat Linux 7.3.
As usual, built with the usual warnings enabled and -Werror.

Ok to commit?

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* c-lang.c (c_emit_char): Don't treat \0 specially unless quoter
	is "'".

Index: c-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/c-lang.c,v
retrieving revision 1.13
diff -u -r1.13 c-lang.c
--- c-lang.c 11 Jul 2002 13:50:49 -0000 1.13
+++ c-lang.c 14 Sep 2002 19:57:11 -0000
@@ -78,9 +78,13 @@
 	case '\007':
 	  fputs_filtered ("\\a", stream);
 	  break;
-        case '\0':
-          fputs_filtered ("\\0", stream);
-          break;
+	case '\0':
+	  if (quoter == '\'')
+	    {
+	      fputs_filtered ("\\0", stream);
+	      break;
+	    }
+	  /* Fall through.  */
 	default:
 	  fprintf_filtered (stream, "\\%.3o", (unsigned int) c);
 	  break;
Index: testsuite/ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* gdb.base/printcmds.exp (test_print_string_constants): Expect
	\000, not \0, in double-quoted string.

Index: testsuite/gdb.base/printcmds.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/printcmds.exp,v
retrieving revision 1.9
diff -u -r1.9 printcmds.exp
--- testsuite/gdb.base/printcmds.exp 10 May 2002 20:25:26 -0000 1.9
+++ testsuite/gdb.base/printcmds.exp 14 Sep 2002 19:57:21 -0000
@@ -620,7 +620,7 @@
     set timeout 60;
 
     gdb_test "p \"a string\""		" = \"a string\""
-    gdb_test "p \"embedded \\000 null\"" " = \"embedded \\\\0 null\""
+    gdb_test "p \"embedded \\000 null\"" " = \"embedded \\\\000 null\""
     gdb_test "p \"abcd\"\[2\]"	" = 99 'c'"
     gdb_test "p sizeof (\"abcdef\")"	" = 7"
     gdb_test "ptype \"foo\""		" = char \\\[4\\\]"


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: RFA: c-lang.c -vs- \0
  2002-09-14 14:29 RFA: c-lang.c -vs- \0 Tom Tromey
@ 2002-09-16 22:29 ` Andrew Cagney
  2002-09-17 10:03   ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cagney @ 2002-09-16 22:29 UTC (permalink / raw)
  To: tromey; +Cc: gdb-patches

> This is an updated version of my \0-printing patch.
> 
> In double-quoted strings we now print \0 as "\000" to avoid ambiguity.
> In single-quoted output we still print '\0'.
> 
> There is also a test suite patch enclosed.  I didn't add a new test,
> as this functionality is already adequately tested.  However, I did
> update the existing tests to reflect the new output.
> 
> Tested with no regressions on x86 Red Hat Linux 7.3.
> As usual, built with the usual warnings enabled and -Werror.
> 
> Ok to commit?
> 
> Tom
> 
> Index: ChangeLog
> from  Tom Tromey  <tromey@redhat.com>
> 
> 	* c-lang.c (c_emit_char): Don't treat \0 specially unless quoter
> 	is "'".

Yes, but ...

> Index: c-lang.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/c-lang.c,v
> retrieving revision 1.13
> diff -u -r1.13 c-lang.c
> --- c-lang.c 11 Jul 2002 13:50:49 -0000 1.13
> +++ c-lang.c 14 Sep 2002 19:57:11 -0000
> @@ -78,9 +78,13 @@
>  	case '\007':
>  	  fputs_filtered ("\\a", stream);
>  	  break;
> -        case '\0':
> -          fputs_filtered ("\\0", stream);
> -          break;
> +	case '\0':
> +	  if (quoter == '\'')
> +	    {
> +	      fputs_filtered ("\\0", stream);
> +	      break;
> +	    }
> +	  /* Fall through.  */

without the fallthrough.  Just clone the line below. (Need to get 
-Wswitch-fallthrough working :-).

The testcase, can then go in as well as ``obvious''.

Andrew


>  	default:
>  	  fprintf_filtered (stream, "\\%.3o", (unsigned int) c);
>  	  break;
> Index: testsuite/ChangeLog
> from  Tom Tromey  <tromey@redhat.com>
> 
> 	* gdb.base/printcmds.exp (test_print_string_constants): Expect
> 	\000, not \0, in double-quoted string.
> 
> Index: testsuite/gdb.base/printcmds.exp
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/gdb.base/printcmds.exp,v
> retrieving revision 1.9
> diff -u -r1.9 printcmds.exp
> --- testsuite/gdb.base/printcmds.exp 10 May 2002 20:25:26 -0000 1.9
> +++ testsuite/gdb.base/printcmds.exp 14 Sep 2002 19:57:21 -0000
> @@ -620,7 +620,7 @@
>      set timeout 60;
>  
>      gdb_test "p \"a string\""		" = \"a string\""
> -    gdb_test "p \"embedded \\000 null\"" " = \"embedded \\\\0 null\""
> +    gdb_test "p \"embedded \\000 null\"" " = \"embedded \\\\000 null\""
>      gdb_test "p \"abcd\"\[2\]"	" = 99 'c'"
>      gdb_test "p sizeof (\"abcdef\")"	" = 7"
>      gdb_test "ptype \"foo\""		" = char \\\[4\\\]"
> 



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: RFA: c-lang.c -vs- \0
  2002-09-16 22:29 ` Andrew Cagney
@ 2002-09-17 10:03   ` Tom Tromey
  0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2002-09-17 10:03 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: gdb-patches

>>>>> "Andrew" == Andrew Cagney <ac131313@ges.redhat.com> writes:

[ patch ]
Andrew> without the fallthrough.  Just clone the line below. (Need to get
Andrew> -Wswitch-fallthrough working :-).

Ok.  I checked it in with this change.

Tom


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-09-17 17:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-14 14:29 RFA: c-lang.c -vs- \0 Tom Tromey
2002-09-16 22:29 ` Andrew Cagney
2002-09-17 10:03   ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox