API change from 'char *' to 'string' for 'utf8_init'. Hand over '--chapter-charset' to the reader in case it might need it (*cough* OGM *cough*).

This commit is contained in:
Moritz Bunkus 2004-11-21 17:31:37 +00:00
parent e9a04ea4a5
commit 4a48cdb0fc
13 changed files with 22 additions and 14 deletions

View File

@ -374,7 +374,7 @@ parse_cue_chapters(mm_text_io_c *in,
if (in->get_byte_order() == BO_NONE) {
a.do_convert = true;
a.cc_utf8 = utf8_init(charset.c_str());
a.cc_utf8 = utf8_init(charset);
} else {
a.do_convert = false;

View File

@ -214,7 +214,7 @@ parse_simple_chapters(mm_text_io_c *in,
if (in->get_byte_order() == BO_NONE) {
do_convert = true;
cc_utf8 = utf8_init(charset.c_str());
cc_utf8 = utf8_init(charset);
} else
do_convert = false;

View File

@ -541,12 +541,12 @@ add_kax_conv(const char *charset,
}
int
utf8_init(const char *charset) {
utf8_init(const string &charset) {
string lc_charset;
iconv_t ict_from_utf8, ict_to_utf8;
int i;
if ((charset == NULL) || (*charset == 0)) {
if (charset == "") {
setlocale(LC_CTYPE, "");
#if defined(COMP_MINGW) || defined(COMP_MSC)
lc_charset = "CP" + to_string(GetACP());

View File

@ -152,7 +152,7 @@ void MTX_DLL_API put_uint64_be(void *buf, uint64_t value);
extern int MTX_DLL_API cc_local_utf8;
int MTX_DLL_API utf8_init(const char *charset);
int MTX_DLL_API utf8_init(const string &charset);
void MTX_DLL_API utf8_done();
char *MTX_DLL_API to_utf8_c(int handle, const char *local);
inline char *

View File

@ -252,7 +252,7 @@ parse_args(int argc,
if ((i + 1) >= argc)
mxerror(_("'-c' lacks a charset.\n"));
conv_handle = utf8_init(argv[i + 1]);
conv_handle = utf8_init(argv[i + 1] == NULL ? "" : argv[i + 1]);
sub_charset = argv[i + 1];
i++;
@ -405,7 +405,7 @@ main(int argc,
#endif
srand(time(NULL));
utf8_init(NULL);
utf8_init("");
conv_utf8 = utf8_init("UTF-8");
xml_element_map_init();

View File

@ -1891,7 +1891,7 @@ setup() {
textdomain("mkvtoolnix");
#endif
cc_local_utf8 = utf8_init(NULL);
cc_local_utf8 = utf8_init("");
xml_element_map_init();
}

View File

@ -82,7 +82,8 @@ ssa_reader_c::ssa_reader_c(track_info_c *nti)
for (i = 0; i < ti->sub_charsets->size(); i++)
if ((*ti->sub_charsets)[i].id == 0) {
sub_charset_found = true;
cc_utf8 = utf8_init((*ti->sub_charsets)[i].language);
cc_utf8 = utf8_init((*ti->sub_charsets)[i].language == NULL ? "" :
(*ti->sub_charsets)[i].language);
break;
}
@ -90,7 +91,7 @@ ssa_reader_c::ssa_reader_c(track_info_c *nti)
if (mm_io->get_byte_order() != BO_NONE)
cc_utf8 = utf8_init("UTF-8");
else
cc_utf8 = utf8_init(ti->sub_charset);
cc_utf8 = utf8_init(ti->sub_charset == NULL ? "" : ti->sub_charset);
}
ti->id = 0; // ID for this track.

View File

@ -1417,6 +1417,7 @@ parse_args(vector<string> &args) {
"'--chapter-charset %s'.\n"), next_arg.c_str());
chapter_charset = next_arg;
ti->chapter_charset = next_arg;
sit++;
} else if ((this_arg == "--cue-chapter-name-format")) {
@ -1829,7 +1830,7 @@ handle_args(int argc,
if (!strcmp(argv[i], "--command-line-charset")) {
if ((i + 1) == argc)
mxerror(_("'--command-line-charset' is missing its argument.\n"));
cc_command_line = utf8_init(argv[i + 1]);
cc_command_line = utf8_init(argv[i + 1] == NULL ? "" : argv[i + 1]);
i++;
} else
args.push_back(to_utf8(cc_command_line, argv[i]));

View File

@ -1766,7 +1766,7 @@ setup() {
#endif
srand(time(NULL));
cc_local_utf8 = utf8_init(NULL);
cc_local_utf8 = utf8_init("");
cluster_helper = new cluster_helper_c();

View File

@ -1378,6 +1378,8 @@ track_info_c::operator =(const track_info_c &src) {
no_attachments = src.no_attachments;
no_tags = src.no_tags;
chapter_charset = src.chapter_charset;
avi_block_align = src.avi_block_align;
avi_samples_per_sec = src.avi_samples_per_sec;
avi_avg_bytes_per_sec = src.avi_avg_bytes_per_sec;

View File

@ -223,6 +223,10 @@ public:
bool no_chapters, no_attachments, no_tags;
// Some file formats can contain chapters, but for some the charset
// cannot be identified unambiguously (*cough* OGM *cough*).
string chapter_charset;
// The following variables are needed for the broken way of
// syncing audio in AVIs: by prepending it with trash. Thanks to
// the nandub author for this really, really sucky implementation.

View File

@ -1743,7 +1743,7 @@ mmg_app::OnInit() {
uint32_t i;
wxString k, v;
cc_local_utf8 = utf8_init(NULL);
cc_local_utf8 = utf8_init("");
xml_element_map_init();
cfg = new wxConfig(wxT("mkvmergeGUI"));

View File

@ -38,7 +38,7 @@ textsubs_packetizer_c::textsubs_packetizer_c(generic_reader_c *nreader,
recode = nrecode;
if (recode) {
if ((ti->sub_charset != NULL) || !is_utf8)
cc_utf8 = utf8_init(ti->sub_charset);
cc_utf8 = utf8_init(ti->sub_charset == NULL ? "" : ti->sub_charset);
else
cc_utf8 = utf8_init("UTF-8");
}