1
/* This is a copy of 'atol-1.c', but without <stdlib.h>.
2
The purpose is to check a native atol() function, as today (2007-02-06)
3
the <stdlib.h> header substitutes an inlined version with strtol() usage.
5
$Id: atol-2.c,v 1.1 2007/02/06 12:36:58 dmix Exp $
12
long atol (const char *);
15
PROGMEM const struct {
36
{ "-987654321", -987654321 },
37
{ "+1234567890", 1234567890 },
38
{ "2147483647", 2147483647 },
39
{ "-2147483647", -2147483647 },
40
{ "-2147483648", 0x80000000 },
42
/* Nonzero end character */
45
{ "1234/", 1234 }, /* '0'-1 == '/' */
46
{ "12345:", 12345 }, /* '9'+1 == ':' */
49
/* Empty symbols at begin */
52
{ "\t\n\v\f\r-321", -321 }, /* bug #18899 */
57
{ "\010123", 0 }, /* '\t'-1 == 010 */
58
{ "\016+123", 0 }, /* '\r'+1 == 016 */
60
/* atol() accepts 10-base only */
66
volatile long vlt = 1; /* for debug conveniency */
73
printf ("result=%ld against t[%d]={\"%s\", %ld}\n",
74
vlt, idx, t[idx].s, t[idx].val);
82
char s[sizeof(t[0].s)];
84
for (i = 0; i < (int)(sizeof(t) / sizeof(t[0])); i++) {
87
if (vlt != (long)pgm_read_dword (& t[i].val))