[comp.misc] H&S III strcat

diamond@jit345.swstokyo.dec.com (Norman Diamond) (03/20/91)

In article <5075771f.20b6d@apollo.HP.COM> vinoski@apollo.HP.COM (Stephen Vinoski) writes:

>... the 3rd edition of "C: A Reference Manual" by Harbison and Steele.
>They state that the strcat() function can be implemented as:
>          char *strcat(char *s1, const char *s2) {
>            s1 += strlen(s1);
>            strcpy(s1, s2);
>            return s1;
>          }
>Since the return value does not point to the beginning of the original s1, is
>this implementation standard-conforming?

No.

>Does anybody actually proofread technical books before publishing them anymore?

Did they ever?
Part of the folklore is that examples should be tested before publishing.
It is a rare author who actually does so.  I'm glad if you can get a refund.
--
Norman Diamond       diamond@tkov50.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.

lmiller@aero.org (Lawrence H. Miller) (03/21/91)

In article <1991Mar20.004013.18442@tkou02.enet.dec.com> diamond@jit345.enet@tkou02.enet.dec.com (Norman Diamond) writes:
>In article <5075771f.20b6d@apollo.HP.COM> vinoski@apollo.HP.COM (Stephen Vinoski) writes:
>
>>Does anybody actually proofread technical books before publishing them anymore?
>
>Did they ever?
>Part of the folklore is that examples should be tested before publishing.
>It is a rare author who actually does so.  I'm glad if you can get a refund.

	In the revision of our C book (**) to conform to the C
	standard, we are rigorously testing our programs on several
	different machines and allegedly standard conforming
	compilers.  Needless to say, this has been most illuminating.
	There are lots of subtle bugs that creep in (one recent one
	was processing bytes as type char: they were unsigned on one
	machine, signed on another--we changed the type to unsigned
	char; another was in using a pointer to an array, and in
	processing the array from end to start; the loop ends up
	with the pointer pointing to one BEFORE the start of the
	array--shame, shame).

	The book will be out later because of this, but at a
	buck a bug paid out, we'll save some money!!

(** Miller and Quilici, Programming in C, John Wiley & Sons)

-- 
Larry Miller
Aerospace Corporation
lmiller@aerospace.aero.org
213-336-5597