mirror of
https://github.com/opnsense/src.git
synced 2026-04-29 01:59:38 -04:00
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.
This commit is contained in:
parent
dcf11ee64e
commit
3d09cebfce
1 changed files with 11 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue