httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Slemko <ma...@znep.com>
Subject Re: PLEASE try compiling snprintf.c (was: Re: snprintf.c uploaded)
Date Sun, 12 Jan 1997 20:58:46 GMT
On Sun, 12 Jan 1997, Jim Jagielski wrote:

> Marc Slemko wrote:
> > 
> > Try linking something and you will notice that you need cvt, gcvt, etc.
> > I think cvt.c and gvct.c are all that I needed to add to make it work.
> > >From my tests, I think there are a few bugs to hunt down in the code
> > too...
> 
> Hmmm... on the systems I've tried, *cvt()s are already available :/

Oh.  Which ones?

Solaris, AIX, SunOS and IRIX do.  FreeBSD and BSD/OS don't.

So do we use vendor libraries where possible or do we rename them all and
use our own?

Oh, and it appears like strx_printv acts like strncpy in that it does not
null terminate the buffer if it has to truncate the string.  That is bad. 
I _think_ the below patch should fix it. 

There are some other places in the code that a cleanup wouldn't hurt, but
so far so good.  

Oh, and ap_snprintf is turning out to be faster than FreeBSD's snprintf in
the tests that I'm doing right now.

--- snprintf.c	1997/01/12 08:39:48	1.1
+++ snprintf.c	1997/01/12 20:30:33
@@ -725,7 +725,7 @@
     * Do the conversion
     */
     cc = __sio_converter( &od, -1, format, ap ) ;
-    if ( len == 0 || od.nextb < od.buf_end )
+    if ( len == 0 || od.nextb <= od.buf_end )
 	*(od.nextb) = '\0' ;
     if ( ccp )
 	*ccp = cc ;



> 
> > 
> > I think what we should end up doing is something like:
> > 
> > #if defined(HAVE_SNPRINTF)
> > #define ap_snprintf snprintf
> > #define ap_vsnprintf vsnprintf
> > #elif defined(USE_SPRINTF_FOR_SNPRINTF)
> > /* big comment about how bad this is */
> > (wrappers to call sprintf)
> > #else
> > (stuff for ap_snprintf and ap_vsnpinrtf)
> > #endif
> > 
> > with the USE_SPRINTF_FOR_SNPRINTF bit being optional.  Personally, I don't
> > see the harm in including it as long as:
> > 	- there is a nice big scary warning message
> > 	- it is not done automatically at all
> > 	- it isn't even documented outside ap_snprintf.c
> > 
> 
> Hmmm.... I would be happier if the USE_SPRINTF_FOR_SNPRINTF was as
> close to the end as possible :) I'll work something out... I have
> to convince myself to overrule my -1 about that.
> 
> 
> -- 
> ====================================================================
>       Jim Jagielski            |       jaguNET Access Services
>      jim@jaguNET.com           |       http://www.jaguNET.com/
>                   "Not the Craw... the CRAW!"
> 




Mime
View raw message