Subject: [PATCH] _describe and literal \n
From: Daniel Shahaf <[email-masked]>
To: [email-masked]
Date: Sat, 23 Jul 2016 18:04:30 +0000
List-Id: Zsh Workers List <zsh-workers.zsh.org>

Current behaviour:
[[[
$ zsh -f
% autoload compinit
% compinit
% _f() { a=( $'foo:hello\nworld' $'bar:lorem\nipsum' ); _describe descr a }
% compdef _f f
% f <TAB>
bar  -- lorem
ipsum
foo  -- hello
world
]]]

Proposed patch:
[[[
diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c
index e8f0a6f..9e3ea3c 100644
--- a/Src/Zle/computil.c
+++ b/Src/Zle/computil.c
@@ -531,7 +531,7 @@ cd_init(char *nam, char *hide, char *mlen, char *sep,
                     tmp++;
 
             if (*tmp)
-                str->desc = ztrdup(rembslash(tmp + 1));
+                str->desc = nicedup(rembslash(tmp + 1), 0 /* heap? */);
             else
                 str->desc = NULL;
             *tmp = '\0';
]]]

Gives:
[[[
% f <TAB>
bar  -- lorem\nipsum
foo  -- hello\nworld
]]]

Is this fix correct?