main shrub/shrubtools / shared / fmt_xlong.c
 1#include "fmt.h"
 2
 3unsigned int
 4fmt_xlong(char *s, unsigned long u)
 5{
 6  register unsigned int len; register unsigned long q; register char c;
 7  len = 1; q = u;
 8  while (q > 15) { ++len; q /= 16; }
 9  if (s) {
10    s += len;
11    do { c = '0' + (u & 15); if (c > '0' + 9) c += 'a' - '0' - 10;
12    *--s = c; u /= 16; } while(u);
13  }
14  return len;
15}