* PATCH: test ${(q+)...}
@ 2015-12-08 15:03 Peter Stephenson
0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2015-12-08 15:03 UTC (permalink / raw)
To: Zsh Hackers' List
Plus an extra dupstring() on the basis that it's better if it doesn't
crash.
pws
diff --git a/Src/utils.c b/Src/utils.c
index 1554fa0..6d0f88d 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -5940,7 +5940,7 @@ quotedzputs(char const *s, FILE *stream)
/* check for empty string */
if(!*s) {
if (!stream)
- return "''";
+ return dupstring("''");
fputs("''", stream);
return NULL;
}
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index 1460ff6..bcea980 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -1866,3 +1866,17 @@
>0
>1 /somewhere
>2 /random /value
+
+ print -r -- ${(q+):-}
+ print -r -- ${(q+)IFS}
+ print -r -- ${(q+):-oneword}
+ print -r -- ${(q+):-two words}
+ print -r -- ${(q+):-three so-called \'words\'}
+ (setopt rcquotes; print -r -- ${(q+):-three so-called \'words\'})
+0:${(q+)...}
+>''
+>$' \t\n\C-@'
+>oneword
+>'two words'
+>'three so-called '\''words'\'
+>'three so-called ''words'''
diff --git a/Test/D07multibyte.ztst b/Test/D07multibyte.ztst
index f95c06d..39ba5ef 100644
--- a/Test/D07multibyte.ztst
+++ b/Test/D07multibyte.ztst
@@ -546,3 +546,10 @@
[[ $'\xe3\x83\x9b' != [[:INCOMPLETE:][:INVALID:]] ]] || print fail 3
[[ $'\xe3\x83\x9b' = ? ]] || print fail 4
0:Testing incomplete and invalid multibyte character components
+
+ print -r -- ${(q+):-ホ}
+ foo='She said "ホ". I said "You can'\''t '\''ホ'\'' me!'
+ print -r -- ${(q+)foo}
+0:${(q+)...} with printable multibyte characters
+>ホ
+>'She said "ホ". I said "You can'\''t '\''ホ'\'' me!'
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-12-08 15:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-08 15:03 PATCH: test ${(q+)...} Peter Stephenson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).