blob: 05a830ec9be36ee04373992db645b4d47b848a4a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
diff -urpN busybox-1.15.2/editors/awk.c busybox-1.15.2-awk/editors/awk.c
--- busybox-1.15.2/editors/awk.c 2009-10-08 02:59:09.000000000 +0200
+++ busybox-1.15.2-awk/editors/awk.c 2009-11-30 02:05:12.000000000 +0100
@@ -2393,12 +2393,14 @@ static var *evaluate(node *op, var *res)
case XC( OC_MOVE ):
/* if source is a temporary string, jusk relink it to dest */
- if (R.v == v1+1 && R.v->string) {
- res = setvar_p(L.v, R.v->string);
- R.v->string = NULL;
- } else {
+//Disabled: if R.v is numeric but happens to have cached R.v->string,
+//then L.v ends up being a string, which is wrong
+// if (R.v == v1+1 && R.v->string) {
+// res = setvar_p(L.v, R.v->string);
+// R.v->string = NULL;
+// } else {
res = copyvar(L.v, R.v);
- }
+// }
break;
case XC( OC_TERNARY ):
diff -urpN busybox-1.15.2/testsuite/awk.tests busybox-1.15.2-awk/testsuite/awk.tests
--- busybox-1.15.2/testsuite/awk.tests 2009-09-26 15:14:57.000000000 +0200
+++ busybox-1.15.2-awk/testsuite/awk.tests 2009-11-30 02:05:12.000000000 +0100
@@ -47,4 +47,21 @@ testing "awk NF in BEGIN" \
":0::::\n" \
"" ""
+prg='
+function b(tmp) {
+ tmp = 0;
+ print "" tmp; #this line causes the bug
+ return tmp;
+}
+function c(tmpc) {
+ tmpc = b(); return tmpc;
+}
+BEGIN {
+ print (c() ? "string" : "number");
+}'
+testing "awk string cast (bug 725)" \
+ "awk '$prg'" \
+ "0\nnumber\n" \
+ "" ""
+
exit $FAILCOUNT
|