This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Java: fix to gcj/311
- To: gcc-patches at gcc dot gnu dot org
- Subject: [PATCH] Java: fix to gcj/311
- From: Alexandre Petit-Bianco <apbianco at cygnus dot com>
- Date: Tue, 5 Sep 2000 19:31:04 -0700
- Reply-to: apbianco at redhat dot com
This is a verified fix to gcj/311. I checking it in.
./A
2000-08-11 Alexandre Petit-Bianco <apbianco@cygnus.com>
* parse.y (do_merge_string_cste): New locals. Create new
STRING_CSTs each time, use memcpy.
Index: parse.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/parse.y,v
retrieving revision 1.206
diff -u -p -r1.206 parse.y
--- parse.y 2000/08/29 21:39:49 1.206
+++ parse.y 2000/09/06 02:29:26
@@ -12892,20 +12892,26 @@ do_merge_string_cste (cste, string, stri
const char *string;
int string_len, after;
{
- int len = TREE_STRING_LENGTH (cste) + string_len;
const char *old = TREE_STRING_POINTER (cste);
+ int old_len = TREE_STRING_LENGTH (cste);
+ int len = old_len + string_len;
+ char *new;
+
+ cste = make_node (STRING_CST);
TREE_STRING_LENGTH (cste) = len;
- TREE_STRING_POINTER (cste) = obstack_alloc (expression_obstack, len+1);
+ new = TREE_STRING_POINTER (cste) = obstack_alloc (expression_obstack, len+1);
+
if (after)
{
- strcpy (TREE_STRING_POINTER (cste), string);
- strcat (TREE_STRING_POINTER (cste), old);
+ memcpy (new, string, string_len);
+ memcpy (&new [string_len], old, old_len);
}
else
{
- strcpy (TREE_STRING_POINTER (cste), old);
- strcat (TREE_STRING_POINTER (cste), string);
+ memcpy (new, old, old_len);
+ memcpy (&new [old_len], string, string_len);
}
+ new [len] = '\0';
return cste;
}