This is the mail archive of the
gas2@sourceware.cygnus.com
mailing list for the binutils project.
type correctness tweek
- To: gas2@sourceware.cygnus.com
- Subject: type correctness tweek
- From: Richard Henderson <rth@cygnus.com>
- Date: Thu, 6 May 1999 19:49:59 -0700
Gas won't build with the metrowerks compiler, because we passed
an unsigned char* to strcpy, which expects char*.
I took this opportunity to not do two passes across the string.
r~
* symbols.c (symbol_find_base): Use memcpy instead of strcpy.
Don't copy before downcaseing.
Index: symbols.c
===================================================================
RCS file: /cvs/binutils/binutils/gas/symbols.c,v
retrieving revision 1.1.1.1
diff -c -p -d -r1.1.1.1 symbols.c
*** symbols.c 1999/05/03 07:28:41 1.1.1.1
--- symbols.c 1999/05/07 02:46:34
*************** symbol_find_base (name, strip_underscore
*** 456,478 ****
#ifdef tc_canonicalize_symbol_name
{
char *copy;
! copy = (char *) alloca (strlen (name) + 1);
! strcpy (copy, name);
name = tc_canonicalize_symbol_name (copy);
}
#endif
if (! symbols_case_sensitive)
{
! unsigned char *copy;
! copy = (unsigned char *) alloca (strlen (name) + 1);
! strcpy (copy, name);
! name = (const char *) copy;
! for (; *copy != '\0'; copy++)
! if (islower (*copy))
! *copy = toupper (*copy);
}
return ((symbolS *) hash_find (sy_hash, name));
--- 456,485 ----
#ifdef tc_canonicalize_symbol_name
{
char *copy;
+ size_t len = strlen (name) + 1;
! copy = (char *) alloca (len);
! memcpy (copy, name, len);
name = tc_canonicalize_symbol_name (copy);
}
#endif
if (! symbols_case_sensitive)
{
! char *copy;
! const char *orig;
! unsigned char c;
! orig = name;
! name = copy = (char *) alloca (strlen (name) + 1);
!
! while ((c = *orig++) != '\0')
! {
! if (islower (c))
! c = toupper (c);
! *copy++ = c;
! }
! *copy = '\0';
}
return ((symbolS *) hash_find (sy_hash, name));