From a07da1989d7ec515d4bb08051ea6940960577446 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 30 Dec 2020 15:30:19 -0800 Subject: Simplified syntax for replacement: just =>, no need for {} --- utils.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'utils.c') diff --git a/utils.c b/utils.c index 53bc3fc..c2473d2 100644 --- a/utils.c +++ b/utils.c @@ -74,6 +74,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. -- cgit v1.2.3