3 #include "../support/FileName.h"
4 #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"
20 void warning(docstring const & title, docstring const & message, bool const &)
28 bool LaTeXFeatures::isAvailable(std::string const &)
34 bool Formats::isZippedFile(support::FileName const &) const
41 using namespace lyx::support;
47 bool test_Layout(string const & input, string const & output)
49 FileName const ifn(makeAbsPath(input));
50 LayoutFileList & l = LayoutFileList::get();
51 LayoutFileIndex i = onlyFileName(l.addLocalLayout(ifn.onlyFileName(), ifn.onlyPath().absFileName()));
53 cerr << "Could not read layout file " << input << ".layout.\n";
56 LayoutFile const & f = l[i];
60 else if (!output.empty())
61 os = new ofstream(output.c_str());
63 for (TextClass::const_iterator it = f.begin(); it != f.end(); ++it) {
68 istringstream iss(oss.str());
69 // swallow "Style Standard" line
71 if (getline(iss, line)) {
75 test.setName(it->name());
76 if (test.read(lex, f)) {
77 // Caution: operator==() is incomplete!
78 // Testing test == *it does not make much sense
80 // It does not work either for styles with
81 // non-empty obsoletedby if the obsoletedby
82 // style was modified after the obsolete style
83 // was defined: Layout::write() writes only the
84 // final version, but the obsolete style was
85 // set to the version at the time it was
86 // defined, and therefore they differ. See e.g.
87 // the obsolete style AMS which is replaced by
88 // Subjectclass in amsdefs.inc, and
89 // Subjectclass is modified later in siamltex.layout.
90 ostringstream osstest;
92 if (osstest.str() != oss.str()) {
93 cerr << "Round trip for style "
94 << to_utf8(it->name())
96 << osstest.str() << oss.str();
100 cerr << "Could not read style "
101 << to_utf8(it->name()) << ".\n";
105 cerr << "Could not read first line for style "
106 << to_utf8(it->name()) << ".\n";
116 int main(int argc, char * argv[])
118 os::init(argc, argv);
119 lyxerr.setStream(cerr);
120 if (argc < 2 || argc > 3) {
121 cerr << "Usage: " << argv[0] << " <input layout file> [<output layout file>]\n";
124 FileName const exe(makeAbsPath(os::internal_path(os::utf8_argv(0))));
125 string const lyxexe = addName(exe.onlyPath().absFileName(), "lyx");
126 init_package(lyxexe, string(), string());
127 if (test_Layout(argv[1], argc > 2 ? argv[2] : ""))