From: Nick Mathewson Date: Wed, 6 Oct 2004 13:26:37 +0000 (+0000) Subject: Add a function to remove a set of characters from a string X-Git-Tag: debian-version-0.0.8+0.0.9pre2-1~68 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b56bb39ed6119edc6088987ba40d0604ac4ffba1;p=thirdparty%2Ftor.git Add a function to remove a set of characters from a string svn:r2420 --- diff --git a/src/common/util.c b/src/common/util.c index 6dd06c7ce6..dde5c7c914 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -200,6 +200,21 @@ char *tor_strndup(const char *s, size_t n) { return dup; } +/** Remove from the string s every character which appears in + * strip. Return the number of characters removed. */ +int tor_strstrip(char *s, const char *strip) +{ + char *read = s; + while (*read) { + if (strchr(strip, *read)) { + ++read; + } else { + *s++ = *read++; + } + } + *s = '\0'; + return read-s; +} #ifndef UNALIGNED_INT_ACCESS_OK /**