zsh-workers
 help / color / mirror / code / Atom feed
* 3.1.0-test3: gcc -ansi -pedantic
@ 1996-11-19 20:45 Thorsten Meinecke
  1996-11-20  6:06 ` Andrej Borsenkow
  1996-11-20  8:57 ` Peter Stephenson
  0 siblings, 2 replies; 4+ messages in thread
From: Thorsten Meinecke @ 1996-11-19 20:45 UTC (permalink / raw)
  To: zsh-workers

Hello, did anyone bother before to build zsh with gcc -ansi -pedantic?

It looks like some of the module-related changes aren't ANSI/ISO C,
and from some of the older stuff it elicits warnings about variable
sized arrays and conversions w/o cast as well.  Furthermore, there's
trouble in module.c, because gcc says ANSI forbids assignment between
function pointer and `void *'.  Most serious:

  ../Src> gcc -c -I.. -I. -I. -DHAVE_CONFIG_H -Wall -Wno-implicit \
  -Wmissing-prototypes -g -ansi -pedantic  zle_main.c
  zle_main.c: In function `zleread':
  zle_main.c:439: warning: ANSI C forbids use of conditional expressions as lvalues
  zle_main.c: In function `unbindzlefunc':
  zle_main.c:1257: initializer element for `keybindlist[0]' is not computable at load time
  zle_main.c:1257: initializer element for `keybindlist[1]' is not computable at load time
  make: *** [zle_main.o] Error 1

I can offer fixes for the error (and the warnings) in the zle_*
module-related code, by introducing yet another level of indirection
to both underlying problems.


*** Src/zle.h	1996/11/19 06:16:34	2.11
--- Src/zle.h	1996/11/19 19:57:02
***************
*** 455,462 ****
   * Commands up to, but not including, ZLECMDCOUNT are in the compiled array *
   * zlecmds.  Anything higher is in the malloc'd array zlecmdadd, so we need *
!  * to subtract ZLECMDCOUNT to get the offset.                               */
  
! #define ZLEGETCMD(X)  ((X) >= ZLECMDCOUNT ? zlecmdadd[(X)-ZLECMDCOUNT] \
! 		       : zlecmds[X])
  
  /* How many new commands to reserve space for at a time */
--- 455,463 ----
   * Commands up to, but not including, ZLECMDCOUNT are in the compiled array *
   * zlecmds.  Anything higher is in the malloc'd array zlecmdadd, so we need *
!  * to subtract ZLECMDCOUNT to get the offset.                               *
!  * ZLEGETCMD expands into an expression of the type (struct zlecmd *).      */ 
  
! #define ZLEGETCMD(X)  ((X) >= ZLECMDCOUNT ? &zlecmdadd[(X)-ZLECMDCOUNT] \
! 		       : &zlecmds[X])
  
  /* How many new commands to reserve space for at a time */
*** Src/zle_main.c	1996/11/19 06:16:35	2.30
--- Src/zle_main.c	1996/11/19 19:36:20
***************
*** 437,441 ****
  		int ce = complexpect;
  
! 		zc = &ZLEGETCMD(bindk);
  		if (!(lastcmd & ZLE_ARG)) {
  		    zmult = 1;
--- 437,441 ----
  		int ce = complexpect;
  
! 		zc = ZLEGETCMD(bindk);
  		if (!(lastcmd & ZLE_ARG)) {
  		    zmult = 1;
***************
*** 881,885 ****
  	putc('\n', bindout);
      } else
! 	fprintf(bindout, "%s\n", ZLEGETCMD(k->func).name);
  }
  
--- 881,885 ----
  	putc('\n', bindout);
      } else
! 	fprintf(bindout, "%s\n", ZLEGETCMD(k->func)->name);
  }
  
***************
*** 954,958 ****
  		printbind(buf, 1, 1);
  	    }
! 	    printf("\t%s\n", ZLEGETCMD(tab[i]).name);
  	}
  	scanhashtable(keybindtab, 1, 0, 0, printbinding, 0);
--- 954,958 ----
  		printbind(buf, 1, 1);
  	    }
! 	    printf("\t%s\n", ZLEGETCMD(tab[i])->name);
  	}
  	scanhashtable(keybindtab, 1, 0, 0, printbinding, 0);
***************
*** 1013,1017 ****
  		putchar('\n');
  	    } else
! 		printf("%s\n", ZLEGETCMD(func).name);
  	    zfree(s, len);
  	    return 0;
--- 1013,1017 ----
  		putchar('\n');
  	    } else
! 		printf("%s\n", ZLEGETCMD(func)->name);
  	    zfree(s, len);
  	    return 0;
***************
*** 1165,1169 ****
      }
      else
! 	fprintf(shout, "%s", ZLEGETCMD(cmd).name);
      if (clearflag)
  	putc('\r', shout), tcmultout(TCUP, TCMULTUP, nlnct);
--- 1165,1169 ----
      }
      else
! 	fprintf(shout, "%s", ZLEGETCMD(cmd)->name);
      if (clearflag)
  	putc('\r', shout), tcmultout(TCUP, TCMULTUP, nlnct);
***************
*** 1205,1211 ****
  	(unset(ALWAYSLASTPROMPT) && zmult != 1);
      if (func == z_selfinsert || func == z_undefinedkey)
! 	fprintf(shout, "%s is on many keys", ZLEGETCMD(func).name);
      else {
! 	fprintf(shout, "%s is", ZLEGETCMD(func).name);
  	for (i = 0; funcfound < MAXFOUND && i < 256; i++)
  	    if (mainbindtab[i] == func) {
--- 1205,1211 ----
  	(unset(ALWAYSLASTPROMPT) && zmult != 1);
      if (func == z_selfinsert || func == z_undefinedkey)
! 	fprintf(shout, "%s is on many keys", ZLEGETCMD(func)->name);
      else {
! 	fprintf(shout, "%s is", ZLEGETCMD(func)->name);
  	for (i = 0; funcfound < MAXFOUND && i < 256; i++)
  	    if (mainbindtab[i] == func) {
***************
*** 1255,1260 ****
      int *bindlist[] = { altbindtab, emacs_cur_bindtab, viins_cur_bindtab,
  			    NULL };
!     HashTable keybindlist[] = { emkeybindtab, vikeybindtab, NULL };
!     HashTable *keybindptr;
  
      PERMALLOC {
--- 1255,1260 ----
      int *bindlist[] = { altbindtab, emacs_cur_bindtab, viins_cur_bindtab,
  			    NULL };
!     HashTable ktab, **keybindptr;
!     HashTable *keybindlist[] = { &emkeybindtab, &vikeybindtab, NULL };
  
      PERMALLOC {
***************
*** 1262,1267 ****
  	    LinkNode ln;
  	    bindremlist = newlinklist();
! 	    if (notall & 3)
! 		keybindptr = &keybindtab;
  
  	    /*
--- 1262,1267 ----
  	    LinkNode ln;
  	    bindremlist = newlinklist();
! 
! 	    ktab = (notall & 3) ? keybindtab : **keybindptr;
  
  	    /*
***************
*** 1271,1275 ****
  	     * delete the bindings one by one later.
  	     */
! 	    scanhashtable(*keybindptr, 0, 0, 0, zerobinding, ifunc);
  
  	    for (ln = firstnode(bindremlist); ln; incnode(ln)) {
--- 1271,1275 ----
  	     * delete the bindings one by one later.
  	     */
! 	    scanhashtable(ktab, 0, 0, 0, zerobinding, ifunc);
  
  	    for (ln = firstnode(bindremlist); ln; incnode(ln)) {
***************
*** 1277,1281 ****
  		char *s = ztrdup(k->nam);
  		int sl = strlen(s);
! 		delprefbinding(*keybindptr, k, s, sl);
  		zfree(s, sl);
  	    }
--- 1277,1281 ----
  		char *s = ztrdup(k->nam);
  		int sl = strlen(s);
! 		delprefbinding(ktab, k, s, sl);
  		zfree(s, sl);
  	    }
*** Src/zle_misc.c	1996/11/19 06:16:35	2.31
--- Src/zle_misc.c	1996/11/19 19:24:08
***************
*** 639,643 ****
  		    *ptr = 0;
  		    for (t0 = 0; t0 != zlecmdtot; t0++) {
! 			struct zlecmd *zc = &ZLEGETCMD(t0);
  			if (!(zc->flags & ZLE_DELETED)
  			    && strpfx(buf, zc->name)) {
--- 639,643 ----
  		    *ptr = 0;
  		    for (t0 = 0; t0 != zlecmdtot; t0++) {
! 			struct zlecmd *zc = ZLEGETCMD(t0);
  			if (!(zc->flags & ZLE_DELETED)
  			    && strpfx(buf, zc->name)) {
*** Src/zle_tricky.c	1996/11/19 06:16:36	2.83
--- Src/zle_tricky.c	1996/11/19 19:24:08
***************
*** 3911,3915 ****
  	return;
      }
!     t = ZLEGETCMD(bindk).name;
      zmult = 1;
      pushline();
--- 3911,3915 ----
  	return;
      }
!     t = ZLEGETCMD(bindk)->name;
      zmult = 1;
      pushline();
*** Src/zle_vi.c	1996/11/19 06:16:37	2.12
--- Src/zle_vi.c	1996/11/19 19:24:08
***************
*** 145,149 ****
  	    return -1;
  	}
! 	zc = &ZLEGETCMD(k2);
  	if (!(zc->flags & ZLE_ARG))
  	    break;
--- 145,149 ----
  	    return -1;
  	}
! 	zc = ZLEGETCMD(k2);
  	if (!(zc->flags & ZLE_ARG))
  	    break;


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: 3.1.0-test3: gcc -ansi -pedantic
  1996-11-19 20:45 3.1.0-test3: gcc -ansi -pedantic Thorsten Meinecke
@ 1996-11-20  6:06 ` Andrej Borsenkow
  1996-11-20  8:57 ` Peter Stephenson
  1 sibling, 0 replies; 4+ messages in thread
From: Andrej Borsenkow @ 1996-11-20  6:06 UTC (permalink / raw)
  To: Thorsten Meinecke; +Cc: zsh-workers

On Tue, 19 Nov 1996, Thorsten Meinecke wrote:

> Hello, did anyone bother before to build zsh with gcc -ansi -pedantic?
> 
> It looks like some of the module-related changes aren't ANSI/ISO C,
> and from some of the older stuff it elicits warnings about variable
> sized arrays and conversions w/o cast as well.  Furthermore, there's
> trouble in module.c, because gcc says ANSI forbids assignment between
> function pointer and `void *'.  Most serious:
> 
>   ../Src> gcc -c -I.. -I. -I. -DHAVE_CONFIG_H -Wall -Wno-implicit \
>   -Wmissing-prototypes -g -ansi -pedantic  zle_main.c
>   zle_main.c: In function `zleread':
>   zle_main.c:439: warning: ANSI C forbids use of conditional expressions as lvalues
>   zle_main.c: In function `unbindzlefunc':
>   zle_main.c:1257: initializer element for `keybindlist[0]' is not computable at load time
>   zle_main.c:1257: initializer element for `keybindlist[1]' is not computable at load time
>   make: *** [zle_main.o] Error 1
> 

I don't use gcc, but my compiler did give the same errors. I just had no
time to send a patch :-(


> I can offer fixes for the error (and the warnings) in the zle_*
> module-related code, by introducing yet another level of indirection
> to both underlying problems.
>

Yes, I was ready to propose the same ;)
thanks

greetings
 
-------------------------------------------------------------------------
Andrej Borsenkow 		Fax:   +7 (095) 252 01 05
SNI ITS Moscow			Tel:   +7 (095) 252 13 88

NERV:  borsenkow.msk		E-Mail: borsenkow.msk@sni.de
-------------------------------------------------------------------------



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: 3.1.0-test3: gcc -ansi -pedantic
  1996-11-19 20:45 3.1.0-test3: gcc -ansi -pedantic Thorsten Meinecke
  1996-11-20  6:06 ` Andrej Borsenkow
@ 1996-11-20  8:57 ` Peter Stephenson
  1996-11-20 15:45   ` Zoltan Hidvegi
  1 sibling, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 1996-11-20  8:57 UTC (permalink / raw)
  To: Zsh hackers list

Thorsten Meinecke wrote:
> Hello, did anyone bother before to build zsh with gcc -ansi -pedantic?

Might as well complete the job:  (1) a pointer lacking a cast in
bin_read() (2) the function casts in module.c (3) the variable-sized
arrays in subst.c (which only affects gcc anyway).  The IRIX
<sys/termios.h> has pairs of ?'s in comments which gcc thinks are
supposed to be triglyphs, which is an additional annoyance.

*** Src/builtin.c.ansi	Mon Nov 18 09:27:19 1996
--- Src/builtin.c	Wed Nov 20 09:38:00 1996
***************
*** 4974,4980 ****
  	    putchar('\n');
  	}
  	if (!ops['e'])
! 	    setsparam(reply, line);
  	return 0;
      }
  
--- 4974,4980 ----
  	    putchar('\n');
  	}
  	if (!ops['e'])
! 	    setsparam(reply, (char *)line);
  	return 0;
      }
  
*** Src/module.c.ansi	Mon Nov 18 09:27:21 1996
--- Src/module.c	Wed Nov 20 09:50:41 1996
***************
*** 46,51 ****
--- 46,53 ----
  
  static LinkList modules;
  
+ typedef int (*Module_func) _((Module));
+ 
  /**/
  void *
  load_module(char *name)
***************
*** 77,83 ****
  {
      char *s, *t;
      char buf[PATH_MAX + 1];
!     int (*fn) _((Module));
  
      s = strrchr(m->nam, '/');
      if (s) {
--- 79,85 ----
  {
      char *s, *t;
      char buf[PATH_MAX + 1];
!     Module_func fn;
  
      s = strrchr(m->nam, '/');
      if (s) {
***************
*** 94,100 ****
  #else
      sprintf(buf, "boot_%s", s);
  #endif
!     fn = dlsym(m->handle, buf);
      return fn ? fn(m) : 1;
  }
  
--- 96,102 ----
  #else
      sprintf(buf, "boot_%s", s);
  #endif
!     fn = (Module_func)dlsym(m->handle, buf);
      return fn ? fn(m) : 1;
  }
  
***************
*** 104,110 ****
  {
      char *s, *t;
      char buf[PATH_MAX + 1];
!     int (*fn) _((Module));
  
      s = strrchr(m->nam, '/');
      if (s) {
--- 106,112 ----
  {
      char *s, *t;
      char buf[PATH_MAX + 1];
!     Module_func fn;
  
      s = strrchr(m->nam, '/');
      if (s) {
***************
*** 121,127 ****
  #else
      sprintf(buf, "cleanup_%s", s);
  #endif
!     fn = dlsym(m->handle, buf);
      return fn ? fn(m) : 0;
  }
  
--- 123,129 ----
  #else
      sprintf(buf, "cleanup_%s", s);
  #endif
!     fn = (Module_func)dlsym(m->handle, buf);
      return fn ? fn(m) : 0;
  }
  
*** Src/subst.c.ansi	Thu Oct 10 12:05:11 1996
--- Src/subst.c	Wed Nov 20 09:47:35 1996
***************
*** 447,453 ****
  cstrpcmp(const void *a, const void *b)
  {
  #ifdef HAVE_STRCOLL
! # ifdef __GNUC__
      char c[strlen(*(char **) a) + 1];
      char d[strlen(*(char **) b) + 1];
  # else
--- 447,453 ----
  cstrpcmp(const void *a, const void *b)
  {
  #ifdef HAVE_STRCOLL
! # if defined(__GNUC__) && !defined(__STRICT_ANSI__)
      char c[strlen(*(char **) a) + 1];
      char d[strlen(*(char **) b) + 1];
  # else
***************
*** 477,483 ****
  invcstrpcmp(const void *a, const void *b)
  {
  #ifdef HAVE_STRCOLL
! # ifdef __GNUC__
      char c[strlen(*(char **) a) + 1];
      char d[strlen(*(char **) b) + 1];
  # else
--- 477,483 ----
  invcstrpcmp(const void *a, const void *b)
  {
  #ifdef HAVE_STRCOLL
! # if defined(__GNUC__) && !defined(__STRICT_ANSI__)
      char c[strlen(*(char **) a) + 1];
      char d[strlen(*(char **) b) + 1];
  # else

-- 
Peter Stephenson <pws@ifh.de>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77413
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: 3.1.0-test3: gcc -ansi -pedantic
  1996-11-20  8:57 ` Peter Stephenson
@ 1996-11-20 15:45   ` Zoltan Hidvegi
  0 siblings, 0 replies; 4+ messages in thread
From: Zoltan Hidvegi @ 1996-11-20 15:45 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers

Peter Stephenson wrote:
> bin_read() (2) the function casts in module.c (3) the variable-sized
> arrays in subst.c (which only affects gcc anyway).  The IRIX

Perhaps it would be best to write a configure check to test wether the
compiler supports variable-sized arrays.  In subst.c the code is much more
efficient with variable-sized arrays that's why I added this hack.  And
when you sort a long list it may cause noticable speed difference (or maybe
not in that case since halloc is really fast, but that consumes lot of heap
memory).

Zoltan


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1996-11-20 15:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-11-19 20:45 3.1.0-test3: gcc -ansi -pedantic Thorsten Meinecke
1996-11-20  6:06 ` Andrej Borsenkow
1996-11-20  8:57 ` Peter Stephenson
1996-11-20 15:45   ` Zoltan Hidvegi

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).