*BSD News Article 8611


Return to BSD News archive

Xref: sserve comp.unix.bsd:8667 alt.security.pgp:77
Path: sserve!manuel.anu.edu.au!munnari.oz.au!spool.mu.edu!uunet!crdgw1!rdsunx.crd.ge.com!ariel!davidsen
From: davidsen@ariel.crd.GE.COM (william E Davidsen)
Newsgroups: comp.unix.bsd,alt.security.pgp
Subject: Re: [386bsd] right patch for pgp port
Message-ID: <1992Dec7.154459.26017@crd.ge.com>
Date: 7 Dec 92 15:44:59 GMT
References: <LHNHd8h0MT@astral.msk.su>
Sender: usenet@crd.ge.com (Required for NNTP)
Reply-To: davidsen@crd.ge.com (bill davidsen)
Organization: GE Corporate R&D Center, Schenectady NY
Lines: 31
Nntp-Posting-Host: ariel.crd.ge.com

In article <LHNHd8h0MT@astral.msk.su>, ache@astral.msk.su (Andrew A. Chernov, Black Mage) writes:
| Hi.
| Recently I see in news some patch for pgp port to 386bsd.
| I check it and shure that it is only partial and non-elegant solution.
| Main problem are that 386bsd's ctype.h incorrect define tolower
| and toupper. This is not for pgp only but for other programs too,
| so we need to correct ctype.h instead of pgp in this case.

| ! #define _toupper(c)     ((c) - 'a' + 'A')
| ! #define _tolower(c)     ((c) - 'A' + 'a')
| ! #define toupper(c)      (islower(c) ? _toupper(c) : (c))
| ! #define tolower(c)      (isupper(c) ? _tolower(c) : (c))

  The only problem with this code is that existing working code will
break, because you evaluate the argument twice.

Example:
  char str[] = "Any string", *sptr = str;
  int m;

  for (m=0; m < 4; ++m) myproc(toupper(*(sptr++));

This not only breaks the logic by stepping the pointer twice per
character but also returns the wrong values. I would suggest that the
only really correct way to do this is by table lookup (don't forget the
AND, either).

  #define toupper(c) _ALLupper[(c) & 0xff]
-- 
bill davidsen, GE Corp. R&D Center; Box 8; Schenectady NY 12345
    Keyboard controller has been disabled, press F1 to continue.