Checksum: 33476 Lines: 48 Path: utzoo!sq!msb From: msb@sq.com (Mark Brader) Date: Mon, 13-Mar-89 20:31:40 EST Message-ID: <1989Mar13.203140.5054@sq.com> Newsgroups: comp.lang.c Subject: Re: Max line length (was Re: programming challenge ...) References: <2102@jasper.UUCP> <207600017@s.cs.uiuc.edu> <9777@bloom-beacon.MIT.EDU> Reply-To: msb@sq.com (Mark Brader) Organization: SoftQuad Inc., Toronto > What is the longest line allowed in a C program? Does the standard say? > Do present compilers care? It's still a proposed standard, technically. X3 has accepted it, so it will be becomes a standard, but it hasn't actually been officially called one yet. # 2.2.4.1 Translation Limits # The implementation shall be able to translate and execute at least # one program that contains at least one instance of every one of the # following limits*: # # ... # 509 characters in a logical source line # ... # *An implementation should avoid imposing fixed translation limits # wherever possible. "Logical" source line is defined in 2.1.1.2 as what you get after you (notionally, at least) replace your system's idea of end-of-line with UNIX-like newline characters, translate trigraphs into the corresponding characters, and then eliminate any backslash-newlines. By the way, any nonempty source file is required to end with an unbackslashed newline. Of course, a compiler is at liberty to ignore this requirement. Now I suppose I should describe trigraphs, to forestall any followups from new readers. C was designed to use almost the full ASCII character set, which causes problems in Europe where the bit patterns that ASCII uses for things like # and \ and { are instead used for accented letters (different ones in different countries, yet), and so, many terminals lack those characters altogether. As a partial workaround for this problem -- and nobody pretends it is more than that -- an ANSI C compiler is required to recognize in its initial translation phase the sequences ??= ??( ??/ ??) ??' ??< ??! ??> ??- (called trigraphs) and replace them respectively with the characters # [ \ ] ^ { | } ~ which are needed for C but may not be available in some character sets. Please DO NOT post suggestions for alternatives to the net; all possibilities have been discussed AT LENGTH. The sed command in my signature below is to fix any old programs that may have accidentally contained trigraphs (the only likely case would be printf ("What??!\n");) by inserting a backslash between the ?'s to break up the trigraph without changing the string. ('\?' == '?' in ANSI C.) Mark Brader, Toronto sed -e "s;??\\([-=(/)']\\);?\\\\?\\1;g" utzoo!sq!msb, msb@sq.com will fix them... -- Karl Heuer