Mail Archives: djgpp-workers/2002/02/12/15:01:25
Hello.
Andris Pavenis wrote:
>
> On Mon, 11 Feb 2002, Richard Dawe wrote:
>
[snip]
> > pavenis AT lanet DOT lv wrote:
> > > diff -ur3 djgpp.orig/src/libc/posix/unistd/confstr.c
> > > djgpp/src/libc/posix/unistd/confstr.c
> > > --- djgpp.orig/src/libc/posix/unistd/confstr.c Wed Jun 20 02:00:46 2001
> > > +++ djgpp/src/libc/posix/unistd/confstr.c Mon Feb 11 18:17:28 2002
> > > @@ -43,7 +43,9 @@
> > > case _CS_POSIX_V6_ILP32_OFF32_LDFLAGS:
> > > case _CS_POSIX_V6_ILP32_OFF32_LIBS:
> > > {
> > > - out_len = snprintf(buf, len, "");
> > > +/* out_len = snprintf(buf, len, ""); */
> > > + if (len>0) *buf=0;
> > > + out_len=0;
> > > ++out_len;
> > > break;
> > > }
> >
> > Why not just set out_len to 1? Also, presumably the comment will be
> > removed too?
>
> snprintf should output number of outputted chars not including trailing \0
> AFAIK, so 0 is correct. gcc-3.1 20020210 emitted warning about empty
> format string. Maybe it will not be so later, so I left snprintf in
> comment. We could also revert this change when (if) we'll need some real
> snprintf there.
What I meant was this: the codes sets out_len to zero, then increments it. Why
not just set it to 1? I hope/expect the compiler could optimise this case.
Bye, Rich =]
--
Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]
- Raw text -