🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.os2.programmer
Article #903

Re: gcc/2 libc: toupper()/tolower() broken in ctype.h

#903
From: Paul Lyon
Date: Mon, 24 Aug 1992 04:43
24 lines
1657 bytes
This is a followup to my earlier post about fixing the toupper() and
tolower() macros in the ctype.h currently in the gcc/2 distribution.

I think I must of been half-asleep when I wrote it :-( My suggested
fix will not, of course, work if the argument expression has
side-effects. For example, toupper(*p++) will lose, since the pointer
will be incremented twice.

In any case Eberhard Mattes already put a better fix in emx, namely
this: 

static __inline__ int _toupper (int c) { return (c-'a'+'A'); }
static __inline__ int _tolower (int c) { return (c-'A'+'a'); }
static __inline__ int toupper(int c) {return (islower(c) ? _toupper(c) : c);}
static __inline__ int tolower(int c) {return (isupper(c) ? _tolower(c) : c);}

I only thought to check the emx ctype.h _after_ I wrote the preceeding
note :-( :-(. Being proper functions, these will not be vulnerable to
expressions with side effects, and the compiler will also type check
your argument and return value while it is at it.

With reddened face...

Paul Lyon
Technical Details
Message-ID: <PLYON.92Aug23234316@emx.cc.utexas.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!europa.asd.contel.com!emory!swrinde!news.dell.com!milano!shrike!ut-emx!emx.utexas.edu!plyon
References: <PLYON.92Aug23194717@emx.cc.utexas.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!europa.asd.contel.com!emory!swrinde!news.dell.com!milano!shrike!ut-emx!emx.utexas.edu!plyon
From: plyon@emx.cc.utexas.edu (Paul Lyon)
Newsgroups: comp.os.os2.programmer
Subject: Re: gcc/2 libc: toupper()/tolower() broken in ctype.h
Message-ID: <PLYON.92Aug23234316@emx.cc.utexas.edu>
Date: 24 Aug 92 04:43:16 GMT
References: <PLYON.92Aug23194717@emx.cc.utexas.edu>
Sender: news@ut-emx.uucp
Distribution: comp.os.os2.programmer
Organization: The University of Texas at Austin
Lines: 24
In-reply-to: plyon@emx.cc.utexas.edu's message of 24 Aug 92 00:47:17 GMT