* fdtable @ 1996-05-07 8:17 Peter Stephenson 1996-05-07 11:19 ` fdtable Zefram 1996-05-07 14:52 ` fdtable Peter Stephenson 0 siblings, 2 replies; 7+ messages in thread From: Peter Stephenson @ 1996-05-07 8:17 UTC (permalink / raw) To: Zsh hackers list In 2.6-beta17, fdtable[] is a char array, and there are tests like if (fdtable[i] < 0) fdtable[i]--; for which gcc on IRIX is complaining about limited range of data type. Shouldn't fdtable[] be `signed char'? (Yes.) *** Src/globals.h.sc Tue May 7 10:09:50 1996 --- Src/globals.h Tue May 7 10:10:13 1996 *************** *** 397,403 **** * table is not used. A table element is set by movefd and cleard * * by zclose. */ ! EXTERN char fdtable[OPEN_MAX]; /* input fd from the coprocess */ --- 397,403 ---- * table is not used. A table element is set by movefd and cleard * * by zclose. */ ! EXTERN signed char fdtable[OPEN_MAX]; /* input fd from the coprocess */ -- Peter Stephenson <pws@ifh.de> Tel: +49 33762 77366 WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77330 Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen DESY-IfH, 15735 Zeuthen, Germany. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: fdtable 1996-05-07 8:17 fdtable Peter Stephenson @ 1996-05-07 11:19 ` Zefram 1996-05-07 14:12 ` fdtable Peter Stephenson 1996-05-07 14:52 ` fdtable Peter Stephenson 1 sibling, 1 reply; 7+ messages in thread From: Zefram @ 1996-05-07 11:19 UTC (permalink / raw) To: Peter Stephenson; +Cc: zsh-workers >In 2.6-beta17, fdtable[] is a char array, and there are tests like > > if (fdtable[i] < 0) > fdtable[i]--; > >for which gcc on IRIX is complaining about limited range of data type. >Shouldn't fdtable[] be `signed char'? (Yes.) Careful! The `signed' keyword does not exist in K&R C. We should either avoid its usage altogether, or do a feature test for it. I think all K&R compilers have char signed by default, so this should work. -zefram ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: fdtable 1996-05-07 11:19 ` fdtable Zefram @ 1996-05-07 14:12 ` Peter Stephenson 0 siblings, 0 replies; 7+ messages in thread From: Peter Stephenson @ 1996-05-07 14:12 UTC (permalink / raw) To: Zsh hackers list > >Shouldn't fdtable[] be `signed char'? (Yes.) > > Careful! The `signed' keyword does not exist in K&R C. We should > either avoid its usage altogether, or do a feature test for it. I > think all K&R compilers have char signed by default, so this should > work. OK, here's a configure version. I haven't rerun autoconf; that needs to be done for this to take effect. By the way, the previous test in configure, for casting signed to unsigned, isn't being cached properly. I think that's because of the name of the variable. *** config.h.in.sig Tue May 7 15:42:38 1996 --- config.h.in Tue May 7 15:57:52 1996 *************** *** 96,101 **** --- 96,104 ---- /* Define to 1 if compiler incorrectly cast signed to unsigned */ #undef BROKEN_SIGNED_TO_UNSIGNED_CASTING + /* Define to 1 if compiler handles `signed' keyword */ + #undef HAVE_SIGNED_KEYWORD + /* Define if your system defines TIOCGWINSZ in sys/ioctl.h. */ #undef GWINSZ_IN_SYS_IOCTL *** configure.in.sig Fri May 3 20:54:33 1996 --- configure.in Tue May 7 16:00:39 1996 *************** *** 154,159 **** --- 154,167 ---- AC_DEFINE(BROKEN_SIGNED_TO_UNSIGNED_CASTING) fi + dnl Checking if complier handles `signed' keyword + AC_CACHE_CHECK(if the signed keyword is handled, zsh_cv_signed_keyword, + [AC_TRY_COMPILE(, [signed char foo; foo = -1;], + zsh_cv_signed_keyword=yes, zsh_cv_signed_keyword=no)]) + if test $zsh_cv_signed_keyword = yes; then + AC_DEFINE(HAVE_SIGNED_KEYWORD) + fi + dnl ------------------ dnl CHECK FOR PROGRAMS dnl ------------------ *** Src/globals.h.sig Tue May 7 15:43:49 1996 --- Src/globals.h Tue May 7 15:56:39 1996 *************** *** 397,403 **** --- 397,408 ---- * table is not used. A table element is set by movefd and cleard * * by zclose. */ + #ifdef HAVE_SIGNED_KEYWORD + EXTERN signed char fdtable[OPEN_MAX]; + #else + /* If `signed' does not exist, we assume char's are signed anyway. */ EXTERN char fdtable[OPEN_MAX]; + #endif /* input fd from the coprocess */ -- Peter Stephenson <pws@ifh.de> Tel: +49 33762 77366 WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77330 Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen DESY-IfH, 15735 Zeuthen, Germany. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: fdtable 1996-05-07 8:17 fdtable Peter Stephenson 1996-05-07 11:19 ` fdtable Zefram @ 1996-05-07 14:52 ` Peter Stephenson 1996-05-07 15:45 ` fdtable Zoltan Hidvegi 1996-05-08 7:54 ` Macros (Was: fdtable) Bas V. de Bakker 1 sibling, 2 replies; 7+ messages in thread From: Peter Stephenson @ 1996-05-07 14:52 UTC (permalink / raw) To: Zsh hackers list I wrote: > Shouldn't fdtable[] be `signed char'? (Yes.) Zefram just pointed out the simplest thing to do was simply to define signed to nothing if it isn't supported. Here's the third attempt. I'd be obliged if somebody using a K&R compiler could have a go at it. (I did try it by altering the cached value to `no'.) *** config.h.in.sig Tue May 7 15:42:38 1996 --- config.h.in Tue May 7 16:43:33 1996 *************** *** 96,101 **** --- 96,104 ---- /* Define to 1 if compiler incorrectly cast signed to unsigned */ #undef BROKEN_SIGNED_TO_UNSIGNED_CASTING + /* Define to nothing if compiler does not handle `signed' keyword */ + #undef signed + /* Define if your system defines TIOCGWINSZ in sys/ioctl.h. */ #undef GWINSZ_IN_SYS_IOCTL *** configure.in.sig Fri May 3 20:54:33 1996 --- configure.in Tue May 7 16:40:11 1996 *************** *** 154,159 **** --- 154,167 ---- AC_DEFINE(BROKEN_SIGNED_TO_UNSIGNED_CASTING) fi + dnl Checking if complier handles `signed' keyword + AC_CACHE_CHECK(if the signed keyword is handled, zsh_cv_signed_keyword, + [AC_TRY_COMPILE(, [signed char foo; foo = -1;], + zsh_cv_signed_keyword=yes, zsh_cv_signed_keyword=no)]) + if test $zsh_cv_signed_keyword = no; then + AC_DEFINE(signed, ) + fi + dnl ------------------ dnl CHECK FOR PROGRAMS dnl ------------------ *** Src/globals.h.sig Tue May 7 15:43:49 1996 --- Src/globals.h Tue May 7 16:41:01 1996 *************** *** 397,403 **** * table is not used. A table element is set by movefd and cleard * * by zclose. */ ! EXTERN char fdtable[OPEN_MAX]; /* input fd from the coprocess */ --- 397,403 ---- * table is not used. A table element is set by movefd and cleard * * by zclose. */ ! EXTERN signed char fdtable[OPEN_MAX]; /* input fd from the coprocess */ -- Peter Stephenson <pws@ifh.de> Tel: +49 33762 77366 WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77330 Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen DESY-IfH, 15735 Zeuthen, Germany. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: fdtable 1996-05-07 14:52 ` fdtable Peter Stephenson @ 1996-05-07 15:45 ` Zoltan Hidvegi 1996-05-08 7:54 ` Macros (Was: fdtable) Bas V. de Bakker 1 sibling, 0 replies; 7+ messages in thread From: Zoltan Hidvegi @ 1996-05-07 15:45 UTC (permalink / raw) To: Peter Stephenson; +Cc: Zsh workers list [-- Attachment #1: Type: application/pgp, Size: 4388 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Macros (Was: fdtable) 1996-05-07 14:52 ` fdtable Peter Stephenson 1996-05-07 15:45 ` fdtable Zoltan Hidvegi @ 1996-05-08 7:54 ` Bas V. de Bakker 1996-05-08 15:05 ` Zefram 1 sibling, 1 reply; 7+ messages in thread From: Bas V. de Bakker @ 1996-05-08 7:54 UTC (permalink / raw) To: zsh-workers Peter Stephenson <pws@ifh.de> writes: > + /* Define to nothing if compiler does not handle `signed' keyword */ > + #undef signed > + There's already another fix by Zoltan, so the following remark no longer applies to this case, but I'd like to make a general remark here: When reading other people's code, I've regularly been bitten by the fact that the code was not what it looked like, due to a #define in one of the so many header files that was (directly or indirectly) included. The potential for errors is much less if one keeps all macros uppercase. So create a SIGNED macro that is either defined to signed or to nothing, like EXTERN. The same is true of things like #define dirent direct #define setpgrp setpgid which are currently used. Bas. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Macros (Was: fdtable) 1996-05-08 7:54 ` Macros (Was: fdtable) Bas V. de Bakker @ 1996-05-08 15:05 ` Zefram 0 siblings, 0 replies; 7+ messages in thread From: Zefram @ 1996-05-08 15:05 UTC (permalink / raw) To: Bas V. de Bakker; +Cc: zsh-workers >When reading other people's code, I've regularly been bitten by the >fact that the code was not what it looked like, due to a #define in >one of the so many header files that was (directly or indirectly) >included. The potential for errors is much less if one keeps all >macros uppercase. So create a SIGNED macro that is either defined to >signed or to nothing, like EXTERN. In the case of signed, I disagree. The signed keyword usually has no effect at all, so #defining it to nothing makes almost no difference to its meaning. const, similarly, is purely a modifier, and #defining it to nothing makes no difference to the meaning of the code, provided it's legal to start with. The EXTERN macro is uppercase because it doesn't simply mean extern; it means extern in most source files, but it is different in one. -zefram ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~1996-05-08 16:03 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 1996-05-07 8:17 fdtable Peter Stephenson 1996-05-07 11:19 ` fdtable Zefram 1996-05-07 14:12 ` fdtable Peter Stephenson 1996-05-07 14:52 ` fdtable Peter Stephenson 1996-05-07 15:45 ` fdtable Zoltan Hidvegi 1996-05-08 7:54 ` Macros (Was: fdtable) Bas V. de Bakker 1996-05-08 15:05 ` Zefram
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).