zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: Minor problem with wchar/iconv headers
@ 2003-03-24 12:17 Peter Stephenson
  0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2003-03-24 12:17 UTC (permalink / raw)
  To: Zsh hackers list

The new code to include wchar.h in utils.c comes after the normal zsh
headers.  This means that zsh's own system.h has already executed the
test `#ifdef offsetof' and if it hasn't found it provided its own
definitions.  It turns out on Solaris 2.8 with gcc 2.95.2 (and therefore
probably elsewhere) that wchar.h hooks in stddef.h, which tries to
define offsetof itself, provoking a warning with the current layout of
include files.

Since it depends on config.h, this needs to be buried somewhere in
system.h.  It seems unlikely including something called `stddef.h' will
cause grief, but you never know...

I've also suppressed a couple of other warnings gcc was coming up with.
I would have to read the C standard in detail to know why the `(const
char **)' cast is necessary to suppress a warning.

Index: zshconfig.ac
===================================================================
RCS file: /cvsroot/zsh/zsh/zshconfig.ac,v
retrieving revision 1.34
diff -u -r1.34 zshconfig.ac
--- zshconfig.ac	15 Mar 2003 17:36:17 -0000	1.34
+++ zshconfig.ac	24 Mar 2003 12:13:38 -0000
@@ -494,7 +494,7 @@
 		 limits.h fcntl.h libc.h sys/utsname.h sys/resource.h \
 		 locale.h errno.h stdio.h stdlib.h unistd.h sys/capability.h \
 		 utmp.h utmpx.h sys/types.h pwd.h grp.h poll.h sys/mman.h \
-		 netinet/in_systm.h pcre.h langinfo.h wchar.h)
+		 netinet/in_systm.h pcre.h langinfo.h wchar.h stddef.h)
 if test $dynamic = yes; then
   AC_CHECK_HEADERS(dlfcn.h)
   AC_CHECK_HEADERS(dl.h)
Index: Src/system.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/system.h,v
retrieving revision 1.15
diff -u -r1.15 system.h
--- Src/system.h	28 Apr 2001 17:38:01 -0000	1.15
+++ Src/system.h	24 Mar 2003 12:13:38 -0000
@@ -89,6 +89,16 @@
 # include <unistd.h>
 #endif
 
+#ifdef HAVE_STDDEF_H
+/*
+ * Seen on Solaris 8 with gcc: stddef defines offsetof, which clashes
+ * with system.h's definition of the symbol unless we include this
+ * first.  Otherwise, this will be hooked in by wchar.h, too late
+ * for comfort.
+ */
+#include <stddef.h>
+#endif
+
 #include <stdio.h>
 #include <ctype.h>
 #include <sys/stat.h>
Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.46
diff -u -r1.46 utils.c
--- Src/utils.c	18 Mar 2003 14:39:49 -0000	1.46
+++ Src/utils.c	24 Mar 2003 12:13:38 -0000
@@ -3395,8 +3395,8 @@
 		for (i=(*s == 'u' ? 4 : 8); i>0; i--) {
 		    if (*++s && idigit(*s))
 		        wval = wval * 16 + (*s - '0');
-		    else if (*s && (*s >= 'a' && *s <= 'f') ||
-		            (*s >= 'A' && *s <= 'F'))
+		    else if (*s && ((*s >= 'a' && *s <= 'f') ||
+				    (*s >= 'A' && *s <= 'F')))
 		        wval = wval * 16 + (*s & 0x1f) + 9;
 		    else {
 		    	s--;
@@ -3430,7 +3430,7 @@
 		    *len = t - buf;
 		    return buf;
 		}
-                iconv(cd, &inptr, &inbytes, &outptr, &outbytes);
+                iconv(cd, (const char **)&inptr, &inbytes, &outptr, &outbytes);
 		iconv_close(cd);
 		count = wctomb(t, *outbuf);
 #endif

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-03-24 12:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-24 12:17 PATCH: Minor problem with wchar/iconv headers Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).