likely.h
prisize_t.h
stack.h
+ startswith.h
strcasecmp.h
strview.h
tokenize.h
pkginclude_HEADERS = cgraph.h
noinst_HEADERS = agxbuf.h alloc.h bitarray.h cghdr.h exit.h itos.h likely.h \
- prisize_t.h stack.h strcasecmp.h strview.h tokenize.h unreachable.h unused.h
+ prisize_t.h stack.h startswith.h strcasecmp.h strview.h tokenize.h \
+ unreachable.h unused.h
noinst_LTLIBRARIES = libcgraph_C.la
lib_LTLIBRARIES = libcgraph.la
pkgconfig_DATA = libcgraph.pc
<ClInclude Include="likely.h" />
<ClInclude Include="prisize_t.h" />
<ClInclude Include="stack.h" />
+ <ClInclude Include="startswith.h" />
<ClInclude Include="strcasecmp.h" />
<ClInclude Include="strview.h" />
<ClInclude Include="tokenize.h" />
<ClInclude Include="stack.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="startswith.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
<ClInclude Include="strcasecmp.h">
<Filter>Header Files</Filter>
</ClInclude>
--- /dev/null
+#pragma once
+
+#include <assert.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <string.h>
+
+/// does the string \p s begin with the string \p prefix?
+static inline bool startswith(const char *s, const char *prefix) {
+ assert(s != NULL);
+ assert(prefix != NULL);
+
+ return strncmp(s, prefix, strlen(prefix)) == 0;
+}