3 #include "../support/debug.h"
4 #include "../support/FileName.h"
5 #include "../support/filetools.h"
6 #include "../LayoutFile.h"
7 #include "../LaTeXFeatures.h"
9 #include "../support/Messages.h"
10 #include "../support/os.h"
11 #include "../support/Package.h"
23 void warning(docstring const & title, docstring const & message, bool)
29 } // namespace frontend
31 bool LaTeXFeatures::isAvailable(std::string const &)
39 using namespace lyx::support;
45 bool test_Layout(string const & input, string const & output)
47 FileName const ifn(makeAbsPath(input));
48 LayoutFileList & l = LayoutFileList::get();
49 LayoutFileIndex i = onlyFileName(l.addLocalLayout(ifn.onlyFileName(), ifn.onlyPath().absFileName()));
51 cerr << "Could not read layout file " << input << ".layout.\n";
54 LayoutFile const & f = l[i];
55 ostream * os = nullptr;
58 else if (!output.empty())
59 os = new ofstream(output.c_str());
61 for (TextClass::const_iterator it = f.begin(); it != f.end(); ++it) {
66 istringstream iss(oss.str());
67 // swallow "Style Standard" line
69 if (getline(iss, line)) {
73 test.setName(it->name());
74 if (test.read(lex, f)) {
75 // Caution: operator==() is incomplete!
76 // Testing test == *it does not make much sense
78 // It does not work either for styles with
79 // non-empty obsoletedby if the obsoletedby
80 // style was modified after the obsolete style
81 // was defined: Layout::write() writes only the
82 // final version, but the obsolete style was
83 // set to the version at the time it was
84 // defined, and therefore they differ. See e.g.
85 // the obsolete style AMS which is replaced by
86 // Subjectclass in amsdefs.inc, and
87 // Subjectclass is modified later in siamltex.layout.
88 ostringstream osstest;
90 if (osstest.str() != oss.str()) {
91 cerr << "Round trip for style "
92 << to_utf8(it->name())
94 << osstest.str() << oss.str();
98 cerr << "Could not read style "
99 << to_utf8(it->name()) << ".\n";
103 cerr << "Could not read first line for style "
104 << to_utf8(it->name()) << ".\n";
114 int main(int argc, char * argv[])
116 os::init(argc, &argv);
117 lyxerr.setStream(cerr);
118 if (argc < 2 || argc > 3) {
119 cerr << "Usage: " << argv[0] << " <input layout file> [<output layout file>]\n";
122 FileName const exe(makeAbsPath(os::internal_path(os::utf8_argv(0))));
123 string const lyxexe = addName(exe.onlyPath().absFileName(), "lyx");
124 init_package(lyxexe, string(), string());
125 if (test_Layout(argv[1], argc > 2 ? argv[2] : ""))