summaryrefslogtreecommitdiffstats
path: root/private/crt32/string/wcsrev.c
diff options
context:
space:
mode:
authorAdam <you@example.com>2020-05-17 05:51:50 +0200
committerAdam <you@example.com>2020-05-17 05:51:50 +0200
commite611b132f9b8abe35b362e5870b74bce94a1e58e (patch)
treea5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/crt32/string/wcsrev.c
downloadNT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip
Diffstat (limited to 'private/crt32/string/wcsrev.c')
-rw-r--r--private/crt32/string/wcsrev.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/private/crt32/string/wcsrev.c b/private/crt32/string/wcsrev.c
new file mode 100644
index 000000000..0ea09b944
--- /dev/null
+++ b/private/crt32/string/wcsrev.c
@@ -0,0 +1,56 @@
+/***
+*wcsrev.c - reverse a wide-character string in place
+*
+* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* defines _wcsrev() - reverse a wchar_t string in place (not including
+* L'\0' character)
+*
+*Revision History:
+* 09-09-91 ETC Created from strrev.c.
+* 04-07-92 KRS Updated and ripped out _INTL switches.
+*
+*******************************************************************************/
+
+#include <cruntime.h>
+#include <string.h>
+
+/***
+*wchar_t *_wcsrev(string) - reverse a wide-character string in place
+*
+*Purpose:
+* Reverses the order of characters in the string. The terminating
+* null character remains in place (wide-characters).
+*
+*Entry:
+* wchar_t *string - string to reverse
+*
+*Exit:
+* returns string - now with reversed characters
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+wchar_t * _CALLTYPE1 _wcsrev (
+ wchar_t * string
+ )
+{
+ wchar_t *start = string;
+ wchar_t *left = string;
+ wchar_t ch;
+
+ while (*string++) /* find end of string */
+ ;
+ string -= 2;
+
+ while (left < string)
+ {
+ ch = *left;
+ *left++ = *string;
+ *string-- = ch;
+ }
+
+ return(start);
+}