monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Monotone-devel] `mtn cat` garbling Windows newlines


From: Stephen Leake
Subject: Re: [Monotone-devel] `mtn cat` garbling Windows newlines
Date: Tue, 11 Sep 2012 06:04:34 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (windows-nt)

address@hidden writes:

>> [Stephe]
>> The problem does seem to be cmd_files.cc dump_file. It needs
>> to write a
>> file_data object to a std::ostream. What function would you
>> recommend
>> instead of '<<'?
>
> I did manage to get something compiled that passed the test on Linux
> but can't find it now. It was something involving (), c_str() and
> val() on the 'dat' variable (not sure about that one, might have been
> dat()). I didn't commit it in case someone better at C++ had a better
> way.

This compiles:

  string const dat_string = dat.inner()(); // FIXME: debugging
  output.write (dat_string.c_str(), dat.inner()().length());

(The dat_string temp var is not needed; it just aids debugging. It
should be deleted to avoid an extra copy)

But it still puts in the extra 0x0d:

address@hidden dump numbers
numbers:
00000000  310d 0a32 0d0a                          1..2..
address@hidden dump stdout
stdout:
00000000  310d 0d0a 320d 0d0a                     1...2...

Running in the debugger, I can see that the extra 0x0d is comming from
write (or something after it); dat_string contains:

(gdb) x /6xb 0x674555c
0x674555c:      0x31    0x0d    0x0a    0x32    0x0d    0x0a

On the other hand, mtn automate get_file_of also uses dump_file, but it
passes (with the original dump_file):

check(mtn("automate", "get_file_of", "numbers"), 0, true, false)
check(samefile("stdout",  "numbers"))

So the problem is in the output stream, not in dump_file. 'mtn cat' uses
cout, 'mtn automate' uses something else (but I thought it eventually
uses cout; I didn't try to find it).

Since 'mtn automate get_file_of' is just as easy to use as 'mtn cat', I
suggest we document this, and leave it.

It's probably worth keeping the cat_does_not_alter_newlines test, with
an xfail, and the above check on get_file_of. That way, if something
changes, we'll know to update the documentation.

-- 
-- Stephe



reply via email to

[Prev in Thread] Current Thread [Next in Thread]