changed awk modules to hard-fail when qse_awk_setrefval() fails

This commit is contained in:
hyung-hwan 2013-04-20 01:57:50 +00:00
parent e01ac6bbac
commit b6b18918b9
10 changed files with 273 additions and 18 deletions

View File

@ -292,11 +292,7 @@ static int read_byid (qse_awk_rtx_t* rtx, dir_list_t* list, qse_long_t id, qse_a
qse_awk_rtx_refupval (rtx, tmp);
n = qse_awk_rtx_setrefval (rtx, ref, tmp);
qse_awk_rtx_refdownval (rtx, tmp);
if (n <= -1)
{
list->errnum = awk_err_to_errnum (qse_awk_rtx_geterrnum (rtx));
return -1;
}
if (n <= -1) return -9999;
}
return 1; /* has entry */
@ -479,6 +475,7 @@ static int fnc_dir_read (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
else
{
ret = read_byid (rtx, list, id, qse_awk_rtx_getarg (rtx, 1));
if (ret == -9999) return -1;
}
/* no error check for qse_awk_rtx_makeintval() here since ret

View File

@ -571,7 +571,8 @@ static int fnc_getnwifcfg (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
qse_awk_rtx_refupval (rtx, tmp);
x = qse_awk_rtx_setrefval (rtx, qse_awk_rtx_getarg (rtx, 2), tmp);
qse_awk_rtx_refdownval (rtx, tmp);
if (x >= 0) ret = 0;
if (x <= -1) return -1;
ret = 0;
}
}
}

View File

@ -475,7 +475,7 @@ static int getsection_byid (
qse_awk_rtx_refupval (rtx, tmp);
n = qse_awk_rtx_setrefval (rtx, ref, tmp);
qse_awk_rtx_refdownval (rtx, tmp);
if (n <= -1) x = UCI_ERR_MEM; /* this is not a correct error code. who cares? */
if (n <= -1) return -9999;
}
else x = UCI_ERR_MEM;
}
@ -540,7 +540,7 @@ static int getoption_byid (
if (n <= -1)
{
map = QSE_NULL;
x = UCI_ERR_MEM;
return -9999;
}
}
else x = UCI_ERR_MEM;
@ -624,7 +624,7 @@ static int getoption_byid (
qse_awk_rtx_refupval (rtx, map);
qse_awk_rtx_refdownval (rtx, map);
map = QSE_NULL;
x = UCI_ERR_MEM;
return -9999;
}
}
}
@ -1242,6 +1242,7 @@ static int fnc_uci_getoption (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
{
ret = getoption_byid (rtx, list, id, item, qse_awk_rtx_getarg (rtx, 2));
qse_awk_rtx_freemem (rtx, item);
if (ret == -9999) return -1;
}
else ret = -UCI_ERR_MEM;
}
@ -1276,6 +1277,7 @@ static int fnc_uci_getsection (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
{
ret = getsection_byid (rtx, list, id, item, qse_awk_rtx_getarg (rtx, 2));
qse_awk_rtx_freemem (rtx, item);
if (ret == -9999) return -1;
}
else ret = -UCI_ERR_MEM;
}

View File

@ -2542,14 +2542,15 @@ done:
{
int x;
qse_awk_rtx_refupval (rtx, rv);
x = qse_awk_rtx_setrefval (rtx, qse_awk_rtx_getarg (rtx, 2), rv);
ret = qse_awk_rtx_setrefval (rtx, qse_awk_rtx_getarg (rtx, 2), rv);
qse_awk_rtx_refdownval (rtx, rv);
if (x <= -1) retv = qse_awk_val_negone;
else retv = qse_awk_val_zero;
if (ret >= 0) qse_awk_rtx_setretval (rtx, qse_awk_val_zero);
}
else
{
qse_awk_rtx_setretval (rtx, qse_awk_val_negone);
}
else retv = qse_awk_val_negone;
qse_awk_rtx_setretval (rtx, qse_awk_val_zero);
}
return ret;

View File

@ -115,6 +115,7 @@ EXTRA_DIST = \
lang-051.awk \
lang-052.awk \
lang-053.awk \
lang-054.awk \
columnate.awk \
levenshtein.awk \
levenshtein-utests.awk \

View File

@ -350,6 +350,7 @@ EXTRA_DIST = \
lang-051.awk \
lang-052.awk \
lang-053.awk \
lang-054.awk \
columnate.awk \
levenshtein.awk \
levenshtein-utests.awk \

View File

@ -0,0 +1,6 @@
# ARGV is an array. if FLEXMAP is off, it should trigger an error.
# If it is on, ARGV can change to a scalar value.
BEGIN {
print getioattr ("xxxx", "rtimeout", ARGV);
print ARGV;
}

View File

@ -1352,7 +1352,7 @@ BEGIN {
printf ("%s\n",10.34);
}
ERROR: CODE 109 LINE 3 COLUMN 2 FILE /home/hyung-hwan/workspace/qse/bld/x86_64-linux-wchar-debug-shared/../../regress/awk/lang-013.awk - recursion detected in format conversion
ERROR: CODE 110 LINE 3 COLUMN 2 FILE /home/hyung-hwan/workspace/qse/bld/x86_64-linux-wchar-debug-shared/../../regress/awk/lang-013.awk - recursion detected in format conversion
--------------------------------------------------------------------------------
[CMD] qseawk --newline=on -d- -f lang-014.awk </dev/stdin 2>&1
--------------------------------------------------------------------------------
@ -1533,7 +1533,7 @@ BEGIN {
delete iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiix;
}
ERROR: CODE 82 LINE 3 COLUMN 9 FILE /home/hyung-hwan/workspace/qse/bld/x86_64-linux-wchar-debug-shared/../../regress/awk/lang-025.awk - 'iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiix' not deletable
ERROR: CODE 81 LINE 3 COLUMN 9 FILE /home/hyung-hwan/workspace/qse/bld/x86_64-linux-wchar-debug-shared/../../regress/awk/lang-025.awk - 'iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiix' not deletable
--------------------------------------------------------------------------------
[CMD] qseawk --newline=on -d- -f lang-026.awk </dev/stdin 2>&1
--------------------------------------------------------------------------------
@ -2458,6 +2458,128 @@ BEGIN {
--------------------------------------------------------------------------------
ERROR: CODE 62 LINE 2 COLUMN 9 FILE /home/hyung-hwan/workspace/qse/bld/x86_64-linux-wchar-debug-shared/../../regress/awk/lang-049.awk - no argument provided
--------------------------------------------------------------------------------
[CMD] qseawk --newline=on --flexmap=off -d- -f lang-050.awk </dev/stdin 2>&1
--------------------------------------------------------------------------------
BEGIN {
a = 20;
a[10] = 30;
for (i in a)
print i,a[i];
}
ERROR: CODE 91 LINE 6 COLUMN 2 FILE /home/hyung-hwan/workspace/qse/bld/x86_64-linux-wchar-debug-shared/../../regress/awk/lang-050.awk - cannot change a scalar to a map
--------------------------------------------------------------------------------
[CMD] qseawk --newline=on --flexmap=on -d- -f lang-050.awk </dev/stdin 2>&1
--------------------------------------------------------------------------------
BEGIN {
a = 20;
a[10] = 30;
for (i in a)
print i,a[i];
}
10 30
--------------------------------------------------------------------------------
[CMD] qseawk --newline=on --flexmap=off -d- -f lang-051.awk </dev/stdin 2>&1
--------------------------------------------------------------------------------
BEGIN {
split("a b c d e",ARGC);
for (i in ARGC)
print i,ARGC[i];
}
ERROR: CODE 94 LINE 7 COLUMN 2 FILE /home/hyung-hwan/workspace/qse/bld/x86_64-linux-wchar-debug-shared/../../regress/awk/lang-051.awk - cannot change a scalar 'ARGC' to a map
--------------------------------------------------------------------------------
[CMD] qseawk --newline=on --flexmap=on -d- -f lang-051.awk </dev/stdin 2>&1
--------------------------------------------------------------------------------
BEGIN {
split("a b c d e",ARGC);
for (i in ARGC)
print i,ARGC[i];
}
1 a
2 b
3 c
4 d
5 e
--------------------------------------------------------------------------------
[CMD] qseawk --newline=on --flexmap=off -d- -f lang-052.awk </dev/stdin 2>&1
--------------------------------------------------------------------------------
BEGIN {
split("a b c d e",ARGV);
for (i in ARGV)
print i,ARGV[i];
}
1 a
2 b
3 c
4 d
5 e
--------------------------------------------------------------------------------
[CMD] qseawk --newline=on --flexmap=on -d- -f lang-052.awk </dev/stdin 2>&1
--------------------------------------------------------------------------------
BEGIN {
split("a b c d e",ARGV);
for (i in ARGV)
print i,ARGV[i];
}
1 a
2 b
3 c
4 d
5 e
--------------------------------------------------------------------------------
[CMD] qseawk --newline=on --flexmap=off -d- -f lang-053.awk </dev/stdin 2>&1
--------------------------------------------------------------------------------
BEGIN {
a[1] = 1;
a[2] = 2;
b[4] = 4;
b[5] = 5;
a = b;
for (i in a)
print i,a[i];
}
ERROR: CODE 92 LINE 10 COLUMN 2 FILE /home/hyung-hwan/workspace/qse/bld/x86_64-linux-wchar-debug-shared/../../regress/awk/lang-053.awk - cannot change a map 'a' to another map
--------------------------------------------------------------------------------
[CMD] qseawk --newline=on --flexmap=on -d- -f lang-053.awk </dev/stdin 2>&1
--------------------------------------------------------------------------------
BEGIN {
a[1] = 1;
a[2] = 2;
b[4] = 4;
b[5] = 5;
a = b;
for (i in a)
print i,a[i];
}
4 4
5 5
--------------------------------------------------------------------------------
[CMD] qseawk --newline=on --flexmap=off -d- -f lang-054.awk </dev/stdin 2>&1
--------------------------------------------------------------------------------
BEGIN {
print getioattr("xxxx","rtimeout",ARGV);
print ARGV;
}
ERROR: CODE 93 LINE 4 COLUMN 8 FILE /home/hyung-hwan/workspace/qse/bld/x86_64-linux-wchar-debug-shared/../../regress/awk/lang-054.awk - cannot change a map 'ARGV' to a scalar
--------------------------------------------------------------------------------
[CMD] qseawk --newline=on --flexmap=on -d- -f lang-054.awk </dev/stdin 2>&1
--------------------------------------------------------------------------------
BEGIN {
print getioattr("xxxx","rtimeout",ARGV);
print ARGV;
}
0
-999
--------------------------------------------------------------------------------
[CMD] qseawk --newline=on -F: -f columnate.awk passwd.dat </dev/stdin 2>&1
--------------------------------------------------------------------------------
root x 0 0 root /root /bin/bash

View File

@ -1352,7 +1352,7 @@ BEGIN {
printf ("%s\n",10.34);
}
ERROR: CODE 109 LINE 3 COLUMN 2 FILE /home/hyung-hwan/workspace/qse/bld/x86_64-linux-wchar-debug-shared/../../regress/awk/lang-013.awk - recursion detected in format conversion
ERROR: CODE 110 LINE 3 COLUMN 2 FILE /home/hyung-hwan/workspace/qse/bld/x86_64-linux-wchar-debug-shared/../../regress/awk/lang-013.awk - recursion detected in format conversion
--------------------------------------------------------------------------------
[CMD] qseawk -m 500000 --newline=on -d- -f lang-014.awk </dev/stdin 2>&1
--------------------------------------------------------------------------------
@ -1533,7 +1533,7 @@ BEGIN {
delete iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiix;
}
ERROR: CODE 82 LINE 3 COLUMN 9 FILE /home/hyung-hwan/workspace/qse/bld/x86_64-linux-wchar-debug-shared/../../regress/awk/lang-025.awk - 'iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiix' not deletable
ERROR: CODE 81 LINE 3 COLUMN 9 FILE /home/hyung-hwan/workspace/qse/bld/x86_64-linux-wchar-debug-shared/../../regress/awk/lang-025.awk - 'iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiix' not deletable
--------------------------------------------------------------------------------
[CMD] qseawk -m 500000 --newline=on -d- -f lang-026.awk </dev/stdin 2>&1
--------------------------------------------------------------------------------
@ -2458,6 +2458,128 @@ BEGIN {
--------------------------------------------------------------------------------
ERROR: CODE 62 LINE 2 COLUMN 9 FILE /home/hyung-hwan/workspace/qse/bld/x86_64-linux-wchar-debug-shared/../../regress/awk/lang-049.awk - no argument provided
--------------------------------------------------------------------------------
[CMD] qseawk -m 500000 --newline=on --flexmap=off -d- -f lang-050.awk </dev/stdin 2>&1
--------------------------------------------------------------------------------
BEGIN {
a = 20;
a[10] = 30;
for (i in a)
print i,a[i];
}
ERROR: CODE 91 LINE 6 COLUMN 2 FILE /home/hyung-hwan/workspace/qse/bld/x86_64-linux-wchar-debug-shared/../../regress/awk/lang-050.awk - cannot change a scalar to a map
--------------------------------------------------------------------------------
[CMD] qseawk -m 500000 --newline=on --flexmap=on -d- -f lang-050.awk </dev/stdin 2>&1
--------------------------------------------------------------------------------
BEGIN {
a = 20;
a[10] = 30;
for (i in a)
print i,a[i];
}
10 30
--------------------------------------------------------------------------------
[CMD] qseawk -m 500000 --newline=on --flexmap=off -d- -f lang-051.awk </dev/stdin 2>&1
--------------------------------------------------------------------------------
BEGIN {
split("a b c d e",ARGC);
for (i in ARGC)
print i,ARGC[i];
}
ERROR: CODE 94 LINE 7 COLUMN 2 FILE /home/hyung-hwan/workspace/qse/bld/x86_64-linux-wchar-debug-shared/../../regress/awk/lang-051.awk - cannot change a scalar 'ARGC' to a map
--------------------------------------------------------------------------------
[CMD] qseawk -m 500000 --newline=on --flexmap=on -d- -f lang-051.awk </dev/stdin 2>&1
--------------------------------------------------------------------------------
BEGIN {
split("a b c d e",ARGC);
for (i in ARGC)
print i,ARGC[i];
}
1 a
2 b
3 c
4 d
5 e
--------------------------------------------------------------------------------
[CMD] qseawk -m 500000 --newline=on --flexmap=off -d- -f lang-052.awk </dev/stdin 2>&1
--------------------------------------------------------------------------------
BEGIN {
split("a b c d e",ARGV);
for (i in ARGV)
print i,ARGV[i];
}
1 a
2 b
3 c
4 d
5 e
--------------------------------------------------------------------------------
[CMD] qseawk -m 500000 --newline=on --flexmap=on -d- -f lang-052.awk </dev/stdin 2>&1
--------------------------------------------------------------------------------
BEGIN {
split("a b c d e",ARGV);
for (i in ARGV)
print i,ARGV[i];
}
1 a
2 b
3 c
4 d
5 e
--------------------------------------------------------------------------------
[CMD] qseawk -m 500000 --newline=on --flexmap=off -d- -f lang-053.awk </dev/stdin 2>&1
--------------------------------------------------------------------------------
BEGIN {
a[1] = 1;
a[2] = 2;
b[4] = 4;
b[5] = 5;
a = b;
for (i in a)
print i,a[i];
}
ERROR: CODE 92 LINE 10 COLUMN 2 FILE /home/hyung-hwan/workspace/qse/bld/x86_64-linux-wchar-debug-shared/../../regress/awk/lang-053.awk - cannot change a map 'a' to another map
--------------------------------------------------------------------------------
[CMD] qseawk -m 500000 --newline=on --flexmap=on -d- -f lang-053.awk </dev/stdin 2>&1
--------------------------------------------------------------------------------
BEGIN {
a[1] = 1;
a[2] = 2;
b[4] = 4;
b[5] = 5;
a = b;
for (i in a)
print i,a[i];
}
4 4
5 5
--------------------------------------------------------------------------------
[CMD] qseawk -m 500000 --newline=on --flexmap=off -d- -f lang-054.awk </dev/stdin 2>&1
--------------------------------------------------------------------------------
BEGIN {
print getioattr("xxxx","rtimeout",ARGV);
print ARGV;
}
ERROR: CODE 93 LINE 4 COLUMN 8 FILE /home/hyung-hwan/workspace/qse/bld/x86_64-linux-wchar-debug-shared/../../regress/awk/lang-054.awk - cannot change a map 'ARGV' to a scalar
--------------------------------------------------------------------------------
[CMD] qseawk -m 500000 --newline=on --flexmap=on -d- -f lang-054.awk </dev/stdin 2>&1
--------------------------------------------------------------------------------
BEGIN {
print getioattr("xxxx","rtimeout",ARGV);
print ARGV;
}
0
-999
--------------------------------------------------------------------------------
[CMD] qseawk -m 500000 --newline=on -F: -f columnate.awk passwd.dat </dev/stdin 2>&1
--------------------------------------------------------------------------------
root x 0 0 root /root /bin/bash

View File

@ -184,6 +184,8 @@ PROGS="
lang-052.awk!!!--newline=on --flexmap=on -d-
lang-053.awk!!!--newline=on --flexmap=off -d-
lang-053.awk!!!--newline=on --flexmap=on -d-
lang-054.awk!!!--newline=on --flexmap=off -d-
lang-054.awk!!!--newline=on --flexmap=on -d-
columnate.awk!passwd.dat!!--newline=on -F:
levenshtein-utests.awk!!!--newline=on