book cover

Errata for The Practice of Programming

p39: Math.abs returns a negative value for Integer.MIN_VALUE, so rand() should be return left + rgen.nextInt(right-left+1);

p74: As on p39, the call to rand should be int r = rand.nextInt(s.size());

p75: In Exercise 3-4, replace State by Prefix.

p87: The GET command should use CRLFs, as in puts $so "GET $q HTTP/1.0\r\n\r\n", though all servers seem to accept it without.

p95: In the diagram, field[3] should have the value (sline + 15), not (sline + 14). This also necessitates a change in shading.

p95: line should be updated immediately after a successful call of realloc to avoid a potential memory leak or corruption. Fixed on the source code page.

p100: Csv::getline can return false for the last line of a file if the line does not end with a newline. Adding an explicit test for str.length() fixes it.

p102: If the last character of a line is the closing quote of a quoted field in Csv::advquoted, j is incremented beyond the end of the string, causing an illegal reference. Testing ++j < s.length() before accessing s[j] prevents this.

The first printing has minor typographical errors in the text on pages 146, 166, and 244.

p192: sizeof(char) is 1.

Copyright © 1999 Lucent Technologies. All rights reserved. Mon Aug 16 08:39:58 EDT 2004