diff options
author | Guy Harris <guy@alum.mit.edu> | 2001-10-30 08:39:02 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2001-10-30 08:39:02 +0000 |
commit | 752e079f12e1aedb07630126239b7ffe0f7ba359 (patch) | |
tree | 234722d971b8d49cb72ee813aedded8d38050569 | |
parent | 62d224011d6315fedb5d66810692e54697f031d9 (diff) | |
download | wireshark-752e079f12e1aedb07630126239b7ffe0f7ba359.tar.gz wireshark-752e079f12e1aedb07630126239b7ffe0f7ba359.tar.bz2 wireshark-752e079f12e1aedb07630126239b7ffe0f7ba359.zip |
In "u64toa()":
If the byte being investigated is 0, don't just do a "continue";
this might be one of the passes on which we have to propagate
carries, so skip the processing of that byte's bits, but fall
through to the carry processing.
In the carry processing loop, don't use "i" as the loop index,
as we're already using it as the outer loop index.
In "u64toh()", use lower-case letters rather than upper-case letters, as
we use "%x" rather than "%X" to print 8, 16, 24, and 32-bit integral
values in the "proto.c" code.
svn path=/trunk/; revision=4103
-rw-r--r-- | int-64bit.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/int-64bit.c b/int-64bit.c index b2f20999fe..4f11088a6b 100644 --- a/int-64bit.c +++ b/int-64bit.c @@ -2,7 +2,7 @@ * Routines for handling of 64-bit integers * 2001 Ronnie Sahlberg * - * $Id: int-64bit.c,v 1.2 2001/10/29 21:53:58 guy Exp $ + * $Id: int-64bit.c,v 1.3 2001/10/30 08:39:02 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -138,12 +138,12 @@ u64toa(const unsigned char *u64ptr) /* optimize, most of these bytes will be 0 ?*/ if(u64ptr[i]==0){ pos+=8; - continue; - } - for(j=0;j<8;j++,pos++){ - if(u64ptr[i]&(1<<j)){ - for(k=0;k<U64STRLEN-1;k++){ - acc[k]+=u64val[pos][k]; + } else { + for(j=0;j<8;j++,pos++){ + if(u64ptr[i]&(1<<j)){ + for(k=0;k<U64STRLEN-1;k++){ + acc[k]+=u64val[pos][k]; + } } } } @@ -156,12 +156,12 @@ u64toa(const unsigned char *u64ptr) */ if((i%4)==0){ /* handle carries */ - for(i=0;i<U64STRLEN-1;i++){ - if(acc[i]>9){ + for(j=0;j<U64STRLEN-1;j++){ + if(acc[j]>9){ int x; - x=acc[i]/10; - acc[i+1]+=x; - acc[i]-=x*10; + x=acc[j]/10; + acc[j+1]+=x; + acc[j]-=x*10; } } } @@ -272,7 +272,7 @@ u64toh(const unsigned char *u64ptr) { static char str[19], *strp; static char ntoh[] = {'0','1','2','3','4','5','6','7', - '8','9','A','B','C','D','E','F'}; + '8','9','a','b','c','d','e','f'}; int i; str[0]='0'; |