forked from osmocom/wireshark
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
This commit is contained in:
parent
62d224011d
commit
752e079f12
26
int-64bit.c
26
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';
|
||||
|
|
Loading…
Reference in New Issue