From 1f0c894080e0a3d62694a056456e378e36eb12a1 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Sun, 23 Apr 2023 17:55:16 -0400 Subject: Refactor Split linux, darwin, and x86 into separate modules --- util.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 util.c (limited to 'util.c') 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; +} + -- cgit