This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFA: c-lang.c -vs- \0


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\\\]"



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]