From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31011 invoked by alias); 14 Sep 2002 21:29:39 -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 31004 invoked from network); 14 Sep 2002 21:29:38 -0000 Received: from unknown (HELO gash2.peakpeak.com) (207.174.178.17) by sources.redhat.com with SMTP; 14 Sep 2002 21:29:38 -0000 Received: from fleche.redhat.com (tz0178.peakpeak.com [207.174.69.178]) by gash2.peakpeak.com (8.9.3/8.9.3) with ESMTP id PAA07267; Sat, 14 Sep 2002 15:29:35 -0600 Received: by fleche.redhat.com (Postfix, from userid 1000) id 4531C4F8214; Sat, 14 Sep 2002 15:28:21 -0600 (MDT) To: gdb-patches@sources.redhat.com Subject: RFA: c-lang.c -vs- \0 From: Tom Tromey Reply-To: tromey@redhat.com X-Attribution: Tom X-Zippy: I predict that by 1993 everyone will live in and around LAS VEGAS and wear BEATLE HAIRCUTS! Date: Sat, 14 Sep 2002 14:29:00 -0000 Message-ID: <871y7wclca.fsf@fleche.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2002-09/txt/msg00299.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 "'". 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 * 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\\\]"