Re: [Libclc-developers] Re: clc_ultostr(5)
Status: Planning
Brought to you by:
augestad
|
From: Hallvard B F. <h.b...@us...> - 2003-03-25 14:53:00
|
Sorry about the empty message.
Jan Engelhardt writes:
>> int clc_ultostr(char *ptr, size_t size, unsigned long num, int base)
>> {
>> (...)
>> /* Point to the last char in buffer */
> Prefering //
C89 only supports '/**/'. '//' is C99/C++.
>> } while (num > 0 && sp != ptr);
'while (num && sp != ptr)' is enough.
>> if(num > 0)
>> return 0;
>> else if(ptr != sp)
>> memmove(ptr, sp, size - (sp - ptr));
Please memmove in either case. Return 1 (or length of string) if no
truncation, 0 if there is a truncated result:
if(ptr != sp)
memmove(ptr, sp, size - (sp - ptr));
return !num;
--
Hallvard
|