diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2016-08-25 22:14:15 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2016-08-25 22:14:15 +0300 |
commit | b03d089e9b87c4e64bd539a1703e740923a67aa4 (patch) | |
tree | c7351e0b46c45d282eba64e478c99c0771a055a1 /eval.c | |
parent | e0dd835cc155c900ca9725a0d36eb0f5a856d9bf (diff) | |
parent | 00682d87a1a1c0535c0fa5adb27867578dc76d49 (diff) | |
download | egawk-b03d089e9b87c4e64bd539a1703e740923a67aa4.tar.gz egawk-b03d089e9b87c4e64bd539a1703e740923a67aa4.tar.bz2 egawk-b03d089e9b87c4e64bd539a1703e740923a67aa4.zip |
Merge branch 'master' into feature/typed-regex
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -575,7 +575,7 @@ posix_compare(NODE *s1, NODE *s2) /* cmp_nodes --- compare two nodes, returning negative, 0, positive */ int -cmp_nodes(NODE *t1, NODE *t2) +cmp_nodes(NODE *t1, NODE *t2, bool use_strcmp) { int ret = 0; size_t len1, len2; @@ -598,7 +598,7 @@ cmp_nodes(NODE *t1, NODE *t2) if (len1 == 0 || len2 == 0) return ldiff; - if (do_posix) + if (do_posix && ! use_strcmp) return posix_compare(t1, t2); l = (ldiff <= 0 ? len1 : len2); @@ -885,7 +885,7 @@ fmt_index(NODE *n) emalloc(fmt_list, NODE **, fmt_num*sizeof(*fmt_list), "fmt_index"); n = force_string(n); while (ix < fmt_hiwater) { - if (cmp_nodes(fmt_list[ix], n) == 0) + if (cmp_nodes(fmt_list[ix], n, true) == 0) return ix; ix++; } @@ -1514,10 +1514,15 @@ eval_condition(NODE *t) return boolval(t); } +typedef enum { + SCALAR_EQ_NEQ, + SCALAR_RELATIONAL +} scalar_cmp_t; + /* cmp_scalars -- compare two nodes on the stack */ static inline int -cmp_scalars() +cmp_scalars(scalar_cmp_t comparison_type) { NODE *t1, *t2; int di; @@ -1528,7 +1533,7 @@ cmp_scalars() DEREF(t2); fatal(_("attempt to use array `%s' in a scalar context"), array_vname(t1)); } - di = cmp_nodes(t1, t2); + di = cmp_nodes(t1, t2, comparison_type == SCALAR_EQ_NEQ); DEREF(t1); DEREF(t2); return di; |