aboutsummaryrefslogtreecommitdiffstats
path: root/awk.h
diff options
context:
space:
mode:
authorAndrew J. Schorr <aschorr@telemetry-investments.com>2016-06-14 16:35:48 -0400
committerAndrew J. Schorr <aschorr@telemetry-investments.com>2016-06-14 16:35:48 -0400
commit5826beec258141776469c5fd9b703d52c81a35fb (patch)
tree2d09f31301c392fa15218d5f133a19f4cfdb5fdb /awk.h
parent56b1798777fe5464014fca3f9744ebdb950b8348 (diff)
downloadegawk-5826beec258141776469c5fd9b703d52c81a35fb.tar.gz
egawk-5826beec258141776469c5fd9b703d52c81a35fb.tar.bz2
egawk-5826beec258141776469c5fd9b703d52c81a35fb.zip
Add a new boolval function to awk.h to make sure we handle this consistently.
Diffstat (limited to 'awk.h')
-rw-r--r--awk.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/awk.h b/awk.h
index 0cbcf049..0a7059b1 100644
--- a/awk.h
+++ b/awk.h
@@ -1843,6 +1843,19 @@ fixtype(NODE *n)
return n;
}
+/*
+ * In `awk', a value is considered to be true if it is nonzero _or_
+ * non-null. Otherwise, the value is false.
+ */
+static inline int
+boolval(NODE *t)
+{
+ (void) fixtype(t);
+ if ((t->flags & NUMBER) != 0)
+ return ! iszero(t);
+ return (t->stlen > 0);
+}
+
static inline void *
emalloc_real(size_t count, const char *where, const char *var, const char *file, int line)
{