🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #13335

Re: String Processing Instruction -- printf, strcpy.

#13335
From: Henry Spencer
Date: Tue, 31 Mar 1987 20:03
19 lines
1486 bytes
> Similarly, I have a strong suspicion that compiling strcmp(a,b) to:
> 
> 	subtract *b from *a
> 	if nonzero, you have the result
> 	else call strcmp()
> 
> (say using the nice _inline_ stuff in the draft C standard) would speed
> it up a lot more than all the instructions you could imagine...

Careful, John, this code has a bug:  on a signed-char machine, the result
when comparing "" to "\203" will be wrong.  Correct lexical comparison
requires that the terminating NUL compare low against all characters, which
is not the way subtraction works on a signed-char machine.  This will get
more important as ISO Latin becomes more common.

Admittedly, many existing implementations of strcmp botch this too!
-- 
"We must choose: the stars or	Henry Spencer @ U of Toronto Zoology
the dust.  Which shall it be?"	{allegra,ihnp4,decvax,pyramid}!utzoo!henry
Technical Details
Message-ID: <7850@utzoo.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!henry
References: <15292@amdcad.UUCP> <978@ames.UUCP> <15694@sun.uucp>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!henry
From: henry@utzoo.UUCP (Henry Spencer)
Newsgroups: comp.arch,comp.lang.c
Subject: Re: String Processing Instruction -- printf, strcpy.
Message-ID: <7850@utzoo.UUCP>
Date: Tue, 31-Mar-87 15:03:05 EST
Article-I.D.: utzoo.7850
Posted: Tue Mar 31 15:03:05 1987
Date-Received: Tue, 31-Mar-87 15:03:05 EST
References: <15292@amdcad.UUCP> <978@ames.UUCP> <15694@sun.uucp>
Organization: U of Toronto Zoology
Lines: 19
Keywords: instruction set architectures, Am29000, printf