diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2023-04-23 17:55:16 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2023-04-23 17:55:16 -0400 |
commit | 1f0c894080e0a3d62694a056456e378e36eb12a1 (patch) | |
tree | 7abd3928808aa9f03a4dd17dd3eb5ecde7607d18 /util.c | |
parent | 0ec45301dc4d1a61cc1d9bd2906cd010c88f81c0 (diff) | |
download | whatami-1f0c894080e0a3d62694a056456e378e36eb12a1.tar.gz |
Refactor
Split linux, darwin, and x86 into separate modules
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; +} + |