*BSD News Article 8568


Return to BSD News archive

Path: sserve!manuel.anu.edu.au!munnari.oz.au!spool.mu.edu!uunet!mcsun!fuug!kiae!demos!newsserv
From: "Andrew A. Chernov, Black Mage" <ache@astral.msk.su>
Newsgroups: comp.unix.bsd
Subject: [386BSD] patch: ctype.h non-ANSI behaviour
Date: Sun, 06 Dec 92 23:58:15 +0300
Distribution: world
Organization: Ha-oh-lahm Yetzirah
Message-ID: <HGdbc8hesR@astral.msk.su>
Sender: news-service@newcom.kiae.su
Reply-To: ache@astral.msk.su
Lines: 40

Hi, it is a really bug, man programs do something like:

#include <ctype.h>
....
	for (s = string; *s; s++)
		*s = tolower(*s);

and got very strange results on non-alpha characters.
I saw fix for library functions, but didn't saw it for macros,
here it is:

*** /usr/include/ctype.h.was Sat Feb 29 03:13:14 1992
--- /usr/include/ctype.h     Sun Dec  6 23:49:03 1992
***************
*** 59,66 ****
  #define	isgraph(c)	((_ctype_ + 1)[c] & (_P|_U|_L|_N))
  #define	iscntrl(c)	((_ctype_ + 1)[c] & _C)
  #define	isascii(c)	((unsigned)(c) <= 0177)
! #define	toupper(c)	((c) - 'a' + 'A')
! #define	tolower(c)	((c) - 'A' + 'a')
  #define	toascii(c)	((c) & 0177)
  
  #endif /* !_CTYPE_H_ */
--- 59,68 ----
  #define	isgraph(c)	((_ctype_ + 1)[c] & (_P|_U|_L|_N))
  #define	iscntrl(c)	((_ctype_ + 1)[c] & _C)
  #define	isascii(c)	((unsigned)(c) <= 0177)
! #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))
  #define	toascii(c)	((c) & 0177)
  
  #endif /* !_CTYPE_H_ */
-- 
In-This-Life:  Andrew A. Chernov    |  "Hay mas dicha, mas contento
Internet:      ache@astral.msk.su   |  "Que adorar una hermosura
Organization:  The RELCOM Corp.,    |  "Brujuleada entre los lejos
               Moscow, Russia       |  "De lo imposible?!"  (Calderon)