Browse Source

hex conversion bug fix.

master
Felix von Leitner 19 years ago
parent
commit
c4914f530b
3 changed files with 6 additions and 9 deletions
  1. +1
    -1
      fmt/fmt_xlong.c
  2. +2
    -7
      socket/fmt_ip6_flat.c
  3. +3
    -1
      t.c

+ 1
- 1
fmt/fmt_xlong.c View File

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


+ 2
- 7
socket/fmt_ip6_flat.c View File

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


+ 3
- 1
t.c View File

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