aboutsummaryrefslogtreecommitdiffstats
path: root/strutil.c
diff options
context:
space:
mode:
Diffstat (limited to 'strutil.c')
-rw-r--r--strutil.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/strutil.c b/strutil.c
new file mode 100644
index 0000000..cc7a1e2
--- /dev/null
+++ b/strutil.c
@@ -0,0 +1,41 @@
+#include "config.h"
+#include "strutil.h"
+
+#include <ctype.h>
+#include <string.h>
+
+RCSID("$Id: strutil.c,v 1.1.1.1 1999/02/02 23:29:39 shmit Exp $");
+
+char *
+getword(const char *src, char *dst)
+{
+ int inquote = 0;
+
+ while (isspace(*src))
+ src++;
+
+ while (*src) {
+ if (*src == '\\' && *++src)
+ *dst++ = *src++;
+ else if (*src == '"') {
+ if (inquote)
+ inquote = 0;
+ else
+ inquote = 1;
+ src++;
+ } else if (*src == '#') {
+ if (!inquote)
+ break;
+ *dst++ = *src++;
+ } else if (!inquote && isspace(*src))
+ break;
+ else
+ *dst++ = *src++;
+ }
+ *dst = '\0';
+
+ if (!*src || *src == '#')
+ return NULL;
+
+ return (char *)src;
+}