[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Monotone-devel] "mtn cat" text/binary impedence mismatch
From: |
Timothy Brownawell |
Subject: |
Re: [Monotone-devel] "mtn cat" text/binary impedence mismatch |
Date: |
Mon, 06 Nov 2006 07:55:24 -0600 |
On Mon, 2006-11-06 at 05:40 -0800, Larry Hastings wrote:
> Brian May wrote:
> > Larry> If I check in a text file on Windows, then use "mtn cat" to
> > Larry> stream it to the console, all the \r\n line endings get
> > Larry> converted into \r\r\n. Maybe it could not do that?
> >
> > Maybe I am mistaken, but I didn't think monotone supported converting
> > text mode formats yet? As in all files are treated as binary on all
> > platforms.
> >
> > In any case, converting \r\n --> \r\r\n seems broken, shouldn't it be
> > converting to just \n?
> >
> Sorry, I should have been more explicit. The problem is that it
> doesn't convert the file, but stdout does.
>
> When mtn.exe writes out a file, it does so in binary mode. However,
> stdout is always implicitly opened in text mode, which on Windows
> means "any time you see \n, write out \r\n". Up go the lights, out go
> the flags, on come the dancers, bang! goes the drum, and now when the
> file contains "\r\n" stdout flushes the "\r", sees the "\n", and
> writes out "\r\n", thus giving you (or me really) "\r\r\n" every
> time... and the show has begun.
>
> I'll try to contribute a fix (using _setmode() on _fileno(stdout)),
> but lacking any sort of build environment it'll be rather like
> building a ship in a bottle. Still, poking around at MinGW header
> files gives me some hope that this will work.
There's a make_io_binary() or somesuch in platform.hh that does that, I
think it's only used for automate right now.
--
Timothy
Free (experimental) public monotone hosting: http://mtn-host.prjek.net