Patch to add ACONCAT macro to libiberty

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Tue Sep 18 09:23:00 GMT 2001


 > From: DJ Delorie <dj@redhat.com>
 > 
 > Next time, please wait for the "approved" email.

Oops, sorry.  I thought your last email was the entirety of your
feedback.  I'll of course update with any changes you want and/or
revert it should you decide so.


 > > gcc:
 > > 	* gcc.c (find_file): Use ACONCAT in lieu of alloca/strcpy/strcat.
 > 
 > I have no approval rights for gcc.c.

I know, that one I took upon myself to install as "obvious".


 > > + /* Determine the length of concatenating an arbitrary number of
 > > +    strings, up to (char *) NULL.  */
 > > + 
 > > + extern unsigned long concat_length PARAMS ((const char *, ...));
 > 
 > This should say "including" not "up to".


I don't think so, I copied that fragment from the comments above the
original concat function.  The NULL in this case refers to the last
argument to concat, not the trailing NULL terminator in any string.
That last NULL argument is not copied, its a marker for the end of the
variable argument list.


 > > + /* Concatenate an arbitrary number of strings into a GLOBAL area of
 > > +    memory, up to (char *) NULL.  The supplied memory is assumed to be
 > > +    large enough.  */
 > > + 
 > > + extern char *concat_copy2 PARAMS ((const char *, ...));
 > 
 > This is not needed; you can use concat_copy and pass libiberty_concat_ptr.

I don't think so, though I'd be pleasantly surprised to be proven
wrong. :-)

The problem here is the fact that the concat functions have variable
arguments.  The only way I know of to handle this in a macro is to use
the double paren stuff (like PARAMS) to stuff the variable arguments
into one macro parameter.  This means you can't add or subtract
arguments when you refer to them in subsequent calls cause they're
encapsulated in parentheses.  Thus I needed a concat_copy2 which had
the same parameter signature as ACONCAT/concat_length.  The one
function that isn't used yet is `concat_copy', but I thought it would
be useful to expose a more general purpose interface.  I can get rid
of it if you want, but I may end up adding back later in another
patch. :-)

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



More information about the Gcc-patches mailing list