This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: BUG: alternatives


IIRC, this idiom is not uncommon.  For example, I believe bash reads
.bash_history using the same sort of "read it all at once, assuming no
translation is needed between disk and memory representations".  Perhaps
you could do whatever was done there for consistency.  Of course, if
nothing was done there, that suggests (3) document (or re-emphasize, for
alternatives, or more generally, for Cygwin) that config files read by a
variety of tools require binary mounts.

Yeah, I'm being lame this morning, offering just speculation and vague
recollections.  Mostly, what I'd suggest is "be consistent with
solutions for other instances of this problem".

stephan();


-----Original Message-----
From: cygwin-owner@cygwin.com [mailto:cygwin-owner@cygwin.com] On Behalf
Of Charles Wilson
Sent: Saturday, November 05, 2005 10:12 AM
To: CygWin
Subject: Re: BUG: alternatives

Gary R. Van Sickle wrote:
> More investigation reveals that it's textmode mounts that alternatives
> doesn't like, not necessarily (although almost certainly as well as)
\r\n
> line endings.
> 

I'm pretty sure the problem is here:

     if (read(fd, buf, sb.st_size) != sb.st_size) {
         close(fd);
         fprintf(stderr, _("failed to read %s: %s\n"), path,
                 strerror(errno));
         return 1;
     }

Since one effect of 'textmode' conversions is that the bytecount "read" 
differs from the size reported by the filesystem, textmode files will 
always fail this test.

(1) I could remove this test -- but then you lose the error checking 
it's attempting to do: make sure the entire file was read into buf, and 
nothing was lost.

(2) I could always open the file in binmode, and change the parseLine 
routine to ignore trailing '\r' on each line. (We'll assume that no 
alternatives config file will ever contain a vertical-feed character).

Suggestions?

--
Chuck


--
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/


--
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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]