From a76c8de44c8c1f47f4db4cef0e9b1ce2f8c52a31 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 13 Mar 2012 09:47:01 +0000 Subject: 30351 + 30352: metafy strings on import into zsh variables --- Src/utils.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'Src/utils.c') diff --git a/Src/utils.c b/Src/utils.c index f07d8cc31..a9b5c2c58 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -4012,6 +4012,28 @@ metafy(char *buf, int len, int heap) } +/* + * Duplicate a string, metafying it as we go. + * + * Typically, this is used only for strings imported from outside + * zsh, as strings internally are either already metafied or passed + * around with an associated length. + */ +/**/ +mod_export char * +ztrdup_metafy(const char *s) +{ + /* To mimic ztrdup() behaviour */ + if (!s) + return NULL; + /* + * metafy() does lots of different things, so the pointer + * isn't const. Using it with META_DUP should be safe. + */ + return metafy((char *)s, -1, META_DUP); +} + + /* * Take a null-terminated, metafied string in s into a literal * representation by converting in place. The length is in *len -- cgit v1.2.3