From 80b0e2c0fdad108454ae87130496f595f0b81b81 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Fri, 7 May 2004 22:02:29 +0000 Subject: - Reworked the internal API - Added common functions for trimming - Debugging - Reworked the module to the new protocol --- common/stringx.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 common/stringx.c (limited to 'common/stringx.c') diff --git a/common/stringx.c b/common/stringx.c new file mode 100644 index 0000000..159a7f4 --- /dev/null +++ b/common/stringx.c @@ -0,0 +1,29 @@ + +#include +#include "stringx.h" + +const char* trim_start(const char* data) +{ + while(*data && isspace(*data)) + ++data; + return 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); +} -- cgit v1.2.3