🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

3 total messages Started by Dan Levin N6BZA Wed, 25 Sep 1985 03:54
XENIX 3.0 toupper() and tolower() broken
#472
Author: Dan Levin N6BZA
Date: Wed, 25 Sep 1985 03:54
28 lines
1437 bytes
Found this one while trying to make sendmail work,... all the lines of
the form
From:
To:
Date:
came out of the form
Rom:
O:
Ate:

Seems that the XENIX 3.0 ctype.h has toupper() and tolower() defined as
macros like this,...
#define toupper(x) (ifsomething(x) ? dosomething(x) : (x))
which breaks badly if (x) is autoincrement or autodecrement. Ie.
toupper(s++) goes to (ifsomething(s++) ? donesomething(s++) : (s++)),
which is clearly wrong.

The fix is to ctype.h, to not use the trinary operator; or to use the
libc versions instead (by #undef'ing toupper() and tolower());

NB:  This only holds for the Intel distribution, I have not checked the
IBM XENIX 3.0 release.

-- 
			***dan

{allegra,astrovax,princeton,twg}!fisher!djl
The misplaced (You call *that* a ski slope??) Californian
Re: XENIX 3.0 toupper() and tolower() broken
#473
Author: Richard L. Klappal
Date: Sat, 28 Sep 1985 05:05
48 lines
2770 bytes
In article <764@fisher.UUCP> djl@fisher.UUCP (Dan Levin  N6BZA ) writes:
>Seems that the XENIX 3.0 ctype.h has toupper() and tolower() defined as
>macros like this,...
>#define toupper(x) (ifsomething(x) ? dosomething(x) : (x))
>which breaks badly if (x) is autoincrement or autodecrement. Ie.
>toupper(s++) goes to (ifsomething(s++) ? donesomething(s++) : (s++)),
>which is clearly wrong.
>
>The fix is to ctype.h, to not use the trinary operator; or to use the
>libc versions instead (by #undef'ing toupper() and tolower());
>
>NB:  This only holds for the Intel distribution, I have not checked the
>IBM XENIX 3.0 release.
>
>-- 
>			***dan
>
>{allegra,astrovax,princeton,twg}!fisher!djl
>The misplaced (You call *that* a ski slope??) Californian

This is not the only bug running around in toupper/tolower.  While
some systems have this implementation, other versions (among which
is the Fortune) do not do any sanity check, they just add/subtract
0x20, thus transforming numerals into control codes or letters,
depending on the direction of conversion.  Harbison & Steele warn
that toupper/tolower are inconsistant between versions if *NIX. and
indicate what they suggested (?? SYSV ?? ANSI ) recommendations are.

My answer has been my own local ROUTINES (not macros) named 
'ucase' and 'lcase' that do the sanity check and compute the
result.  It causes a little redundant code on machines that work
right, but is nice insurance anyplace they don't, without conflicting
with the internal names (viz. tolower or _tolower, etc).

(Apologies if I misspelled either of the names above, it doesn't
look right, but the book is upstairs)

-- 

Richard Klappal

UUCP:		..!ihnp4!chinet!uklpl!rlk  | "Money is truthful.  If a man
MCIMail:	rklappal		   | speaks of his honor, make him
Compuserve:	74106,1021		   | pay cash."
USPS:		1 S 299 Danby Street	   | 
		Villa Park IL 60181	   |	Lazarus Long 
TEL:		(312) 620-4988		   |	    (aka R. Heinlein)
-------------------------------------------------------------------------
Re: XENIX 3.0 toupper() and tolower() broken
#474
Author: T.Glinos
Date: Sun, 29 Sep 1985 00:31
31 lines
1536 bytes
> Found this one while trying to make sendmail work,... all the lines of
> the form
> From:
> To:
> Date:
> came out of the form
> Rom:
> O:
> Ate:
> 
> Seems that the XENIX 3.0 ctype.h has toupper() and tolower() defined as
> macros like this,...
> #define toupper(x) (ifsomething(x) ? dosomething(x) : (x))
> which breaks badly if (x) is autoincrement or autodecrement. Ie.
> toupper(s++) goes to (ifsomething(s++) ? donesomething(s++) : (s++)),
> which is clearly wrong.
> 
> The fix is to ctype.h, to not use the trinary operator; or to use the
> libc versions instead (by #undef'ing toupper() and tolower());
> 
> NB:  This only holds for the Intel distribution, I have not checked the
> IBM XENIX 3.0 release.
> 
> -- 
> 			***dan
> 
> {allegra,astrovax,princeton,twg}!fisher!djl
> The misplaced (You call *that* a ski slope??) Californian

*** REPLACE THIS LINE WITH YOUR MESSAGE ***
XENIX System V has this all fixed.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads