Skip to content

Commit

Permalink
added strip_trailing_spaces() function that removes spaces/tabs at th…
Browse files Browse the repository at this point in the history
…e end of a string
  • Loading branch information
jolange committed Dec 29, 2016
1 parent 968bd1b commit f3eb209
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions utils.h
Expand Up @@ -137,6 +137,15 @@ static inline int ends_with(const char *str, const char *suffix)
return strstr(str, suffix) + strlen(suffix) == str + strlen(str);
}

static inline void strip_trailing_spaces(char *str)
{
char *end = str + strlen(str);
while (end > str && is_space(*(end-1))) {
end--;
}
*end = 0;
}

static inline uint32_t hash_str(const char *s)
{
const unsigned char *p = (const unsigned char *)s;
Expand Down

0 comments on commit f3eb209

Please sign in to comment.