Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/historical/nawk/dist From wajap at github:



details:   https://anonhg.NetBSD.org/src/rev/d5b36fc21341
branches:  trunk
changeset: 956634:d5b36fc21341
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Nov 02 22:58:51 2020 +0000

description:
>From wajap at github:
- eat whitespace in infnan checks
- set fval to 0 if we are not a floating point number

diffstat:

 external/historical/nawk/dist/tran.c |  6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diffs (28 lines):

diff -r dacbaff139aa -r d5b36fc21341 external/historical/nawk/dist/tran.c
--- a/external/historical/nawk/dist/tran.c      Mon Nov 02 22:50:55 2020 +0000
+++ b/external/historical/nawk/dist/tran.c      Mon Nov 02 22:58:51 2020 +0000
@@ -399,11 +399,15 @@
 {
        while (*s && tolower((unsigned char)*s) == *v)
                s++, v++;
+       while (isspace((unsigned char)*s))
+               s++;
        return !(*s || *v);
 }
 
 static int checkinfnan(const char *s)
 {
+       while (isspace((unsigned char)*s))
+               s++;
        if (*s == '+' || *s == '-')
                s++;
        switch (tolower((unsigned char)*s)) {
@@ -427,6 +431,8 @@
        if (!isnum(vp)) {       /* not a number */
                if (checkinfnan(vp->sval))
                        vp->fval = atof(vp->sval);      /* best guess */
+               else
+                       vp->fval = 0.0;
                if (is_number(vp->sval) && !(vp->tval&CON)) {
                        vp->tval |= NUM;        /* make NUM only sparingly */
                }



Home | Main Index | Thread Index | Old Index