aboutsummaryrefslogtreecommitdiff
path: root/fbwarn/src/extString.c
diff options
context:
space:
mode:
Diffstat (limited to 'fbwarn/src/extString.c')
-rw-r--r--fbwarn/src/extString.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/fbwarn/src/extString.c b/fbwarn/src/extString.c
index c93cffd..abe6728 100644
--- a/fbwarn/src/extString.c
+++ b/fbwarn/src/extString.c
@@ -13,3 +13,22 @@ char *strlwr(char *str)
return str;
}
+
+char *trim(char *str)
+{
+ char *result = strdup(str);
+ char *end;
+
+ while(isspace((unsigned char)*result)) result++;
+
+ if(*result == 0)
+ return result;
+
+ end = result + strlen(result) - 1;
+ while(end > result && isspace((unsigned char)*end)) end--;
+
+ // Write new null terminator character
+ end[1] = '\0';
+
+ return result;
+}