diff options
-rw-r--r-- | editors/awk.c | 3 | ||||
-rwxr-xr-x | testsuite/awk.tests | 6 |
2 files changed, 9 insertions, 0 deletions
diff --git a/editors/awk.c b/editors/awk.c index 079d0bde5..728ee8685 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -3128,6 +3128,9 @@ static var *evaluate(node *op, var *res) | |||
3128 | 3128 | ||
3129 | case XC( OC_MOVE ): | 3129 | case XC( OC_MOVE ): |
3130 | debug_printf_eval("MOVE\n"); | 3130 | debug_printf_eval("MOVE\n"); |
3131 | /* make sure that we never return a temp var */ | ||
3132 | if (L.v == TMPVAR0) | ||
3133 | L.v = res; | ||
3131 | /* if source is a temporary string, jusk relink it to dest */ | 3134 | /* if source is a temporary string, jusk relink it to dest */ |
3132 | if (R.v == TMPVAR1 | 3135 | if (R.v == TMPVAR1 |
3133 | && !(R.v->type & VF_NUMBER) | 3136 | && !(R.v->type & VF_NUMBER) |
diff --git a/testsuite/awk.tests b/testsuite/awk.tests index 93e25d8c1..bbf0fbff1 100755 --- a/testsuite/awk.tests +++ b/testsuite/awk.tests | |||
@@ -479,4 +479,10 @@ testing 'awk backslash+newline eaten with no trace' \ | |||
479 | "Hello world\n" \ | 479 | "Hello world\n" \ |
480 | '' '' | 480 | '' '' |
481 | 481 | ||
482 | testing 'awk assign while test' \ | ||
483 | "awk '\$1==\$1=\"foo\" {print \$1}'" \ | ||
484 | "foo\n" \ | ||
485 | "" \ | ||
486 | "foo" | ||
487 | |||
482 | exit $FAILCOUNT | 488 | exit $FAILCOUNT |