Changeset 27592
- Timestamp:
- 11/16/08 22:51:18 (2 months ago)
- Files:
-
- lyx-devel/trunk/src/Encoding.cpp (modified) (4 diffs)
- lyx-devel/trunk/src/tex2lyx/Makefile.am (modified) (1 diff)
- lyx-devel/trunk/src/tex2lyx/Parser.cpp (modified) (2 diffs)
- lyx-devel/trunk/src/tex2lyx/Parser.h (modified) (1 diff)
- lyx-devel/trunk/src/tex2lyx/preamble.cpp (modified) (4 diffs)
- lyx-devel/trunk/src/tex2lyx/tex2lyx.cpp (modified) (5 diffs)
- lyx-devel/trunk/src/tex2lyx/text.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
lyx-devel/trunk/src/Encoding.cpp
r27425 r27592 514 514 void Encodings::initUnicodeMath(Buffer const & buffer) 515 515 { 516 #ifdef TEX2LYX 517 // The code below is not needed in tex2lyx and requires additional stuff 518 (void)buffer; 519 #else 516 520 mathcmd.clear(); 517 521 textcmd.clear(); … … 524 528 for (; it != end; ++it) 525 529 it->initUnicodeMath(); 530 #endif 526 531 } 527 532 … … 529 534 void Encodings::validate(char_type c, LaTeXFeatures & features, bool for_mathed) 530 535 { 536 #ifdef TEX2LYX 537 // The code below is not needed in tex2lyx and requires additional stuff 538 (void)c; 539 (void)features; 540 (void)for_mathed; 541 #else 531 542 CharInfoMap::const_iterator const it = unicodesymbols.find(c); 532 543 if (it != unicodesymbols.end()) { … … 567 578 features.require("lyxmathsym"); 568 579 } 580 #endif 569 581 } 570 582 lyx-devel/trunk/src/tex2lyx/Makefile.am
r27573 r27592 42 42 ../lengthcommon.cpp \ 43 43 ../Color.cpp \ 44 ../Color.h 44 ../Color.h \ 45 ../Encoding.cpp 45 46 46 47 BUILT_SOURCES = $(PCH_FILE) lyx-devel/trunk/src/tex2lyx/Parser.cpp
r27563 r27592 11 11 #include <config.h> 12 12 13 #include "Encoding.h" 13 14 #include "Parser.h" 14 15 … … 147 148 { 148 149 delete iss_; 150 } 151 152 153 void Parser::setEncoding(std::string const & e) 154 { 155 Encoding const * enc = encodings.fromLaTeXName(e); 156 cerr << "setting encoding to " << enc->iconvName(); 157 is_ << lyx::setEncoding(enc->iconvName()); 149 158 } 150 159 lyx-devel/trunk/src/tex2lyx/Parser.h
r27563 r27592 120 120 ~Parser(); 121 121 122 /// change the encoding of the input stream 123 void setEncoding(std::string const & encoding); 124 122 125 /// 123 126 int lineno() const { return lineno_; } lyx-devel/trunk/src/tex2lyx/preamble.cpp
r27563 r27592 249 249 250 250 251 void handle_package( string const & name, string const & opts,251 void handle_package(Parser &p, string const & name, string const & opts, 252 252 bool in_lyx_preamble) 253 253 { … … 327 327 328 328 else if (name == "inputenc") { 329 // only set when there is not more than one inputenc option 330 // therefore check for the "," character 331 // also only set when there is not more then one babel language option 329 // only set when there is not more than one inputenc 330 // option therefore check for the "," character also 331 // only set when there is not more then one babel 332 // language option 332 333 if (opts.find(",") == string::npos && one_language == true) { 333 334 if (opts == "ascii") … … 338 339 h_inputencoding = opts; 339 340 } 341 if (!options.empty()) 342 p.setEncoding(options.back()); 340 343 options.clear(); 341 344 } … … 664 667 string const options = p.getArg('[', ']'); 665 668 string const name = p.getArg('{', '}'); 666 if (options.empty() && name.find(',')) { 667 vector<string> vecnames; 668 split(name, vecnames, ','); 669 vector<string>::const_iterator it = vecnames.begin(); 670 vector<string>::const_iterator end = vecnames.end(); 671 for (; it != end; ++it) 672 handle_package(trim(*it), string(), 673 in_lyx_preamble); 674 } else { 675 handle_package(name, options, in_lyx_preamble); 676 } 669 vector<string> vecnames; 670 split(name, vecnames, ','); 671 vector<string>::const_iterator it = vecnames.begin(); 672 vector<string>::const_iterator end = vecnames.end(); 673 for (; it != end; ++it) 674 handle_package(p, trim(*it), options, 675 in_lyx_preamble); 677 676 } 678 677 679 678 else if (t.cs() == "inputencoding") { 680 h_inputencoding = p.getArg('{','}'); 679 string const encoding = p.getArg('{','}'); 680 h_inputencoding = encoding; 681 p.setEncoding(encoding); 681 682 } 682 683 lyx-devel/trunk/src/tex2lyx/tex2lyx.cpp
r27563 r27592 16 16 17 17 #include "Context.h" 18 #include "Encoding.h" 19 #include "Layout.h" 18 20 #include "TextClass.h" 19 #include "Layout.h"20 21 21 22 #include "support/convert.h" … … 422 423 bool tex2lyx(FileName const & infilename, ostream & os) 423 424 { 424 ifdocstream is(infilename.toFilesystemEncoding().c_str()); 425 ifdocstream is; 426 // forbid buffering on this stream 427 is.rdbuf()->pubsetbuf(0,0); 428 is.open(infilename.toFilesystemEncoding().c_str()); 425 429 if (!is.good()) { 426 430 cerr << "Could not open input file \"" << infilename … … 488 492 try { 489 493 init_package(internal_path(to_utf8(from_local8bit(argv[0]))), 490 cl_system_support, cl_user_support,491 top_build_dir_is_two_levels_up);494 cl_system_support, cl_user_support, 495 top_build_dir_is_two_levels_up); 492 496 } catch (ExceptionMessage const & message) { 493 497 cerr << to_utf8(message.title_) << ":\n" 494 << to_utf8(message.details_) << endl;498 << to_utf8(message.details_) << endl; 495 499 if (message.type_ == ErrorException) 496 500 exit(1); … … 510 514 outfilename = changeExtension(infilename, ".lyx"); 511 515 516 // Read the syntax tables 512 517 FileName const system_syntaxfile = libFileSearch("", "syntax.default"); 513 518 if (system_syntaxfile.empty()) { … … 519 524 read_syntaxfile(makeAbsPath(syntaxfile)); 520 525 526 // Read the encodings table. 527 FileName const symbols_path = libFileSearch(string(), "unicodesymbols"); 528 if (symbols_path.empty()) { 529 cerr << "Error: Could not find file \"unicodesymbols\"." 530 << endl; 531 exit(1); 532 } 533 FileName const enc_path = libFileSearch(string(), "encodings"); 534 if (enc_path.empty()) { 535 cerr << "Error: Could not find file \"encodings\"." 536 << endl; 537 exit(1); 538 } 539 encodings.read(enc_path, symbols_path); 540 541 // The real work now. 521 542 masterFilePath = onlyPath(infilename); 522 543 parentFilePath = masterFilePath; 523 524 544 if (outfilename == "-") { 525 545 if (tex2lyx(FileName(infilename), cout)) lyx-devel/trunk/src/tex2lyx/text.cpp
r27563 r27592 1764 1764 context.check_layout(os); 1765 1765 string const s = p.verbatim_item(); 1766 //FIXME: this never triggers in UTF8 1766 1767 if (s == "\xb1" || s == "\xb3" || s == "\xb2" || s == "\xb5") 1767 1768 os << s; … … 2239 2240 } 2240 2241 2242 #if 0 2243 //FIXME: rewrite this 2241 2244 else if (t.cs() == "\"") { 2242 2245 context.check_layout(os); … … 2250 2253 else handle_ert(os, "\"{" + name + "}", context); 2251 2254 } 2255 #endif 2252 2256 2253 2257 // Problem: \= creates a tabstop inside the tabbing environment … … 2274 2278 } 2275 2279 2280 #if 0 2281 //FIXME: rewrite this 2276 2282 else if (t.cs() == "ss") { 2277 2283 context.check_layout(os); … … 2279 2285 skip_braces(p); // eat {} 2280 2286 } 2287 #endif 2281 2288 2282 2289 else if (t.cs() == "i" || t.cs() == "j" || t.cs() == "l" ||
