monotone-devel
[Top][All Lists]
Advanced

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

Re: [Monotone-devel] Re: Bug in CRLF conversions


From: Richard Levitte - VMS Whacker
Subject: Re: [Monotone-devel] Re: Bug in CRLF conversions
Date: Sun, 29 Jan 2006 20:54:03 +0100 (CET)

In message <address@hidden> on Sun, 29 Jan 2006 14:03:18 -0500, Yury Polyanskiy 
<address@hidden> said:

ypolyans> The behavior is unexpected in two aspects (as I said before):
ypolyans>  1) split_lines(), join_lines() adds \n to the end of file
ypolyans>     if it lacked one
ypolyans>  2) LF->CRLF translation is done in irreversible way: lone
ypolyans>     \r's are replaced by \r\n and thus can not be repaired
ypolyans>     by "monotone commit".

The two line endings returned by get_linesep_conv() are only used when
writing the files.  When reading them (at least when reading them from
the workspace), monotone is trying to be smart and looks for all kinds
of line ends when it splits lines.  \r, \n and \r\n are treated the
same.

ypolyans> Proposal: make line_end_convert() simply do a (just to
ypolyans> illustrate idea, using strcat is dumb of course):
ypolyans> 
ypolyans>    b = file;
ypolyans>    while(b && *b){
ypolyans>       e = strstr(b, linesep_old);
ypolyans>       if(e){ *e = 0; e += strlen(linesep_old); };
ypolyans>       strcat(file_new, b);
ypolyans>       strcat(file_new, linesep_new);
ypolyans>       b = e;
ypolyans>    }
ypolyans> 
ypolyans> My question: if the behavior of line_end_convert() is
ypolyans> changed this way will that ruin something else for somebody?
ypolyans> And if not can it be please included in official release?

For the moment, there is no 'linesep_old'.  That's not how it is
defined.  And really, for a text file, there's no harm at all
converting all kinds of line endings to the one that the target area
(the database or the workspace) should have.  The danger is that we
don't properly recognise binary files internally, and mess them up
hugely as soon as the internal and external linesep aren't the same.

If you want to focus on something, I'd focus on getting monotone to
handle binary files in a better way (as in, at all).

Cheers,
Richard

-----
Please consider sponsoring my work on free software.
See http://www.free.lp.se/sponsoring.html for details.

-- 
Richard Levitte                         address@hidden
                                        http://richard.levitte.org/

"When I became a man I put away childish things, including
 the fear of childishness and the desire to be very grown up."
                                                -- C.S. Lewis




reply via email to

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