about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--Src/utils.c2
-rw-r--r--Test/D04parameter.ztst14
-rw-r--r--Test/D07multibyte.ztst7
4 files changed, 26 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 5b9558610..75f4eeb2f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2015-12-08  Peter Stephenson  <p.stephenson@samsung.com>
 
+	* 37348: Src/utils.c, Test/D04parameter.ztst,
+	Test/D07multibyte.ztst: tests for ${(q+)...} and extra
+	dupstring() needed for empty string case.
+
 	* 37347: Functions/VCS_Info/VCS_INFO_nvcsformats: msgs
 	shouldn't be local here, but in caller (where it already is).
 
diff --git a/Src/utils.c b/Src/utils.c
index 1554fa0ae..6d0f88d6d 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 1460ff6b6..bcea980ad 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 f95c06d9a..39ba5ef8b 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!'