aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2012-07-11 01:27:15 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2012-07-11 01:27:15 +0200
commitdf8066a78ccd9b899244145f6be0171957a41a1e (patch)
tree1deceaacbf772c04dbcf84173b7b23e66b7f8598 /editors
parente1db338a5187c008819932a4166f3aa27958c48e (diff)
downloadbusybox-df8066a78ccd9b899244145f6be0171957a41a1e.tar.gz
awk: fix FS assignment behavior. Closes 5108
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'editors')
-rw-r--r--editors/awk.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/editors/awk.c b/editors/awk.c
index d69720d64..42f6ef866 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -1812,6 +1812,18 @@ static void handle_special(var *v)
is_f0_split = FALSE;
} else if (v == intvar[FS]) {
+ /*
+ * The POSIX-2008 standard says that changing FS should have no effect on the
+ * current input line, but only on the next one. The language is:
+ *
+ * > Before the first reference to a field in the record is evaluated, the record
+ * > shall be split into fields, according to the rules in Regular Expressions,
+ * > using the value of FS that was current at the time the record was read.
+ *
+ * So, split up current line before assignment to FS:
+ */
+ split_f0();
+
mk_splitter(getvar_s(v), &fsplitter);
} else if (v == intvar[RS]) {