From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19491 invoked by alias); 17 Sep 2002 05:29:35 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 19480 invoked from network); 17 Sep 2002 05:29:31 -0000 Received: from unknown (HELO localhost.redhat.com) (24.112.240.27) by sources.redhat.com with SMTP; 17 Sep 2002 05:29:31 -0000 Received: from ges.redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 667E93D77; Tue, 17 Sep 2002 01:29:31 -0400 (EDT) Message-ID: <3D86BDBB.4070203@ges.redhat.com> Date: Mon, 16 Sep 2002 22:29:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.0) Gecko/20020824 X-Accept-Language: en-us, en MIME-Version: 1.0 To: tromey@redhat.com Cc: gdb-patches@sources.redhat.com Subject: Re: RFA: c-lang.c -vs- \0 References: <871y7wclca.fsf@fleche.redhat.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2002-09/txt/msg00334.txt.bz2 > 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 > > * 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 > > * 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\\\]" >