hex conversion bug fix.

master
leitner 24 years ago
parent 647dd96943
commit 5c1abf12b5

@ -1,7 +1,7 @@
#include "fmt.h"
static inline char tohex(char c) {
return c>10?c-10+'a':c+'0';
return c>=10?c-10+'a':c+'0';
}
unsigned int fmt_xlong(char *dest,unsigned long i) {

@ -1,12 +1,7 @@
#include "ip6.h"
static char tohex(char num) {
if (num<10)
return num+'0';
else if (num<16)
return num-10+'a';
else
return -1;
static inline char tohex(char c) {
return c>=10?c-10+'a':c+'0';
}
unsigned int fmt_ip6_flat(char *s,const char ip[16])

4
t.c

@ -20,11 +20,13 @@ int main(int argc,char* argv[]) {
buffer_flush(buffer_1small);
#endif
buf[fmt_xlong(buf,0)]=0;
puts(buf);
rdtscl(a);
c=str_len(buf);
rdtscl(b);
/*byte_zero_djb(buf,j); */
printf("\n%lu %d\n",b-a,c);
// printf("\n%lu %d\n",b-a,c);
#if 0
buffer_puts(buffer_1small,"hello, world\n");
buffer_flush(buffer_1small);

Loading…
Cancel
Save