385 |
memcpy(p, day_tab + t->tm_wday * 4, 4); |
memcpy(p, day_tab + t->tm_wday * 4, 4); |
386 |
} |
} |
387 |
|
|
388 |
void simple_itoa(unsigned int i, char buf[22]) |
void simple_itoa(unsigned long int i, char buf[22]) |
389 |
{ |
{ |
390 |
/* 21 digits plus null terminator, good for 64-bit or smaller ints |
/* 21 digits plus null terminator, good for 64-bit or smaller ints |
391 |
* for bigger ints, use a bigger buffer! |
* for bigger ints, use a bigger buffer! |
393 |
* 4294967295 is, incidentally, MAX_UINT (on 32bit systems at this time) |
* 4294967295 is, incidentally, MAX_UINT (on 32bit systems at this time) |
394 |
* and is 10 bytes long |
* and is 10 bytes long |
395 |
*/ |
*/ |
|
/* FIXME */ |
|
396 |
char *p = &buf[21]; |
char *p = &buf[21]; |
397 |
|
int digits = 1; /* include null char */ |
398 |
|
|
399 |
*p-- = '\0'; |
*p-- = '\0'; |
400 |
do { |
do { |
401 |
|
digits++; |
402 |
*p-- = '0' + i % 10; |
*p-- = '0' + i % 10; |
403 |
i /= 10; |
i /= 10; |
404 |
} while (i > 0); |
} while (i > 0); |
405 |
|
|
406 |
|
p++; |
407 |
|
if (p!=buf) memmove( buf, p, digits); |
408 |
|
|
409 |
return; |
return; |
410 |
} |
} |
411 |
|
|
413 |
* Therefore, -1 indicates error |
* Therefore, -1 indicates error |
414 |
*/ |
*/ |
415 |
|
|
416 |
int boa_atoi(char *s) |
int boa_atoi(const char *s) |
417 |
{ |
{ |
418 |
int retval; |
int retval; |
419 |
char reconv[22]; |
char reconv[22]; |
421 |
if (!isdigit(*s)) |
if (!isdigit(*s)) |
422 |
return -1; |
return -1; |
423 |
|
|
424 |
retval = atoi(s); |
retval = atoi( s); |
425 |
if (retval < 0) |
if (retval < 0) |
426 |
return -1; |
return -1; |
427 |
|
|