aboutsummaryrefslogtreecommitdiff
path: root/contrib/ntp/libntp/atolfp.c
diff options
context:
space:
mode:
authorCy Schubert <cy@FreeBSD.org>2015-03-30 13:30:15 +0000
committerCy Schubert <cy@FreeBSD.org>2015-03-30 13:30:15 +0000
commit2b15cb3d0922bd70ea592f0da9b4a5b167f4d53f (patch)
tree388af01c574ac107295ae453bab1e272bbfcda27 /contrib/ntp/libntp/atolfp.c
parenta83592093c063d2b02127a1de7c7c93d5f600bd2 (diff)
parentf7cba3a80d9ebefc57776fffd17a4ae68f72e494 (diff)
MFV ntp 4.2.8p1 (r258945, r275970, r276091, r276092, r276093, r278284)
Thanks to roberto for providing pointers to wedge this into HEAD. Approved by: roberto
Notes
Notes: svn path=/head/; revision=280849
Diffstat (limited to 'contrib/ntp/libntp/atolfp.c')
-rw-r--r--contrib/ntp/libntp/atolfp.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/contrib/ntp/libntp/atolfp.c b/contrib/ntp/libntp/atolfp.c
index ff50947f0c47..3a65f6bcb2f7 100644
--- a/contrib/ntp/libntp/atolfp.c
+++ b/contrib/ntp/libntp/atolfp.c
@@ -1,11 +1,13 @@
/*
* atolfp - convert an ascii string to an l_fp number
*/
+#include <config.h>
#include <stdio.h>
#include <ctype.h>
#include "ntp_fp.h"
#include "ntp_string.h"
+#include "ntp_assert.h"
/*
* Powers of 10
@@ -38,6 +40,8 @@ atolfp(
int isneg;
static const char *digits = "0123456789";
+ NTP_REQUIRE(str != NULL);
+
isneg = 0;
dec_i = dec_f = 0;
ndec = 0;
@@ -48,7 +52,7 @@ atolfp(
*
* [spaces][-|+][digits][.][digits][spaces|\n|\0]
*/
- while (isspace((int)*cp))
+ while (isspace((unsigned char)*cp))
cp++;
if (*cp == '-') {
@@ -59,7 +63,7 @@ atolfp(
if (*cp == '+')
cp++;
- if (*cp != '.' && !isdigit((int)*cp))
+ if (*cp != '.' && !isdigit((unsigned char)*cp))
return 0;
while (*cp != '\0' && (ind = strchr(digits, *cp)) != NULL) {
@@ -68,7 +72,7 @@ atolfp(
cp++;
}
- if (*cp != '\0' && !isspace((int)*cp)) {
+ if (*cp != '\0' && !isspace((unsigned char)*cp)) {
if (*cp++ != '.')
return 0;
@@ -80,10 +84,10 @@ atolfp(
cp++;
}
- while (isdigit((int)*cp))
+ while (isdigit((unsigned char)*cp))
cp++;
- if (*cp != '\0' && !isspace((int)*cp))
+ if (*cp != '\0' && !isspace((unsigned char)*cp))
return 0;
}