summaryrefslogtreecommitdiff
path: root/node.c
diff options
context:
space:
mode:
Diffstat (limited to 'node.c')
-rw-r--r--node.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/node.c b/node.c
index 12d7a046..cbf5c56e 100644
--- a/node.c
+++ b/node.c
@@ -370,7 +370,7 @@ int
cmp_awknums(const NODE *t1, const NODE *t2)
{
/*
- * This routine is also used to sort numeric array indices or values.
+ * This routine is used to sort numeric array indices or values.
* For the purposes of sorting, NaN is considered greater than
* any other value, and all NaN values are considered equivalent and equal.
* This isn't in compliance with IEEE standard, but compliance w.r.t. NaN
@@ -390,7 +390,6 @@ cmp_awknums(const NODE *t1, const NODE *t2)
return 1;
}
-
/* make_str_node --- make a string node */
NODE *
@@ -1083,3 +1082,24 @@ more_blocks(int id)
}
#endif
+
+/* make_bool_node --- make a boolean-valued node */
+
+extern NODE *
+make_bool_node(bool value)
+{
+ NODE *val;
+ const char *sval;
+ AWKNUM nval;
+
+ sval = (value ? "1" : "0");
+ nval = (value ? 1.0 : 0.0);
+
+ val = make_number(nval);
+ val->stptr = estrdup(sval, strlen(sval));
+ val->stlen = strlen(sval);
+ val->flags |= NUMCUR|STRCUR|BOOL;
+ val->stfmt = STFMT_UNUSED;
+
+ return val;
+}