lib: move strcasecmp()
authorJan Beulich <jbeulich@suse.com>
Thu, 22 Apr 2021 12:51:08 +0000 (14:51 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 22 Apr 2021 12:51:08 +0000 (14:51 +0200)
Allow the function to be individually linkable, discardable, and
overridable.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Julien Grall <jgrall@amazon.com>
xen/common/string.c
xen/lib/Makefile
xen/lib/strcasecmp.c [new file with mode: 0644]

index abb1689edd9fe32e88fd34a79e3721345353a6fe..2b81daef89ef47eca481c1d1588653d23224495e 100644 (file)
@@ -41,21 +41,6 @@ int strnicmp(const char *s1, const char *s2, size_t len)
 }
 #endif
 
-#ifndef __HAVE_ARCH_STRCASECMP
-int (strcasecmp)(const char *s1, const char *s2)
-{
-    int c1, c2;
-
-    do
-    {
-        c1 = tolower(*s1++);
-        c2 = tolower(*s2++);
-    } while ( c1 == c2 && c1 != 0 );
-
-    return c1 - c2;
-}
-#endif
-
 #ifndef __HAVE_ARCH_STRSPN
 /**
  * strspn - Calculate the length of the initial substring of @s which only
index 57a7095ffac51637c0346d4acd210126e1bb7121..6264b3aae3e07413c4519f5ca17b260cf49cb002 100644 (file)
@@ -14,6 +14,7 @@ lib-y += muldiv64.o
 lib-y += parse-size.o
 lib-y += rbtree.o
 lib-y += sort.o
+lib-y += strcasecmp.o
 lib-y += strchr.o
 lib-y += strcmp.o
 lib-y += strlcat.o
diff --git a/xen/lib/strcasecmp.c b/xen/lib/strcasecmp.c
new file mode 100644 (file)
index 0000000..c2a4113
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ *  Copyright (C) 1991, 1992  Linus Torvalds
+ */
+
+#include <xen/string.h>
+#include <xen/ctype.h>
+
+int (strcasecmp)(const char *s1, const char *s2)
+{
+    int c1, c2;
+
+    do
+    {
+        c1 = tolower(*s1++);
+        c2 = tolower(*s2++);
+    } while ( c1 == c2 && c1 != 0 );
+
+    return c1 - c2;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ */