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


Groups > comp.lang.c > #65342

Re: Fgets question

Path csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Fgets question
Date Sat, 11 Jul 2015 14:04:49 -0700
Organization None to speak of
Lines 29
Message-ID <lnr3oepfri.fsf@kst-u.example.com> (permalink)
References <0b5d570e-eed5-4162-b5f9-44b2058639ee@googlegroups.com> <lnpp44c1bq.fsf@kst-u.example.com> <kfnfv4u28k0.fsf@x-alumni2.alumni.caltech.edu>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Injection-Info mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="18098"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX184KM60mUm1rE6Uul4WGMDa"
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
Cancel-Lock sha1:uUrIQMYN34hc/gZ1aIEcUm6qpnQ= sha1:3phFv4JRfBXbywxLu/LeYJolzDc=
Xref csiph.com comp.lang.c:65342

Show key headers only | View raw


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.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

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