Commit 233aabc8 authored by rswindell's avatar rswindell
Browse files

Add strListStripStrings().

parent 0b6132f9
......@@ -778,3 +778,23 @@ int strListTruncateStrings(str_list_t list, const char* set)
}
return i;
}
/* Strip chars in 'set' from strings in list */
int strListStripStrings(str_list_t list, const char* set)
{
size_t i;
char* o;
char* p;
if(list == NULL)
return 0;
for(i = 0; list[i] != NULL; i++) {
for(o = p = list[i]; (*p != '\0'); p++) {
if(strchr(set, *p) == NULL)
*(o++) = *p;
}
*o = '\0';
}
return i;
}
......@@ -164,6 +164,8 @@ DLLEXPORT int strListTruncateTrailingWhitespaces(str_list_t);
DLLEXPORT int strListTruncateTrailingLineEndings(str_list_t);
/* Truncate strings in list at first occurrence of any char in 'set' */
DLLEXPORT int strListTruncateStrings(str_list_t, const char* set);
/* Remove all occurrences of chars in set from string in list */
DLLEXPORT int strListStripStrings(str_list_t, const char* set);
/************/
/* File I/O */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment