[comp.lang.c] Harbison & Steele III errata

vinoski@apollo.hp.com (Stephen Vinoski) (06/07/91)

[Sam Harbison asked me to post the following errata for him.  -steve]


Errata: Harbison & Steele, C: A REFERENCE MANUAL, Third Edition
Sam Harbison (harbison@bert.pinecreek.com)
Wednesday, June 5, 1991

Here is a complete  list of the problems discovered in
the Third Edition of Harbison & Steele's C: A REFERENCE MANUAL
(Prentice Hall, 1991). They are divided into three sections:

  1. substantive problems (that make the description of C appear incorrect)
  2. some comments on the grammar used (for clarification)
  3. typographical problems

The substantive problems should be corrected in the third and later
printings of the book. You may wish to make a note of them in your 
present copies.

I'm sorry the list is as long as it is, but I want to thank Steve
Clamage of TauMetric Corp., Roy J. Fuller of the University of
Arkansas, and George V. Reilly of Brown University for reporting
problems. I especially want to thank Steve Vinoski of HP Apollo
Division, who proofread the entire third edition and reported most of
problems listed here. Please send any additional comments on the book
to me at harbison@bert.pinecreek.com.

SUBSTANTIVE CHANGES

p. 38	In line 18, change "if (n !== m)" to "if (n != m)".
p. 69	In lines 21-24, the type specifier examples should 
	be formatted into two columns, like this:

	void			union { int a; char b; }
	int			enum {red, blue, green}
	unsigned long int	char
	my_struct_type		float

p. 82	In the first line in the table, change "int *x();" 
	to "int x();".
p. 89	Line 9 should read

	char q[5]   = { 'A', '\0', '\0', '\0', '\0' };

	to emphasize that all elements of the array are 
	initialized.
p. 110	In line 14, change "p<array[N]" to "p<&array[N]".
p. 128	The statement following the union type syntax is incorrect--ANSI C 
	allows unions to contain bit fields, although traditional C 
	does not. Change the sentence to read: "The syntax for defining 
	components is the same as that used for structures.  In traditional 
	C, unions must not contain bit fields, but in ANSI C this 
	restriction is removed."
p. 163	In line 7, change "the promotion to float" to "the 
	promotion to double".
p. 185	In the third paragraph, change "into its first 
	argument a reversed copy of its second argument" to 
	"into its second argument a reversed copy of its first 
	argument".
p. 186	In the syntax for multiplicative-expression: change 
	"cast-expression" to "unary-expression." Alternatively, 
	make the changes discussed later in this message.
p. 197	In the first line of the table at the bottom of the 
	page, for a=1 and b=0, change the entry under "a||b" 
	from 0 to 1.  [(1||0)==1]
p. 226	In the insertsort example, add a declaration of 
	temp by changing the existing declaration to read:

	register int i, j, temp;

p. 233	In line four, change "largest" to "smallest".
p. 287	The example illustrating strcpy is incorrect 
	because it does not return the original value of the 
	argument dest. The corrected example is shown below:

	#include <string.h>
	char *strcat(dest,src)
		char *dest;
		const char *src;
	{
		char *s = dest + strlen(dest);  /* changed */
		strcpy(s, src);
		return dest;
	}

p. 308	In line 11, change "fputs" to "fgets".
p. 327	In the prototype for ANSI vsprintf, change the 
	third argument from "char *arg" to "va_list arg". 
p. 328	In line 4, the variable global_trace_enabled is 
	never used; its declaration can be removed.
p. 335	In line 1, the sentence should begin "The function 
	relalloc behaves like realloc except...".
p. 350	In both prototypes for system, change "command" to 
	"*command".
p. 372	Include the change made on p. 186 on this page 
	also.

COMMENTS ON THE C GRAMMAR

The cast-expression Syntax

The syntax for unary-expression and cast-expression in C:ARM (p. 179)
differs from ANSI C. Either can be used to describe C, but the ANSI
grammar is probably clearer. Here are the changes that bring C:ARM
into line with the ANSI C grammar, and the pages on which they could
be made.

multiplicative-expression:	p. 186, 372
	cast-expression
	multiplicative-expression  mult-op  cast-expression

cast-expression:	p. 179, 366
	unary-expression
	( type-name ) cast-expression

unary-expression:	p. 179, 377
	postfix-expression
	sizeof-expression
	unary-minus-expression
	unary-plus-expression
	logical-negation-expression
	bitwise-negation-expression
	address-expression
	indirection-expression
	preincrement-expression
	predecrement-expression

unary-minus-expression:	p. 181, 377
	- cast-expression

unary-plus-expression:	p. 181, 377
	+ cast-expression

logical-negation-expression:	p. 182, 372
	! cast-expression

bitwise-negation-expression:	p. 182, 366
	~ cast-expression

address-expression:	p. 183, 365
	& cast-expression

indirection-expression:	p. 184, 371
	* cast-expression


Declaration-list Syntax

On p. 215, the syntax for declaration-list is written in a
right-associative style whereas all other similar grammatical
productions are left-associative (such as statement-list, immediately
following).  To be consistent, it should be written as

declaration-list :
	declaration
	declaration-list  declaration


TYPOGRAPHICAL PROBLEMS

(The phrase "change the font of X" means "change X from proportional
[Times] to fixed-width [Courier] font, or vice versa, as appropriate".)

p. v	In the Table of Contents, section 14.2: change "Memcmp" to "memcmp".
p. 12	In the third line from the bottom, change the font of "/*".
p. 13	In the "Token Parsing" table footnote, change the fonts in
	"b, -, -, x".
p. 32ff	All even page numbers in chapter 3 should be in boldface.
p. 34	In line 29, add a period after "illegal".
p. 50	In line 4, change the font of "name".
p. 53	In exercise 1, definitions (c) and (d) should be in 
	the program typeface.
p. 82	In line 13, change the font of "ary".
p. 87	In the second line from bottom, change "element j 
	the array" to "element j of the array".
p. 133	The references at the end of section 5.7.4 would be 
	better placed at the end of section 5.7.3.
P. 161	In the example code, change the curly quotation characters `` and '' 
	to ". Also, the comment on the last line of the example 
	should line up with the previous comments.
p. 162	In footnote 1 of the table, change "if and only it" 
	to "if and only if it".
p. 177	In the references, change the font in "void type".
	This problem appears several times in the book, but this will be 
	the only mention of it.
p. 178	In line 7, change "modified" to "modified".
p. 184	In the second line from the bottom, change "modified" to "modified".
p. 191	In the first line, remove the space before the 
	period ending the sentence.
p. 214	In line 6, change `"do;";' to `"do";'.
p. 214	The sixth line from the bottom of the page is not 
	aligned properly with the other examples.
p. 233	The eighth line from the bottom, smallest = a[j], 
	should be indented under the if statement, or included 
	on the same line with the if statement.
p. 241	In line 13 and 18, the example prototypes for strncpy and 
	fprintf differ from the prototypes that actually appear in 
	the ANSI C header files. See p. 287 and p. 316 for 
	the true prototypes.
p. 251	In line 27, change the font of "register".
p. 272	In Table 11-3, in the entry for frac_digit, change "shwon" to "shown".
p. 273	In line 13, change "Draft Proposed ANSI C" to "ANSI C".
p. 291	In line 14 of the example program, change "woords" to "words".
p. 292	In line 3, change "woords" to "words".
p. 296	In the prototype for ANSI memchr, change "size t" to "size_t".  
p. 297	In line 2 of section 14.2, change "character" to "characters".
p. 300	In last line, change "file" to "files".
p. 304	In line 3 of sec. 15.4, change "program.;" to 
	"program;" and change "stdout" to "stdout".
p. 308	In line 12, change "put into" to "put it into".
p. 317	In line 5 of sec. 15.11.2, change "an" to "a".
p. 318	In line 2 of sec. 15.11.3, eliminate the space 
	before the period ending the line.
p. 320	In line 12 of sec. 15.11.6, change the font of "L".
p. 329	In line 1 of sec. 15.14, change "takes takes" to "takes".
p. 330	In line 2 of sec. 15.15, change the font of "filename".
p. 330	In line 1 of sec. 15.16, change the font of "A".
p. 344	In line 7 of sec. 18.2, change the font of "time".
p. 352	In line 3, change "steams" to "streams" (twice).
p. 358	In line 2, the sentence should begin "The function 
	main, which programmers must define to establish an 
	entry point in their C programs, is also described...".

Sam Harbison 
Pine Creek Software; 305 S. Craig St., Suite 300; Pittsburgh, PA  15213
+1 412 681 9811; harbison@bert.pinecreek.com
-- 
| Steve Vinoski  (508)256-0176 x5904       | Internet: vinoski@apollo.hp.com  |
| HP Apollo Division, Chelmsford, MA 01824 | UUCP: ...!apollo!vinoski         |