[PATCH] 2nd try: WCHAR_{MAX,INT} and correct error in wcscmp and wcsncmp.

Kazuhiro Fujieda fujieda@jaist.ac.jp
Wed Sep 4 06:17:00 GMT 2002


I made another patch imitating how FILENAME_MAX is defined in stdio.h.
____
  | AIST      Kazuhiro Fujieda <fujieda@jaist.ac.jp>
  | HOKURIKU  Center for Information Science
o_/ 1990      Japan Advanced Institute of Science and Technology
-------------- next part --------------
2002-09-04  Kazuhiro Fujieda  <fujieda@jaist.ac.jp>
	* libc/include/sys/config.h: Define accordingly __WCHAR_MAX__.
	* libc/include/wchar.h: Define WCHAR_MIN as 0 and WCHAR_MAX as
	__WCHAR_MAX__ or 0x7fffffffu.
	* libc/string/wcscmp.c: Delete wrong and unnecessary type cast.
	* libc/string/wcsncmp.c: Ditto.
-------------- next part --------------
Index: cygwin-i18n/newlib/libc/include/wchar.h
diff -u cygwin-i18n/newlib/libc/include/wchar.h:1.1.1.2 cygwin-i18n/newlib/libc/include/wchar.h:1.1.2.8
--- 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	Wed Sep  4 21:44:54 2002
@@ -19,6 +19,16 @@
 # define WEOF ((wint_t)-1)
 #endif
 
+#ifndef WCHAR_MIN
+#define WCHAR_MIN 0
+#endif
+
+#ifndef WCHAR_MAX
+#define WCHAR_MAX __WCHAR_MAX__
+#else
+#define WCHAR_MAX 0x7fffffffu
+#endif
+
 #ifndef MBSTATE_T
 #define MBSTATE_T
 typedef _mbstate_t mbstate_t;
Index: cygwin-i18n/newlib/libc/include/sys/config.h
diff -u cygwin-i18n/newlib/libc/include/sys/config.h:1.1.1.5 cygwin-i18n/newlib/libc/include/sys/config.h:1.1.1.1.2.6
--- cygwin-i18n/newlib/libc/include/sys/config.h:1.1.1.5	Thu Aug 29 18:06:45 2002
+++ cygwin-i18n/newlib/libc/include/sys/config.h	Wed Sep  4 21:44:55 2002
@@ -170,4 +170,11 @@
 #define _READ_WRITE_RETURN_TYPE int
 #endif
 
+#ifndef __WCHAR_MAX__ 
+#if __INT_MAX__ == 32767 || defined(__CYGWIN__) || \
+    defined (_WIN32) || defined(GO32)
+#define __WCHAR_MAX__ 0xffffu
+#endif
+#endif
+
 #endif /* __SYS_CONFIG_H__ */
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;


More information about the Newlib mailing list