taylor@hpldat.UUCP (Dave Taylor) (05/23/87)
From: harvard!adelie.Adelie.COM!barry@seismo.CSS.GOV (Barry A. Burke) "filter" prints bogus status messages, and will even occaisionally core dump on a BSD system (including Ultrix). Trace back to half-successful attempt at disabling the (bad) "tolower" macro definition in hdrs/filter.h. Here's a diff to Elm/hdrs/filter.h to correct things. I'd advise not running filter on a BSD unless this patch is applied- you probably won't realize you're not getting all your mail. While I was at it, I re-instated the bell, and also eliminated the redefinition of _IOFBF. -- *** filter.h.orig Wed May 20 22:02:47 1987 --- filter.h Wed May 20 22:03:19 1987 *************** *** 7,13 #ifdef BSD # undef tolower - # define tolower(c) (isupper(c)? c = c - 'A' + 'a' : c) #endif /** define a few handy macros for later use... **/ --- 7,12 ----- #ifdef BSD # undef tolower #endif /** define a few handy macros for later use... **/ *************** *** 12,18 /** define a few handy macros for later use... **/ ! #define BEEP (audible? "" : "") #define the_same(a,b) (strncmp(a,b,strlen(b)) == 0) --- 11,17 ----- /** define a few handy macros for later use... **/ ! #define BEEP (audible? "\007" : "") #define the_same(a,b) (strncmp(a,b,strlen(b)) == 0) *************** *** 146,152 extern char _vbuf[5*BUFSIZ]; /* space for file buffering */ ! # define _IOFBF 0 /* doesn't matter - ignored */ # define setvbuf(fd,a,b,c) setbuffer(fd, _vbuf, 5*BUFSIZ) --- 145,153 ----- extern char _vbuf[5*BUFSIZ]; /* space for file buffering */ ! # ifndef _IOFBF /* fix for Ultrix-is already defined */ ! # define _IOFBF 0 /* doesn't matter - ignored */ ! # endif # define setvbuf(fd,a,b,c) setbuffer(fd, _vbuf, 5*BUFSIZ) -- LIVE: Barry A. Burke, (617) 499-6370 USPS: Adelie Corporation, 125 CambridgePark Drive Cambridge, MA 02140 UUCP: barry@adelie.Adelie.COM / ..!{harvard,ll-xn,necntc,mirror}!adelie!barry ARPA: barry@adelie.Adelie.COM (via MX) / barry%adelie@harvard.Harvard.EDU -- I think that I shall never see A billboard lovely as a tree. Perhaps, unless the billboards fall I'll never see a tree at all.
daemon@hplabsc.UUCP (05/30/87)
Uhhh. This portion of your patch works on Ultrix 2.0, (tolower() is in libc.a), but under BSD4.[23] tolower has to be defined (it's a macro). ) )From: harvard!adelie.Adelie.COM!barry@seismo.CSS.GOV (Barry A. Burke) ) )"filter" prints bogus status messages, and will even occaisionally core dump )on a BSD system (including Ultrix). Trace back to half-successful attempt at )disabling the (bad) "tolower" macro definition in hdrs/filter.h. ) )*** filter.h.orig Wed May 20 22:02:47 1987 )--- filter.h Wed May 20 22:03:19 1987 )*************** )*** 7,13 ) ) #ifdef BSD ) # undef tolower )- # define tolower(c) (isupper(c)? c = c - 'A' + 'a' : c) ) #endif ) ) /** define a few handy macros for later use... **/ ) )--- 7,12 ----- ) ) #ifdef BSD ) # undef tolower ) #endif ) ) /** define a few handy macros for later use... **/ # define tolower(c) (isupper(c)? (c - 'A' + 'a') : c) seems to work. -- I hate mud. I like blue clean flowing water. LA sucks water. That doesn't mean I like LA. (Actually, I like a lot of things in LA) + Jim Budler Advanced Micro Devices, Inc. (408) 749-5806 + + Compuserve: 72415,1200; Delphi: JIMBUDLER; Usenet: jimb@amdcad.AMD.COM +
daemon@hplabsc.UUCP (06/02/87)
In article <1917@hplabsc.HP.COM>, jimb@dopey.AMD.COM (Jim Budler) writes: > > # define tolower(c) (isupper(c)? (c - 'A' + 'a') : c) > > seems to work. There has been much discussion concerning the usage of the toupper() & tolower() macros on various systems. This has got to be one of the items within "C" which varies most widely from machine to machine. I have seen at least six different styles of macro invocations and function calls for these operations on various machines. System-V.2 currently implements toupper() & tolower() as functions with _toupper() and _tolower() as [somewhat defective] macros. Jim's example above addresses the problem (on some systems) of passing an out-of-range character to the macro which then gets translated to a garbage value. The trouble with this example is that it breaks whenever the argument is anything other than a single character - since the argument "c" will be processed at least twice. For example: tolower('a'); or tolower('X'); both work fine, but ... tolower( getchar() ); gets translated to: isupper( getchar() ) ? (getchar() - 'A' + 'a') : getchar() ); which causes two calls to getchar to be made - yielding unexpected results. There are many other examples of complex argument constructs which cause the typical macro to fail (but will work OK on function calls!) To address this problem, I have developed the following two macros which can take the place of toupper() and tolower(). They will accept any argument and will return a sane (ie. expected) result. "_dumVAR_" is used to store an intermediate result which is what allows the macro to work without resorting to a function call. Note that these invocations simply include the test which isupper() & islower() would perform if included, as in Jim's example above. char _dumVAR_; #define UC(c) (((_dumVAR_ = (c)) >= 'a' && _dumVAR_ <= 'z') ? \ (_dumVAR_ - 'a' + 'A') : _dumVAR_) #define LC(c) (((_dumVAR_ = (c)) >= 'A' && _dumVAR_ <= 'Z') ? \ (_dumVAR_ - 'A' + 'a') : _dumVAR_) To use these macros in the elm system, place them in the sysdefs.h file and then edit the Makefile(s) to include the following defines on the compile lines: -Dtolower=LC -Dtoupper=UC -- Jeffery Small (203) 776-2000 UUCP: ihnp4!---\ C. Jeffery Small and Associates hsi!cjsa!jeff 123 York Street, New Haven, CT 06511 hao!noao!---/