[CF-Devel] bug in some libc 64 bit parsing

crossfire-devel-admin at archives.real-time.com crossfire-devel-admin at archives.real-time.com
Mon Mar 17 15:11:52 CST 2003


Hello,

I took the last cvs snapshot of Crossfire Server, and I had a problem when I
launch the compiled server : the "experience" table don't load at the first
"big" (real 64 bit) level value (12 I think).

After some tracing, I noticed it's because my "atoll" libc function is broken
(the one with GLIBC_2.1.1 of a Mandrake/Redhat 6.0 Linux Distribution on x86).

atoll in this version of the libc+distribution act on 32 bit values only : see
example of this program :


/*************************************************************
/* fichier longlong.c */
/* Olivier Huet */

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

typedef long long sint64;

sint64 myatoll(const char *ch)
{
	sint64 res = 0;
	if (ch != NULL)
	{
		while (isdigit(*ch))
		{
			res=res*10 + (*ch-'0');
			++ch;
		}
	}
	return res;
}

int main()
{
	long long toto = 6283200000LL;
	const char *sToto = "6283200000";

	long long interToto = atoll(sToto);
	long long myInterToto = myatoll(sToto);
	
	printf("sizeof(long long)=%i"
		   ", toto=%lld"
		   ", interToto=%lld"
		   ", myInterToto=%lld\n"
		   ,
		   sizeof(long long),
		   toto,
		   interToto,
		   myInterToto
		);
	return 0;
}
/************************************************************************/


--> When compiled and ran :
gcc -Wall -o longlong longlong.c && longlong
sizeof(long long)=8, toto=6283200000, interToto=1988232704, myInterToto=6283200000



atoll don't work with this.

When replacing all "atoll" calls in the crossfire server with this "myatoll"
function, it looks like it worked well (the server launched), but I didn't try
with these real experience value (I don't have such powerfull players).

So it would perhaps be a good idea to put something like that... (in porting.c
?), perhaps embraced with a define that is defined when there is this "buggy 64
bit parsing".


Olivier.


_______________________________________________
crossfire-devel mailing list
     
     crossfire-devel at lists.real-time.com
     
     
     https://mailman.real-time.com/mailman/listinfo/crossfire-devel
     
     
    


More information about the crossfire mailing list