# # patch "ChangeLog" # from [907e3d003a8021a1698fe9119f5f71e61a94658e] # to [61d04ec10a23b1a5260b472132f26c27877bb020] # # patch "file_io.cc" # from [9507250333f6a8542fdfbe4268786ee068e22c16] # to [e78d02521cffd8f4d5c3d2f312d2f137d5674be9] # # patch "tests/t_lf_crlf.at" # from [5c7f37f18e1ae4e195a4f7581145705d390e1747] # to [e7fdfaf92b9f90899551f4a77a36487a1e7cf537] # # patch "transforms.cc" # from [2a581089c4ae9455d8617a0f5d540033c3e8d085] # to [7c75b6c118e849c06ac04466a1546ac2b152c1a4] # --- ChangeLog +++ ChangeLog @@ -1,3 +1,12 @@ +2005-04-19 Emile Snyder + + * file_io.cc: Fix bugs with read/write_localized_data when using + CRLF line ending conversion. + * transforms.cc: Fix line_end_convert to add correct end of line + string if the split_into_lines() call causes us to lose one from + the end. + * tests/t_lf_crlf.at: Clean up and no longer XFAIL. + 2005-04-19 Sebastian Spaeth * monotone.texi: modified documentation to match changes due to --- file_io.cc +++ file_io.cc @@ -459,11 +459,15 @@ string tmp1, tmp2; tmp2 = tdat(); - if (do_charconv) - charset_convert(ext_charset, db_charset, tmp1, tmp2); - tmp1 = tmp2; - if (do_lineconv) - line_end_convert(db_linesep, tmp1, tmp2); + if (do_charconv) { + tmp1 = tmp2; + charset_convert(ext_charset, db_charset, tmp1, tmp2); + } + L(F("read_localized_data: from path '%s' got data\n%s\n") % path % tmp1); + if (do_lineconv) { + tmp1 = tmp2; + line_end_convert(db_linesep, tmp1, tmp2); + } dat = tmp2; } @@ -545,11 +549,15 @@ string tmp1, tmp2; tmp2 = dat(); - if (do_lineconv) - line_end_convert(ext_linesep, tmp1, tmp2); - tmp1 = tmp2; - if (do_charconv) - charset_convert(db_charset, ext_charset, tmp1, tmp2); + L(F("write_localized_data: from path '%s' got data\n%s\n") % path % tmp2); + if (do_lineconv) { + tmp1 = tmp2; + line_end_convert(ext_linesep, tmp1, tmp2); + } + if (do_charconv) { + tmp1 = tmp2; + charset_convert(db_charset, ext_charset, tmp1, tmp2); + } write_data(path, data(tmp2)); } --- tests/t_lf_crlf.at +++ tests/t_lf_crlf.at @@ -1,44 +1,40 @@ AT_SETUP([use get_linesep_conv hook]) MONOTONE_SETUP -NEED_UNB64 -# This test is a bug report. -AT_XFAIL_IF(true) - # This test excercises the common case of wanting to do newline # character conversion so that win32 users can have native line endings # in their working copies. +AT_CHECK(printf "foo\r\n", [], [stdout]) +AT_CHECK(mv stdout foo.crlf) -# wrote files with 'foo\r\n' and 'foo\r\nfoo\r\n' and used mimencode -# to generate the following b64 encoded contents. -# -# Note the newline before the closing ']', it's necessary. -# -AT_DATA(foo.lfcr.b64, [Zm9vDQo= -]) -AT_DATA(foofoo.lfcr.b64, [Zm9vDQpmb28NCg== -]) +AT_CHECK(printf "foo\r\nfoo\r\n", [], [stdout]) +AT_CHECK(mv stdout foofoo.crlf) -UNB64(foo.lfcr.b64, foo.lfcr) -UNB64(foofoo.lfcr.b64, foofoo.lfcr) - -AT_DATA(linesep.lua, [ +AT_DATA(linesep.conv.lua, [ function get_linesep_conv(name) return {"LF", "CRLF"} end ]) -AT_CHECK(cp foo.lfcr foo, [], [ignore], [ignore]) -AT_CHECK(MONOTONE --rcfile=linesep.lua add foo, [], [ignore], [ignore]) -AT_CHECK(MONOTONE --rcfile=linesep.lua --branch=foo commit -m foo, [], [ignore], [ignore]) +AT_DATA(linesep.null.lua, []) + +AT_CHECK(cp linesep.conv.lua linesep.lua) + +AT_CHECK(cp foo.crlf foo, [], [ignore], [ignore]) +AT_CHECK(MONOTONE --debug --rcfile=linesep.lua add foo, [], [], [stderr]) +AT_CHECK(mv stderr log.0) +AT_CHECK(MONOTONE --debug --rcfile=linesep.lua --branch=foo commit -m foo, [], [ignore], [stderr]) +AT_CHECK(mv stderr log.1) FOO_REV=`BASE_REVISION` -AT_CHECK(cp foofoo.lfcr foo, [], [ignore], [ignore]) -AT_CHECK(MONOTONE --rcfile=linesep.lua commit -m foofoo, [], [ignore], [ignore]) +AT_CHECK(cp foofoo.crlf foo, [], [ignore], [ignore]) +AT_CHECK(MONOTONE --debug --rcfile=linesep.lua commit -m foofoo, [], [ignore], [stderr]) +AT_CHECK(mv stderr log.2) FOO_FOO_REV=`BASE_REVISION` -AT_CHECK(MONOTONE --rcfile=linesep.lua update $FOO_REV, [], [ignore], [ignore]) -AT_CHECK(cmp foo foo.lfcr, [], [ignore], [ignore]) +AT_CHECK(MONOTONE --debug --rcfile=linesep.lua update $FOO_REV, [], [ignore], [stderr]) +AT_CHECK(mv stderr log.3) +AT_CHECK(cmp foo foo.crlf, [], [ignore], [ignore]) AT_CLEANUP --- transforms.cc +++ transforms.cc @@ -675,9 +675,8 @@ vector tmp; split_into_lines(src, tmp); join_lines(tmp, dst, linesep_str); - if (src.size() >= 1 && - (src[src.size() - 1] == '\r' || - src[src.size() - 1] == '\n')) + if (src.size() >= linesep.size() && + (src.compare(src.size() - linesep.size(), linesep.size(), linesep) == 0)) dst += linesep_str; }