about summary refs log tree commit diff
path: root/Src/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/string.c')
-rw-r--r--Src/string.c20
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;
+}