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

Re: PATCH: Errors compiling on HP-UX with HP's compiler



On Mon, 20 Dec 2010 06:00:37 +0000
Paul Ackersviller <pda@xxxxxxxxxxxxxxxx> wrote:
> I must be using gcc more often than not to have just run across this.
> HP's compiler, I think rightly, refuses to do arithmetic on these two
> void pointers.  Does gcc treat them as char * for that purpose?
> The casts can obviously be done without.

Thanks, we should really have been picked that up by now...

Some older systems used char * in read() and write(), and in fact
there's a definition in prototypes.h that's somewhat out of date to cope
with that.  I wouldn't be at all surprised if it didn't compile on any
such system any more, but it might as well be left open.  Given that
write_loop() and read_loop() now always take char *, and a char * will
be converted to a void * without any problem, I think I'll remove the
outdated type definitions and do without the casts...

Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.116
diff -p -u -r1.116 init.c
--- Src/init.c	15 Jul 2010 18:44:13 -0000	1.116
+++ Src/init.c	20 Dec 2010 10:02:04 -0000
@@ -1380,7 +1380,7 @@ VA_DCL
 	pptbuf = unmetafy(promptexpand(lp ? *lp : NULL, 0, NULL, NULL,
 				       NULL),
 			  &pptlen);
-	write_loop(2, (WRITE_ARG_2_T)pptbuf, pptlen);
+	write_loop(2, pptbuf, pptlen);
 	free(pptbuf);
 
 	ret = shingetline();
Index: Src/input.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/input.c,v
retrieving revision 1.20
diff -p -u -r1.20 input.c
--- Src/input.c	25 Mar 2010 14:03:51 -0000	1.20
+++ Src/input.c	20 Dec 2010 10:02:04 -0000
@@ -260,7 +260,7 @@ inputline(void)
 	    int pptlen;
 	    pptbuf = unmetafy(promptexpand(ingetcpmptl ? *ingetcpmptl : NULL,
 					   0, NULL, NULL, NULL), &pptlen);
-	    write_loop(2, (WRITE_ARG_2_T)pptbuf, pptlen);
+	    write_loop(2, pptbuf, pptlen);
 	    free(pptbuf);
 	}
 	ingetcline = shingetline();
Index: Src/prototypes.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/prototypes.h,v
retrieving revision 1.4
diff -p -u -r1.4 prototypes.h
--- Src/prototypes.h	13 Apr 2001 16:29:28 -0000	1.4
+++ Src/prototypes.h	20 Dec 2010 10:02:04 -0000
@@ -44,13 +44,6 @@ extern int tputs _((char *cp, int affcnt
 
 /* MISSING PROTOTYPES FOR VARIOUS OPERATING SYSTEMS */
 
-/* HP/UX 9 c89 */
-#if defined(__hpux) && defined(_XPG3) && !defined(_POSIX1_1988)
-# define WRITE_ARG_2_T void *
-#else
-# define WRITE_ARG_2_T char *
-#endif
-
 #if defined(__hpux) && defined(_HPUX_SOURCE) && !defined(_XPG4_EXTENDED)
 # define SELECT_ARG_2_T int *
 #else
Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.251
diff -p -u -r1.251 utils.c
--- Src/utils.c	6 Dec 2010 19:34:33 -0000	1.251
+++ Src/utils.c	20 Dec 2010 10:02:04 -0000
@@ -2272,7 +2272,7 @@ checkrmall(char *s)
 
 /**/
 mod_export ssize_t
-read_loop(int fd, void *buf, size_t len)
+read_loop(int fd, char *buf, size_t len)
 {
     ssize_t got = len;
 
@@ -2298,7 +2298,7 @@ read_loop(int fd, void *buf, size_t len)
 
 /**/
 mod_export ssize_t
-write_loop(int fd, const void *buf, size_t len)
+write_loop(int fd, const char *buf, size_t len)
 {
     ssize_t wrote = len;
 
Index: Src/Zle/zle_main.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v
retrieving revision 1.126
diff -p -u -r1.126 zle_main.c
--- Src/Zle/zle_main.c	20 Sep 2010 09:27:46 -0000	1.126
+++ Src/Zle/zle_main.c	20 Dec 2010 10:02:04 -0000
@@ -1132,7 +1132,7 @@ zleread(char **lp, char **rp, int flags,
 	pptbuf = unmetafy(promptexpand(lp ? *lp : NULL, 0, NULL, NULL,
 				       &pmpt_attr),
 			  &pptlen);
-	write_loop(2, (WRITE_ARG_2_T)pptbuf, pptlen);
+	write_loop(2, pptbuf, pptlen);
 	free(pptbuf);
 	return shingetline();
     }

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


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom



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