aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2011-02-13 19:56:21 +0200
committerArnold D. Robbins <arnold@skeeve.com>2011-02-13 19:56:21 +0200
commitc160d41490f752f55312f2de91cdd94cc9270141 (patch)
tree16d97a0a90b9465f76da3404d10e347d6f91faac
parent050e7204af5086a851c22beb0829e9b9a163e8e1 (diff)
downloadegawk-c160d41490f752f55312f2de91cdd94cc9270141.tar.gz
egawk-c160d41490f752f55312f2de91cdd94cc9270141.tar.bz2
egawk-c160d41490f752f55312f2de91cdd94cc9270141.zip
Profile fix and test for it.
-rw-r--r--ChangeLog16
-rw-r--r--array.c5
-rw-r--r--profile.c6
-rw-r--r--test/ChangeLog5
-rw-r--r--test/Makefile.am8
-rw-r--r--test/Makefile.in8
-rw-r--r--test/profile3.awk9
-rw-r--r--test/profile3.ok14
8 files changed, 64 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index c30a95ad..c96851be 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Sun Feb 13 07:12:50 2011 John Haque <j.eh@mchsi.com>
+
+ * profile.c (pprint): In case Op_indirect_func_call, pop off
+ indirect var after function parameters.
+ Thanks to Hermann Peifer <peifer@gmx.eu> for the bug report.
+ * array.c (do_delete): Always free an empty sub-array name and node.
+ * ChangeLog: Fix typos.
+
Fri Feb 11 10:26:25 2011 Arnold D. Robbins <arnold@skeeve.com>
* io.c (remad_std_file): Close oldfd first, in case we've
@@ -93,12 +101,12 @@ Tue Feb 1 23:01:40 2011 John Haque <j.eh@mchsi.com>
(LEX_DO, LEX_WHILE, LEX_SWITCH, LEX_FOR): Simplify grammar. Use
Op_no_op as target for break. Adjust call to fix_break_continue.
(mk_for_loop): Ditto.
- * eval.c (r_interpret): Nuke cases Op_push_loop and Op_pop_lop.
+ * eval.c (r_interpret): Nuke cases Op_push_loop and Op_pop_loop.
Simplify Op_K_break and Op_K_continue. Remove declaration of in_loop
and all loop detection code thereof.
* debug.c (pre_execute, post_execute): Adjust declarations and code.
(print_instruction): Nuke cases Op_push_loop and Op_pop_loop.
- * eval.c (r_interpret): Adjust calls to pre_execute and post_execute.
+ * eval.c (r_interpret): Adjust calls to pre_execute and post_execute.
* profile.c (pprint): Adjust cases Op_K_for, Op_K_do, Op_K_while,
Op_K_switch and Op_K_arrayfor. Add cases Op_K_case and Op_K_default.
Remove Op_push_loop and Op_pop_loop.
@@ -154,7 +162,7 @@ Thu Jan 27 21:21:13 2011 John Haque <j.eh@mchsi.com>
* awkgram.y (constant_fold): Code cleanups. Fix bug in the code for
string concatenation.
- * configure.ac: Remove unneed extra call to AC_LANG.
+ * configure.ac: Remove unneeded extra call to AC_LANG.
Thu Jan 27 15:00:42 2011 Arnold D. Robbins <arnold@skeeve.com>
@@ -581,7 +589,7 @@ Sun Oct 31 05:56:23 2010 John Haque <j.eh@mchsi.com>
(add_item): Ditto. Use field symbol, not subs to store field number and
adjust accordingly everywhere.
Unrelated: handle function parameter correctly, watch and display now
- prints the param name instead of the actual array name.
+ prints the param name instead of the actual array name.
(find_subscript): New function.
(initialize_watch_item): Use the new function find_subscript
to locate an array element NODE.
diff --git a/array.c b/array.c
index 3dd9a99d..eb5ed941 100644
--- a/array.c
+++ b/array.c
@@ -698,7 +698,10 @@ do_delete(NODE *symbol, int nsubs)
if (r->var_array != NULL || nsubs > 1)
return;
/* else
- cleared a sub_array, free index */
+ cleared a sub-array, free the array node
+ and the bucket in parent array */
+ efree(r->vname);
+ freenode(r);
} else if (--nsubs > 0) {
/* e.g.: a[1] = 1; delete a[1][1] */
free_subs(nsubs);
diff --git a/profile.c b/profile.c
index 06dfb16a..b958e915 100644
--- a/profile.c
+++ b/profile.c
@@ -619,8 +619,6 @@ cleanup:
break;
case Op_indirect_func_call:
- t1 = pp_pop(); /* indirect var */
- pp_free(t1);
case Op_func_call:
{
char *fname = pc->func_name;
@@ -638,6 +636,10 @@ cleanup:
efree(tmp);
} else
str = pp_concat(pre, fname, "()");
+ if (pc->opcode == Op_indirect_func_call) {
+ t1 = pp_pop(); /* indirect var */
+ pp_free(t1);
+ }
pp_push(pc->opcode, str, CAN_FREE);
}
break;
diff --git a/test/ChangeLog b/test/ChangeLog
index 87190839..b0593353 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+Sun Feb 13 19:55:15 2011 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.am (profile3): New test.
+ * profile3.awk, profile3.ok: New files.
+
Fri Feb 11 10:29:48 2011 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.am (manyfiles): Bump limit up above 1024, which is
diff --git a/test/Makefile.am b/test/Makefile.am
index 2d5060eb..65082f7f 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -518,6 +518,8 @@ EXTRA_DIST = \
prdupval.in \
prdupval.ok \
profile2.ok \
+ profile3.awk \
+ profile3.ok \
prec.awk \
prec.ok \
printf0.awk \
@@ -1322,6 +1324,12 @@ profile2:
@sed 1,2d < awkprof.out > _$@; rm awkprof.out
@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@
+profile3:
+ @echo $@
+ @$(PGAWK) -f $(srcdir)/$@.awk > /dev/null
+ @sed 1,2d < awkprof.out > _$@; rm awkprof.out
+ @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@
+
# Targets generated for other tests:
include Maketests
diff --git a/test/Makefile.in b/test/Makefile.in
index a32ae99c..f5ec9b1a 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -703,6 +703,8 @@ EXTRA_DIST = \
prdupval.in \
prdupval.ok \
profile2.ok \
+ profile3.awk \
+ profile3.ok \
prec.awk \
prec.ok \
printf0.awk \
@@ -1669,6 +1671,12 @@ profile2:
@$(PGAWK) -f $(srcdir)/xref.awk $(srcdir)/dtdgport.awk > /dev/null
@sed 1,2d < awkprof.out > _$@; rm awkprof.out
@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@
+
+profile3:
+ @echo $@
+ @$(PGAWK) -f $(srcdir)/$@.awk > /dev/null
+ @sed 1,2d < awkprof.out > _$@; rm awkprof.out
+ @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@
Gt-dummy:
# file Maketests, generated from Makefile.am by the Gentests program
addcomma:
diff --git a/test/profile3.awk b/test/profile3.awk
new file mode 100644
index 00000000..e519374e
--- /dev/null
+++ b/test/profile3.awk
@@ -0,0 +1,9 @@
+BEGIN {
+ the_func = "p"
+ print @the_func("Hello")
+}
+
+function p(str)
+{
+ print "! " str " !"
+}
diff --git a/test/profile3.ok b/test/profile3.ok
new file mode 100644
index 00000000..50172c48
--- /dev/null
+++ b/test/profile3.ok
@@ -0,0 +1,14 @@
+ # BEGIN block(s)
+
+ BEGIN {
+ 1 the_func = "p"
+ 1 print @the_func("Hello")
+ }
+
+
+ # Functions, listed alphabetically
+
+ 1 function p(str)
+ {
+ 1 print "! " str " !"
+ }