Expand description
string submodule.
String manipulation utilities for zshrs
Direct port of Src/string.c (201 lines, 11 ported).
Duplicate string on heap when length is known // c:44 Append a string to an allocated string, reallocating to make room. // c:182
C zsh distinguishes two allocation lanes — zalloc (permanent
storage, freed by zsfree) and zhalloc (heap-arena, bulk-
freed at the end of the current dispatch). Rust’s String always
owns its allocation and Drops when it falls out of scope, so the
two lanes collapse into one. The function names below are kept
verbatim for caller-side parity with the C source — passing
through to a single owned String regardless of whether C would
have used zalloc or zhalloc.
Byte-faithfulness: C’s memcpy(r, s, len) copies bytes without
regard for UTF-8 boundaries. The Rust ports use as_bytes slicing
plus from_utf8_lossy so a len that lands mid-codepoint doesn’t
panic — matching the C behavior of producing a possibly-truncated
byte string.
Functions§
- appstr
- Port of
appstr(char *base, char const *append)fromSrc/string.c:186. - bicat
- Port of
bicat(const char *s1, const char *s2)fromSrc/string.c:145. - dupstring
- Port of
dupstring(const char *s)fromSrc/string.c:33. - dupstring_
wlen - Port of
dupstring_wlen(const char *s, unsigned len)fromSrc/string.c:48. - dupstrpfx
- Port of
dupstrpfx(const char *s, int len)fromSrc/string.c:161. - dyncat
- Port of
dyncat(const char *s1, const char *s2)fromSrc/string.c:131. - strend
- Port of
strend(char *str)fromSrc/string.c:196. - tricat
- Port of
tricat(char const *s1, char const *s2, char const *s3)fromSrc/string.c:98. - wcs_
ztrdup - Port of
wcs_ztrdup(const wchar_t *s)fromSrc/string.c:77. - zhtricat
- Port of
zhtricat(char const *s1, char const *s2, char const *s3)fromSrc/string.c:114. - ztrdup
- Port of
ztrdup(const char *s)fromSrc/string.c:62. - ztrduppfx
- Port of
ztrduppfx(const char *s, int len)fromSrc/string.c:172.