aboutsummaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2016-08-25 22:13:11 +0300
committerArnold D. Robbins <arnold@skeeve.com>2016-08-25 22:13:11 +0300
commit0987a787868a1d0772da19766de8a621f3a3be74 (patch)
tree3ac585daf738f56080afcd4c01f9ca6cce4cb184 /eval.c
parent7585f55d91374fb93725fa2ed53a84c118f14a72 (diff)
parent00682d87a1a1c0535c0fa5adb27867578dc76d49 (diff)
downloadegawk-0987a787868a1d0772da19766de8a621f3a3be74.tar.gz
egawk-0987a787868a1d0772da19766de8a621f3a3be74.tar.bz2
egawk-0987a787868a1d0772da19766de8a621f3a3be74.zip
Merge branch 'master' into feature/nocopy
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/eval.c b/eval.c
index fc468543..cfd71b43 100644
--- a/eval.c
+++ b/eval.c
@@ -573,7 +573,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;
@@ -596,7 +596,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);
@@ -882,7 +882,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++;
}
@@ -1502,10 +1502,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;
@@ -1516,7 +1521,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;