diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2006-10-25 18:58:43 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2006-10-25 18:58:43 +0000 |
commit | 21a1e2be5a3a504ff2ebd7e80d306041e066e6bb (patch) | |
tree | e92e14330a3faf508424b2b3b60810c63a4d4608 /usr.sbin/ifstated | |
parent | bdb4dc481347d2dc58bd43d49d860a1a6c2df938 (diff) |
strtonum, Pierre-Yves Ritschard <pyr@spootnik.org>
Diffstat (limited to 'usr.sbin/ifstated')
-rw-r--r-- | usr.sbin/ifstated/parse.y | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/usr.sbin/ifstated/parse.y b/usr.sbin/ifstated/parse.y index 8caed9314b5..4b9673ddc19 100644 --- a/usr.sbin/ifstated/parse.y +++ b/usr.sbin/ifstated/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.15 2006/10/25 18:57:34 henning Exp $ */ +/* $OpenBSD: parse.y,v 1.16 2006/10/25 18:58:42 henning Exp $ */ /* * Copyright (c) 2004 Ryan McBride <mcbride@openbsd.org> @@ -72,7 +72,6 @@ struct sym { void link_states(struct ifsd_action *); int symset(const char *, const char *, int); char *symget(const char *); -int atoul(char *, u_long *); void set_expression_depth(struct ifsd_expression *, int); void init_state(struct ifsd_state *); struct ifsd_ifstate *new_ifstate(u_short, int); @@ -120,14 +119,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); } ; @@ -781,22 +782,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); -} - void set_expression_depth(struct ifsd_expression *expression, int depth) { |