summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/misc.c b/misc.c
index dfa0bb33a..3d6bc3563 100644
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: misc.c,v 1.119 2017/11/25 06:46:22 dtucker Exp $ */ 1/* $OpenBSD: misc.c,v 1.120 2017/12/05 23:59:47 dtucker Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * Copyright (c) 2005,2006 Damien Miller. All rights reserved. 4 * Copyright (c) 2005,2006 Damien Miller. All rights reserved.
@@ -2112,3 +2112,17 @@ bad:
2112 *errstr = errbuf; 2112 *errstr = errbuf;
2113 return 0; 2113 return 0;
2114} 2114}
2115
2116const char *
2117atoi_err(const char *nptr, int *val)
2118{
2119 const char *errstr = NULL;
2120 long long num;
2121
2122 if (nptr == NULL || *nptr == '\0')
2123 return "missing";
2124 num = strtonum(nptr, 0, INT_MAX, &errstr);
2125 if (errstr == NULL)
2126 *val = (int)num;
2127 return errstr;
2128}