From: Guillaume <guillaume.thouvenin@polymtl.ca>
To: Zack Weinberg <zack@codesourcery.com>
Cc: Florian Krohm <florian@edamail.fishkill.ibm.com>,
Guillaume <guillaume.thouvenin@polymtl.ca>,
Joe Buck <jbuck@synopsys.com>, <gcc@gcc.gnu.org>
Subject: Re: fdump-ast-original and strg:
Date: Fri, 23 Nov 2001 16:40:00 -0000 [thread overview]
Message-ID: <Pine.LNX.4.33L2.0111301642590.2323-100000@leffetriple.localdomain> (raw)
In-Reply-To: <20011130102600.A20309@codesourcery.com>
On Fri, 30 Nov 2001, Zack Weinberg wrote:
> > 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.
>
> "\0122" will work fine. (Or, in this case, "\n2" assuming ASCII.)
Yes it will produce "\n2"
>
> We already have code to emit strings safely, into the assembly output;
> you could just use that.
I will look to your code tonight. I put what I've done at the end of the
mail and I will modify it if I can find code to emit strings safely.
The function dump_string_cst() produced the following output:
@51 string_cst type: @58 strg: "Hello\nit's a \t\"test\"\n" lngt: 22
for the following input:
fprintf (stderr, "Hello\nit's a \t\"test\"\n");
Thanks to all of you for your help
Guillaume
-----------
diff -urN gcc-3.0.2-20011014/gcc/c-dump.c
gcc-3.0.2-20011014-mod/gcc/c-dump.c
--- gcc-3.0.2-20011014/gcc/c-dump.c Tue Jun 5 03:46:58 2001
+++ gcc-3.0.2-20011014-mod/gcc/c-dump.c Fri Nov 30 16:25:48 2001
@@ -214,6 +214,49 @@
di->column += 14;
}
+void
+dump_string_cst (di, string)
+ dump_info_p di;
+ const char *string;
+{
+ int index;
+
+ fprintf (di->stream, "strg: \"");
+ for (index = 0; string[index] != '\0' ; index++)
+ {
+ switch (string[index])
+ {
+ case '\a':
+ fprintf (di->stream, "%c%c", '\\', 'a');
+ break;
+ case '\b':
+ fprintf (di->stream, "%c%c", '\\', 'b');
+ break;
+ case '\t':
+ fprintf (di->stream, "%c%c", '\\', 't');
+ break;
+ case '\n':
+ fprintf (di->stream, "%c%c", '\\', 'n');
+ break;
+ case '\v':
+ fprintf (di->stream, "%c%c", '\\', 'v');
+ break;
+ case '\f':
+ fprintf (di->stream, "%c%c", '\\', 'f');
+ break;
+ case '\r':
+ fprintf (di->stream, "%c%c", '\\', 'r');
+ break;
+ case '\"':
+ fprintf (di->stream, "%c%c", '\\', '\"');
+ break;
+ default :
+ fprintf (di->stream, "%c", string[index]);
+ }
+ }
+ fprintf (di->stream, "\"");
+}
+
/* Dump the string field S. */
static void
@@ -646,7 +689,7 @@
break;
case STRING_CST:
- fprintf (di->stream, "strg: %-7s ", TREE_STRING_POINTER (t));
+ dump_string_cst (di, TREE_STRING_POINTER(t));
dump_int (di, "lngt", TREE_STRING_LENGTH (t));
break;
diff -urN gcc-3.0.2-20011014/gcc/c-dump.h
gcc-3.0.2-20011014-mod/gcc/c-dump.h
--- gcc-3.0.2-20011014/gcc/c-dump.h Tue Jun 5 03:46:58 2001
+++ gcc-3.0.2-20011014-mod/gcc/c-dump.h Fri Nov 30 16:23:12 2001
@@ -80,6 +80,8 @@
PARAMS ((dump_info_p, const char *, int));
extern void dump_string
PARAMS ((dump_info_p, const char *));
+extern void dump_string_cst
+ PARAMS ((dump_info_p, const char *));
extern void dump_stmt
PARAMS ((dump_info_p, tree));
extern void dump_next_stmt
--------------------
WARNING: multiple messages have this Message-ID
From: Guillaume <guillaume.thouvenin@polymtl.ca>
To: Zack Weinberg <zack@codesourcery.com>
Cc: Florian Krohm <florian@edamail.fishkill.ibm.com>,
Guillaume <guillaume.thouvenin@polymtl.ca>,
Joe Buck <jbuck@synopsys.com>, <gcc@gcc.gnu.org>
Subject: Re: fdump-ast-original and strg:
Date: Fri, 30 Nov 2001 13:55:00 -0000 [thread overview]
Message-ID: <Pine.LNX.4.33L2.0111301642590.2323-100000@leffetriple.localdomain> (raw)
Message-ID: <20011130135500.L_gNH4Z5avWzISlqdKdwn12eT8vThxOnsNJ0y1Ptp3U@z> (raw)
In-Reply-To: <20011130102600.A20309@codesourcery.com>
On Fri, 30 Nov 2001, Zack Weinberg wrote:
> > 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.
>
> "\0122" will work fine. (Or, in this case, "\n2" assuming ASCII.)
Yes it will produce "\n2"
>
> We already have code to emit strings safely, into the assembly output;
> you could just use that.
I will look to your code tonight. I put what I've done at the end of the
mail and I will modify it if I can find code to emit strings safely.
The function dump_string_cst() produced the following output:
@51 string_cst type: @58 strg: "Hello\nit's a \t\"test\"\n" lngt: 22
for the following input:
fprintf (stderr, "Hello\nit's a \t\"test\"\n");
Thanks to all of you for your help
Guillaume
-----------
diff -urN gcc-3.0.2-20011014/gcc/c-dump.c
gcc-3.0.2-20011014-mod/gcc/c-dump.c
--- gcc-3.0.2-20011014/gcc/c-dump.c Tue Jun 5 03:46:58 2001
+++ gcc-3.0.2-20011014-mod/gcc/c-dump.c Fri Nov 30 16:25:48 2001
@@ -214,6 +214,49 @@
di->column += 14;
}
+void
+dump_string_cst (di, string)
+ dump_info_p di;
+ const char *string;
+{
+ int index;
+
+ fprintf (di->stream, "strg: \"");
+ for (index = 0; string[index] != '\0' ; index++)
+ {
+ switch (string[index])
+ {
+ case '\a':
+ fprintf (di->stream, "%c%c", '\\', 'a');
+ break;
+ case '\b':
+ fprintf (di->stream, "%c%c", '\\', 'b');
+ break;
+ case '\t':
+ fprintf (di->stream, "%c%c", '\\', 't');
+ break;
+ case '\n':
+ fprintf (di->stream, "%c%c", '\\', 'n');
+ break;
+ case '\v':
+ fprintf (di->stream, "%c%c", '\\', 'v');
+ break;
+ case '\f':
+ fprintf (di->stream, "%c%c", '\\', 'f');
+ break;
+ case '\r':
+ fprintf (di->stream, "%c%c", '\\', 'r');
+ break;
+ case '\"':
+ fprintf (di->stream, "%c%c", '\\', '\"');
+ break;
+ default :
+ fprintf (di->stream, "%c", string[index]);
+ }
+ }
+ fprintf (di->stream, "\"");
+}
+
/* Dump the string field S. */
static void
@@ -646,7 +689,7 @@
break;
case STRING_CST:
- fprintf (di->stream, "strg: %-7s ", TREE_STRING_POINTER (t));
+ dump_string_cst (di, TREE_STRING_POINTER(t));
dump_int (di, "lngt", TREE_STRING_LENGTH (t));
break;
diff -urN gcc-3.0.2-20011014/gcc/c-dump.h
gcc-3.0.2-20011014-mod/gcc/c-dump.h
--- gcc-3.0.2-20011014/gcc/c-dump.h Tue Jun 5 03:46:58 2001
+++ gcc-3.0.2-20011014-mod/gcc/c-dump.h Fri Nov 30 16:23:12 2001
@@ -80,6 +80,8 @@
PARAMS ((dump_info_p, const char *, int));
extern void dump_string
PARAMS ((dump_info_p, const char *));
+extern void dump_string_cst
+ PARAMS ((dump_info_p, const char *));
extern void dump_stmt
PARAMS ((dump_info_p, tree));
extern void dump_next_stmt
--------------------
next prev parent reply other threads:[~2001-11-30 21:55 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-11-22 13:14 Guillaume
2001-11-22 13:14 ` Joe Buck
2001-11-23 8:49 ` Guillaume
2001-11-23 8:52 ` Florian Krohm
2001-11-23 10:56 ` Joe Buck
2001-11-30 10:22 ` Joe Buck
2001-11-23 11:04 ` Dale Johannesen
2001-11-23 16:20 ` TImode ?inhibited? in main 3.1 branch davide.rossetti
2001-11-30 12:31 ` davide.rossetti
2001-11-23 17:46 ` fdump-ast-original and strg: Tim Hollebeek
2001-11-23 18:26 ` Dale Johannesen
2001-11-30 15:02 ` Dale Johannesen
2001-11-30 14:59 ` Tim Hollebeek
2001-11-30 10:24 ` Dale Johannesen
2001-11-23 11:14 ` Zack Weinberg
2001-11-23 14:13 ` Florian Krohm
2001-11-23 14:42 ` Joe Buck
2001-11-23 23:16 ` Richard Henderson
2001-11-24 3:30 ` Zack Weinberg
2001-11-24 3:38 ` Richard Henderson
2001-11-30 15:50 ` Richard Henderson
2001-11-30 15:37 ` Zack Weinberg
2001-11-30 15:28 ` Richard Henderson
2001-11-30 11:01 ` Joe Buck
2001-11-30 10:54 ` Florian Krohm
2001-11-23 16:40 ` Guillaume [this message]
2001-11-30 13:55 ` Guillaume
2001-11-30 10:26 ` Zack Weinberg
2001-11-30 10:12 ` Florian Krohm
2001-11-30 9:54 ` Guillaume
2001-11-29 19:00 ` Joe Buck
2001-11-29 18:46 ` Guillaume
2001-11-24 11:14 mike stump
2001-11-24 12:41 ` Joe Buck
2001-11-30 17:12 ` Joe Buck
2001-11-30 16:59 ` mike stump
2001-11-24 14:37 mike stump
2001-11-24 17:15 ` Joseph S. Myers
2001-11-30 18:35 ` Joseph S. Myers
2001-12-03 14:23 ` Richard Henderson
2001-11-30 17:49 ` mike stump
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.33L2.0111301642590.2323-100000@leffetriple.localdomain \
--to=guillaume.thouvenin@polymtl.ca \
--cc=florian@edamail.fishkill.ibm.com \
--cc=gcc@gcc.gnu.org \
--cc=jbuck@synopsys.com \
--cc=zack@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).