Module Name: src
Committed By: riastradh
Date: Sun Dec 19 10:48:01 UTC 2021
Modified Files:
src/sys/external/bsd/drm2/include/linux: string.h
Log Message:
match_string
To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/external/bsd/drm2/include/linux/string.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/external/bsd/drm2/include/linux/string.h
diff -u src/sys/external/bsd/drm2/include/linux/string.h:1.8 src/sys/external/bsd/drm2/include/linux/string.h:1.9
--- src/sys/external/bsd/drm2/include/linux/string.h:1.8 Sun Dec 19 09:51:20 2021
+++ src/sys/external/bsd/drm2/include/linux/string.h Sun Dec 19 10:48:00 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: string.h,v 1.8 2021/12/19 09:51:20 riastradh Exp $ */
+/* $NetBSD: string.h,v 1.9 2021/12/19 10:48:00 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -133,4 +133,20 @@ memset_p(void **p, void *v, size_t n)
#define str_has_prefix(str, prefix) strncmp(str, prefix, strlen(prefix))
+static inline int
+match_string(const char *const *haystack, size_t n, const char *needle)
+{
+ int i;
+
+ for (i = 0; i < n; i++) {
+ if (haystack[i] == NULL)
+ break;
+ if (strcmp(haystack[i], needle) == 0)
+ return i;
+ if (i == INT_MAX)
+ break;
+ }
+ return -EINVAL;
+}
+
#endif /* _LINUX_STRING_H_ */