public inbox for gas2@sourceware.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@cygnus.com>
To: gas2@sourceware.cygnus.com
Subject: type correctness tweek
Date: Thu, 06 May 1999 19:50:00 -0000	[thread overview]
Message-ID: <19990506194959.A14761@cygnus.com> (raw)

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));

                 reply	other threads:[~1999-05-06 19:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=19990506194959.A14761@cygnus.com \
    --to=rth@cygnus.com \
    --cc=gas2@sourceware.cygnus.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).