aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--array.c8
-rw-r--r--debug.c2
-rw-r--r--eval.c8
-rw-r--r--profile.c4
5 files changed, 21 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 42fe783c..660b7191 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/array.c b/array.c
index 82e99a4b..e814e976 100644
--- a/array.c
+++ b/array.c
@@ -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 */
diff --git a/debug.c b/debug.c
index 0a66b462..ea652478 100644
--- a/debug.c
+++ b/debug.c
@@ -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));
diff --git a/eval.c b/eval.c
index cd5a5844..22f30773 100644
--- a/eval.c
+++ b/eval.c
@@ -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;
diff --git a/profile.c b/profile.c
index 01d1e42f..eb788377 100644
--- a/profile.c
+++ b/profile.c
@@ -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)