mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Add a function to remove a set of characters from a string
svn:r2420
This commit is contained in:
@@ -200,6 +200,21 @@ char *tor_strndup(const char *s, size_t n) {
|
||||
return dup;
|
||||
}
|
||||
|
||||
/** Remove from the string <b>s</b> every character which appears in
|
||||
* <b>strip</b>. 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
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user