<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><font color="#0000ff">Branden Robin wrote:</font></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr"><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><font color="#000000">>> info groff gives semantics for including nonempty files that don't end<br>
>> with newline. Such files violate the <span style="background-color:rgb(0,255,0)">Posix definition of text file.</span></font></blockquote><div><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><font color="#0000ff">Not so fast.   POSIX does not define a text file (that's an ANSI C-ism - thank you DOS -- more in minute). </font></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><font color="#0000ff"><br></font></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><font color="#0000ff">Even in the original POSIX definition we were very careful to >>never<< do that abomination.  What the current POSIX specs says is:</font></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><font color="#0000ff"><br></font></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_quote gmail_quote_container"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><font color="#ff0000">3.164 File</font></div></div><div class="gmail_quote gmail_quote_container"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><font color="#ff0000">An object that can be written to, or read from, or both. A file has certain attributes, including access permissions and type. File types include <span style="background-color:rgb(255,255,0)">regular file,</span> character special file, block special file, FIFO special file, symbolic link, socket, and directory. <span style="background-color:rgb(255,255,0)">Other types of files may be supported by the implementation.</span></font></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><font color="#ff0000"><br></font></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><font color="#ff0000">....</font></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><font color="#ff0000"><br></font></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><font color="#ff0000">3.317 Regular File<br>A file that is a randomly accessible sequence of bytes, <span style="background-color:rgb(255,255,0)">with no further structure imposed by the system.</span></font></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><font color="#ff0000"><span style="background-color:rgb(255,255,0)"><br></span></font></div></div></blockquote><span class="gmail_default" style=""><font color="#ff0000" style="font-family:arial,helvetica,sans-serif"></font><font color="#0000ff" style="font-family:arial,helvetica,sans-serif">In fact, nowhere in the term "text file" defined (or used — search for it) in the POSIX standard. </font></span><font face="arial, helvetica, sans-serif" style="color:rgb(0,0,255)">  The problem is that at the same time, ANSI </font><span class="gmail_default" style="color:rgb(0,0,255);font-family:arial,helvetica,sans-serif">C </span><font face="arial, helvetica, sans-serif" style="color:rgb(0,0,255)">was being defined in the early 1980s  The DOS weenies wanted to support the silly two characters line terminations and old notion of </font><span class="gmail_default" style="color:rgb(0,0,255);font-family:arial,helvetica,sans-serif">a</span> <span class="gmail_default" style="color:rgb(0,0,255);font-family:arial,helvetica,sans-serif">structured </span><font face="arial, helvetica, sans-serif" style="color:rgb(0,0,255)">"text file"</font><span class="gmail_default" style="color:rgb(0,0,255);font-family:arial,helvetica,sans-serif"> which PC/MS-DOS had inherited from the DEC and IBM OS's of 1960s and what IBM has called "access methods" in the old days (in UNIX everything is just a stream of bytes thank you or in Multics, everything is segment).</span><font face="arial, helvetica, sans-serif" style="color:rgb(0,0,255)">  The UNIX folks on the C committee were very much against </font><span class="gmail_default" style="color:rgb(0,0,255);font-family:arial,helvetica,sans-serif">adding the support — which Lattice C for MS-DOS had added at the time but happened to be the most popular C compiler for the DOS</span><font face="arial, helvetica, sans-serif" style="color:rgb(0,0,255)"> </font><span class="gmail_default" style="color:rgb(0,0,255);font-family:arial,helvetica,sans-serif">target and the number of user of the compiler  was growing extremely rapidly.  They were also pushing for things like the </span><span class="gmail_default" style=""><font face="monospace" style="" color="#38761d">near</font><font style="" face="arial, sans-serif" color="#0000ff"> and </font><font face="monospace" style="" color="#38761d">far</font></span><span class="gmail_default" style="color:rgb(0,0,255);font-family:arial,helvetica,sans-serif"> keywords.  I</span><font face="arial, helvetica, sans-serif" style="color:rgb(0,0,255)">t was quite a fight</font><span class="gmail_default" style="color:rgb(0,0,255);font-family:arial,helvetica,sans-serif"> in the C community.</span><font face="arial, helvetica, sans-serif" style="color:rgb(0,0,255)"> </font><span class="gmail_default" style="color:rgb(0,0,255);font-family:arial,helvetica,sans-serif">(It was one of the additions that caused Dennis to quip: <i>"</i></span><i><font color="#0000ff">When I read commentary about suggestions for where C should go, I often think back and give thanks that it wasn't developed under the advice of a worldwide crowd.<span class="gmail_default" style="font-family:arial,helvetica,sans-serif">"</span></font></i><div><font color="#0000ff" style="font-family:arial,helvetica,sans-serif"><br></font></div><div><font color="#0000ff" style="font-family:arial,helvetica,sans-serif"><span class="gmail_default" style="font-family:arial,helvetica,sans-serif">Anyway, t</span>he <span class="gmail_default" style="font-family:arial,helvetica,sans-serif">UNIX folk had to decide which eveils the DOS folks were pushes they could live with and a </span>compromise was the creation of the new</font><font face="monospace" color="#38761d"> "rb" "wb" "ab"</font><font color="#0000ff" style="font-family:arial,helvetica,sans-serif"> crud in the </font><font color="#38761d" face="monospace">fopen(3)</font><font style=""><font color="#0000ff" style="font-family:arial,helvetica,sans-serif"> call</font><span class="gmail_default" style=""><font color="#0000ff" style="font-family:arial,helvetica,sans-serif"> since we you use </font><font color="#38761d" style="" face="monospace">"r", "w", "b" </font></span></font><span style="font-family:arial,helvetica,sans-serif;color:rgb(0,0,255)"><span class="gmail_default" style="font-family:arial,helvetica,sans-serif">as because POSIX allows UNIX to </span><span class="gmail_default" style="font-family:arial,helvetica,sans-serif">open a what ANSI C called a "text file" since there no such thing under POSIX.</span></span><div><font color="#0000ff" face="arial, helvetica, sans-serif"><br></font><div><div><div><font color="#0000ff" face="arial, helvetica, sans-serif"><span class="gmail_default" style="font-family:arial,helvetica,sans-serif">But in</span><span class="gmail_default" style="font-family:arial,helvetica,sans-serif"> the ANSI C spec (which, remember, is >>only<< for C source code), it says:</span></font></div><div><font color="#0000ff" face="arial, helvetica, sans-serif"><span class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></span></font></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font color="#ff0000">5.2.1 Character sets</font></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><font color="#ff0000">.... <span style="font-family:Arial,Helvetica,sans-serif">The representation of each member of the source and execution basic character sets shall fit in a byte.</span></font></div><font color="#ff0000">In both the source and execution basic character sets, the value of each character after 0 in the above<br>list of decimal digits shall be one greater than the value of the previous. <span style="background-color:rgb(255,255,0)">In source files, there shall<br>be some way of indicating the end of each line of text; this International Standard treats such an<br>end-of-line indicator as if it were a single new-line character. </span>In the basic execution character set,<br>there shall be control characters representing alert, backspace, carriage return, and new line. If any<br>other characters are encountered in a source file (except in an identifier, a character constant, a string<br>literal, a header name, a comment, or a preprocessing token that is never converted to a token), the<br>behavior is undefined.</font><br></div><div><font color="#ff0000" style="background-color:rgb(255,255,255)"><br></font></div></blockquote><span class="gmail_default" style="font-family:arial,helvetica,sans-serif;background-color:rgb(255,255,255)"><font color="#0000ff" style="">The key point in the highlighted text in ANSI C is that it does not <b>require it</b>.   A problem in the  ANSI C standard is that does >>use<< the term "text file" although ANSI C never really defines what one is (and probably could not because of the fight - UNIX would have said -- nope -- no structure required.  ANSI C does say in:<br></font></span></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><span class="gmail_default" style="font-family:arial,helvetica,sans-serif;background-color:rgb(255,255,255)"><font color="#ff0000">7.21.2 Streams</font></span></div><div><span class="gmail_default" style="font-family:arial,helvetica,sans-serif;background-color:rgb(255,255,255)"><font color="#ff0000">...</font></span></div><div><span class="gmail_default" style="font-family:arial,helvetica,sans-serif;background-color:rgb(255,255,255)"><font color="#ff0000">Environmental limits<br>An implementation shall support text files with lines containing at least 254 characters, including<br>the terminating new-line character. The value of the macro BUFSIZ shall be at least 256.</font></span></div></blockquote><span class="gmail_default" style=""><font color="#0000ff" style="font-family:arial,helvetica,sans-serif">The whole compromise was that you did not have to use termination of type. If the concept of a '</font>textfile<font color="#0000ff" style="font-family:arial,helvetica,sans-serif">" is local to the implementation. UNIX folks get to keep doing things as they did before, so if you used fopen with </font><font color="#38761d" style="font-family:arial,helvetica,sans-serif">"r"</font><font color="#0000ff" style="font-family:arial,helvetica,sans-serif"> or </font><font color="#38761d" style="" face="monospace">"w"</font><font color="#0000ff" style="font-family:arial,helvetica,sans-serif"> </font>its<font color="#0000ff" style="font-family:arial,helvetica,sans-serif"> up to the program to worry about the format of the file "access modes" from the 1960s were not needed.</font></span></div></div></div></div><div hspace="streak-pt-mark" style="max-height:1px"><img alt="" style="width:0px;max-height:0px;overflow:hidden" src="https://mailfoogae.appspot.com/t?sender=aY2xlbWNAY2NjLmNvbQ%3D%3D&type=zerocontent&guid=128503f1-d113-4b43-9ec5-056e60095edc"><font color="#ffffff" size="1">ᐧ</font></div>