[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] lib: move strrchr()
commit a50eb38545319dd52ba891dc47a8d0b478823d90 Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Thu Apr 22 14:50:44 2021 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Thu Apr 22 14:50:44 2021 +0200 lib: move strrchr() 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 | 18 ------------------ xen/lib/Makefile | 1 + xen/lib/strrchr.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/xen/common/string.c b/xen/common/string.c index f433b15afd..7c4edc17e3 100644 --- a/xen/common/string.c +++ b/xen/common/string.c @@ -56,24 +56,6 @@ int (strcasecmp)(const char *s1, const char *s2) } #endif -#ifndef __HAVE_ARCH_STRRCHR -/** - * strrchr - Find the last occurrence of a character in a string - * @s: The string to be searched - * @c: The character to search for - */ -char *(strrchr)(const char *s, int c) -{ - const char *p = s + strlen(s); - - for (; *p != (char)c; --p) - if (p == s) - return NULL; - - return (char *)p; -} -#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 b69b516369..e531e2dfb3 100644 --- a/xen/lib/Makefile +++ b/xen/lib/Makefile @@ -21,6 +21,7 @@ lib-y += strlcpy.o lib-y += strlen.o lib-y += strncmp.o lib-y += strnlen.o +lib-y += strrchr.o lib-$(CONFIG_X86) += xxhash32.o lib-$(CONFIG_X86) += xxhash64.o diff --git a/xen/lib/strrchr.c b/xen/lib/strrchr.c new file mode 100644 index 0000000000..0d53dd9518 --- /dev/null +++ b/xen/lib/strrchr.c @@ -0,0 +1,31 @@ +/* + * Copyright (C) 1991, 1992 Linus Torvalds + */ + +#include <xen/string.h> + +/** + * strrchr - Find the last occurrence of a character in a string + * @s: The string to be searched + * @c: The character to search for + */ +char *(strrchr)(const char *s, int c) +{ + const char *p = s + strlen(s); + + for (; *p != (char)c; --p) + if (p == s) + return NULL; + + return (char *)p; +} + +/* + * 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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |