From mboxrd@z Thu Jan 1 00:00:00 1970 From: Guillaume To: Joe Buck Cc: Subject: Re: fdump-ast-original and strg: Date: Fri, 30 Nov 2001 09:54:00 -0000 Message-ID: References: <200111300300.TAA05503@atrus.synopsys.com> X-SW-Source: 2001-11/msg01628.html Message-ID: <20011130095400.ojQExXDaZNAcQ7z_xnruiaMwCYscrL01mEY9OB6sdvs@z> 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