summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2012-01-08 10:18:07 +0000
committerJason Woodward2012-01-08 11:51:51 +0000
commit4ce0ecf5eb98fbb574b956e9c95ace7859edc39b (patch)
treee09e64a4e92c1d1c39767bb85c3dbd4e82e4c553
parent5f9daef4ca8cd6bd4c330554b087e90f7e31dcc6 (diff)
downloadslapt-get-4ce0ecf5eb98fbb574b956e9c95ace7859edc39b.tar.gz
added slapt_strip_whitespace
-rw-r--r--src/common.c8
-rw-r--r--src/common.h2
2 files changed, 10 insertions, 0 deletions
diff --git a/src/common.c b/src/common.c
index cabfa86..35a22ff 100644
--- a/src/common.c
+++ b/src/common.c
@@ -497,3 +497,11 @@ slapt_list_t *slapt_parse_delimited_list(char *line, char delim)
return list;
}
+char *slapt_strip_whitespace (const char * s)
+{
+ int len = strlen (s);
+ while (isspace(s[len - 1])) --len;
+ while (*s && isspace(* s)) ++s, --len;
+ return strndup (s, len);
+}
+
diff --git a/src/common.h b/src/common.h
index d351f2a..eaa068a 100644
--- a/src/common.h
+++ b/src/common.h
@@ -86,3 +86,5 @@ void slapt_add_list_item(slapt_list_t *list,const char *item);
void slapt_remove_list_item(slapt_list_t *list,const char *item);
const char *slapt_search_list(slapt_list_t *list, const char *needle);
void slapt_free_list(slapt_list_t *list);
+
+char *slapt_strip_whitespace (const char * s);