summaryrefslogtreecommitdiff
path: root/libc/string/strrchr.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/string/strrchr.c')
-rw-r--r--libc/string/strrchr.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/libc/string/strrchr.c b/libc/string/strrchr.c
index 374abb694..cb30afea7 100644
--- a/libc/string/strrchr.c
+++ b/libc/string/strrchr.c
@@ -1,16 +1,35 @@
/*
+ * Copyright (C) 2002 Manuel Novoa III
* Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define L_strrchr
-#define Wstrrchr __strrchr
+#include "_string.h"
-#include "wstring.c"
+#ifdef WANT_WIDE
+# define __Wstrrchr __wcsrchr
+# define Wstrrchr wcsrchr
+#else
+# define __Wstrrchr __strrchr
+# define Wstrrchr strrchr
+#endif
-strong_alias(__strrchr, strrchr)
+Wchar attribute_hidden *__Wstrrchr(register const Wchar *s, Wint c)
+{
+ register const Wchar *p;
-weak_alias(strrchr, rindex)
+ p = NULL;
+ do {
+ if (*s == (Wchar) c) {
+ p = s;
+ }
+ } while (*s++);
-#undef L_strrchr
+ return (Wchar *) p; /* silence the warning */
+}
+
+strong_alias(__Wstrrchr,Wstrrchr)
+#ifndef WANT_WIDE
+strong_alias(__strrchr,rindex)
+#endif