diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2011-12-06 22:00:44 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2011-12-06 22:00:44 +0200 |
commit | 3ba2f61ff006c308a904c8b1a4bc433082ce87c8 (patch) | |
tree | 634e529b16d2d8ea6b3655172f58d35e014edcb0 | |
parent | 1527865d3c430aa203ed23fa7ecbeea30a604724 (diff) | |
download | egawk-3ba2f61ff006c308a904c8b1a4bc433082ce87c8.tar.gz egawk-3ba2f61ff006c308a904c8b1a4bc433082ce87c8.tar.bz2 egawk-3ba2f61ff006c308a904c8b1a4bc433082ce87c8.zip |
Misc fixes from John.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | array.c | 8 | ||||
-rw-r--r-- | debug.c | 2 | ||||
-rw-r--r-- | eval.c | 8 | ||||
-rw-r--r-- | profile.c | 4 |
5 files changed, 21 insertions, 10 deletions
@@ -1,3 +1,12 @@ +2011-12-06 John Haque <j.eh@mchsi.com> + + * debug.c (source_find): Fix misplaced call to efree. + * profile.c (redir2str): Add a missing comma in the redirtab array. + * eval.c (r_interpret): Disallow call to exit if currule is undefined. + This avoids the possiblity of running END blocks more than once when + used in a user-defined sorted-in comparision function. + * array.c (sort_user_func): Adjust appropriately. + 2011-12-06 Arnold D. Robbins <arnold@skeeve.com> * awk.h, mbsupport.h: Changes for MBS support on DJGPP @@ -1509,7 +1509,6 @@ sort_user_func(const void *p1, const void *p2) NODE *idx1, *idx2, *val1, *val2; AWKNUM ret; INSTRUCTION *code; - extern int exiting; t1 = *((const NODE *const *) p1); t2 = *((const NODE *const *) p2); @@ -1534,9 +1533,6 @@ sort_user_func(const void *p1, const void *p2) /* execute the comparison function */ (void) interpret(code); - if (exiting) /* do not assume anything about the user-defined function! */ - gawk_exit(exit_val); - /* return value of the comparison function */ POP_NUMBER(ret); @@ -1672,9 +1668,9 @@ assoc_list(NODE *array, const char *sort_str, SORT_CTXT sort_ctxt) (code + 1)->expr_count = 4; /* function takes 4 arguments */ code->nexti = bcalloc(Op_stop, 1, 0); - /* make non-local jumps `next' and `nextfile' fatal in + /* make non-redirected getline, exit, `next' and `nextfile' fatal in * callback function by setting currule in interpret() - * to undefined (0). `exit' is handled in sort_user_func. + * to undefined (0). */ (code + 1)->inrule = currule; /* save current rule */ @@ -498,8 +498,8 @@ source_find(char *src) efree(path); return s; } - efree(path); } + efree(path); } d_error(_("cannot find source file named `%s' (%s)"), src, strerror(errno_val)); @@ -2507,7 +2507,7 @@ func_call: break; case Op_K_getline: /* no redirection */ - if (currule == BEGINFILE || currule == ENDFILE) + if (! currule || currule == BEGINFILE || currule == ENDFILE) fatal(_("non-redirected `getline' invalid inside `%s' rule"), ruletab[currule]); @@ -2654,6 +2654,12 @@ func_call: break; case Op_K_exit: + /* exit not allowed in user-defined comparison functions for "sorted_in"; + * This is done so that END blocks aren't executed more than once. + */ + if (! currule) + fatal(_("`exit' cannot be called in the current context")); + exiting = TRUE; POP_NUMBER(x1); exit_val = (int) x1; @@ -1362,8 +1362,8 @@ redir2str(int redirtype) " >> ", /* redirect_append */ " | ", /* redirect_pipe */ " | ", /* redirect_pipein */ - " < " /* redirect_input */ - " |& " /* redirect_twoway */ + " < ", /* redirect_input */ + " |& ", /* redirect_twoway */ }; if (redirtype < 0 || redirtype > redirect_twoway) |