PATCH: Output names safely in assembly
Gabriel Dos Reis
gdr@codesourcery.com
Sat May 25 08:10:00 GMT 2002
"Kaveh R. Ghazi" <ghazi@caip.rutgers.edu> writes:
| > 2002-05-23 Gabriel Dos Reis <gdr@codesourcery.com>
| > Zack Weinberg <zack@codesourcery.com>
| >
| > * toplev.c (output_clean_symbol_name): Define.
| >
| > + /* Output NAME into FILE after having turned it into something
| > + usable as an identifier in a target's assembly file. */
| > + void
| > + output_clean_symbol_name (file, name)
| > + FILE *file;
| > + const char *name;
| > + {
| > + /* Make a copy of NAME. */
| > + char *id = (char *)xmalloc (strlen (name) + 1);
| > + strcpy (id, name);
|
| xstrdup?
Yes. Actually, we would want use alloca() but we changed our mind since
it wouldn't necessarily be available at stage1.
| > +
| > + /* Make it look like a valid identifier for an assembler. */
| > + clean_symbol_name (id);
| > +
| > + fputs (file, name);
|
| Args reversed?
Yes. A glitch of an internal debate of whether we should be using
fprintf() or fputs(). I wander why it wasn't caugth by the bootstrap.
Fixed thusly, commited under the obvious rule.
-- Gaby
2002-05-25 Gabriel Dos Reis <gdr@codesourcery.com>
* toplev.c (output_clean_symbol_name): Use xstrdup. Fix thinko.
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.635
diff -p -r1.635 toplev.c
*** toplev.c 25 May 2002 01:56:55 -0000 1.635
--- toplev.c 25 May 2002 14:37:09 -0000
***************
*** 1,3 ****
--- 1,4 ----
+
/* Top level of GNU C compiler
Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000, 2001, 2002 Free Software Foundation, Inc.
*************** output_clean_symbol_name (file, name)
*** 1718,1730 ****
const char *name;
{
/* Make a copy of NAME. */
! char *id = (char *)xmalloc (strlen (name) + 1);
! strcpy (id, name);
/* Make it look like a valid identifier for an assembler. */
clean_symbol_name (id);
! fputs (file, name);
free (id);
}
--- 1719,1730 ----
const char *name;
{
/* Make a copy of NAME. */
! char *id = xstrdup (name);
/* Make it look like a valid identifier for an assembler. */
clean_symbol_name (id);
! fputs (name, file);
free (id);
}
More information about the Gcc-patches
mailing list