From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13316 invoked by alias); 10 Sep 2002 23:29:06 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 13303 invoked from network); 10 Sep 2002 23:29:05 -0000 Received: from unknown (HELO gash2.peakpeak.com) (207.174.178.17) by sources.redhat.com with SMTP; 10 Sep 2002 23:29:05 -0000 Received: from fleche.redhat.com (tz0167.peakpeak.com [207.174.69.167]) by gash2.peakpeak.com (8.9.3/8.9.3) with ESMTP id RAA28772; Tue, 10 Sep 2002 17:29:02 -0600 Received: by fleche.redhat.com (Postfix, from userid 1000) id D3D734F80F1; Tue, 10 Sep 2002 17:28:57 -0600 (MDT) To: Gdb List Subject: question about c-lang.c From: Tom Tromey Reply-To: tromey@redhat.com X-Attribution: Tom X-Zippy: All this time I've been VIEWING a RUSSIAN MIDGET SODOMIZE a HOUSECAT! Date: Tue, 10 Sep 2002 16:29:00 -0000 Message-ID: <87k7lta0g6.fsf@fleche.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2002-09/txt/msg00087.txt.bz2 Today I happened to read c-lang.c:c_emit_char(). Suppose a string contains the characters \0 (nul), `0' and finally `1'. (See appended source.) Now print this string: (gdb) p *c @ 4 $2 = "\001" This output is ambiguous, as \001 has another meaning. I believe this is a problem for programs using MI. They can't correctly parse this output (should they want to). I've appended one possible fix. This isn't ideal since it also changes how char literals are printed. Perhaps that is acceptable? Tom #include char *c = "\00001"; int main () { printf ("%s\n", c); return 0; } Index: ChangeLog from Tom Tromey * c-lang.c (c_emit_char): Don't treat \0 specially. 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 10 Sep 2002 23:26:06 -0000 @@ -78,9 +78,6 @@ case '\007': fputs_filtered ("\\a", stream); break; - case '\0': - fputs_filtered ("\\0", stream); - break; default: fprintf_filtered (stream, "\\%.3o", (unsigned int) c); break;