X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ftex2lyx%2Ftex2lyx.cpp;h=2ef209fc42305fc03731aa0a84da5197c6637535;hb=5bfd1c22d25e992ff0519931e1fb5590fc1e9024;hp=8772d6bea735e3630ab04782ebfd6f435b28b68b;hpb=fa5519d4f06b6d7c6e560d7a60f13bd9a26d9f5b;p=lyx.git diff --git a/src/tex2lyx/tex2lyx.cpp b/src/tex2lyx/tex2lyx.cpp index 8772d6bea7..2ef209fc42 100644 --- a/src/tex2lyx/tex2lyx.cpp +++ b/src/tex2lyx/tex2lyx.cpp @@ -205,7 +205,7 @@ typedef map ModuleMap; ModuleMap modules; -bool addModule(string const module, LayoutFile const & baseClass, LayoutModuleList & m, vector & visited) +bool addModule(string const & module, LayoutFile const & baseClass, LayoutModuleList & m, vector & visited) { // avoid endless loop for circular dependency vector::const_iterator const vb = visited.begin(); @@ -494,7 +494,7 @@ void read_syntaxfile(FileName const & file_name) // modeled after TeX. // Unknown tokens are just silently ignored, this helps us to skip some // reLyX specific things. - Parser p(is); + Parser p(is, string()); while (p.good()) { Token const & t = p.get_token(); if (t.cat() == catEscape) { @@ -519,6 +519,7 @@ void read_syntaxfile(FileName const & file_name) string documentclass; string default_encoding; +bool fixed_encoding = false; string syntaxfile; bool copy_files = false; bool overwrite_files = false; @@ -531,12 +532,13 @@ typedef int (*cmd_helper)(string const &, string const &); int parse_help(string const &, string const &) { - cerr << "Usage: tex2lyx [options] infile.tex [outfile.lyx]\n" + cout << "Usage: tex2lyx [options] infile.tex [outfile.lyx]\n" "Options:\n" "\t-c textclass Declare the textclass.\n" "\t-m mod1[,mod2...] Load the given modules.\n" "\t-copyfiles Copy all included files to the directory of outfile.lyx.\n" "\t-e encoding Set the default encoding (latex name).\n" + "\t-fixedenc encoding Like -e, but ignore encoding changing commands while parsing.\n" "\t-f Force overwrite of .lyx files.\n" "\t-help Print this message and quit.\n" "\t-n translate literate programming (noweb, sweave,... ) file.\n" @@ -561,11 +563,12 @@ int parse_help(string const &, string const &) int parse_version(string const &, string const &) { - lyxerr << "tex2lyx " << lyx_version - << " (" << lyx_release_date << ")" << endl; - lyxerr << "Built on " << __DATE__ << ", " << __TIME__ << endl; + cout << "tex2lyx " << lyx_version + << " (" << lyx_release_date << ")" << endl; + cout << "Built on " << lyx_build_date << ", " << lyx_build_time + << endl; - lyxerr << lyx_version_info << endl; + cout << lyx_version_info << endl; exit(error_code); } @@ -605,6 +608,16 @@ int parse_encoding(string const & arg, string const &) } +int parse_fixed_encoding(string const & arg, string const &) +{ + if (arg.empty()) + error_message("Missing encoding string after -fixedenc switch"); + default_encoding = arg; + fixed_encoding = true; + return 1; +} + + int parse_syntaxfile(string const & arg, string const &) { if (arg.empty()) @@ -686,6 +699,7 @@ void easyParse(int & argc, char * argv[]) cmdmap["-c"] = parse_class; cmdmap["-m"] = parse_module; cmdmap["-e"] = parse_encoding; + cmdmap["-fixedenc"] = parse_fixed_encoding; cmdmap["-f"] = parse_force; cmdmap["-s"] = parse_syntaxfile; cmdmap["-n"] = parse_noweb; @@ -775,6 +789,14 @@ bool roundtripMode() } +string fixedEncoding() +{ + if (fixed_encoding) + return default_encoding; + return ""; +} + + namespace { /*! @@ -803,7 +825,7 @@ bool tex2lyx(idocstream & is, ostream & os, string encoding) } } - Parser p(is); + Parser p(is, fixed_encoding ? default_encoding : string()); p.setEncoding(encoding); //p.dump();