fixed bugs of not handling <NL> properly in local/global variable declarations.

This commit is contained in:
2009-06-27 20:50:54 +00:00
parent e337e01d46
commit c31adc3f7c
13 changed files with 162 additions and 28 deletions

View File

@ -0,0 +1,3 @@
# cannot use function name as a parameter name
function f(f) { print f; }
BEGIN { f("hello"); }

View File

@ -0,0 +1,7 @@
function f(f)
{
print f;
f("my hello");
}
BEGIN { f(10); }

View File

@ -0,0 +1,3 @@
# should print 50
function fn(f) { f = 20; }
BEGIN { f = 50; fn(100); print f; }

View File

@ -0,0 +1,3 @@
# A function and a named variable cannot have the same name.
function a () { }
BEGIN { a = 20; }

View File

@ -0,0 +1,7 @@
function a (a) { print a; }
BEGIN {
local a;
a = 20;
a (1000);
}

View File

@ -0,0 +1,2 @@
global a;
function a () { }

View File

@ -0,0 +1,4 @@
function fn () { a = 20; return a;}
global a;
BEGIN { a = 30; print fn (); print a; }

View File

@ -0,0 +1,16 @@
global x;
BEGIN {
x = 1;
{
local x;
x = 2;
{
local x;
x = 3;
print x;
}
print x;
}
print x;
}

View File

@ -0,0 +1,9 @@
function a (a) { print a; }
BEGIN {
local a;
a = 20;
}
END { a (1000); }

View File

@ -23,6 +23,7 @@ print_usage()
###################
QSEAWK=${QSEAWK:=../../cmd/awk/qseawk}
TMPFILE="${TMPFILE:=./regress.temp}"
PROGS="
cou-001.awk/cou.dat//
@ -81,6 +82,16 @@ PROGS="
emp-026.awk/emp.dat//
emp-027.awk/emp.dat//
lang-001.awk///--implicit=off --explicit=on --newline=on -o-
lang-002.awk///--implicit=off --explicit=on --newline=on -o-
lang-003.awk///--implicit=off --explicit=on --newline=on -o-
lang-004.awk///--implicit=off --explicit=on --newline=on -o-
lang-005.awk///--implicit=off --explicit=on --newline=on -o-
lang-006.awk///--implicit=off --explicit=on --newline=on -o-
lang-007.awk///--implicit=off --explicit=on --newline=on -o-
lang-008.awk///--implicit=off --explicit=on --newline=on -o-
lang-009.awk/lang-009.awk//--implicit=off --explicit=on --newline=on -o-
quicksort.awk/quicksort.dat//
quicksort2.awk/quicksort2.dat//
asm.awk/asm.s/asm.dat/
@ -96,13 +107,24 @@ PROGS="
exit 1;
}
for prog in ${PROGS}
echo "${PROGS}" > "${TMPFILE}"
while read prog
do
[ -z "${prog}" ] && continue
script="`echo ${prog} | cut -d/ -f1`"
datafile="`echo ${prog} | cut -d/ -f2`"
redinfile="`echo ${prog} | cut -d/ -f3`"
awkopts="`echo ${prog} | cut -d/ -f4`"
[ -z "${script}" ] && continue
[ -f "${script}" ] ||
{
echo_so "${script} not found"
continue
}
if [ -n "${redinfile}" ]
then
echo_so "${QSEAWK} ${awkopts} -f ${script} ${datafile} < ${redinfile}"
@ -111,6 +133,9 @@ do
echo_so "${QSEAWK} ${awkopts} -f ${script} ${datafile}"
${QSEAWK} ${awkopts} -f ${script} ${datafile}
fi
done
done < "${TMPFILE}"
rm -f "${TMPFILE}"
exit 0