Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Diff between Draft Proposed ANSI C and ANSI C K&R Books

163 views
Skip to first unread message

Josh Lam

unread,
Jun 22, 1992, 12:09:43 PM6/22/92
to
Hi

The version of 'The C Programming Language' 2nd Edition by Kerhighan and
Ritchie that I have is based on the 'Draft-Proposed ANSI C (1988). I was
wondering if there are any significant (though minor) changes between the
draft and final?

I made several random page comparison between the K&R books based on the
draft version and the final version and so far, their contents (ie the
language definition) are still the same. I don't mean to dwell on small
details but I would rather not get another book if I can continue to use
mine. On the same token, if there are some changes (no matter how few
there are), knowing them could save me some head aches down the road.

Thanks for any comments.

--
Josh Lam
Honeywell Inc
l...@saifr00.cfsat.honeywell.com

David Spuler

unread,
Jun 22, 1992, 10:12:34 PM6/22/92
to

>Hi

>The version of 'The C Programming Language' 2nd Edition by Kerhighan and
>Ritchie that I have is based on the 'Draft-Proposed ANSI C (1988). I was
>wondering if there are any significant (though minor) changes between the
>draft and final?

>I made several random page comparison between the K&R books based on the
>draft version and the final version and so far, their contents (ie the
>language definition) are still the same. I don't mean to dwell on small
>details but I would rather not get another book if I can continue to use
>mine. On the same token, if there are some changes (no matter how few
>there are), knowing them could save me some head aches down the road.

There are a few minor changes but basically it is the same. I compiled a
list a while ago (in this same group I think :-) ) but I don't know where it
is now. A few changes I recall are:

1. Spaces in scanf format string are "ignored" in K&R2, but cause whitespace
reading in ANSI; only really affects spaces before %c, %[ formats.
e.g. scanf(" %c"); has different meaning - reads first character in
K&R2 but reads first non-whitespace character in ANSI.

2. Partial automatic aggregate initialization differs. For example, if arr[] is
a function local variable with the following definition:

int arr[2] = { 1 };

K&R2 says that arr[1] (second entry) is undefined uninitialized values,
but ANSI says that arr[1] is zero.. i.e. the rest of the unlisted
initializers are assumed to be literal zeros.

Both say that int arr[2]; without initializers are uninitialized.
Same issues apply to automatic struct initializations.

3. K&R2 does not cover much of the "internationalization" stuff related to
multi-byte characters and locales. Useful stuff if your program is
supposed to run all over the world in different languages.
There are many extra library functions (which I think K&R2 omits) and
a few extra lexical issues (multi-byte character strings and constants
which start with a prefix L --> L"This is a multi-byte string", L'ab').

--
David Spuler, James Cook University of North Queensland, Australia
Author of "Comprehensive C", Prentice-Hall, 1992, pp416, ISBN 0-13-156514-1
INTRO TOPICS: types, operators, structures, strings, fns, ptrs, files etc etc
ADVANCED TOPICS: efficiency, debugging, style, portability, large programs

John F. Woods

unread,
Jun 23, 1992, 11:54:11 AM6/23/92
to
The second printing of K&R2 should fully match the ANSI standard. Dennis
Ritchie posted a change list for the first printing which I will summarize
(since I put a printed copy in my copy of K&R2 but didn't keep an electronic
copy):

* The Preface and Introduction were updated to describe the state of the
Standard.
* atof is in stdlib.h, not math.h (pp 71, 76, 82, 121)
* missing automatic array initializers are zero. (86)
* on page 168, change 1 to 1.0 in frand() to avoid potential overflow
* Typos on 87, 89, 164, 165, 180.
* pp 192, 212: Noalias went. It was non-negotiable.
* p 199, section A6.6, add this paragraph at the end:
A pointer may be converted to another pointer whose type is the same
except for the addition or removal of qualifiers (A4.4, A8.2) of the
object type to which the pointer refers. If qualifiers are added, the
new pointer is equivalent to the old except for restrictions implied
by the new qualifiers. If qualifiers are removed, operations on the
underlying object remain subject to the qualifiers in its actual
declaration.
* p 199, beginning of A6.8: "Any pointer may be converted to..." changes to
"Any pointer >to an object< may be converted to"
* p204, A7.4.4: "The operand of the unary + operator must have arithmetic or
pointer type" should read "must have arithmetic type".
* p206, A7.9: "Pointers to objects of the same type may be compared..." should
read "Pointers to objects of the same type >(ignoring any qualifiers)< may
be compared."
* The indented material on p. 209, "According to the restrictions ... relaxing
it." is removed.
* p 219 middle, initialization of structures, add "Unnamed bit-field members
are ignored, and are not initialized."
* p 242, App B: add "fflush(NULL) flushes all output streams." to fflush
description.
* p 243: change to "it must be called before reading, writing >or any other
operation<" in setvbuf description.
* p 249: add "Comparison functions treat arguments as unsigned char arrays."
to string.h description.
* p 255: change range of tm_sec to (0,61) for leap seconds. CLK_TCK was
changed late (12/15/88) to CLOCKS_PER_SEC.
* p 257: drop U and L suffixes from <limits.h> constants. tm_sec range (00,61)
here, too.

* App C
* p 261 Change "External declarations without any specifiers..." to "External
>data< declarations without any specifiers..."

* The index was reprinted to fix a couple of typos and account for motion
within Appendix A; one page of the table of contents is changed.
--------
If anyone has an electronic copy of the original, please post it, in case I
have added typos.

K&R2 still disagrees with ANSI on whitespace directives in scanf format
strings (K&R2 says they're ignored, ANSI says they cause the skipping of
whitespace) (assuming that dmr's list of changes that I received was complete).

K&R2 still does not cover internationalization or the offsetof() macro.

Henry Spencer

unread,
Jun 23, 1992, 12:56:48 PM6/23/92
to
In article <13...@ksr.com> j...@ksr.com (John F. Woods) writes:
>K&R2 still disagrees with ANSI [in small ways]...

>K&R2 still does not cover internationalization or the offsetof() macro.

In general, one should beware of assuming that K&R2 is a complete and
accurate presentation of ANSI C. It's close -- it gives you the spirit
of the language pretty well -- but it is *not* the reference to use when
you're trying to decide fine points of standard conformance. There is
even an out-and-out error or two (although recent revisions may have
fixed the one I found and reported to Dennis).
--
There is nothing wrong with making | Henry Spencer @ U of Toronto Zoology
mistakes, but... make *new* ones. -D.Sim| he...@zoo.toronto.edu utzoo!henry

Christopher Beierl

unread,
Jun 25, 1992, 1:08:52 PM6/25/92
to
In article <1992Jun22.1...@saifr00.cfsat.honeywell.com> l...@saifr00.cfsat.honeywell.com (Josh Lam) writes:
>The version of 'The C Programming Language' 2nd Edition by Kerhighan and
>Ritchie that I have is based on the 'Draft-Proposed ANSI C (1988). I was
>wondering if there are any significant (though minor) changes between the
>draft and final?

Here are Dennis Ritchie's errata for the first printing of
the 2nd edition, as posted to comp.lang.c

-----------------K&R2 errata 5-Jun-1989 ------------------
Now that X3J11 has voted to send its draft to X3, and further
substantive changes in the draft standard are unlikely, Brian
and I are preparing fixes to put in any future printings
of the second edition of "The C Programming Language."
Fortunately, they are minor. For the benefit of previous
and near-future purchasers, here are the changes that were made:

Two or three sentences in the Preface and Introduction are updated


to describe the state of the Standard.

atof is in stdlib.h, not math.h: changes 71, 76, 82, 121.

On page 86, error corrected: missing automatic array initializers
are zero too.

On page 168: changed 1 to 1.0 in frand() to avoid potential overflow.

Minor typos are corrected on pages 87, 89, 164, 165, 180.

The inconspicuous references to 'noalias' on pages 192 and
212 are removed.

The following paragraph is added to the end of section A6.6 (p 199):

A pointer may be converted to another pointer whose type
is the same except for the addition or removal of qualifiers
(A4.4, A8.2) of the object type to which the pointer
refers. If qualifiers are added, the new pointer is
equivalent to the old except for restrictions implied
by the new qualifiers. If qualifiers are removed, operations
on the underlying object remain subject to the qualifiers
in its actual declaration.

On p. 199, beginning of section A6.8, "Any pointer may be converted
to type void *..." is changed to "Any pointer >to an object< may
be converted to type void *...".

On p. 204, A7.4.4, "The operand of the unary + operator must have
arithmetic or pointer type..." should read "must have arithmetic type...".

On p. 206, A7.9, about relational operators: "Pointers to objects
of the same type may be compared..." is changed to "Pointers to
object of the same type >(ignoring any qualifiers)< may be compared...".

The indented material on p. 209, "According to the restrictions...

relaxing it." is removed. [This is related to the paragraph added above.
The wording of the draft of a year ago made it useless to
take an (int *) pointer, cast it to (const int *), then cast
it back to (int *).]

On p. 219 middle, initialization of structures, add "Unnamed bit-field


members are ignored, and are not initialized."


Appendix B changes:

p 242: add "fflush(NULL) flushes all output streams." to fflush description.

p 243: change to "it must be called before reading, writing >or any
other operation<" in setvbuf description.

p 249: add "Comparison functions treat arguments as unsigned char arrays."
to string.h description.

p 255: change range of tm_sec to (0,61) for leap seconds.


CLK_TCK was changed late (12/15/88) to CLOCKS_PER_SEC.

p 257: drop U and L suffixes from <limits.h> constants.
tm_sec range (00,61) here too.

Appendix C change:

p 261: Change "External declarations without any specifiers..." to

"External >data< declarations without any specifiers...".

The index has been reprinted to fix a couple of typos and account for


motion within Appendix A; one page of the table of contents is changed.

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Christopher T. Beierl Hewlett-Packard/Apollo - UTD - Media Technology Lab
INTERNET: beie...@apollo.hp.com PHONE: (508) 436-4054
USMAIL: 300 Apollo Dr., Chelmsford, MA 01824 TELNET: 436-4054

Christopher Beierl

unread,
Jun 25, 1992, 1:49:48 PM6/25/92
to
>The version of 'The C Programming Language' 2nd Edition by Kerhighan and
>Ritchie that I have is based on the 'Draft-Proposed ANSI C (1988). I was
>wondering if there are any significant (though minor) changes between the
>draft and final?

Here are Dennis Ritchie's errata for the first printing of

Max Stern 310-524-6152

unread,
Jun 26, 1992, 12:30:05 PM6/26/92
to
In article <1992Jun25.1...@apollo.hp.com> beie...@apollo.hp.com (Christopher Beierl) writes:
>In article <1992Jun22.1...@saifr00.cfsat.honeywell.com> l...@saifr00.cfsat.honeywell.com (Josh Lam) writes:
>>The version of 'The C Programming Language' 2nd Edition by Kerhighan and
>>Ritchie that I have is based on the 'Draft-Proposed ANSI C (1988). I was
>>wondering if there are any significant (though minor) changes between the
>>draft and final?
>
>Here are Dennis Ritchie's errata for the first printing of
>the 2nd edition, as posted to comp.lang.c
>
> -----------------K&R2 errata 5-Jun-1989 ------------------

[stuff deleted...]

>
>Minor typos are corrected on pages 87, 89, 164, 165, 180.
>

[lots of stuff deleted]

I have found the following typo in K&R II which doesn't seem to be
covered in the above posting, but I don't know how to get it to the
authors. Can someone forward it to them?

Description of strncpy on page 249, "... if t has..." should be
"... if ct has...".
--

|\/| /_\ \/
| | / \ /\ l...@torreypinesca.ncr.com

Dennis Ritchie

unread,
Jun 27, 1992, 2:18:43 AM6/27/92
to
Here is a newer version of the errata list than the one that
was reposted. It's not really new (mod date of the file is
Jan 91) and not much different, but does note the p. 249
blemish. It's missing Henry Spencer's observation.

Dennis Ritchie
att!research!dmr
d...@research.att.com
-----

Changes to The C Programming Language, 2nd Edition

As the C standard wended its way through the approval
process and became final, Brian and I prepared fixes to put
in new printings of the second edition of ``The C
Programming Language.'' These printings are identified by a
large red ``ANSI C'' in the upper right quadrant.
Fortunately, the changes are minor; some repair our bugs, a
few account for last-minute changes in the draft standard.


For the benefit of previous and near-future purchasers, here
are the changes that were made:

Two or three sentences in the Preface and Introduction are
updated to describe the state of the Standard.

atof is in <stdlib.h>, not <math.h>; this changes 71, 76,
82, 121.

On page 86, error corrected: elided initializers are 0
for automatic as well as static variables.

On page 168: changed 1 to 1.0 to avoid potential overflow.

Minor typos are corrected on pages 87, 89, 164, 165, 168,
180.

The inconspicuous references to noalias on pages 192 and

211 are removed.

The following paragraph is added to the end of section A6.6
(p 199):

A pointer may be converted to another pointer whose
type is the same except for the addition or removal of
qualifiers (A4.4, A8.2) of the object type to which the
pointer refers. If qualifiers are added, the new
pointer is equivalent to the old except for
restrictions implied by the new qualifiers. If
qualifiers are removed, operations on the underlying
object remain subject to the qualifiers in its actual
declaration.


On p. 199, beginning of section A6.8, ``Any pointer may be
converted to type void *...'' is changed to ``Any pointer
>to an object< may be converted to type void *...''.

On p. 204, A7.4.4, ``The operand of the unary + operator
must have arithmetic or pointer type...'' should read ``must
have arithmetic type...''.

On p. 206, A7.9, about relational operators: ``Pointers to
objects of the same type may be compared...'' is changed to
``Pointers to object of the same type >(ignoring any
qualifiers)< may be compared...''.

The indented material on p. 209, ``According to the
restrictions... relaxing it.'' is removed. [This is
related to the paragraph added above. The wording of the

penultimate draft made it useless to take an (int *)


pointer, cast it to (const int *), then cast it back to
(int *).]

On p. 219 middle, initialization of structures, add
``Unnamed bit-field members are ignored, and are not
initialized.''


Appendix B changes:

p 242: Add ``fflush(NULL) flushes all output streams.'' to
fflush description.

p 243: Change to ``it must be called before reading,


writing >or any other operation<'' in setvbuf description.

p 249: Add ``Comparison functions treat arguments as


unsigned char arrays.'' to <string.h> description.

p 255: Change range of tm_sec to (0,61) for leap seconds.

p 255: Change CLK_TCK to CLOCKS_PER_SEC.

p 257: Drop U and L suffixes from <limits.h> constants.
tm_sec range is (00,61) here too.

Appendix C change:

p 261: Change ``External declarations without any
specifiers...'' to ``External >data< declarations without
any specifiers...''.

The index has been reprinted to fix a couple of typos and
account for motion within Appendix A; one page of the table
of contents is changed.


October, 1989: Minor changes on page 131 to add & to last
example, on page 208 to change ``equal'' to ``unequal'' in
the description of logical OR, and on page 254 to clarify
that only volatile automatics are saved with longjmp.

Not yet fixed in any printing:

page 53: Note under the table should say & as well as + - *
has higher precedence as a unary operator.

page 111: indent is too large, and a bit of program text is
cut off.

page 231 extra right paren in nested call to cat macro.

page 246: first argument of sscanf should have type
const char *.

page 249: in description of strncpy, t => ct.

0 new messages