Checksum: 33397
Lines: 56
Path: utzoo!sq!msb
From: msb@sq.uucp (Mark Brader)
Date: Sat, 26-Dec-87 16:20:52 EST
Message-ID: <1987Dec26.162052.26935@sq.uucp>
Newsgroups: comp.lang.c
Subject: Re: (So-Called) ANSI C
Summary: Examples of code broken
References: <4668@pyr.gatech.EDU> <495@xyzzy.UUCP>
Reply-To: msb@sq.UUCP (Mark Brader)
Organization: SoftQuad Inc., Toronto

[If you get this twice it's not my fault, I canceled the (buggy) first one.]

> In other words, give me some example of "existing C programs broken" by
> the draft standard.  I'm not aware of any interesting cases.

[1] One that was just discussed on the net recently... forward references
    to static functions must, under the Draft, be declared with the keyword
    "static"; Henry Spencer reports that his compiler will not even accept
    this syntax.  It'll mean a bunch of changes to sqtroff, for instance.

[2] You can't explicitly declare library functions if you include the
    header file, because they might be macros.  Formerly only a specified
    few could be macros.

[3] The function or macro isascii(), which was supposed to be used to verify
    that an argument of any of the ctype functions or macros was in range
    if it might not have been, has been removed.

A (constructed) example of formerly good code violating all three of the above:

	#include <stdio.h>
	#include <ctype.h>

	int
	main()
	{
		char *foo();
		FILE *f1, *fopen();
		int i;

		f1 = fopen (foo(), "r");
		i = getc (f1);
		++i;
		if (isascii(i) && islower(i)) i = '-';
		...
	}

	static char *
	foo()
	{
		...
	}

The reason given in the Rationale for [1] is that it will help compilers
in environments where internal linkage is handled differently from external,
which would otherwise require an extra pass to handle such code.
The reason given for [2] is to allow implementers flexibility.
The reason given for [3] is that isascii()'s name is suggestive of an
ASCII environment and its function does not generalize easily.
I complained about [2] and [3] in the first round of public comments.

Incidentally, there were only 32 comment letters received on the first
round.  I found this rather disappointing given the level of interest
on the net.

Mark Brader, utzoo!sq!msb, msb@sq.com		C unions never strike!
