Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Subject: RE: BUG: alternatives Date: Sat, 5 Nov 2005 11:06:31 -0800 Message-ID: From: "Stephan Mueller" To: "Charles Wilson" , "CygWin" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id jA5JBXUu025530 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 AT cygwin DOT com [mailto:cygwin-owner AT cygwin DOT 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/