diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2012-03-13 09:47:01 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2012-03-13 09:47:01 +0000 |
commit | a76c8de44c8c1f47f4db4cef0e9b1ce2f8c52a31 (patch) | |
tree | e3be887d4462f8496155de34048955a97933c878 /Src/utils.c | |
parent | afa112474c981941ad95ef82cbe75479556ed23a (diff) | |
download | zsh-a76c8de44c8c1f47f4db4cef0e9b1ce2f8c52a31.tar.gz zsh-a76c8de44c8c1f47f4db4cef0e9b1ce2f8c52a31.tar.xz zsh-a76c8de44c8c1f47f4db4cef0e9b1ce2f8c52a31.zip |
30351 + 30352: metafy strings on import into zsh variables
Diffstat (limited to 'Src/utils.c')
-rw-r--r-- | Src/utils.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Src/utils.c b/Src/utils.c index f07d8cc31..a9b5c2c58 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -4013,6 +4013,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 * len is non-NULL; if len is NULL, you don't know the length of |