Re: io:lines() and 0円
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: io:lines() and 0円
- From: Sean Conner <sean@...>
- Date: 2014年2月21日 05:28:12 -0500
It was thus said that the Great Francisco Olarte once stated:
>
> >> > How is discarding '015円' any different from mapping "015円012円" to "012円"?
> >> Isn't obvious? The simpler example: '015円' => '', some more:
> >> 'ab015円cd015円012円' => abcd\n vs. ab\rcd\n
How I should have answered that was, "no, that was not obvious to me." In
all my years of programming, I had not come across a text file with both CR
and LF that weren't paired together.
> >> > The problem with that is if the file in question has multiple NUL byte
> >> > runs (enough to fill a buffer, or even an unfortunate alignment where the
> >> > last byte read in the buffer is NUL).
> >> Not an issue. If C guaranteed me fgets would not touch the buffer
> >> after the null, I can fill it with ones, and as I know it MUST have a
> >> null at the end I can scan backwards, the first one is the terminating
> >> null.
>
> > Sigh. That *still* wouldn't work. Assume (for sake of argument) a buffer
> > size of 8 bytes. You fill it with all ones (0xFF):
> > FF FF FF FF FF FF FF FF
> > And you read the following binary file using your version of fgets():
> > 34 89 00 FF 23 08 FF FF
> > So the buffer now contains:
> > 34 89 00 FF 23 08 FF FF
>
> Are you trying to kid me again? My buffer will contain a terminating
> null, that is guaranteed by fgets. Where is it?
My mistake. I am sorry about that.
-spc
- References:
- Re: io:lines() and 0円, René Rebe
- Re: io:lines() and 0円, René Rebe
- Re: io:lines() and 0円, Sean Conner
- Re: io:lines() and 0円, Francisco Olarte
- Re: io:lines() and 0円, Enrico Colombini
- Re: io:lines() and 0円, Francisco Olarte
- Re: io:lines() and 0円, Sean Conner
- Re: io:lines() and 0円, Francisco Olarte
- Re: io:lines() and 0円, Sean Conner
- Re: io:lines() and 0円, Francisco Olarte