diff options
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -0,0 +1,23 @@ +#include "common.h" + +/*** + * Strip whitespace from end of string + * @param s string + * @return count of characters stripped + */ +size_t rstrip(char *s) { + char *ch; + size_t i; + + i = 0; + ch = &s[strlen(s)]; + if (ch) { + while (isspace(*ch) || iscntrl(*ch)) { + *ch = '\0'; + --ch; + i++; + } + } + return i; +} + |