summaryrefslogtreecommitdiff
path: root/common/stringx.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/stringx.c')
-rw-r--r--common/stringx.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/common/stringx.c b/common/stringx.c
index f4d9910..a2bc90d 100644
--- a/common/stringx.c
+++ b/common/stringx.c
@@ -261,6 +261,32 @@ int is_blank_line(const char* line)
return *line == 0;
}
+char* trim_start(const char* data)
+{
+ while(*data && isspace(*data))
+ ++data;
+ return (char*)data;
+}
+
+char* trim_end(char* data)
+{
+ char* t = data + strlen(data);
+
+ while(t > data && isspace(*(t - 1)))
+ {
+ t--;
+ *t = 0;
+ }
+
+ return data;
+}
+
+char* trim_space(char* data)
+{
+ data = (char*)trim_start(data);
+ return trim_end(data);
+}
+
/* -----------------------------------------------------------------------
* Locking
*/