aboutsummaryrefslogtreecommitdiff
path: root/stdlib/tst-strtol.c
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/tst-strtol.c')
-rw-r--r--stdlib/tst-strtol.c49
1 files changed, 26 insertions, 23 deletions
diff --git a/stdlib/tst-strtol.c b/stdlib/tst-strtol.c
index e351e97..0857871 100644
--- a/stdlib/tst-strtol.c
+++ b/stdlib/tst-strtol.c
@@ -79,16 +79,19 @@ main (int argc, char ** argv)
register const struct ltest *lt;
char *ep;
int status = 0;
+ int save_errno;
for (lt = tests; lt->str != NULL; ++lt)
{
register long int l;
errno = 0;
- l = strtol(lt->str, &ep, lt->base);
- printf("strtol(\"%s\", , %d) test %u",
- lt->str, lt->base, (unsigned int) (lt - tests));
- if (l == (long int) lt->expect && *ep == lt->left && errno == lt->err)
+ l = strtol (lt->str, &ep, lt->base);
+ save_errno = errno;
+ printf ("strtol(\"%s\", , %d) test %u",
+ lt->str, lt->base, (unsigned int) (lt - tests));
+ if (l == (long int) lt->expect && *ep == lt->left
+ && save_errno == lt->err)
puts("\tOK");
else
{
@@ -99,13 +102,13 @@ main (int argc, char ** argv)
if (lt->left != *ep)
{
char exp1[5], exp2[5];
- expand(exp1, *ep);
- expand(exp2, lt->left);
- printf(" leaves '%s', expected '%s'\n", exp1, exp2);
+ expand (exp1, *ep);
+ expand (exp2, lt->left);
+ printf (" leaves '%s', expected '%s'\n", exp1, exp2);
}
if (errno != lt->err)
- printf(" errno %d (%s) instead of %d (%s)\n",
- errno, strerror(errno), lt->err, strerror(lt->err));
+ printf (" errno %d (%s) instead of %d (%s)\n",
+ errno, strerror (errno), lt->err, strerror (lt->err));
status = 1;
}
}
@@ -115,32 +118,32 @@ main (int argc, char ** argv)
register unsigned long int ul;
errno = 0;
- ul = strtoul(lt->str, &ep, lt->base);
- printf("strtoul(\"%s\", , %d) test %u",
- lt->str, lt->base, (unsigned int) (lt - tests));
+ ul = strtoul (lt->str, &ep, lt->base);
+ printf ("strtoul(\"%s\", , %d) test %u",
+ lt->str, lt->base, (unsigned int) (lt - tests));
if (ul == lt->expect && *ep == lt->left && errno == lt->err)
puts("\tOK");
else
{
- puts("\tBAD");
+ puts ("\tBAD");
if (ul != lt->expect)
- printf(" returns %lu, expected %lu\n",
- ul, lt->expect);
+ printf (" returns %lu, expected %lu\n",
+ ul, lt->expect);
if (lt->left != *ep)
{
char exp1[5], exp2[5];
- expand(exp1, *ep);
- expand(exp2, lt->left);
- printf(" leaves '%s', expected '%s'\n", exp1, exp2);
+ expand (exp1, *ep);
+ expand (exp2, lt->left);
+ printf (" leaves '%s', expected '%s'\n", exp1, exp2);
}
if (errno != lt->err)
- printf(" errno %d (%s) instead of %d (%s)\n",
- errno, strerror(errno), lt->err, strerror(lt->err));
+ printf (" errno %d (%s) instead of %d (%s)\n",
+ errno, strerror (errno), lt->err, strerror (lt->err));
status = 1;
}
}
- exit(status ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit (status ? EXIT_FAILURE : EXIT_SUCCESS);
}
static void
@@ -148,11 +151,11 @@ expand (dst, c)
char *dst;
int c;
{
- if (isprint(c))
+ if (isprint (c))
{
dst[0] = c;
dst[1] = '\0';
}
else
- (void) sprintf(dst, "%#.3o", (unsigned int) c);
+ (void) sprintf (dst, "%#.3o", (unsigned int) c);
}