aboutsummaryrefslogtreecommitdiffstats
path: root/array.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2011-04-24 12:45:47 +0300
committerArnold D. Robbins <arnold@skeeve.com>2011-04-24 12:45:47 +0300
commit8eb45b02e704c95866970005fe771e3507fb935c (patch)
treeffe48f1a5f46e15e6df6b7c509a592f7f9300f3f /array.c
parent203dfc888be3f45d3f70c9cdb91e870ae7796257 (diff)
downloadegawk-8eb45b02e704c95866970005fe771e3507fb935c.tar.gz
egawk-8eb45b02e704c95866970005fe771e3507fb935c.tar.bz2
egawk-8eb45b02e704c95866970005fe771e3507fb935c.zip
Patch from John, update man page.
Diffstat (limited to 'array.c')
-rw-r--r--array.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/array.c b/array.c
index 32b85065..1bf6a068 100644
--- a/array.c
+++ b/array.c
@@ -1371,8 +1371,8 @@ static int
sort_user_func(const void *p1, const void *p2)
{
const NODE *t1, *t2;
- NODE *idx1, *idx2, *val1, *val2, *r;
- int ret;
+ NODE *idx1, *idx2, *val1, *val2;
+ AWKNUM ret;
INSTRUCTION *code;
extern int exiting;
@@ -1403,11 +1403,9 @@ sort_user_func(const void *p1, const void *p2)
gawk_exit(exit_val);
/* return value of the comparison function */
- r = POP_SCALAR();
- ret = (int) force_number(r);
- DEREF(r);
+ POP_NUMBER(ret);
- return ret;
+ return (ret < 0.0) ? -1 : (ret > 0.0);
}
@@ -1522,6 +1520,14 @@ sort_selection(NODE *sort_str, SORT_CTXT sort_ctxt)
allparts |= bval;
}
+ if (allparts == Unsorted) {
+ NODE *f;
+ /* user-defined function overrides default */
+
+ if ((f = lookup(sort_str->stptr)) != NULL && f->type == Node_func)
+ return -1;
+ }
+
/* num_words <= 3 */
return (allparts & INDEX_MASK);