aboutsummaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2023-04-23 17:55:16 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2023-04-23 17:55:16 -0400
commit1f0c894080e0a3d62694a056456e378e36eb12a1 (patch)
tree7abd3928808aa9f03a4dd17dd3eb5ecde7607d18 /util.c
parent0ec45301dc4d1a61cc1d9bd2906cd010c88f81c0 (diff)
downloadwhatami-1f0c894080e0a3d62694a056456e378e36eb12a1.tar.gz
Refactor
Split linux, darwin, and x86 into separate modules
Diffstat (limited to 'util.c')
-rw-r--r--util.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/util.c b/util.c
new file mode 100644
index 0000000..1f74ad5
--- /dev/null
+++ b/util.c
@@ -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;
+}
+