diff options
| author | Clint Adams <clint@users.sourceforge.net> | 2000-09-22 22:16:15 +0000 |
|---|---|---|
| committer | Clint Adams <clint@users.sourceforge.net> | 2000-09-22 22:16:15 +0000 |
| commit | 2a625db39df5e5e5f72556f0cd4a02005115c50f (patch) | |
| tree | 9eb6be89333525ea9c74c14887da7a37aa8739cb /Src/string.c | |
| parent | Fiddle with _expand_word and its doc. (diff) | |
| download | zsh-2a625db39df5e5e5f72556f0cd4a02005115c50f.tar zsh-2a625db39df5e5e5f72556f0cd4a02005115c50f.tar.gz zsh-2a625db39df5e5e5f72556f0cd4a02005115c50f.tar.bz2 zsh-2a625db39df5e5e5f72556f0cd4a02005115c50f.tar.lz zsh-2a625db39df5e5e5f72556f0cd4a02005115c50f.tar.xz zsh-2a625db39df5e5e5f72556f0cd4a02005115c50f.tar.zst zsh-2a625db39df5e5e5f72556f0cd4a02005115c50f.zip | |
12859: dynamically-allocate buffer in ztat(), ztrdupstring()
Diffstat (limited to 'Src/string.c')
| -rw-r--r-- | Src/string.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Src/string.c b/Src/string.c index 3dad89911..57775359e 100644 --- a/Src/string.c +++ b/Src/string.c @@ -133,3 +133,23 @@ appstr(char *base, char const *append) { return strcat(realloc(base, strlen(base) + strlen(append) + 1), append); } + +/* Duplicate a string, stripping delimiters. */ + +/**/ +mod_export char * +ztrdupstrip(const char *nam, char delim) +{ + char *p, *buf; + + buf = zalloc(strlen(nam)); + + for (p = buf; *nam; nam++) + if (*nam == delim && nam[1]) + *p++ = *++nam; + else + *p++ = *nam; + *p = '\0'; + + return buf; +} |
