Fix calls to malloc, realloc in prefix.c

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Thu Feb 17 14:23:00 GMT 2000


 > From: Zack Weinberg <zack@wolery.cumb.org>
 > 
 > You have inspired me... try this patch on for size.  Does a bunch of
 > stuff:


Great thanks!  Comments below.



 > - compile fix-header with $(CC) and add some commentary about why


Err, even though it should never run in a cross compile, I don't
entirely agree with this.

But I guess it should be okay...  maybe... :-)

Anyway to be consistent, you should also change the includes of
hconfig.h to config.h in any file affected.



 >  GCC_NEED_DECLARATIONS(bcopy bzero bcmp \
 > -	index rindex getenv atol sbrk abort atof strerror getcwd getwd \
 > +	index rindex getenv atol sbrk abort atof getcwd getwd \
 >  	strsignal putc_unlocked fputs_unlocked strstr environ)

Don't take strerror decl check out here.  Its still called in fixincl.c
so we should still provide a decl if the system doesn't.  (At least until
all calls are changed to xstrerror.)


 > Index: system.h
 > --- system.h	2000/01/17 15:47:29	1.59
 > +++ system.h	2000/02/17 18:41:13
 > @@ -394,17 +394,6 @@ extern PTR calloc PARAMS ((size_t, size_
 >  extern PTR realloc PARAMS ((PTR, size_t));
 >  #endif
 >  
 > -#ifdef HAVE_STRERROR
 > -# ifdef NEED_DECLARATION_STRERROR
 > -#  ifndef strerror
 > -extern char *strerror PARAMS ((int));
 > -#  endif
 > -# endif
 > -#else /* ! HAVE_STRERROR */
 > -extern int sys_nerr;
 > -extern char *sys_errlist[];
 > -#endif /* HAVE_STRERROR */
 > -


Likewise, you can nuke the sys_nerr/sys_errlist, but keep the strerror
prototype.  E.g.:

#ifdef NEED_DECLARATION_STRERROR
# ifndef strerror
extern char *strerror PARAMS ((int));
# endif
#endif




 > -  cpp_error (pfile, "%s: %s", name, my_strerror (errno));
 > +  cpp_error (pfile, "%s: %s", name, strerror (errno));
 >  }
 >  
 >  void
 > @@ -473,5 +439,5 @@ cpp_notice_from_errno (pfile, name)
 >       cpp_reader *pfile;
 >       const char *name;
 >  {
 > -  cpp_notice (pfile, "%s: %s", name, my_strerror (errno));
 > +  cpp_notice (pfile, "%s: %s", name, strerror (errno));

Why not use xstrerror here?  Keep us close to being able to remove the
prototype of strerror. :-)

		--Kaveh
--
Kaveh R. Ghazi			Engagement Manager / Project Services
ghazi@caip.rutgers.edu		Qwest Internet Solutions


More information about the Gcc-patches mailing list