[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] lib: move strstr()



commit 1f9d9b0b3e72d93ce8dfb33b51a8e44f77321e99
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Thu Apr 22 14:50:54 2021 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Apr 22 14:50:54 2021 +0200

    lib: move strstr()
    
    Allow the function to be individually linkable, discardable, and
    overridable.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Julien Grall <jgrall@xxxxxxxxxx>
---
 xen/common/string.c | 21 ---------------------
 xen/lib/Makefile    |  1 +
 xen/lib/strstr.c    | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 35 insertions(+), 21 deletions(-)

diff --git a/xen/common/string.c b/xen/common/string.c
index 7c4edc17e3..abb1689edd 100644
--- a/xen/common/string.c
+++ b/xen/common/string.c
@@ -131,27 +131,6 @@ char * strsep(char **s, const char *ct)
 }
 #endif
 
-#ifndef __HAVE_ARCH_STRSTR
-/**
- * strstr - Find the first substring in a %NUL terminated string
- * @s1: The string to be searched
- * @s2: The string to search for
- */
-char *(strstr)(const char *s1, const char *s2)
-{
-       size_t l1, l2 = strlen(s2);
-
-       if (!l2)
-               return (char *)s1;
-
-       for (l1 = strlen(s1); l1 >= l2; --l1, ++s1)
-               if (!memcmp(s1, s2, l2))
-                       return (char *)s1;
-
-       return NULL;
-}
-#endif
-
 /*
  * Local variables:
  * mode: C
diff --git a/xen/lib/Makefile b/xen/lib/Makefile
index e531e2dfb3..57a7095ffa 100644
--- a/xen/lib/Makefile
+++ b/xen/lib/Makefile
@@ -22,6 +22,7 @@ lib-y += strlen.o
 lib-y += strncmp.o
 lib-y += strnlen.o
 lib-y += strrchr.o
+lib-y += strstr.o
 lib-$(CONFIG_X86) += xxhash32.o
 lib-$(CONFIG_X86) += xxhash64.o
 
diff --git a/xen/lib/strstr.c b/xen/lib/strstr.c
new file mode 100644
index 0000000000..c305f5acb3
--- /dev/null
+++ b/xen/lib/strstr.c
@@ -0,0 +1,34 @@
+/*
+ *  Copyright (C) 1991, 1992  Linus Torvalds
+ */
+
+#include <xen/string.h>
+
+/**
+ * strstr - Find the first substring in a %NUL terminated string
+ * @s1: The string to be searched
+ * @s2: The string to search for
+ */
+char *(strstr)(const char *s1, const char *s2)
+{
+       size_t l1, l2 = strlen(s2);
+
+       if (!l2)
+               return (char *)s1;
+
+       for (l1 = strlen(s1); l1 >= l2; --l1, ++s1)
+               if (!memcmp(s1, s2, l2))
+                       return (char *)s1;
+
+       return NULL;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ */
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.