|
Prev: The map function
Next: FAQ 1.1 What is Perl?
From: Martijn Lievaart on 20 Apr 2008 17:47 On Sun, 20 Apr 2008 15:07:55 -0500, brian d foy wrote: > In article <fudqbu021qf(a)news4.newsguy.com>, szr <szrRE(a)szromanMO.comVE> > wrote: > >> Jürgen Exner wrote: > >> > No. It is a different way of saying "If there is stuff after the last >> > newline then that stuff doesn't constitute a proper line..." >> >> I don't recall there being any sort of rule saying a text file's last >> character /has/ to be a line terminator, though I can see how it would >> seem better formed if it does. > > There's no rule for it, but a lot of things expect it. Just Google "no > newline at end of file" to see for yourelf. As I understand it, this has always been the rule in unixy environments. I even think that Dos/Windows is the exception to the rule, and (almost) all other environments need a line terminator after the last line, but I'm not to sure about that. And it makes sens. it's a line terminator, not a line separator.... M4
From: A. Sinan Unur on 20 Apr 2008 19:37 brian d foy <brian.d.foy(a)gmail.com> wrote in news:200420081507550257%brian.d.foy(a)gmail.com: > In article <fudqbu021qf(a)news4.newsguy.com>, szr > <szrRE(a)szromanMO.comVE> wrote: > >> J�rgen Exner wrote: > >> > No. It is a different way of saying "If there is stuff after >> > the last newline then that stuff doesn't constitute a proper >> > line..." >> >> I don't recall there being any sort of rule saying a text file's >> last character /has/ to be a line terminator, though I can see >> how it would seem better formed if it does. > > There's no rule for it, but a lot of things expect it. Just > Google "no newline at end of file" to see for yourelf. AFAIK, the C standard requires lines in text files to be terminated with the platform specific newline character sequence. Sinan -- A. Sinan Unur <1usa(a)llenroc.ude.invalid> (remove .invalid and reverse each component for email address) comp.lang.perl.misc guidelines on the WWW: http://www.rehabitation.com/clpmisc/
From: J�rgen Exner on 20 Apr 2008 20:14 "szr" <szrRE(a)szromanMO.comVE> wrote: >I don't recall there being any sort of rule saying a text file's last >character /has/ to be a line terminator, Well, it's really the question of if the newline is a seperator or a terminator. If you consider it to be a line separator then you don't need a closing newling. If you consider it to be a line terminator, then a line without its terminator wouldn't be well formed. > though I can see how it would seem better formed if it does. There are tools and even editors which won't work properly if the last line is not terminated properly. jue
From: Peter J. Holzer on 24 Apr 2008 08:57
On 2008-04-19 22:05, szr <szrRE(a)szromanMO.comVE> wrote: > I don't recall there being any sort of rule saying a text file's last > character /has/ to be a line terminator, though I can see how it would > seem better formed if it does. IEEE Standard 1003.1 (aka POSIX) defines "line" as: | 3.205 Line | | A sequence of zero or more non- <newline>s plus a terminating | <newline>. And "text file" as: | 3.392 Text File | | A file that contains characters organized into one or more lines. The | lines do not contain NUL characters and none can exceed {LINE_MAX} | bytes in length, including the <newline>. Although IEEE Std | 1003.1-2001 does not distinguish between text files and binary files | (see the ISO C standard), many utilities only produce predictable or | meaningful output when operating on text files. The standard utilities | that have such restrictions always specify "text files" in their STDIN | or INPUT FILES sections. Sinan already mentioned the C standard, but that doesn't specify how files are represented on disk - a text file could be a series of fixed or variable length records without any "newline characters" at all, as long as the stdio library performs the necessary conversions. hp |