|
|
@ -153,9 +153,8 @@ void gpr_reverse_bytes(char *str, int len) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int gpr_ltoa(long value, char *string) { |
|
|
|
int gpr_ltoa(long value, char *string) { |
|
|
|
unsigned long uval; |
|
|
|
long sign; |
|
|
|
int i = 0; |
|
|
|
int i = 0; |
|
|
|
int neg = value < 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (value == 0) { |
|
|
|
if (value == 0) { |
|
|
|
string[0] = '0'; |
|
|
|
string[0] = '0'; |
|
|
@ -163,25 +162,20 @@ int gpr_ltoa(long value, char *string) { |
|
|
|
return 1; |
|
|
|
return 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (neg) { |
|
|
|
sign = value < 0 ? -1 : 1; |
|
|
|
uval = (unsigned long)-value; |
|
|
|
while (value) { |
|
|
|
} else { |
|
|
|
string[i++] = (char)('0' + sign * (value % 10)); |
|
|
|
uval = (unsigned long)value; |
|
|
|
value /= 10; |
|
|
|
} |
|
|
|
} |
|
|
|
while (uval) { |
|
|
|
if (sign < 0) string[i++] = '-'; |
|
|
|
string[i++] = (char)('0' + uval % 10); |
|
|
|
|
|
|
|
uval /= 10; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (neg) string[i++] = '-'; |
|
|
|
|
|
|
|
gpr_reverse_bytes(string, i); |
|
|
|
gpr_reverse_bytes(string, i); |
|
|
|
string[i] = 0; |
|
|
|
string[i] = 0; |
|
|
|
return i; |
|
|
|
return i; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int gpr_int64toa(gpr_int64 value, char *string) { |
|
|
|
int gpr_int64toa(gpr_int64 value, char *string) { |
|
|
|
gpr_uint64 uval; |
|
|
|
gpr_int64 sign; |
|
|
|
int i = 0; |
|
|
|
int i = 0; |
|
|
|
int neg = value < 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (value == 0) { |
|
|
|
if (value == 0) { |
|
|
|
string[0] = '0'; |
|
|
|
string[0] = '0'; |
|
|
@ -189,16 +183,12 @@ int gpr_int64toa(gpr_int64 value, char *string) { |
|
|
|
return 1; |
|
|
|
return 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (neg) { |
|
|
|
sign = value < 0 ? -1 : 1; |
|
|
|
uval = (gpr_uint64)-value; |
|
|
|
while (value) { |
|
|
|
} else { |
|
|
|
string[i++] = (char)('0' + sign * (value % 10)); |
|
|
|
uval = (gpr_uint64)value; |
|
|
|
value /= 10; |
|
|
|
} |
|
|
|
|
|
|
|
while (uval) { |
|
|
|
|
|
|
|
string[i++] = (char)('0' + uval % 10); |
|
|
|
|
|
|
|
uval /= 10; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (neg) string[i++] = '-'; |
|
|
|
if (sign < 0) string[i++] = '-'; |
|
|
|
gpr_reverse_bytes(string, i); |
|
|
|
gpr_reverse_bytes(string, i); |
|
|
|
string[i] = 0; |
|
|
|
string[i] = 0; |
|
|
|
return i; |
|
|
|
return i; |
|
|
|