[Libclc-developers] Re: clc_ultostr(5)
Status: Planning
Brought to you by:
augestad
|
From: Jan E. <je...@li...> - 2003-03-23 10:17:05
|
>I found a few more bugs in this function. Below is a copy of the latest
>CVS version. Lesson learned: No more submissions without a test program? ;-)
I was too lazy to download libclc for this machine ;)
>int clc_ultostr(char *ptr, size_t size, unsigned long num, int base)
>{
> const char *sym = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
> char* sp;
Hey your style ain't even consistent (char* and char *)
> /* Point to the last char in buffer */
Prefering //
I once addressed that sp was startp, but that seems to be overlooked,
anyway it's fixed . in here.
> sp = ptr + size - 1;
> *sp = '\0';
> do {
> *--sp = sym[num % base];
> num /= base;
> } while (num > 0 && sp != ptr);
>
> if(num > 0)
> return 0;
> else if(ptr != sp)
> memmove(ptr, sp, size - (sp - ptr));
Other thing: when you said comp.lang.c shall approve functions,
I recall that they claimed about the topicality of libclc in there...
i think this list is fine for it.
- Jan Engelhardt
|