summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2006-10-25 18:55:42 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2006-10-25 18:55:42 +0000
commit50a9265f92a9d690704dec5fef9b8edf80573747 (patch)
treec29444a0e2aaea3391be0e7084f0c6d0553dc678
parent725b5089eb2f84e6db2846ee2956f4dbd8af42be (diff)
strtonum, Pierre-Yves Ritschard <pyr@spootnik.org>
-rw-r--r--usr.sbin/dvmrpd/parse.y29
1 files changed, 7 insertions, 22 deletions
diff --git a/usr.sbin/dvmrpd/parse.y b/usr.sbin/dvmrpd/parse.y
index 2625cc8c531..e5fcbd948e3 100644
--- a/usr.sbin/dvmrpd/parse.y
+++ b/usr.sbin/dvmrpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.2 2006/10/25 18:52:13 henning Exp $ */
+/* $OpenBSD: parse.y,v 1.3 2006/10/25 18:55:41 henning Exp $ */
/*
* Copyright (c) 2004, 2005, 2006 Esben Norby <norby@openbsd.org>
@@ -87,7 +87,6 @@ struct sym {
int symset(const char *, const char *, int);
char *symget(const char *);
-int atoul(char *, u_long *);
struct iface *conf_get_if(struct kif *);
struct iface *new_group(void);
@@ -125,14 +124,16 @@ grammar : /* empty */
;
number : STRING {
- u_long ulval;
+ u_int32_t uval;
+ const char *errstr;
- if (atoul($1, &ulval) == -1) {
- yyerror("%s is not a number", $1);
+ uval = strtonum($1, 0, UINT_MAX, &errstr);
+ if (errstr) {
+ yyerror("number %s is %s", $1, errstr);
free($1);
YYERROR;
} else
- $$ = ulval;
+ $$ = uval;
free($1);
}
;
@@ -737,22 +738,6 @@ symget(const char *nam)
return (NULL);
}
-int
-atoul(char *s, u_long *ulvalp)
-{
- u_long ulval;
- char *ep;
-
- errno = 0;
- ulval = strtoul(s, &ep, 0);
- if (s[0] == '\0' || *ep != '\0')
- return (-1);
- if (errno == ERANGE && ulval == ULONG_MAX)
- return (-1);
- *ulvalp = ulval;
- return (0);
-}
-
struct iface *
conf_get_if(struct kif *kif)
{