1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-11-23 01:31:27 +01:00

30351 + 30352: metafy strings on import into zsh variables

This commit is contained in:
Peter Stephenson 2012-03-13 09:47:01 +00:00
parent afa112474c
commit a76c8de44c
3 changed files with 47 additions and 17 deletions

View file

@ -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