Merged 2002:2004

This commit is contained in:
Moritz Bunkus 2004-08-21 09:42:38 +00:00
parent c3310655f5
commit 7f656b5108
2 changed files with 20 additions and 3 deletions

View File

@ -1,3 +1,10 @@
2004-08-21 Moritz Bunkus <moritz@bunkus.org>
* mkvmerge: bug fix: Use 'setjmp' and 'longjmp' Instead of
throwing a C++ exception during the chapter parsing
stage. Otherwise libexpat will abort with a non-descriptive error
message on Windows.
2004-08-20 Moritz Bunkus <moritz@bunkus.org>
* mkvmerge: bug fix: SSA/ASS subs with the old codec ID 'S_SSA'

View File

@ -15,6 +15,7 @@
#include <expat.h>
#include <ctype.h>
#include <setjmp.h>
#include <stdarg.h>
#include <string>
@ -42,6 +43,9 @@ typedef struct {
vector<EbmlElement *> *parents;
KaxChapters *chapters;
jmp_buf parse_error_jmp;
string *parse_error_msg;
} parser_data_t;
// {{{ XML chapters
@ -81,7 +85,9 @@ cperror(parser_data_t *pdata,
vsprintf(&new_string[strlen(new_string)], new_fmt.c_str(), ap);
va_end(ap);
strcat(new_string, "\n");
throw error_c(new_string, true);
*pdata->parse_error_msg = new_string;
safefree(new_string);
longjmp(pdata->parse_error_jmp, 1);
}
#define el_get_bool(pdata, el) el_get_uint(pdata, el, 0, true)
@ -731,6 +737,7 @@ parse_xml_chapters(mm_text_io_c *in,
pdata->parser = parser;
pdata->file_name = in->get_file_name();
pdata->parents = new vector<EbmlElement *>;
pdata->parse_error_msg = new string;
XML_SetUserData(parser, pdata);
XML_SetElementHandler(parser, start_element, end_element);
@ -741,6 +748,8 @@ parse_xml_chapters(mm_text_io_c *in,
error = "";
try {
if (setjmp(pdata->parse_error_jmp) == 1)
throw error_c(*pdata->parse_error_msg);
done = !in->getline2(buffer);
while (!done) {
buffer += "\n";
@ -753,8 +762,8 @@ parse_xml_chapters(mm_text_io_c *in,
error += "Remember that special characters like &, <, > and \" "
"must be escaped in the usual HTML way: &amp; for '&', "
"&lt; for '<', &gt; for '>' and &quot; for '\"'. ";
error += "Aborting.";
throw error_c(error.c_str());
error += "Aborting.\n";
throw error_c(error);
}
done = !in->getline2(buffer);
@ -776,6 +785,7 @@ parse_xml_chapters(mm_text_io_c *in,
XML_ParserFree(parser);
delete pdata->parents;
delete pdata->parse_error_msg;
safefree(pdata);
if ((chapters != NULL) && (verbose > 1))