httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Slemko <ma...@znep.com>
Subject ap_snprintf and 64-bit machines
Date Sat, 18 Jan 1997 22:02:50 GMT
After looking at it, I'm not sure there is a problem.

Take the following code:

	int main () {
		char buf[1000];

		snprintf(buf, sizeof(buf), "%u", (int)-1);
		printf("buf = %s\n", buf);
		ap_snprintf(buf, sizeof(buf), "%u", (int)-1);
		printf("buf = %s\n", buf);
	}

On an Alpha running Linux I get:

	buf = 4294967295
	buf = 18446744073709551615

snprintf is the one that seems wrong to me.  I would expect the code to
print 2^64 - 1 like ap_snprintf does, not 2^32 - 1 like snprintf does.
Does snprintf do that on Linux just because some broken programs
assume things will work that way?  What do other 64-bit platforms do?

I _think_ that is the main source of differences.  (well, there
are a whole whack of other differences between the sample output
from my test program and the output you get, but that is because
some of my numbers are generated based on INT_MAX.)

In any case, I don't see it being a problem.

Oh, and "#include <string.h>" should be added to util_snprintf.c me
thinks.


Mime
View raw message