Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #65369

Re: Fgets question

From Richard Damon <Richard@Damon-Family.org>
Newsgroups comp.lang.c
Subject Re: Fgets question
References <0b5d570e-eed5-4162-b5f9-44b2058639ee@googlegroups.com> <lnpp44c1bq.fsf@kst-u.example.com> <kfnfv4u28k0.fsf@x-alumni2.alumni.caltech.edu> <lnr3oepfri.fsf@kst-u.example.com>
Message-ID <93iox.79302$kh3.70861@fx08.iad> (permalink)
Organization Forte - www.forteinc.com
Date 2015-07-11 19:56 -0400

Show all headers | View raw


On 7/11/15 5:04 PM, Keith Thompson wrote:
> Tim Rentsch <txr@alumni.caltech.edu> writes:
>> Keith Thompson <kst-u@mib.org> writes:
> [...]
>>> *However* the description of text streams in 7.21.2 says that a trailing
>>> new-line may be required.  (By implication, if there is no new-line at
>>> the very end of the file, the behavior is undefined.)  [snip]
>>
>> FWIW I think you may be reading that wrongly.  The requirement is not
>> on the program but on the line.  ("Whether the last line requires a
>> terminating new-line character is implementation-defined.")  It's
>> not obvious that leaving off a final new-line was meant to be (or
>> was meant not to be) undefined behavior.
>
> Can you clarify what a requirement *on the line* means?
> Implementations have behavior; lines don't.  I think it's just
> slightly odd wording.  In any case, it's the implementation that
> has to specify whether it's required or not.
>
> If, for a given implementation, the last line doesn't require a
> terminating new-line, writing a text file with no newline and then
> reading it has well defined behavior.  If the last line *does*
> require it, then the standard doesn't say what the behavior of a
> program that omits it is -- thus, undefined behavior.
>

My impression is that these are the requirements to get the promise that 
the input data matches the output data.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Fgets question Paul N <gw7rib@aol.com> - 2015-07-06 14:06 -0700
  Re: Fgets question Barry Schwarz <schwarzb@dqel.com> - 2015-07-06 15:09 -0700
    Re: Fgets question Keith Thompson <kst-u@mib.org> - 2015-07-06 16:41 -0700
      Re: Fgets question Paul N <gw7rib@aol.com> - 2015-07-07 15:16 -0700
  Re: Fgets question Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-07-06 23:13 +0100
    Re: Fgets question Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-07-07 00:57 +0100
  Re: Fgets question Keith Thompson <kst-u@mib.org> - 2015-07-06 16:29 -0700
    Re: Fgets question Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-11 05:16 -0700
      Re: Fgets question Keith Thompson <kst-u@mib.org> - 2015-07-11 14:04 -0700
        Re: Fgets question Richard Damon <Richard@Damon-Family.org> - 2015-07-11 19:56 -0400
        Re: Fgets question Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-15 09:26 -0700
          Re: Fgets question Keith Thompson <kst-u@mib.org> - 2015-07-15 10:42 -0700
            Re: Fgets question Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-20 10:53 -0700
              Re: Fgets question Keith Thompson <kst-u@mib.org> - 2015-07-20 12:51 -0700
                Re: Fgets question Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-24 10:10 -0700
                Re: Fgets question Keith Thompson <kst-u@mib.org> - 2015-07-24 12:15 -0700
                Re: Fgets question Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-26 16:41 -0700
                Re: Fgets question Keith Thompson <kst-u@mib.org> - 2015-07-27 11:42 -0700
                Re: Fgets question Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-30 15:42 -0700

csiph-web