diff options
author | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2016-06-14 16:35:48 -0400 |
---|---|---|
committer | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2016-06-14 16:35:48 -0400 |
commit | 5826beec258141776469c5fd9b703d52c81a35fb (patch) | |
tree | 2d09f31301c392fa15218d5f133a19f4cfdb5fdb /awk.h | |
parent | 56b1798777fe5464014fca3f9744ebdb950b8348 (diff) | |
download | egawk-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.h | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -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) { |