Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Cagney <ac131313@ges.redhat.com>
To: tromey@redhat.com
Cc: gdb-patches@sources.redhat.com
Subject: Re: RFA: c-lang.c -vs- \0
Date: Mon, 16 Sep 2002 22:29:00 -0000	[thread overview]
Message-ID: <3D86BDBB.4070203@ges.redhat.com> (raw)
In-Reply-To: <871y7wclca.fsf@fleche.redhat.com>

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



  reply	other threads:[~2002-09-17  5:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-14 14:29 Tom Tromey
2002-09-16 22:29 ` Andrew Cagney [this message]
2002-09-17 10:03   ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3D86BDBB.4070203@ges.redhat.com \
    --to=ac131313@ges.redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox