[PATCH] Adding wcs* and wmem* in libc/string.
Kazuhiro Fujieda
fujieda@jaist.ac.jp
Sun Sep 1 10:01:00 GMT 2002
In the last patch, I left a wrong and unnecessary type cast in
each of wcscmp and wcsncmp. I didn't understand why these type
casts are necessary in NetBSD C library and how wchar_t is
defined in newlib.
The following patch remove the type casts, then it add
definitions of WCHAR_MAX and WCHAR_MIN (C90Amend1/C99
requires these definitions in wchar.h).
-------------- next part --------------
2002-09-02 Kazuhiro Fujieda <fujieda@jaist.ac.jp>
* libc/string/wcscmp.c: Delete wrong and unnecessary type cast.
* libc/string/wcsncmp.c: Ditto.
* libc/include/wchar.h: Add WCHAR_MAX and WCHAR_MIN definitions.
-------------- next part --------------
diff -u cygwin-i18n/newlib/libc/include/wchar.h:1.1.1.2 cygwin-i18n/newlib/libc/include/wchar.h:1.1.2.5
--- cygwin-i18n/newlib/libc/include/wchar.h:1.1.1.2 Fri Aug 30 05:58:11 2002
+++ cygwin-i18n/newlib/libc/include/wchar.h Mon Sep 2 00:49:28 2002
@@ -19,6 +19,20 @@
# define WEOF ((wint_t)-1)
#endif
+#ifndef WCHAR_MIN
+#define WCHAR_MIN 0
+#endif
+
+#ifndef WCHAR_MAX
+#ifdef CYGWIN
+/* assume wchar_t = ushort and the max is the last char in UCS-2. */
+#define WCHAR_MAX USHRT_MAX
+#else
+/* assume wchar_t = int and the max is the last char in UCS-4. */
+#define WCHAR_MAX INT_MAX
+#endif
+#endif
+
#ifndef MBSTATE_T
#define MBSTATE_T
typedef _mbstate_t mbstate_t;
Index: cygwin-i18n/newlib/libc/string/wcscmp.c
diff -u cygwin-i18n/newlib/libc/string/wcscmp.c:1.1.1.1 cygwin-i18n/newlib/libc/string/wcscmp.c:1.1.2.6
--- cygwin-i18n/newlib/libc/string/wcscmp.c:1.1.1.1 Fri Aug 30 05:58:17 2002
+++ cygwin-i18n/newlib/libc/string/wcscmp.c Mon Sep 2 01:29:57 2002
@@ -78,6 +78,5 @@
while (*s1 == *s2++)
if (*s1++ == 0)
return (0);
- /* XXX assumes wchar_t = short */
- return (*(_CONST unsigned short *) s1 - *(_CONST unsigned short *) --s2);
+ return (*s1 - *--s2);
}
Index: cygwin-i18n/newlib/libc/string/wcsncmp.c
diff -u cygwin-i18n/newlib/libc/string/wcsncmp.c:1.1.1.1 cygwin-i18n/newlib/libc/string/wcsncmp.c:1.1.2.5
--- cygwin-i18n/newlib/libc/string/wcsncmp.c:1.1.1.1 Fri Aug 30 05:58:17 2002
+++ cygwin-i18n/newlib/libc/string/wcsncmp.c Mon Sep 2 01:29:57 2002
@@ -80,9 +80,7 @@
{
if (*s1 != *s2++)
{
- /* XXX assumes wchar_t = short */
- return (*(_CONST unsigned short *) s1 -
- *(_CONST unsigned short *) --s2);
+ return (*s1 - *--s2);
}
if (*s1++ == 0)
break;
-------------- next part --------------
____
| AIST Kazuhiro Fujieda <fujieda@jaist.ac.jp>
| HOKURIKU Center for Information Science
o_/ 1990 Japan Advanced Institute of Science and Technology
More information about the Newlib
mailing list