Subject: Re: [[email-masked]: Erratum in H&S CARM 3rd ed.]

From: [email-masked]
Date: Sun, 01 Mar 92 12:48:17 PST

Thank you for your bug report on CARM/3.  There is no errata list for
the 1st or 2nd editions.  Below is the most recent errata list for the 3rd
edition.

Errata: C: A Reference Manual, Third Edition
Sunday, September 22, 1991.

This is a cumulative list of changes and comments on Harbison and
Steele's C: A Reference Manual, Third Edition, Prentice Hall, 1991.
Some or all of these problems may have been corrected in the third and
later printings of the book.  Please send any additional comments to
[email-masked].

I would like to thank Aurelio Bignoli, Steve Clamage of TauMetric
Corp., Roy J. Fuller of the University of Arkansas, Morris M. Kessan,
George V. Reilly of Brown University, Mark Lan of Microsoft, Mike
Hewett of IBM, and Steve Vegdahl 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.

1	Content Problems

Please make the following corrections if necessary.

p. 19	In the last paragraph, the first sentence should be changed 
	to, "If the value of an integer constant exceeds the largest 
	integer representable in type unsigned long, the result is
	undefined." (The original sentence applied to traditional C.)
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. 169	In the definition of 'primary-expression,' change 
	'name' to 'identifier' and change 'literal' to 'constant.'
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-expres-sion" to "unary-expression." Alternatively, 
	make the changes discussed section 3.1 below.
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. 364	The character for decimal code 58 is missing; it 
	should be a colon, ':'.
p. 372	Include the change made on p. 186 on this page also.
p. 374	Change the definition of 'primary-expression' as on p. 169.

2  Typographical Problems

The following spelling and typesetting problems have been 
noticed.

p. v	In the Table of Contents, section 14.2: change "Memcmp"
	 to "memcmp".
p. 12	In the third line from the bottom, change "/*" to 
	"/*" (font change).
p. 13	In the "Token Parsing" table footnote, change 
	"b, -, -, x" to "b, -, -, x" (font change).
p. 16	In the definition of constant, change floating-point-constant 
	to floating-constant.
p. 19	In Table 2-1, first column, the constant 077777 is in the 
	wrong font.
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 "name" to "name" (font change).
p. 53	In exercise 1, definitions (c) and (d) should be in 
	the program typeface.
p. 82	In line 13, change "ary" to "ary" (font change).
p. 87	In the second line from bottom, change "element j 
	the array" to "element j of the array".
p. 119	The heading on this page and the next four odd-numbered 
	pages should be "Sec. 5.6 Structure Types."
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 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. 166	In the title on the first table, change "values" to "lvalues."
p. 177	In the references, change "void type" to 
	"void type" (font change). This prob-lem 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.
	At the end of the first paragraph, change "the result of 
	applying the shift operators << and >>" to "the result of 
	applying the shift operator >>".
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 "register" to "register" (font 
	change).
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 "L" to "L" 
	(font change).
p. 329	In line 1 of sec. 15.14, change "takes takes" 
	to "takes".
p. 330	In line 2 of sec. 15.15, change "filename" to 
	"filename" (font change).
p. 330	In line 1 of sec. 15.16, change "A" to "A" 
	(font change).
p. 344	In line 7 of sec. 18.2, change "time" to "time" 
	(font change).
p. 345  In line -3, change "daving dime" to "saving 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...".
p. 367	In the definition of constant, change floating-point-
	constant to floating-constant.
p. 373	In the definition of pointer, the section numbers 
	should be flush right.

3 Comments

The following comments may clarify certain parts of the book.

3.1 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

3.2 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

3.3 Miscellaneous Clarifications

p. 56	The syntax for type specifiers in the book differs from 
	that found in other C books, although the result should be 
	the same. We state that only one type specifier can appear 
	in a declaration, but we also consider "unsigned long" and 
	"unsigned long int" to be distinct specifiers (p. 101). Other 
	books restrict type specifiers to be single tokens, and 
	then permit multiple type specifiers to appear in 
	declarations, with some constraints (e.g., see the ANSI 
	standard, section 3.5.2). When using our multi-token 
	specifiers, the individual tokens need not be adjacent 
	in the declaration, nor do they have to be in the listed 
	order. Of course, it is better style to keep them together 
	and in order.
p. 167	In Table 7-1, the precedence of postfix ++ and -- 
	should be 17 to emphasize their symmetry with the other 
	postfix operators. This is not a change in the semantics.
p. 359	In the description of argv and argc, it should be 
	mentioned that ANSI C requires argv[argc] to be NULL.

Sam Harbison 
Pine Creek Software; Suite 300; 305 South Craig Street; Pittsburgh, PA 15213;
USA. Phone&FAX: +1 412 681 9811. E-mail: [email-masked].