strtonum.c: Update to OpenBSD v1.7, style tweaks

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2016-01-07 02:58:06 +01:00
1 parent 74dcaddc55
commit 8aecba2b7a
2 files changed
+8 -7

No files matched your search

+1
View File
@@ -16,6 +16,7 @@ All notable changes to the project are documented in this file.
support for circular queues (CIRCLEQ). support for circular queues (CIRCLEQ).
- Update `strlcpy.c` to OpenBSD v1.12, readability fixes. - Update `strlcpy.c` to OpenBSD v1.12, readability fixes.
- Update `strlcat.c` to OpenBSD v1.14, readability fixes. - Update `strlcat.c` to OpenBSD v1.14, readability fixes.
- Update `strtonum.c` to OpenBSD v1.7, tiniest of style tweaks.
[v1.2.0][] - 2015-11-23 [v1.2.0][] - 2015-11-23
+7 -7
View File
@@ -1,4 +1,4 @@
/* $OpenBSD: strtonum.c,v 1.6 2004/08/03 19:38:01 millert Exp $ */ /* $OpenBSD: strtonum.c,v 1.7 2013/04/17 18:40:58 tedu Exp $ */
/* /*
* Copyright (c) 2004 Ted Unangst and Todd Miller * Copyright (c) 2004 Ted Unangst and Todd Miller
@@ -22,17 +22,17 @@
#include <stdlib.h> #include <stdlib.h>
#ifndef strtonum #ifndef strtonum
#define INVALID 1 #define INVALID 1
#define TOOSMALL 2 #define TOOSMALL 2
#define TOOLARGE 3 #define TOOLARGE 3
long long long long
strtonum(const char *numstr, long long minval, long long maxval, strtonum(const char *numstr, long long minval, long long maxval,
const char **errstrp) const char **errstrp)
{ {
long long ll = 0; long long ll = 0;
char *ep;
int error = 0; int error = 0;
char *ep;
struct errval { struct errval {
const char *errstr; const char *errstr;
int err; int err;
@@ -45,9 +45,9 @@ strtonum(const char *numstr, long long minval, long long maxval,
ev[0].err = errno; ev[0].err = errno;
errno = 0; errno = 0;
if (minval > maxval) if (minval > maxval) {
error = INVALID; error = INVALID;
else { } else {
ll = strtoll(numstr, &ep, 10); ll = strtoll(numstr, &ep, 10);
if (numstr == ep || *ep != '\0') if (numstr == ep || *ep != '\0')
error = INVALID; error = INVALID;