Mail Archives: cygwin/2005/06/24/14:17:23
On Fri, 24 Jun 2005, Igor Pechtchanski wrote:
> On Fri, 24 Jun 2005, Herb Martin wrote:
>
> > > >My suspicion is that stat is counting cr-lf as two characters but the
> > > >input routines are treating these as one.
> > > >
> > > >If the file has about 20 lines, then that's 20 missing characters???
> > >
> > > Yes, this is right. And yes, this could be the cause of the
> > > situation you're noticing.
> >
> > Is there a standard Cygwin 'idiom' or function for dealing with this
> > mismatch, or should I just re-invent the wheel.
>
> Sure -- just force binary mode on the file (i.e., open it using O_BINARY
> for the open() call, or the "rb" mode for the fopen() call). The mount
> type only applies if the mode is unspecified.
A clarification: force binary mode on the opened file in your program, not
the actual on-disk data.
Note that if you do that, you'd also need to handle the CR ('\r', or 0x0d)
characters explicitly in your program.
HTH,
Igor
--
http://cs.nyu.edu/~pechtcha/
|\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT com
|,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D.
'---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow!
"The Sun will pass between the Earth and the Moon tonight for a total
Lunar eclipse..." -- WCBS Radio Newsbrief, Oct 27 2004, 12:01 pm EDT
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -