text I/O: always treat newlines as EOL regardless of detected EOL style

Problematic were files for which DOS-style EOLs were
detected (carriage return followed by newline, \r\n) but which had
some lines terminated solely by a newline (\n). In such a case the
EOL was only detected upon seeing the next \r\n, and the value
returned from the `getline()` function would return something that
everyone would judge to be multiple lines of text.

Fixes #2594.
This commit is contained in:
Moritz Bunkus 2019-08-10 16:00:05 +02:00
parent 5d18a7d804
commit 190827ee5a
No known key found for this signature in database
GPG Key ID: 74AF00ADF2E32C85
4 changed files with 10 additions and 1 deletions

View File

@ -12,6 +12,9 @@
files even if the `clip_codec_identifier` playlist item field is not set to
`M2TS` in the MPLS file. Fixes #2601.
* all: fixed the spelling of the H.264 & H.265 codec names.
* mkvmerge: fixed handling of text files that use both DOS-style and
Unix-style line endings resulting in problems such as text subtitle files
not being parsed correctly. Fixes #2594.
# Version 35.0.0 "All The Love In The World" 2019-06-22

View File

@ -246,7 +246,7 @@ mm_text_io_c::getline(boost::optional<std::size_t> max_chars) {
continue;
}
if ((1 == len) && (utf8char[0] == '\n') && (!p->uses_carriage_returns || previous_was_carriage_return))
if ((1 == len) && (utf8char[0] == '\n'))
return s;
if (previous_was_carriage_return) {

View File

@ -518,3 +518,4 @@ T_669ssa_ass_zero_duration:1bbca62bfcc25b7480e8bbfb228f510e-c34beca52c9bf3eac07c
T_670h265_interlaced:720x480+1920x1080+1920x1080+1920x1080+1920x1080+1920x1080+1920x1080+1920x1080+1920x1080+1920x1080+1920x1080:passed:20190126-134743:0.040331695
T_671emojis:063f1c31e5ba1046edd225f387eb0d81-true:passed:20190312-202232:0.016691955
T_672codec_name:8548fda1649436cf8036dfdb32be369c-true:passed:20190617-195042:0.027569471
T_673srt_different_eol_styles:c1932566efe7110914a21720fc1ac69f:passed:20190810-160539:0.070217493

View File

@ -0,0 +1,5 @@
#!/usr/bin/ruby -w
# T_673srt_different_eol_styles
describe "mkvmerge / SRT text subtitles with both DOS & Unix style line endings"
test_merge "data/subtitles/srt/different_eol_styles.srt", :exit_code => :warning