From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16944 invoked by alias); 30 Nov 2001 18:12:13 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 16913 invoked from network); 30 Nov 2001 18:12:11 -0000 Received: from unknown (HELO mailgw.chips.ibm.com) (192.91.197.8) by hostedprojects.ges.redhat.com with SMTP; 30 Nov 2001 18:12:11 -0000 Received: from mailrelay.btv.ibm.com (mailrelay.btv.ibm.com [9.61.34.174]) by mailgw.chips.ibm.com (8.9.3/8.9.3) with ESMTP id NAA35142; Fri, 30 Nov 2001 13:12:10 -0500 Received: from postoffice.fishkill.ibm.com (postoffice.fishkill.ibm.com [9.50.30.33]) by mailrelay.btv.ibm.com (8.8.8/8.8.8) with ESMTP id NAA15940; Fri, 30 Nov 2001 13:12:10 -0500 Received: from warp9.fishkill.ibm.com (postfix@warp9.fishkill.ibm.com [9.50.173.37]) by postoffice.fishkill.ibm.com (8.8.8/8.8.8) with ESMTP id NAA39952; Fri, 30 Nov 2001 13:12:09 -0500 Received: from warp9.fishkill.ibm.com (localhost.localdomain [127.0.0.1]) by warp9.fishkill.ibm.com (Postfix) with SMTP id 3982F3C357; Fri, 30 Nov 2001 13:12:07 -0500 (EST) Content-Type: text/plain; charset="iso-8859-1" From: Florian Krohm To: Guillaume , Joe Buck Subject: Re: fdump-ast-original and strg: Date: Fri, 23 Nov 2001 08:52:00 -0000 X-Mailer: KMail [version 1.2] Cc: References: In-Reply-To: MIME-Version: 1.0 Message-Id: <01113013120701.01459@warp9.fishkill.ibm.com> Content-Transfer-Encoding: 8bit X-SW-Source: 2001-11/txt/msg01128.txt.bz2 I'm afraid, things are even a bit more complex. Consider a string containing two characters, the first of which contains the bit pattern 00001010. The second character is '2'. If you want to recover the original representation for that string you will have to use a string concatenation e.g. "\12" "2" or "\x6" "2". Note that you cannot write "\122" as that would specify only a single character. You could call this a pathological example, but I think you want to come up with an algorithm that can handle the general case. Florian On Friday 30 November 2001 12:54, Guillaume wrote: > On Thu, 29 Nov 2001, Joe Buck wrote: > > Guillaume Thouvenin writes: > > ... > > > > > The problem is the following. If you have something like: > > > > > > -- part of a C code -- > > > > > > fprintf(stderr, "error strg: toto"); > > > > > > -- > > > > > > The asg given by gcc gives the following line: > > > > > > @247 string_cst type: @268 strg: error strg: toto lngt: 5 > > > > > > So, I add a very basic modification inside GCC (in c-dump.c) and now, > > > it produces this line: > > > > > > @247 string_cst type: @268 strg: "error strg: toto" lngt: > > > 5 > > > > This seems reasonable, but does your patch do the whole job? What > > happens if the string contains newlines, control characters, or '"'? It > > would seem reasonable to make the output match the input (that is, output > > \", \n, etc). > > No it doesn't do the whole job. If you have something like : > > fprintf (stderr, "Hello\nit's a \"test\"\n"); > > It will produce : > > @54 string_cst type: @67 strg: "Hello > it's a "test" > " lngt: 21 > > So, the good output should be > > @54 string_cst type: @67 strg: "Hello\nit's a \"test\"\n" > lngt: 21 > > > Actually, strings with newlines, control characters and '"' are treated by > my parser. The only modification that I done in GCC is in file c-dump.c: > > line 649: > --- > 648: case STRING_CST: > 649: fprintf (di->stream, "strg: \"%-7s\" ", TREE_STRING_POINTER (t)); > ^^ ^^ > 650: dump_int (di, "lngt", TREE_STRING_LENGTH (t)); > 651: break; > > So, I can try to path GCC to make output match the input? > > Guillaume From mboxrd@z Thu Jan 1 00:00:00 1970 From: Florian Krohm To: Guillaume , Joe Buck Cc: Subject: Re: fdump-ast-original and strg: Date: Fri, 30 Nov 2001 10:12:00 -0000 Message-ID: <01113013120701.01459@warp9.fishkill.ibm.com> References: X-SW-Source: 2001-11/msg01629.html Message-ID: <20011130101200.-D4TjhzjrFlASezqCYZPnD4Bh9CasRAe7xATNiWk_hc@z> I'm afraid, things are even a bit more complex. Consider a string containing two characters, the first of which contains the bit pattern 00001010. The second character is '2'. If you want to recover the original representation for that string you will have to use a string concatenation e.g. "\12" "2" or "\x6" "2". Note that you cannot write "\122" as that would specify only a single character. You could call this a pathological example, but I think you want to come up with an algorithm that can handle the general case. Florian On Friday 30 November 2001 12:54, Guillaume wrote: > On Thu, 29 Nov 2001, Joe Buck wrote: > > Guillaume Thouvenin writes: > > ... > > > > > The problem is the following. If you have something like: > > > > > > -- part of a C code -- > > > > > > fprintf(stderr, "error strg: toto"); > > > > > > -- > > > > > > The asg given by gcc gives the following line: > > > > > > @247 string_cst type: @268 strg: error strg: toto lngt: 5 > > > > > > So, I add a very basic modification inside GCC (in c-dump.c) and now, > > > it produces this line: > > > > > > @247 string_cst type: @268 strg: "error strg: toto" lngt: > > > 5 > > > > This seems reasonable, but does your patch do the whole job? What > > happens if the string contains newlines, control characters, or '"'? It > > would seem reasonable to make the output match the input (that is, output > > \", \n, etc). > > No it doesn't do the whole job. If you have something like : > > fprintf (stderr, "Hello\nit's a \"test\"\n"); > > It will produce : > > @54 string_cst type: @67 strg: "Hello > it's a "test" > " lngt: 21 > > So, the good output should be > > @54 string_cst type: @67 strg: "Hello\nit's a \"test\"\n" > lngt: 21 > > > Actually, strings with newlines, control characters and '"' are treated by > my parser. The only modification that I done in GCC is in file c-dump.c: > > line 649: > --- > 648: case STRING_CST: > 649: fprintf (di->stream, "strg: \"%-7s\" ", TREE_STRING_POINTER (t)); > ^^ ^^ > 650: dump_int (di, "lngt", TREE_STRING_LENGTH (t)); > 651: break; > > So, I can try to path GCC to make output match the input? > > Guillaume