Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: result of warnings from Cygwin



I wasn't going to post this, but it occurs to me people may have
comments about better ways to do some of these to avoid warnings.
One of them is actually a bug---it's wrong to test a wchar_t (rather
than a wint_t) against WEOF even if it happens to work on some systems.

zsh now compiles by default with MULTIBYTE_SUPPORT on Cygwin, but
I haven't the first clue how to get a command line window with a
sensible character set (i.e. UTF-8).

Index: Src/parse.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/parse.c,v
retrieving revision 1.58
diff -u -r1.58 parse.c
--- Src/parse.c	11 Jul 2006 15:36:37 -0000	1.58
+++ Src/parse.c	4 Aug 2006 13:13:04 -0000
@@ -2966,17 +2966,23 @@
     return 0;
 }
 
+/**/
 #if defined(HAVE_SYS_MMAN_H) && defined(HAVE_MMAP) && defined(HAVE_MUNMAP)
 
 #include <sys/mman.h>
 
+/**/
 #if defined(MAP_SHARED) && defined(PROT_READ)
 
+/**/
 #define USE_MMAP 1
 
+/**/
 #endif
+/**/
 #endif
 
+/**/
 #ifdef USE_MMAP
 
 /* List of dump files mapped. */
@@ -3060,6 +3066,7 @@
 
 #define zwcstat(f, b) (!!stat(f, b))
 
+/**/
 #endif
 
 /* Try to load a function from one of the possible wordcode files for it.
Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.132
diff -u -r1.132 utils.c
--- Src/utils.c	4 Aug 2006 11:42:20 -0000	1.132
+++ Src/utils.c	4 Aug 2006 13:13:05 -0000
@@ -79,10 +79,15 @@
 	    if (!mblen)
 		break;
 	    /* No good unless all characters are convertible */
-	    if (*wcptr == WEOF)
+	    if (wci == WEOF)
 		return;
 	    *wcptr++ = (wchar_t)wci;
 #ifdef DEBUG
+	    /*
+	     * This generates a warning from the compiler (and is
+	     * indeed useless) if chars are unsigned.  It's
+	     * extreme paranoia anyway.
+	     */
 	    if (wcptr[-1] < 0)
 		fprintf(stderr, "BUG: Bad cast to wchar_t\n");
 #endif
@@ -501,6 +506,9 @@
 	/*
 	 * Can't or don't want to convert character: use UCS-2 or
 	 * UCS-4 code in print escape format.
+	 *
+	 * This comparison fails and generates a compiler warning
+	 * if wchar_t is 16 bits, but the code is still correct.
 	 */
 	if (c >=  0x10000) {
 	    sprintf(buf, "\\U%.8x", (unsigned int)c);

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php



Messages sorted by: Reverse Date, Date, Thread, Author