aboutsummaryrefslogtreecommitdiff
path: root/utils/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils/string.c')
-rw-r--r--utils/string.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/utils/string.c b/utils/string.c
new file mode 100644
index 0000000..1975306
--- /dev/null
+++ b/utils/string.c
@@ -0,0 +1,24 @@
+#include <ctype.h>
+#include <string.h>
+
+char *
+ltrim(char *s)
+{
+ while(isspace(*s)) s++;
+ return s;
+}
+
+char *
+rtrim(char *s)
+{
+ char* back = s + strlen(s);
+ while(isspace(*--back));
+ *(back+1) = '\0';
+ return s;
+}
+
+char *
+trim(char *s)
+{
+ return rtrim(ltrim(s));
+} \ No newline at end of file