aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editors/awk.c3
-rwxr-xr-xtestsuite/awk.tests19
2 files changed, 21 insertions, 1 deletions
diff --git a/editors/awk.c b/editors/awk.c
index 3224788c0..0b573a065 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -2661,7 +2661,8 @@ static var *evaluate(node *op, var *res)
2661 var *vbeg, *v; 2661 var *vbeg, *v;
2662 const char *sv_progname; 2662 const char *sv_progname;
2663 2663
2664 if (!op->r.f->body.first) 2664 /* The body might be empty, still has to eval the args */
2665 if (!op->r.n->info)
2665 syntax_error(EMSG_UNDEF_FUNC); 2666 syntax_error(EMSG_UNDEF_FUNC);
2666 2667
2667 vbeg = v = nvalloc(op->r.f->nargs + 1); 2668 vbeg = v = nvalloc(op->r.f->nargs + 1);
diff --git a/testsuite/awk.tests b/testsuite/awk.tests
index f9c3b6b4d..dad49c3f5 100755
--- a/testsuite/awk.tests
+++ b/testsuite/awk.tests
@@ -25,6 +25,25 @@ testing "awk if string == " "awk 'BEGIN{if(\"a\"==\"ab\") print \"bar\"}'" ""
25 25
26# 4294967295 = 0xffffffff 26# 4294967295 = 0xffffffff
27testing "awk bitwise op" "awk '{ print or(4294967295,1) }'" "4.29497e+09\n" "" "\n" 27testing "awk bitwise op" "awk '{ print or(4294967295,1) }'" "4.29497e+09\n" "" "\n"
28
29# we were testing for a non-empty body when deciding if a function was
30# defined or not. The testcase below caused:
31# awk: cmd. line:8: Call to undefined function
32prg='
33function empty_fun(count) {
34 # empty
35}
36END {
37 i=1
38 print "L" i "\n"
39 empty_fun(i + i + ++i)
40 print "L" i "\n"
41}'
42testing "awk handles empty function f(arg){}" \
43 "awk '$prg'" \
44 "L1\n\nL2\n\n" \
45 "" ""
46
28optional DESKTOP 47optional DESKTOP
29testing "awk hex const 1" "awk '{ print or(0xffffffff,1) }'" "4.29497e+09\n" "" "\n" 48testing "awk hex const 1" "awk '{ print or(0xffffffff,1) }'" "4.29497e+09\n" "" "\n"
30testing "awk hex const 2" "awk '{ print or(0x80000000,1) }'" "2.14748e+09\n" "" "\n" 49testing "awk hex const 2" "awk '{ print or(0x80000000,1) }'" "2.14748e+09\n" "" "\n"