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"
23 void warning(docstring const & title, docstring const & message, bool const &)
31 bool LaTeXFeatures::isAvailable(std::string const &)
37 bool Formats::isZippedFile(support::FileName const &) const
44 using namespace lyx::support;
50 bool test_Layout(string const & input, string const & output)
52 FileName const ifn(makeAbsPath(input));
53 LayoutFileList & l = LayoutFileList::get();
54 LayoutFileIndex i = onlyFileName(l.addLocalLayout(ifn.onlyFileName(), ifn.onlyPath().absFileName()));
56 cerr << "Could not read layout file " << input << ".layout.\n";
59 LayoutFile const & f = l[i];
63 else if (!output.empty())
64 os = new ofstream(output.c_str());
66 for (TextClass::const_iterator it = f.begin(); it != f.end(); ++it) {
71 istringstream iss(oss.str());
72 // swallow "Style Standard" line
74 if (getline(iss, line)) {
78 test.setName(it->name());
79 if (test.read(lex, f)) {
80 // Caution: operator==() is incomplete!
81 // Testing test == *it does not make much sense
83 // It does not work either for styles with
84 // non-empty obsoletedby if the obsoletedby
85 // style was modified after the obsolete style
86 // was defined: Layout::write() writes only the
87 // final version, but the obsolete style was
88 // set to the version at the time it was
89 // defined, and therefore they differ. See e.g.
90 // the obsolete style AMS which is replaced by
91 // Subjectclass in amsdefs.inc, and
92 // Subjectclass is modified later in siamltex.layout.
93 ostringstream osstest;
95 if (osstest.str() != oss.str()) {
96 cerr << "Round trip for style "
97 << to_utf8(it->name())
99 << osstest.str() << oss.str();
103 cerr << "Could not read style "
104 << to_utf8(it->name()) << ".\n";
108 cerr << "Could not read first line for style "
109 << to_utf8(it->name()) << ".\n";
119 int main(int argc, char * argv[])
121 os::init(argc, argv);
122 lyxerr.setStream(cerr);
123 if (argc < 2 || argc > 3) {
124 cerr << "Usage: " << argv[0] << " <input layout file> [<output layout file>]\n";
127 FileName const exe(makeAbsPath(os::internal_path(os::utf8_argv(0))));
128 string const lyxexe = addName(exe.onlyPath().absFileName(), "lyx");
129 init_package(lyxexe, string(), string());
130 if (test_Layout(argv[1], argc > 2 ? argv[2] : ""))