aboutsummaryrefslogtreecommitdiffstats
path: root/array.c
diff options
context:
space:
mode:
Diffstat (limited to 'array.c')
-rw-r--r--array.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/array.c b/array.c
index 4ff365ff..e3bbc835 100644
--- a/array.c
+++ b/array.c
@@ -824,6 +824,12 @@ asort_actual(int nargs, sort_context_t ctxt)
fatal(_("%s: second argument is not an array"),
ctxt == ASORT ? "asort" : "asorti");
}
+ if (dest == symbol_table)
+ fatal(_("%s: SYMTAB cannot be used as second argument"),
+ ctxt == ASORT ? "asort" : "asorti");
+ else if (dest == func_table)
+ fatal(_("%s: FUNCTAB cannot be used as second argument"),
+ ctxt == ASORT ? "asort" : "asorti");
}
array = POP_PARAM();
@@ -831,11 +837,11 @@ asort_actual(int nargs, sort_context_t ctxt)
fatal(_("%s: first argument is not an array"),
ctxt == ASORT ? "asort" : "asorti");
}
- else if (array == symbol_table)
- fatal(_("%s: first argument cannot be SYMTAB"),
+ else if (array == symbol_table && dest == NULL)
+ fatal(_("%s: first argument cannot be SYMTAB without a second argument"),
ctxt == ASORT ? "asort" : "asorti");
- else if (array == func_table)
- fatal(_("%s: first argument cannot be FUNCTAB"),
+ else if (array == func_table && dest == NULL)
+ fatal(_("%s: first argument cannot be FUNCTAB without a second argument"),
ctxt == ASORT ? "asort" : "asorti");
if (dest != NULL) {
@@ -906,7 +912,15 @@ asort_actual(int nargs, sort_context_t ctxt)
if (r->type == Node_val)
value = dupnode(r);
- else {
+ else if (r->type == Node_var)
+ /* SYMTAB ... */
+ value = dupnode(r->var_value);
+ else if (r->type == Node_builtin_func
+ || r->type == Node_func
+ || r->type == Node_ext_func) {
+ /* FUNCTAB ... */
+ value = make_string(r->vname, strlen(r->vname));
+ } else {
NODE *arr;
arr = make_array();
subs = force_string(subs);