Browse Source

hex conversion bug fix.

master
Felix von Leitner 21 years ago
parent
commit
c4914f530b
  1. 2
      fmt/fmt_xlong.c
  2. 9
      socket/fmt_ip6_flat.c
  3. 4
      t.c

2
fmt/fmt_xlong.c

@ -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) {

9
socket/fmt_ip6_flat.c

@ -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