Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2023-06-08 11:42:39 +0300
committerDenys Vlasenko <vda.linux@googlemail.com>2023-06-08 11:42:39 +0300
commit2ca39ffd447ca874fcea933194829717d5573247 (patch)
tree6d9eb4ba80ad9feec70c3f4f25dd3f7629c5fe5a /testsuite
parent113685fbcd4c3432ec9b640583d50ba8da2102e8 (diff)
awk: fix subst code to handle "start of word" pattern correctly (needs REG_STARTEND)
function old new delta awk_sub 637 714 +77 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'testsuite')
-rwxr-xr-xtestsuite/awk.tests28
1 files changed, 15 insertions, 13 deletions
diff --git a/testsuite/awk.tests b/testsuite/awk.tests
index c61d32947..5a792c241 100755
--- a/testsuite/awk.tests
+++ b/testsuite/awk.tests
@@ -557,14 +557,12 @@ testing 'awk gensub backslashes \' \
'awk '$sq'BEGIN { s="\\"; print "s=" s; print gensub("a", s, "g", "a|a") }'$sq \
's=\\
\\|\\
-' \
- '' ''
+' '' ''
testing 'awk gensub backslashes \\' \
'awk '$sq'BEGIN { s="\\\\"; print "s=" s; print gensub("a", s, "g", "a|a") }'$sq \
's=\\\\
\\|\\
-' \
- '' ''
+' '' ''
# gawk 5.1.1 handles trailing unpaired \ inconsistently.
# If replace string is single \, it is used verbatim,
# but if it is \\\ (three slashes), gawk uses "\<NUL>" (!!!), not "\\" as you would expect.
@@ -572,31 +570,35 @@ testing 'awk gensub backslashes \\\' \
'awk '$sq'BEGIN { s="\\\\\\"; print "s=" s; print gensub("a", s, "g", "a|a") }'$sq \
's=\\\\\\
\\\\|\\\\
-' \
- '' ''
+' '' ''
testing 'awk gensub backslashes \\\\' \
'awk '$sq'BEGIN { s="\\\\\\\\"; print "s=" s; print gensub("a", s, "g", "a|a") }'$sq \
's=\\\\\\\\
\\\\|\\\\
-' \
- '' ''
+' '' ''
testing 'awk gensub backslashes \&' \
'awk '$sq'BEGIN { s="\\&"; print "s=" s; print gensub("a", s, "g", "a|a") }'$sq \
's=\\&
&|&
-' \
- '' ''
+' '' ''
testing 'awk gensub backslashes \0' \
'awk '$sq'BEGIN { s="\\0"; print "s=" s; print gensub("a", s, "g", "a|a") }'$sq \
's=\\0
a|a
-' \
- '' ''
+' '' ''
testing 'awk gensub backslashes \\0' \
'awk '$sq'BEGIN { s="\\\\0"; print "s=" s; print gensub("a", s, "g", "a|a") }'$sq \
's=\\\\0
\\0|\\0
-' \
+' '' ''
+
+# The "b" in "abc" should not match <b* pattern.
+# Currently we use REG_STARTEND ("This flag is a BSD extension, not present in POSIX")
+# to implement the code to handle this correctly, but if your libc has no REG_STARTEND,
+# the alternative code mishandles this case.
+testing 'awk gsub erroneous word start match' \
+ "awk 'BEGIN { a=\"abc\"; gsub(/\<b*/,\"\",a); print a }'" \
+ 'abc\n' \
'' ''
exit $FAILCOUNT