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:
parent
afa112474c
commit
a76c8de44c
3 changed files with 47 additions and 17 deletions
22
Src/utils.c
22
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue