aboutsummaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/utils.c b/utils.c
index 53bc3fc..c2473d2 100644
--- a/utils.c
+++ b/utils.c
@@ -75,6 +75,20 @@ int matchchar(const char **str, char c)
}
/*
+ * Check if a string is found and if so, move past it.
+ */
+int matchstr(const char **str, const char *target)
+{
+ const char *next = after_spaces(*str);
+ if (strncmp(next, target, strlen(target)) == 0) {
+ *str = &next[strlen(target)];
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+/*
* Process a string escape sequence for a character and return the
* character that was escaped.
* Set *end = the first character past the end of the escape sequence.