diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2011-04-24 12:45:47 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2011-04-24 12:45:47 +0300 |
commit | 8eb45b02e704c95866970005fe771e3507fb935c (patch) | |
tree | ffe48f1a5f46e15e6df6b7c509a592f7f9300f3f /array.c | |
parent | 203dfc888be3f45d3f70c9cdb91e870ae7796257 (diff) | |
download | egawk-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.c | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -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); |