Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
419 B

21 years ago
#include "fmt.h"
#include "haveinline.h"
21 years ago
static inline char tohex(char c) {
return (char)(c>=10?c-10+'a':c+'0');
21 years ago
}
size_t fmt_xlong(char *dest,unsigned long i) {
21 years ago
register unsigned long len,tmp;
/* first count the number of bytes needed */
for (len=1, tmp=i; tmp>15; ++len) tmp>>=4;
if (dest)
21 years ago
for (tmp=i, dest+=len; ; ) {
21 years ago
*--dest = tohex(tmp&15);
21 years ago
if (!(tmp>>=4)) break;
}
21 years ago
return len;
}