Re: [bug-gnulib] Re: extend the scope of xasprintf

2006-05-11 Thread Bruno Haible
Paul Eggert wrote: > I guess it partly depends on whether one prefers code to be easy to > read, or easy to write. I usually prefer the former. I also prefer code to be easy to read. But while reading code, casts don't attract my attention particularly... Bruno

Re: [bug-gnulib] Re: extend the scope of xasprintf

2006-05-10 Thread Paul Eggert
Bruno Haible <[EMAIL PROTECTED]> writes: > The less you have to think when manipulating some code, the better. True, but there are other concerns. When I read C code like this: (char *) I stop mentally and ask "why is that cast there?" Casts like that are dangerous, and I need to

Re: [bug-gnulib] Re: extend the scope of xasprintf

2006-05-10 Thread Bruno Haible
Mark D. Baushke wrote: > > static inline char * > > xstrcat (size_t argcount, va_list args) > > { > > char *result; > > ...elided... > > > /* Allocate and fill the result string. */ > > result = (char *) xmalloc (totalsize + 1); > > Why is the cast needed? I was under the impression that GNU

Re: [bug-gnulib] Re: extend the scope of xasprintf

2006-05-09 Thread Bruno Haible
Paul Eggert wrote: > totalsize is of type size_t, so SIZE_MAX is the problem case here, not > INT_MAX. Good point. Also a possible overflow in the xsum() calls before is needed. I'm committing this changed code. Bruno static inline char * xstrcat (size_t argcount, va_list args) { char *resu

Re: [bug-gnulib] Re: extend the scope of xasprintf

2006-05-09 Thread Bruno Haible
Eric Blake wrote: > > + p = result; > > + va_copy (ap, args); > > Why are you using va_copy a second time? vsprintf is allowed to consume > its va_list argument (aka use va_arg on it), so long as it leaves the > va_close for the caller. Right. This is an optim I had neglected. Thanks. > > +