Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Method other than strlen to check for truncation with fgets? |
| Date | 2015-05-07 08:49 -0700 |
| Organization | None to speak of |
| Message-ID | <87sib8jskj.fsf@kst-u.example.com> (permalink) |
| References | <midqe0$62n$1@dont-email.me> <mieros$th2$1@speranza.aioe.org> <87fv788yrv.fsf@bsb.me.uk> |
Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
> Lőrinczy Zsigmond <nospam@for.me> writes:
>> On 2015.05.06. 21:35, mathog wrote:
>>> If fgets reads a line larger than the buffer then the
>>> buffer will end with "...\0" instead of the usual
>>> "...\n\0". This is usually handled something like:
>>
>> The input might contain \0 so this method is unreliable.
>
> The method is reliable even if there are nulls in the input (provided
> fgets processes them just like any other character).
But fgets is not required to do so.
N1570 7.21.2:
Data read in from a text stream will necessarily compare equal to
the data that were earlier written out to that stream only if:
the data consist only of printing characters and the control
characters horizontal tab and new-line; no new-line character
is immediately preceded by space characters; and the last
character is a new-line character. Whether space characters
that are written out immediately before a new-line character
appear when read in is implementation-defined.
--
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
Method other than strlen to check for truncation with fgets? mathog <dmathog@gmail.com> - 2015-05-06 12:35 -0700
Re: Method other than strlen to check for truncation with fgets? Barry Schwarz <schwarzb@dqel.com> - 2015-05-06 15:14 -0700
Re: Method other than strlen to check for truncation with fgets? mathog <dmathog@gmail.com> - 2015-05-06 16:14 -0700
Re: Method other than strlen to check for truncation with fgets? Barry Schwarz <schwarzb@dqel.com> - 2015-05-06 17:51 -0700
Re: Method other than strlen to check for truncation with fgets? Tim Rentsch <txr@alumni.caltech.edu> - 2015-05-06 18:23 -0700
Re: Method other than strlen to check for truncation with fgets? mathog <dmathog@gmail.com> - 2015-05-07 10:07 -0700
Re: Method other than strlen to check for truncation with fgets? Tim Rentsch <txr@alumni.caltech.edu> - 2015-05-07 16:06 -0700
Re: Method other than strlen to check for truncation with fgets? James Kuyper <jameskuyper@verizon.net> - 2015-05-06 22:20 -0400
Re: Method other than strlen to check for truncation with fgets? mathog <dmathog@gmail.com> - 2015-05-07 10:29 -0700
Re: Method other than strlen to check for truncation with fgets? James Kuyper <jameskuyper@verizon.net> - 2015-05-07 14:09 -0400
Re: Method other than strlen to check for truncation with fgets? mathog <dmathog@gmail.com> - 2015-05-07 12:48 -0700
Re: Method other than strlen to check for truncation with fgets? James Kuyper <jameskuyper@verizon.net> - 2015-05-07 17:01 -0400
Re: Method other than strlen to check for truncation with fgets? mathog <dmathog@gmail.com> - 2015-05-08 10:59 -0700
Re: Method other than strlen to check for truncation with fgets? James Kuyper <jameskuyper@verizon.net> - 2015-05-08 14:48 -0400
Re: Method other than strlen to check for truncation with fgets? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-05-08 18:37 +0000
Re: Method other than strlen to check for truncation with fgets? James Kuyper <jameskuyper@verizon.net> - 2015-05-08 15:06 -0400
Re: Method other than strlen to check for truncation with fgets? Lőrinczy Zsigmond <nospam@for.me> - 2015-05-07 07:04 +0200
Re: Method other than strlen to check for truncation with fgets? Richard Heathfield <rjh@cpax.org.uk> - 2015-05-07 06:52 +0100
Re: Method other than strlen to check for truncation with fgets? Lőrinczy Zsigmond <zsiga@nospam.for.me> - 2015-05-07 09:58 +0200
Re: Method other than strlen to check for truncation with fgets? Stephen Sprunk <stephen@sprunk.org> - 2015-05-07 09:12 -0500
Re: Method other than strlen to check for truncation with fgets? Keith Thompson <kst-u@mib.org> - 2015-05-07 08:51 -0700
Re: Method other than strlen to check for truncation with fgets? Lőrinczy Zsigmond <zsiga@nospam.for.me> - 2015-05-07 19:09 +0200
Re: Method other than strlen to check for truncation with fgets? James Kuyper <jameskuyper@verizon.net> - 2015-05-07 14:15 -0400
Re: Method other than strlen to check for truncation with fgets? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-07 11:31 +0100
Re: Method other than strlen to check for truncation with fgets? Lőrinczy Zsigmond <zsiga@nospam.for.me> - 2015-05-07 15:41 +0200
Re: Method other than strlen to check for truncation with fgets? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-08 02:44 +0100
Re: Method other than strlen to check for truncation with fgets? James Kuyper <jameskuyper@verizon.net> - 2015-05-07 23:24 -0400
Re: Method other than strlen to check for truncation with fgets? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-08 04:41 +0100
Re: Method other than strlen to check for truncation with fgets? Keith Thompson <kst-u@mib.org> - 2015-05-07 08:49 -0700
Re: Method other than strlen to check for truncation with fgets? James Kuyper <jameskuyper@verizon.net> - 2015-05-07 12:19 -0400
Re: Method other than strlen to check for truncation with fgets? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-05-07 18:08 +0000
Re: Method other than strlen to check for truncation with fgets? James Kuyper <jameskuyper@verizon.net> - 2015-05-07 12:19 -0400
Re: Method other than strlen to check for truncation with fgets? mathog <dmathog@gmail.com> - 2015-05-07 09:57 -0700
Re: Method other than strlen to check for truncation with fgets? Siri Cruz <chine.bleu@yahoo.com> - 2015-05-07 11:31 -0700
Re: Method other than strlen to check for truncation with fgets? Keith Thompson <kst-u@mib.org> - 2015-05-07 12:00 -0700
Re: Method other than strlen to check for truncation with fgets? Siri Cruz <chine.bleu@yahoo.com> - 2015-05-07 12:44 -0700
Re: Method other than strlen to check for truncation with fgets? Keith Thompson <kst-u@mib.org> - 2015-05-07 14:03 -0700
Re: Method other than strlen to check for truncation with fgets? Siri Cruz <chine.bleu@yahoo.com> - 2015-05-07 15:28 -0700
csiph-web