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