diff --git a/src/extract/xtr_textsubs.cpp b/src/extract/xtr_textsubs.cpp index bb5519a6f..92785d338 100644 --- a/src/extract/xtr_textsubs.cpp +++ b/src/extract/xtr_textsubs.cpp @@ -345,6 +345,14 @@ xtr_usf_c::create_file(xtr_base_c *_master, } else { try { + int end_tag_pos; + string codec_private_mod, end_tag = ""; + + codec_private_mod = m_codec_private; + end_tag_pos = codec_private_mod.find(end_tag); + if (0 <= end_tag_pos) + codec_private_mod.erase(end_tag_pos, end_tag.length()); + out = new mm_file_io_c(file_name, MODE_CREATE); m_formatter = @@ -352,8 +360,7 @@ xtr_usf_c::create_file(xtr_base_c *_master, m_formatter->set_doctype("USFSubtitles", "USFV100.dtd"); m_formatter->set_stylesheet("text/xsl", "USFV100.xsl"); m_formatter->write_header(); - m_formatter->format("\n"); - m_formatter->format(m_codec_private + "\n"); + m_formatter->format(codec_private_mod + "\n"); } catch (mm_io_error_c &error) { mxerror("Failed to create the file '%s': %d (%s)\n", file_name.c_str(), errno, strerror(errno)); diff --git a/src/input/r_usf.cpp b/src/input/r_usf.cpp index c7208953a..7bef6e932 100644 --- a/src/input/r_usf.cpp +++ b/src/input/r_usf.cpp @@ -130,6 +130,8 @@ usf_reader_c::usf_reader_c(track_info_c &_ti) } } + m_private_data += ""; + for (i = 0; m_tracks.size() > i; ++i) { stable_sort(m_tracks[i].m_entries.begin(), m_tracks[i].m_entries.end()); m_tracks[i].m_current_entry = m_tracks[i].m_entries.begin(); @@ -167,10 +169,6 @@ usf_reader_c::start_cb(const char *name, m_previous_start = name; m_parents.push_back(name); - if (1 >= m_parents.size()) - // Nothing to do for the root element. - return; - // Generate the full path to this node. for (i = 0; m_parents.size() > i; ++i) { if (!node.empty()) @@ -203,7 +201,10 @@ usf_reader_c::start_cb(const char *name, return; } - if (node == "USFSubtitles.subtitles") { + if (node == "USFSubtitles") + m_private_data += create_xml_node_name(name, atts); + + else if (node == "USFSubtitles.subtitles") { usf_track_t new_track; m_tracks.push_back(new_track);