fixed bugs of not handling <NL> properly in local/global variable declarations.
This commit is contained in:
3
qse/regress/awk/lang-001.awk
Normal file
3
qse/regress/awk/lang-001.awk
Normal file
@ -0,0 +1,3 @@
|
||||
# cannot use function name as a parameter name
|
||||
function f(f) { print f; }
|
||||
BEGIN { f("hello"); }
|
7
qse/regress/awk/lang-002.awk
Normal file
7
qse/regress/awk/lang-002.awk
Normal file
@ -0,0 +1,7 @@
|
||||
function f(f)
|
||||
{
|
||||
print f;
|
||||
f("my hello");
|
||||
}
|
||||
|
||||
BEGIN { f(10); }
|
3
qse/regress/awk/lang-003.awk
Normal file
3
qse/regress/awk/lang-003.awk
Normal file
@ -0,0 +1,3 @@
|
||||
# should print 50
|
||||
function fn(f) { f = 20; }
|
||||
BEGIN { f = 50; fn(100); print f; }
|
3
qse/regress/awk/lang-004.awk
Normal file
3
qse/regress/awk/lang-004.awk
Normal file
@ -0,0 +1,3 @@
|
||||
# A function and a named variable cannot have the same name.
|
||||
function a () { }
|
||||
BEGIN { a = 20; }
|
7
qse/regress/awk/lang-005.awk
Normal file
7
qse/regress/awk/lang-005.awk
Normal file
@ -0,0 +1,7 @@
|
||||
function a (a) { print a; }
|
||||
|
||||
BEGIN {
|
||||
local a;
|
||||
a = 20;
|
||||
a (1000);
|
||||
}
|
2
qse/regress/awk/lang-006.awk
Normal file
2
qse/regress/awk/lang-006.awk
Normal file
@ -0,0 +1,2 @@
|
||||
global a;
|
||||
function a () { }
|
4
qse/regress/awk/lang-007.awk
Normal file
4
qse/regress/awk/lang-007.awk
Normal file
@ -0,0 +1,4 @@
|
||||
function fn () { a = 20; return a;}
|
||||
global a;
|
||||
BEGIN { a = 30; print fn (); print a; }
|
||||
|
16
qse/regress/awk/lang-008.awk
Normal file
16
qse/regress/awk/lang-008.awk
Normal file
@ -0,0 +1,16 @@
|
||||
global x;
|
||||
BEGIN {
|
||||
x = 1;
|
||||
{
|
||||
local x;
|
||||
x = 2;
|
||||
{
|
||||
local x;
|
||||
x = 3;
|
||||
print x;
|
||||
}
|
||||
print x;
|
||||
}
|
||||
print x;
|
||||
}
|
||||
|
9
qse/regress/awk/lang-009.awk
Normal file
9
qse/regress/awk/lang-009.awk
Normal file
@ -0,0 +1,9 @@
|
||||
function a (a) { print a; }
|
||||
|
||||
BEGIN {
|
||||
local a;
|
||||
a = 20;
|
||||
}
|
||||
|
||||
END { a (1000); }
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user