From 86b063b99d78df97fcd761073f437ce00b018712 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 31 Jul 2018 09:21:43 +0300 Subject: Fix handling of physical newlines in -v arguments and related improvemnts. --- main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'main.c') diff --git a/main.c b/main.c index 25a628ba..4e94bddd 100644 --- a/main.c +++ b/main.c @@ -1165,11 +1165,18 @@ arg_assign(char *arg, bool initing) fatal(_("cannot use function `%s' as variable name"), arg); } + // POSIX disallows any newlines inside strings + // The scanner handles that for program files. + // We have to check here for strings passed to -v. + if (do_posix && strchr(cp, '\n') != NULL) + fatal(_("POSIX does not allow physical newlines in string values")); + /* * BWK awk expands escapes inside assignments. * This makes sense, so we do it too. + * In addition, remove \- as in scanning. */ - it = make_str_node(cp, strlen(cp), SCAN); + it = make_str_node(cp, strlen(cp), SCAN | ELIDE_BACK_NL); it->flags |= USER_INPUT; #ifdef LC_NUMERIC /* -- cgit v1.2.3