httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexei Kosut <>
Subject Re: please test snprintf (really this time)
Date Mon, 13 Jan 1997 02:20:43 GMT
On Sun, 12 Jan 1997, Marc Slemko wrote:

> Please get
> and extract it.  It contains ap_snprintf routines and a test program
> that isn't very pretty but has some use.  Then try the following:
> 	- if you don't have *cvt(), uncomment the CVTFLAGS line in the
> 	  Makefile to use the ones in ap_snprintf.c.  If your OS
> 	  does have them, and is something that isn't marked below as
> 	  having them, let me know.  In any case, be sure to try
> 	  the tests once with CVTFLAGS uncommented since I'm leaning
> 	  towards saying it should be shipped to use our own (stolen)
> 	  *cgt()'s for all systems.

That doesn't work with HP-UX 9.04 (9000/826) and gcc 2.7.2 (it doesn't
compile at all with HP's cc, but I have the cheap, non-working one):

        gcc -DNEED_CVT -Wall -ansi -c ap_snprintf.c
ap_snprintf.c:108: conflicting types for `ap_ecvt'
previous declaration of `ap_ecvt'
ap_snprintf.c:114: conflicting types for `ap_fcvt'
previous declaration of `ap_fcvt'
ap_snprintf.c:125: conflicting types for `ap_gcvt'
previous declaration of `ap_gcvt'
*** Error code 1

Without NEED_CVT, it works fine. (they're also defined in
/usr/include/stdlib.h, not just the gcc headers). How about including
stdlib.h *after* redefining ecvt, fcvt and gcvt? HP-UX uses size_t
instead of int in the function decls, so you end up defining the ap_*
functions differently, once in stdlib.h, and then again in
ap_snprintf.c. If you move the define to the top of the file, it
compiles and runs fine.

> 	- if your OS has snprintf, make diff will show the differences
> 	  between the same program using ap_snprintf and your vendor
> 	  snprintf.

HP-UX has snprintf(), but test-sn gives me a very different output
than test-ap: All the precisions are off. Section 2 of test-ap.out,
for example, is comprised of "000", whereas section 2 of test-sn.out
is comprised of "00000000000000000000" and "000000000.000000e+00" and
some other variations. Things like that all over. I can email the
output if someone wants it.

Timewise, they both seem to take about the same amount of time:
sometimes test-ap is .1 or .2 seconds faster, sometimes test-sn is.

> 	- make good-diff will show the differences between what
> 	  ap_snprintf should output (ie. what it does for me) and what
> 	  it does on your platform.  Some differences, mainly related
> 	  to [-]0, are expected.

no differences, I passed.

> Please report any compile time warnings or (especially) errors and any
> unexpected output in the diffs to me.

        gcc -Wall -ansi test.c -o test-sn
test.c: In function `main':
test.c:38: warning: implicit declaration of function `snprintf'

This is because although there is an snprintf in libc, it does not
exist in any of the header files. Is this a clue to us not to use it?
It would appear so.

Alexei Kosut <>      The Apache HTTP Server

View raw message