fixed a bug of not checking a parameter name against the function name
This commit is contained in:
parent
c31adc3f7c
commit
b9d3b490a2
@ -1,3 +0,0 @@
|
||||
|
||||
function f(f) { print f; }
|
||||
BEGIN { f("hello"); }
|
@ -1,5 +0,0 @@
|
||||
function f(f)
|
||||
{
|
||||
print f;
|
||||
f("my hello");
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
# should print 50
|
||||
function fn(f) { f = 20; }
|
||||
BEGIN { f = 50; fn(100); print f; }
|
@ -1,3 +0,0 @@
|
||||
# A function and a named variable cannot have the same name.
|
||||
function a () { }
|
||||
BEGIN { a = 20; }
|
@ -1,3 +0,0 @@
|
||||
function a () { }
|
||||
BEGIN { local a; a = 20; }
|
||||
|
@ -1,2 +0,0 @@
|
||||
global a;
|
||||
function a () { }
|
@ -1,4 +0,0 @@
|
||||
function fn () { a = 20; return a;}
|
||||
global a;
|
||||
BEGIN { a = 30; print fn (); print a; }
|
||||
|
@ -1,16 +0,0 @@
|
||||
global x;
|
||||
BEGIN {
|
||||
x = 1;
|
||||
{
|
||||
local x;
|
||||
x = 2;
|
||||
{
|
||||
local x;
|
||||
x = 3;
|
||||
print x;
|
||||
}
|
||||
print x;
|
||||
}
|
||||
print x;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: parse.c 214 2009-06-27 02:50:54Z hyunghwan.chung $
|
||||
* $Id: parse.c 215 2009-06-27 05:52:54Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
|
||||
@ -930,13 +930,16 @@ static qse_awk_nde_t* parse_function (qse_awk_t* awk)
|
||||
/* NOTE: the following is not a conflict.
|
||||
* so the parameter is not checked against
|
||||
* global variables.
|
||||
* gbl x;
|
||||
* global x;
|
||||
* function f (x) { print x; }
|
||||
* x in print x is a parameter
|
||||
*/
|
||||
|
||||
/* check if a parameter conflicts with other parameters */
|
||||
if (qse_lda_search (awk->parse.params,
|
||||
/* check if a parameter conflicts with the function
|
||||
* name or other parameters */
|
||||
if (qse_strxncmp (
|
||||
param, param_len, name_dup, name_len) == 0 ||
|
||||
qse_lda_search (awk->parse.params,
|
||||
0, param, param_len) != QSE_LDA_NIL)
|
||||
{
|
||||
QSE_AWK_FREE (awk, name_dup);
|
||||
@ -989,6 +992,8 @@ static qse_awk_nde_t* parse_function (qse_awk_t* awk)
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if (get_token(awk) <= -1)
|
||||
{
|
||||
QSE_AWK_FREE (awk, name_dup);
|
||||
@ -996,6 +1001,8 @@ static qse_awk_nde_t* parse_function (qse_awk_t* awk)
|
||||
return QSE_NULL;
|
||||
}
|
||||
}
|
||||
while (MATCH(awk,TOKEN_NEWLINE));
|
||||
}
|
||||
|
||||
if (get_token(awk) <= -1)
|
||||
{
|
||||
@ -3723,18 +3730,23 @@ static qse_awk_nde_t* parse_fncall (
|
||||
|
||||
if (!MATCH(awk,TOKEN_COMMA))
|
||||
{
|
||||
if (head != QSE_NULL) qse_awk_clrpt (awk, head);
|
||||
|
||||
if (head != QSE_NULL)
|
||||
qse_awk_clrpt (awk, head);
|
||||
SETERRTOK (awk, QSE_AWK_ECOMMA);
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if (get_token(awk) <= -1)
|
||||
{
|
||||
if (head != QSE_NULL) qse_awk_clrpt (awk, head);
|
||||
if (head != QSE_NULL)
|
||||
qse_awk_clrpt (awk, head);
|
||||
return QSE_NULL;
|
||||
}
|
||||
}
|
||||
while (MATCH(awk,TOKEN_NEWLINE));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,14 +0,0 @@
|
||||
ld zero # initialize sum to zero
|
||||
st sum
|
||||
loop get # read a number
|
||||
jz done # no more input if number is zero
|
||||
add sum # add in accumulated sum
|
||||
st sum # store new value back in sum
|
||||
j loop # go back and read another number
|
||||
|
||||
done ld sum # print sum
|
||||
put
|
||||
halt
|
||||
|
||||
zero const 0
|
||||
sum const
|
Loading…
Reference in New Issue
Block a user