From 50ee4fb90a525c9b543cabe78a3df6d8588bba30 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Thu, 22 Apr 2021 14:51:08 +0200 Subject: [PATCH] lib: move strcasecmp() Allow the function to be individually linkable, discardable, and overridable. Signed-off-by: Jan Beulich Acked-by: Julien Grall --- xen/common/string.c | 15 --------------- xen/lib/Makefile | 1 + xen/lib/strcasecmp.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 15 deletions(-) create mode 100644 xen/lib/strcasecmp.c diff --git a/xen/common/string.c b/xen/common/string.c index abb1689edd..2b81daef89 100644 --- a/xen/common/string.c +++ b/xen/common/string.c @@ -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 diff --git a/xen/lib/Makefile b/xen/lib/Makefile index 57a7095ffa..6264b3aae3 100644 --- a/xen/lib/Makefile +++ b/xen/lib/Makefile @@ -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 index 0000000000..c2a411310e --- /dev/null +++ b/xen/lib/strcasecmp.c @@ -0,0 +1,29 @@ +/* + * Copyright (C) 1991, 1992 Linus Torvalds + */ + +#include +#include + +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: + */ -- 2.30.2