summaryrefslogtreecommitdiffstats
path: root/private/crt32/string/wcsrchr.c
diff options
context:
space:
mode:
Diffstat (limited to 'private/crt32/string/wcsrchr.c')
-rw-r--r--private/crt32/string/wcsrchr.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/private/crt32/string/wcsrchr.c b/private/crt32/string/wcsrchr.c
new file mode 100644
index 000000000..9dc3b004a
--- /dev/null
+++ b/private/crt32/string/wcsrchr.c
@@ -0,0 +1,56 @@
+/***
+*wcsrchr.c - find last occurrence of wchar_t character in wide string
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* defines wcsrchr() - find the last occurrence of a given character
+* in a string (wide-characters).
+*
+*Revision History:
+* 09-09-91 ETC Created from strrchr.c.
+* 04-07-92 KRS Updated and ripped out _INTL switches.
+*
+*******************************************************************************/
+
+#include <cruntime.h>
+#include <string.h>
+
+/***
+*wchar_t *wcsrchr(string, ch) - find last occurrence of ch in wide string
+*
+*Purpose:
+* Finds the last occurrence of ch in string. The terminating
+* null character is used as part of the search (wide-characters).
+*
+*Entry:
+* wchar_t *string - string to search in
+* wchar_t ch - character to search for
+*
+*Exit:
+* returns a pointer to the last occurrence of ch in the given
+* string
+* returns NULL if ch does not occurr in the string
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+wchar_t * _CALLTYPE1 wcsrchr (
+ const wchar_t * string,
+ wchar_t ch
+ )
+{
+ wchar_t *start = (wchar_t *)string;
+
+ while (*string++) /* find end of string */
+ ;
+ /* search towards front */
+ while (--string != start && *string != (wchar_t)ch)
+ ;
+
+ if (*string == (wchar_t)ch) /* wchar_t found ? */
+ return( (wchar_t *)string );
+
+ return(NULL);
+}