summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorsabetts <sabetts>2006-09-27 01:00:45 +0000
committersabetts <sabetts>2006-09-27 01:00:45 +0000
commitb80a2d14bf72a4758eca46156a7c3ad606473bb7 (patch)
tree7a86b490490b7c947d331c02e618c07d5239db18 /src/main.c
parentad859c2d9b0f19ff55ea016d23a97853ef99b89e (diff)
downloadratpoison-b80a2d14bf72a4758eca46156a7c3ad606473bb7.zip
*** empty log message ***
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index 05e09f6..c8582f0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -151,6 +151,37 @@ xsprintf (char *fmt, ...)
return buffer;
}
+/* strtok but do it for whitespace and be locale compliant. */
+char *
+strtok_ws (char *s)
+{
+ char *nonws;
+ static char *pointer = NULL;
+
+ printf ("pointer: %p\n", pointer);
+
+ if (s)
+ pointer = s;
+
+ /* skip to first non-whitespace char. */
+ while (*pointer && isspace (*pointer)) pointer++;
+
+ /* If we reached the end of the string here then there is no more
+ data. */
+ if (*pointer == 0)
+ return NULL;
+
+ /* Now skip to the end of the data. */
+ nonws = pointer;
+ while (*pointer && !isspace (*pointer)) pointer++;
+ if (*pointer)
+ {
+ *pointer = 0;
+ pointer++;
+ }
+ return nonws;
+}
+
/* A case insensitive strncmp. */
int
str_comp (char *s1, char *s2, int len)