Module Name: src
Committed By: dholland
Date: Mon May 30 17:48:29 UTC 2016
Modified Files:
src/lib/libform: type_numeric.c
Log Message:
PR 51190 David Binderman: simplify redundant conditionals.
Also add paranoia when looping on isdigit().
To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/libform/type_numeric.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libform/type_numeric.c
diff -u src/lib/libform/type_numeric.c:1.8 src/lib/libform/type_numeric.c:1.9
--- src/lib/libform/type_numeric.c:1.8 Thu Oct 28 21:14:52 2004
+++ src/lib/libform/type_numeric.c Mon May 30 17:48:29 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: type_numeric.c,v 1.8 2004/10/28 21:14:52 dsl Exp $ */
+/* $NetBSD: type_numeric.c,v 1.9 2016/05/30 17:48:29 dholland Exp $ */
/*-
* Copyright (c) 1998-1999 Brett Lymn
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: type_numeric.c,v 1.8 2004/10/28 21:14:52 dsl Exp $");
+__RCSID("$NetBSD: type_numeric.c,v 1.9 2016/05/30 17:48:29 dholland Exp $");
#include <stdlib.h>
#include <string.h>
@@ -136,16 +136,15 @@ numeric_check_field(FIELD *field, char *
cur++;
/* if not at end of string then check for decimal... */
- if ((buf[cur] != '\0') && (buf[cur] == '.')) {
+ if (buf[cur] == '.') {
cur++;
- /* check for more digits now.... */
- while(isdigit((unsigned char)buf[cur]))
+ /* check for more digits now.... */
+ while (buf[cur] && isdigit((unsigned char)buf[cur]))
cur++;
}
/* check for an exponent */
- if ((buf[cur] != '\0') &&
- ((buf[cur] == 'E') || (buf[cur] == 'e'))) {
+ if ((buf[cur] == 'E') || (buf[cur] == 'e')) {
cur++;
if (buf[cur] == '\0')
return FALSE;