summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2001-12-17 23:14:14 +0000
committerache <ache@FreeBSD.org>2001-12-17 23:14:14 +0000
commit67e3e37c96fe507d9be6a6fc7b6b948582fbf62c (patch)
treec1eacab027a774a528c67c5aba3ddfba454c4a4e /bin
parent6abf6dd855ba8d1a0e1360b33ce40fe1e86e5435 (diff)
downloadFreeBSD-src-67e3e37c96fe507d9be6a6fc7b6b948582fbf62c.zip
FreeBSD-src-67e3e37c96fe507d9be6a6fc7b6b948582fbf62c.tar.gz
1) Localize (LC_CTYPE)
2) Catch "" to 0 conversion for OSes that not catch it in strto*() (f.e. -stable). It is needed because POSIX agrees with both variants.
Diffstat (limited to 'bin')
-rw-r--r--bin/test/test.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/bin/test/test.c b/bin/test/test.c
index eed394c..b88085c 100644
--- a/bin/test/test.c
+++ b/bin/test/test.c
@@ -32,6 +32,8 @@ static const char rcsid[] =
#define main testcmd
#include "bltin/bltin.h"
#else
+#include <locale.h>
+
static void error(const char *, ...) __attribute__((__noreturn__));
static void
@@ -213,6 +215,9 @@ main(argc, argv)
if (--argc <= 0)
return 1;
+#ifndef SHELL
+ (void)setlocale(LC_CTYPE, "");
+#endif
/* XXX work around the absence of an eaccess(2) syscall */
(void)setgid(getegid());
(void)setuid(geteuid());
@@ -469,6 +474,9 @@ getn(s)
errno = 0;
r = strtol(s, &p, 10);
+ if (s == p)
+ error("%s: bad number", s);
+
if (errno != 0)
error((errno == EINVAL) ? "%s: bad number" :
"%s: out of range", s);
@@ -493,6 +501,9 @@ getq(s)
errno = 0;
r = strtoq(s, &p, 10);
+ if (s == p)
+ error("%s: bad number", s);
+
if (errno != 0)
error((errno == EINVAL) ? "%s: bad number" :
"%s: out of range", s);
OpenPOWER on IntegriCloud