Context::~Context()
{
if (!par_extra_stuff.empty())
- cerr << "Bug: Ignoring par-level extra stuff '"
- << par_extra_stuff << '\'' << endl;
+ warning_message("Bug: Ignoring par-level extra stuff '"
+ + par_extra_stuff + '\'');
}
#include "Parser.h"
+#include "tex2lyx.h"
+
#include "Encoding.h"
#include "support/lstrings.h"
#include "support/textutils.h"
if (s_.empty())
is_.get(c);
else {
- //cerr << "unparsed: " << to_utf8(s_) <<endl;
+ //warning_message("unparsed: " + to_utf8(s_));
c = s_[0];
s_.erase(0,1);
}
// instead. Therefore, we cannot misparse high bytes as {, } or \\.
Encoding const * const enc = encodings.fromLaTeXName(e, p, true);
if (!enc) {
- cerr << "Unknown encoding " << e << ". Ignoring." << std::endl;
+ warning_message("Unknown encoding " + e + ". Ignoring.");
return false;
}
return setEncoding(enc->iconvName());
bool Parser::setEncoding(std::string const & e)
{
- //cerr << "setting encoding to " << e << std::endl;
+ //warning_message("setting encoding to " + e);
encoding_iconv_ = e;
// If the encoding is fixed, we must not change the stream encoding
// (because the whole input uses that encoding, e.g. if it comes from
if (pos_ >= tokens_.size())
return dummy;
}
- // cerr << "looking at token " << tokens_[pos_]
- // << " pos: " << pos_ << '\n';
+ // warning_message("looking at token " + tokens_[pos_]
+ // + " pos: " + pos_ <<);
return tokens_[pos_++];
}
// If positions_ is not empty we are doing some kind
// of look ahead
if (!positions_.empty())
- cerr << " Ignoring comment: "
- << curr_token().asInput();
+ warning_message("Ignoring comment: " + curr_token().asInput());
} else {
putback();
break;
// If positions_ is not empty we are doing some kind
// of look ahead
if (!positions_.empty())
- cerr << "Unignoring comment: "
- << curr_token().asInput();
+ warning_message("Unignoring comment: " + curr_token().asInput());
putback();
}
else
// Ignore comments
if (t.cat() == catComment) {
if (!t.cs().empty())
- cerr << "Ignoring comment: " << t.asInput();
+ warning_message("Ignoring comment: " + t.asInput());
continue;
}
if (allow_escaping) {
} else if (t.asInput() == "\\end") {
string const end = getArg('{', '}');
if (end != name)
- cerr << "\\end{" << end
- << "} does not match \\begin{" << name
- << "}." << endl;
+ warning_message("\\end{" + end
+ + "} does not match \\begin{"
+ + name + "}.");
return os.str();
} else
os << t.asInput();
}
- cerr << "unexpected end of input" << endl;
+ warning_message("unexpected end of input");
return os.str();
}
} else
os << t.asInput();
}
- cerr << "unexpected end of input" << endl;
+ warning_message("unexpected end of input");
return os.str();
}
// check if first token is really the start character
Token tok = get_token();
if (tok.character() != left) {
- cerr << "first character does not match start character of command \\" << name << endl;
+ warning_message("first character does not match start character of command \\" + name);
return string();
}
ostringstream os;
} else
os << t.asInput();
}
- cerr << "unexpected end of input" << endl;
+ warning_message("unexpected end of input");
return os.str();
}
break;
} else {
if (!allow_linebreak && t.asInput() == "\n") {
- cerr << "unexpected end of input" << endl;
+ warning_message("unexpected end of input");
popPosition();
setCatcodes(NORMAL_CATCODES);
return Arg(false, string());
}
if (!good()) {
- cerr << "unexpected end of input" << endl;
+ warning_message("unexpected end of input");
popPosition();
setCatcodes(NORMAL_CATCODES);
return Arg(false, string());
}
case catIgnore: {
- cerr << "ignoring a char: " << static_cast<uint32_t>(c) << "\n";
+ warning_message("ignoring a char: " + static_cast<uint32_t>(c));
break;
}
default:
push_back(Token(docstring(1, c), catcode(c)));
}
- //cerr << tokens_.back();
+ //warning_message(tokens_.back());
}
encoding, Encoding::inputenc, true);
if (!enc) {
if (!detectEncoding)
- cerr << "Unknown encoding " << encoding
- << ". Ignoring." << std::endl;
+ warning_message("Unknown encoding " + encoding + ". Ignoring.");
} else {
if (!enc->unsafe() && options.size() == 1 && one_language == true) {
h_inputencoding = enc->name();
|| opt == "subsection")
h_multibib = opt;
else
- cerr << "Ignoring unknown refsection value '"
- << opt << "'.";
+ warning_message("Ignoring unknown refsection value '" + opt + "'.");
}
opt = process_keyval_opt(options, "bibencoding");
if (!opt.empty())
// We need to do something with the options...
if (!options.empty() && !detectEncoding)
- cerr << "Ignoring options '" << join(options, ",")
- << "' of package " << name << '.' << endl;
+ warning_message("Ignoring options '" + join(options, ",")
+ + "' of package " + name + '.');
// remove the whitespace
p.skip_spaces();
&& comment.substr(0, magicXeLaTeX.size()) == magicXeLaTeX
&& h_inputencoding == "auto-legacy") {
if (!detectEncoding)
- cerr << "XeLaTeX comment found, switching to UTF8\n";
+ warning_message("XeLaTeX comment found, switching to UTF8");
h_inputencoding = "utf8";
}
smatch sub;
encoding, Encoding::inputenc, true);
if (!enc) {
if (!detectEncoding)
- cerr << "Unknown encoding " << encoding
- << ". Ignoring." << std::endl;
+ warning_message("Unknown encoding " + encoding + ". Ignoring.");
} else {
if (!enc->unsafe())
h_inputencoding = enc->name();
if (makeAbsPath(filename, path).exists())
fix_child_filename(filename);
else
- cerr << "Warning: Could not find included file '"
- << filename << "'." << endl;
+ warning_message("Warning: Could not find included file '"
+ + filename + "'.");
outname = changeExtension(filename, "lyx");
h_includeonlys.push_back(outname);
}
#include <config.h>
+#include "tex2lyx.h"
#include "LaTeXFeatures.h"
#include "LyXRC.h"
#include "output_xhtml.h"
namespace Alert {
void warning(docstring const & title, docstring const & message, bool)
{
- cerr << to_utf8(title) << "\n" << to_utf8(message) << endl;
+ warning_message(to_utf8(title) + "\n" + to_utf8(message));
}
} // namespace Alert
} // namespace frontend
else if (t.cs() == "cr") {
// lyx can't handle \\cr
- cerr << "Warning: Converting TeX '\\cr' to LaTeX '\\\\'."
- << endl;
+ warning_message("Converting TeX '\\cr' to LaTeX '\\\\'.");
os << "\\\\";
}
ColInfo const & start)
{
if (p.get_token().cat() != catBegin)
- cerr << "Wrong syntax for table column alignment.\n"
- "Expected '{', got '" << p.curr_token().asInput()
- << "'.\n";
+ warning_message("Wrong syntax for table column alignment.\n"
+ "Expected '{', got '" + p.curr_token().asInput()+ "'");
ColInfo next = start;
for (Token t = p.get_token(); p.good() && t.cat() != catEnd;
// "%\n" combination
p.skip_spaces();
} else
- cerr << "Ignoring comment: " << t.asInput();
+ warning_message("Ignoring comment: " + t.asInput());
continue;
}
string const s = trimSpaceAndEol(p.verbatim_item());
if (colinfo.empty())
// This is not possible in LaTeX.
- cerr << "Ignoring separator '<{"
- << s << "}'." << endl;
+ warning_message("Ignoring separator '<{" + s + "}'.");
else {
ColInfo & ci = colinfo.back();
ci2special(ci);
handle_colalign(p2, colinfo, next);
next = ColInfo();
} else {
- cerr << "Ignoring column specification"
- " '*{" << num << "}{"
- << arg << "}'." << endl;
+ warning_message("Ignoring column specification"
+ " '*{" + num + "}{" + arg + "}'.");
}
break;
}
t.cs() == "\\" ||
t.cs() == "cr") {
if (t.cs() == "cr")
- cerr << "Warning: Converting TeX "
- "'\\cr' to LaTeX '\\\\'."
- << endl;
+ warning_message("Warning: Converting TeX "
+ "'\\cr' to LaTeX '\\\\'.");
// stuff before the line break
os << comments << HLINE << hlines << HLINE
<< LINE;
- //cerr << "hlines: " << hlines << endl;
+ //warning_message("hlines: " + hlines);
hlines.erase();
comments.erase();
pos = ROW_START;
if (support::contains(hlines, "\\hline") ||
support::contains(hlines, "\\cline") ||
support::contains(hlines, "\\newpage"))
- cerr << "Ignoring '" << hlines
- << "' in a cell" << endl;
+ warning_message("Ignoring '" + hlines + "' in a cell");
else
os << hlines;
hlines.erase();
else if (t.cat() == catEnd) {
if (flags & FLAG_BRACE_LAST)
return;
- cerr << "unexpected '}'\n";
+ warning_message("unexpected '}'");
}
else if (t.cat() == catAlign) {
// We can have hline stuff if the last line is incomplete
if (!hlines.empty()) {
// this does not work in LaTeX, so we ignore it
- cerr << "Ignoring '" << hlines << "' at end of tabular"
- << endl;
+ warning_message("Ignoring '" + hlines + "' at end of tabular");
}
}
else if (posopts == "[b]")
tabularvalignment = "bottom";
else
- cerr << "vertical tabular positioning '"
- << posopts << "' ignored\n";
+ warning_message("vertical tabular positioning '"
+ + posopts + "' ignored");
}
vector<ColInfo> colinfo;
ltType endlastfoot;
// split into rows
- //cerr << "// split into rows\n";
+ //warning_message("// split into rows");
for (size_t row = 0; row < rowinfo.size();) {
// init row
// split row
vector<string> dummy;
- //cerr << "\n########### LINE: " << lines[row] << "########\n";
+ //warning_message("########### LINE: " << lines[row] << "########");
split(lines[row], dummy, HLINE);
// handle horizontal line fragments
if (dummy.size() != 3) {
if ((dummy.size() != 1 && dummy.size() != 2) ||
row != rowinfo.size() - 1)
- cerr << "unexpected dummy size: " << dummy.size()
- << " content: " << lines[row] << "\n";
+ warning_message("unexpected dummy size: " + convert<string>(dummy.size())
+ + " content: " + lines[row]);
dummy.resize(3);
}
lines[row] = dummy[1];
- //cerr << "line: " << row << " above 0: " << dummy[0] << "\n";
- //cerr << "line: " << row << " below 2: " << dummy[2] << "\n";
- //cerr << "line: " << row << " cells 1: " << dummy[1] << "\n";
+ //warning_message("line: " + row + " above 0: " + dummy[0]);
+ //warning_message("line: " + row + " below 2: " + dummy[2]);
+ //warning_message("line: " + row + " cells 1: " + dummy[1]);
for (int i = 0; i <= 2; i += 2) {
- //cerr << " reading from line string '" << dummy[i] << "'\n";
+ //warning_message(" reading from line string '" + dummy[i]);
Parser p1(dummy[size_type(i)]);
while (p1.good()) {
Token t = p1.get_token();
- //cerr << "read token: " << t << "\n";
+ //warning_message("read token: " + t);
if (t.cs() == "hline" || t.cs() == "toprule" ||
t.cs() == "midrule" ||
t.cs() == "bottomrule") {
if (row > 0) // extra bottomline above
handle_hline_below(rowinfo[row - 1], cellinfo[row - 1]);
else
- cerr << "dropping extra "
- << t.cs() << '\n';
- //cerr << "below row: " << row-1 << endl;
+ warning_message("dropping extra " + t.cs());
+ //warning_message("below row: " + row-1);
} else {
handle_hline_above(rowinfo[row], cellinfo[row]);
- //cerr << "above row: " << row << endl;
+ //warning_message("above row: " + row);
}
} else {
- //cerr << "below row: " << row << endl;
+ //warning_message("below row: " + row);
handle_hline_below(rowinfo[row], cellinfo[row]);
}
} else if (t.cs() == "cline" || t.cs() == "cmidrule") {
trim = p1.getFullParentheseArg();
}
string arg = p1.verbatim_item();
- //cerr << "read " << t.cs() << " arg: '" << arg << "', trim: '" << trim << "'\n";
+ //warning_message("read " + t.cs() + " arg: '" + arg + "', trim: '" + trim);
vector<string> cols;
split(arg, cols, '-');
cols.resize(2);
size_t from = convert<unsigned int>(cols[0]);
if (from == 0)
- cerr << "Could not parse "
- << t.cs() << " start column."
- << endl;
+ warning_message("Could not parse " + t.cs() + " start column.");
else
// 1 based index -> 0 based
--from;
if (from >= colinfo.size()) {
- cerr << t.cs() << " starts at "
- "non existing column "
- << (from + 1) << endl;
+ warning_message(t.cs() + " starts at "
+ "non existing column " + convert<string>(from + 1));
from = colinfo.size() - 1;
}
size_t to = convert<unsigned int>(cols[1]);
if (to == 0)
- cerr << "Could not parse "
- << t.cs() << " end column."
- << endl;
+ warning_message("Could not parse " + t.cs() + " end column.");
else
// 1 based index -> 0 based
--to;
if (to >= colinfo.size()) {
- cerr << t.cs() << " ends at "
- "non existing column "
- << (to + 1) << endl;
+ warning_message(t.cs() + " ends at non existing column "
+ + convert<string>(to + 1));
to = colinfo.size() - 1;
}
for (size_t col = from; col <= to; ++col) {
- //cerr << "row: " << row << " col: " << col << " i: " << i << endl;
+ //warning_message("row: " + row + " col: " + col + " i: " + i);
if (i == 0) {
rowinfo[row].topline = true;
cellinfo[row][col].topline = true;
rowinfo[row - 1].newpage = true;
else
// This does not work in LaTeX
- cerr << "Ignoring "
- "'\\newpage' "
- "before rows."
- << endl;
+ warning_message("Ignoring "
+ "'\\newpage' "
+ "before rows.");
} else
rowinfo[row].newpage = true;
} else {
- cerr << "unexpected line token: " << t << endl;
+ warning_message("unexpected line token: " + t.cs());
}
}
}
split(lines[row], cells, TAB);
for (size_t col = 0, cell = 0; cell < cells.size();
++col, ++cell) {
- //cerr << "cell content: '" << cells[cell] << "'\n";
+ //warning_message("cell content: '" + cells[cell]);
if (col >= colinfo.size()) {
// This does not work in LaTeX
- cerr << "Ignoring extra cell '"
- << cells[cell] << "'." << endl;
+ warning_message("Ignoring extra cell '" + cells[cell] + "'.");
continue;
}
string cellcont = cells[cell];
if (parse.hasOpt()) {
string const vpos = parse.getArg('[', ']');
parse.skip_spaces(true);
- cerr << "Ignoring multirow's vpos arg '"
- << vpos << "'!" << endl;
+ warning_message("Ignoring multirow's vpos arg '"
+ + vpos + "'!");
}
// how many cells?
parse.get_token();
if (parse.hasOpt()) {
string const bs = parse.getArg('[', ']');
parse.skip_spaces(true);
- cerr << "Ignoring multirow's bigstrut arg '"
- << bs << "'!" << endl;
+ warning_message("Ignoring multirow's bigstrut arg '"
+ + bs + "'!");
}
// the width argument
string const width = parse.getArg('{', '}');
// This may or may not work in LaTeX,
// but it does not work in LyX.
// FIXME: Handle it correctly!
- cerr << "Moving cell content '"
- << cells[cell]
- << "' into a multirow cell. "
- "This will probably not work."
- << endl;
+ warning_message("Moving cell content '"
+ + cells[cell]
+ + "' into a multirow cell. "
+ "This will probably not work.");
}
cellinfo[row][col].content += os2.str();
} else if (parse.next_token().cs() == "multicolumn") {
// This may or may not work in LaTeX,
// but it does not work in LyX.
// FIXME: Handle it correctly!
- cerr << "Moving cell content '"
- << cells[cell]
- << "' into a multicolumn cell. "
- "This will probably not work."
- << endl;
+ warning_message("Moving cell content '"
+ + cells[cell]
+ + "' into a multicolumn cell. "
+ "This will probably not work.");
}
cellinfo[row][col].content += os2.str();
for (size_t i = 0; i < ncells - 1; ++i) {
++col;
if (col >= colinfo.size()) {
- cerr << "The cell '"
- << cells[cell]
- << "' specifies "
- << convert<string>(ncells)
- << " columns while the table has only "
- << convert<string>(colinfo.size())
- << " columns!"
- << " Therefore the surplus columns will be ignored."
- << endl;
+ warning_message("The cell '"
+ + cells[cell]
+ + "' specifies "
+ + convert<string>(ncells)
+ + " columns while the table has only "
+ + convert<string>(colinfo.size())
+ + " columns!"
+ + " Therefore the surplus columns will be ignored.");
break;
}
cellinfo[row][col].multi = CELL_PART_OF_MULTICOLUMN;
rowinfo[row].caption = true;
for (size_t c = 1; c < cells.size(); ++c) {
if (!cells[c].empty()) {
- cerr << "Moving cell content '"
- << cells[c]
- << "' into the caption cell. "
- "This will probably not work."
- << endl;
+ warning_message("Moving cell content '"
+ + cells[c]
+ + "' into the caption cell. "
+ "This will probably not work.");
cells[0] += cells[c];
}
}
rowinfo[row].caption = true;
for (size_t c = 1; c < cells.size(); ++c) {
if (!cells[c].empty()) {
- cerr << "Moving cell content '"
- << cells[c]
- << "' into the caption cell. "
- "This will probably not work."
- << endl;
+ warning_message("Moving cell content '"
+ + cells[c]
+ + "' into the caption cell. "
+ "This will probably not work.");
cells[0] += cells[c];
}
}
}
}
- //cerr << "// handle almost empty last row what we have\n";
+ //warning_message("// handle almost empty last row what we have");
// handle almost empty last row
if (row && lines[row].empty() && row + 1 == rowinfo.size()) {
- //cerr << "remove empty last line\n";
+ //warning_message("remove empty last line");
if (rowinfo[row].topline)
rowinfo[row - 1].bottomline = true;
for (size_t col = 0; col < colinfo.size(); ++col)
else if (name == "tabularx")
preamble.registerAutomaticallyLoadedPackage("tabularx");
- //cerr << "// output what we have\n";
+ //warning_message("output what we have");
// output what we have
size_type cols = colinfo.size();
for (auto const & col : colinfo) {
os << write_attribute("tabularwidth", tabularwidth) << ">\n";
- //cerr << "// after header\n";
+ //warning_message("after header");
for (auto const & col : colinfo) {
if (col.decimal_point != '\0' && col.align != 'd')
continue;
<< write_attribute("varwidth", col.varwidth)
<< ">\n";
}
- //cerr << "// after cols\n";
+ //warning_message("after cols");
for (size_t row = 0; row < rowinfo.size(); ++row) {
os << "<row"
<< write_attribute("rightline", cell.rightlines > 0)
<< write_attribute("rotate", cell.rotate)
<< write_attribute("mroffset", cell.mroffset);
- //cerr << "\nrow: " << row << " col: " << col;
+ //warning_message("\nrow: " + row + " col: " + col);
//if (cell.topline)
- // cerr << " topline=\"true\"";
+ // warning_message(" topline=\"true\"");
//if (cell.bottomline)
- // cerr << " bottomline=\"true\"";
+ // warning_message(" bottomline=\"true\"");
os << " usebox=\"none\""
<< write_attribute("width", translate_len(cell.width));
if (cell.multi != CELL_NORMAL)
Specify the encoding using the LaTeX name as defined in the encodings file.
\fBtex2lyx\fR will ignore any encoding changing commands in the input.
.TP
+.BI \-q
+Quite mode. \fBtex2lyx\fR will not output any warning messages.
+.TP
.BI \-n
Noweb. Translate a noweb (aka literate programming) file. This should be
(almost?) equivalent to running \*[lq]noweb2lyx foo.tex foo.lyx\*[rq]. This option
void split(string const & s, vector<string> & result, char delim)
{
- //cerr << "split 1: '" << s << "'\n";
+ //warning_message("split 1: '" + s + "'");
istringstream is(s);
string t;
while (getline(is, t, delim))
result.push_back(t);
- //cerr << "split 2\n";
+ //warning_message("split 2");
}
vector<string>::const_iterator const vb = visited.begin();
vector<string>::const_iterator const ve = visited.end();
if (find(vb, ve, module) != ve) {
- cerr << "Circular dependency detected for module " << module << '\n';
+ warning_message("Circular dependency detected for module " + module);
return false;
}
LyXModule const * const lm = theModuleList[module];
if (!lm) {
- cerr << "Could not find module " << module << " in module list.\n";
+ warning_message("Could not find module " + module + " in module list.");
return false;
}
bool foundone = false;
}
}
if (!foundone) {
- cerr << "Could not add required modules for " << module << ".\n";
+ warning_message("Could not add required modules for " + module + ".");
return false;
}
if (!m.moduleCanBeAdded(module, &baseClass))
{
ifdocstream is(file_name.toFilesystemEncoding().c_str());
if (!is.good()) {
- cerr << "Could not open syntax file \"" << file_name
- << "\" for reading." << endl;
+ cerr << "Could not open syntax file \""
+ << file_name << "\" for reading." << std::endl;
return false;
}
// We can use our TeX parser, since the syntax of the layout file is
string syntaxfile;
bool copy_files = false;
bool overwrite_files = false;
+bool no_warnings = false;
bool skip_children = false;
int error_code = 0;
"\t-fixedenc encoding Like -e, but ignore encoding changing commands while parsing.\n"
"\t-f Force overwrite of .lyx files.\n"
"\t-help Print this message and quit.\n"
- "\t-n translate literate programming (noweb, sweave,... ) file.\n"
+ "\t-n Translate literate programming (noweb, sweave,... ) file.\n"
+ "\t-q Omit warnings.\n"
+ "\t-roundtrip Re-export created .lyx file infile.lyx.lyx to infile.lyx.tex.\n"
"\t-skipchildren Do not translate included child documents.\n"
- "\t-roundtrip re-export created .lyx file infile.lyx.lyx to infile.lyx.tex.\n"
- "\t-s syntaxfile read additional syntax file.\n"
+ "\t-s syntaxfile Read additional syntax file.\n"
"\t-sysdir SYSDIR Set system directory to SYSDIR.\n"
"\t Default: " << package().system_support() << "\n"
"\t-userdir USERDIR Set user directory to USERDIR.\n"
}
+int parse_quite(string const &, string const &)
+{
+ no_warnings = true;
+ return 0;
+}
+
+
int parse_noweb(string const &, string const &)
{
noweb_mode = true;
cmdmap["-skipchildren"] = parse_skipchildren;
cmdmap["-sysdir"] = parse_sysdir;
cmdmap["-userdir"] = parse_userdir;
+ cmdmap["-q"] = parse_quite;
cmdmap["-roundtrip"] = parse_roundtrip;
cmdmap["-copyfiles"] = parse_copyfiles;
}
if (outfilename.isReadableFile()) {
if (overwrite_files) {
- cerr << "Overwriting existing file "
- << outfilename << endl;
+ warning_message("Overwriting existing file " + outfilename.absFileName());
} else {
cerr << "Not overwriting existing file "
<< outfilename << endl;
return false;
}
} else {
- cerr << "Creating file " << outfilename << endl;
+ warning_message("Creating file " + outfilename.absFileName());
}
ofstream os(outfilename.toFilesystemEncoding().c_str());
if (!os.good()) {
}
+void warning_message(string const & message)
+{
+ if (!no_warnings)
+ cerr << "tex2lyx warning: " << message << endl;
+}
+
+
namespace {
int TeX2LyXApp::run()
support::FileName const & outfilename,
std::string const & encoding);
+/// A general warning message that can be silenced with -q
+void warning_message(std::string const & message);
} // namespace lyx
position = "t";
}
if (position != "t" && position != "c" && position != "b") {
- cerr << "invalid position " << position << " for "
- << inner_type << endl;
+ warning_message("invalid position " + position
+ + " for " + inner_type);
position = "c";
}
if (p.hasOpt()) {
hor_pos = opt;
if (hor_pos != "l" && hor_pos != "c" &&
hor_pos != "r" && hor_pos != "s") {
- cerr << "invalid hor_pos " << hor_pos
- << " for " << inner_type << endl;
+ warning_message("invalid hor_pos "
+ + hor_pos + " for "
+ + inner_type);
hor_pos = "c";
}
}
inner_pos = p.getArg('[', ']');
if (inner_pos != "c" && inner_pos != "t" &&
inner_pos != "b" && inner_pos != "s") {
- cerr << "invalid inner_pos "
- << inner_pos << " for "
- << inner_type << endl;
+ warning_message("invalid inner_pos "
+ + inner_pos + " for "
+ + inner_type);
inner_pos = position;
}
}
hor_pos = opt;
if (hor_pos != "l" && hor_pos != "c" &&
hor_pos != "r" && hor_pos != "s") {
- cerr << "invalid hor_pos " << hor_pos
- << " for " << outer_type << endl;
+ warning_message("invalid hor_pos "
+ + hor_pos + " for "
+ + outer_type);
hor_pos = "c";
}
} else {
if (p.next_token().cat() == catBegin)
p.get_token();
else
- cerr << "Warning: Ignoring missing '{' after \\"
- << outer_type << '.' << endl;
+ warning_message("Ignoring missing '{' after \\"
+ + outer_type + '.');
eat_whitespace(p, os, parent_context, false);
}
string inner;
return;
if (!dstpath.isDirectory()) {
if (!dstpath.createPath()) {
- cerr << "Warning: Could not create directory for file `"
- << dst.absFileName() << "´." << endl;
+ warning_message("Could not create directory for file `"
+ + dst.absFileName() + "´.");
return;
}
}
if (dst.isReadableFile()) {
if (overwriteFiles())
- cerr << "Warning: Overwriting existing file `"
- << dst.absFileName() << "´." << endl;
+ warning_message("Overwriting existing file `"
+ + dst.absFileName() + "´.");
else {
- cerr << "Warning: Not overwriting existing file `"
- << dst.absFileName() << "´." << endl;
+ warning_message("Not overwriting existing file `"
+ + dst.absFileName() + "´.");
return;
}
}
if (!src.copyTo(dst))
- cerr << "Warning: Could not copy file `" << src.absFileName()
- << "´ to `" << dst.absFileName() << "´." << endl;
+ warning_message("Could not copy file `" + src.absFileName()
+ + "´ to `" + dst.absFileName() + "´.");
}
p.putback();
p.deparse();
- //cerr << "params=[" << params.second << "], code=[" << code.second << "]" <<endl;
+ //warning_message("params=[" + params.second + "], code=[" + code.second + "]");
// We must have a valid layout before outputting the Chunk inset.
context.check_layout(os);
Context chunkcontext(true, context.textclass);
}
if (t.cat() == catSuper || t.cat() == catSub) {
- cerr << "catcode " << t << " illegal in text mode\n";
+ string const cc = (t.cat() == catSuper) ? "catSuper" : "catSub";
+ warning_message("catcode " + cc + " illegal in text mode");
continue;
}
if (p.next_token().character() == ']')
p.get_token();
else
- cerr << "Warning: Inserting missing ']' in '"
- << s << "'." << endl;
+ warning_message("Inserting missing ']' in '" + s + "'.");
output_ert_inset(os, s, context);
continue;
}
if (flags & FLAG_BRACE_LAST) {
return;
}
- cerr << "stray '}' in text\n";
+ warning_message("stray '}' in text");
output_ert_inset(os, "}", context);
continue;
}
// eat environment name
string const name = p.getArg('{', '}');
if (name != active_environment())
- cerr << "\\end{" + name + "} does not match \\begin{"
- + active_environment() + "}\n";
+ warning_message("\\end{" + name + "} does not match \\begin{"
+ + active_environment() + "}");
return;
}
p.error("found 'end' unexpectedly");
fix_child_filename(name);
copy_file(absname, name);
} else
- cerr << "Warning: Could not find file '"
- << name << "'." << endl;
+ warning_message("Could not find file '" + name + "'.");
context.check_layout(os);
begin_inset(os, "External\n\ttemplate ");
os << "GnumericSpreadsheet\n\tfilename "
known_pdftex_graphics_formats);
if (!dvips_name.empty()) {
if (!pdftex_name.empty()) {
- cerr << "This file contains the "
- "latex snippet\n"
- "\"\\includegraphics{"
- << name << "}\".\n"
- "However, files\n\""
- << dvips_name << "\" and\n\""
- << pdftex_name << "\"\n"
- "both exist, so I had to make a "
- "choice and took the first one.\n"
- "Please move the unwanted one "
- "someplace else and try again\n"
- "if my choice was wrong."
- << endl;
+ warning_message("This file contains the "
+ "latex snippet\n"
+ "\"\\includegraphics{" + name + "}\".\n"
+ "However, files\n\""
+ + dvips_name + "\" and\n\""
+ + pdftex_name + "\"\n"
+ "both exist, so I had to make a "
+ "choice and took the first one.\n"
+ "Please move the unwanted one "
+ "someplace else and try again\n"
+ "if my choice was wrong.");
}
name = dvips_name;
} else if (!pdftex_name.empty()) {
fix_child_filename(name);
copy_file(absname, name);
} else
- cerr << "Warning: Could not find graphics file '"
- << name << "'." << endl;
+ warning_message("Could not find graphics file '" + name + "'.");
context.check_layout(os);
begin_inset(os, "Graphics ");
if (!ss.str().empty())
os << "\trotateOrigin " << ss.str() << '\n';
else
- cerr << "Warning: Ignoring unknown includegraphics origin argument '" << opt << "'\n";
+ warning_message("Ignoring unknown includegraphics origin argument '" + opt + "'");
}
if (opts.find("keepaspectratio") != opts.end())
os << "\tkeepAspectRatio\n";
<< opts["bbllx"] << " " << opts["bblly"] << " "
<< opts["bburx"] << " " << opts["bbury"] << '\n';
else if (numberOfbbOptions > 0)
- cerr << "Warning: Ignoring incomplete includegraphics boundingbox arguments.\n";
+ warning_message("Ignoring incomplete includegraphics boundingbox arguments.");
numberOfbbOptions = 0;
if (opts.find("natwidth") != opts.end())
numberOfbbOptions++;
os << "\tBoundingBox 0bp 0bp "
<< opts["natwidth"] << " " << opts["natheight"] << '\n';
else if (numberOfbbOptions > 0)
- cerr << "Warning: Ignoring incomplete includegraphics boundingbox arguments.\n";
+ warning_message("Ignoring incomplete includegraphics boundingbox arguments.");
ostringstream special;
if (opts.find("hiresbb") != opts.end())
special << "hiresbb,";
// time in the text language.
time_t ptime = from_asctime_utc(localtime);
if (ptime == static_cast<time_t>(-1)) {
- cerr << "Warning: Could not parse time `" << localtime
- << "´ for change tracking, using current time instead.\n";
+ warning_message("Could not parse time `" + localtime
+ + "´ for change tracking, using current time instead.");
ptime = current_time();
}
if (t.cs() == "lyxadded")
string const citation = p.verbatim_item();
if (!before.empty() && argumentOrder == '\0') {
- cerr << "Warning: Assuming argument order "
- "of jurabib version 0.6 for\n'"
- << command << before << after << '{'
- << citation << "}'.\n"
- "Add 'jurabiborder' to the jurabib "
- "package options if you used an\n"
- "earlier jurabib version." << endl;
+ warning_message("Assuming argument order "
+ "of jurabib version 0.6 for\n'"
+ + command + before + after + '{'
+ + citation + "}'.\n"
+ "Add 'jurabiborder' to the jurabib "
+ "package options if you used an\n"
+ "earlier jurabib version.");
}
bool literal = false;
pair<bool, string> aft;
output_ert_inset(os, "\\verb" + delim
+ arg.second + delim, context);
else
- cerr << "invalid \\verb command. Skipping" << endl;
+ warning_message("invalid \\verb command. Skipping");
continue;
}
copy_file(abssrc, outname);
}
} else {
- cerr << "Warning: Could not find included file '"
- << filename << "'." << endl;
+ warning_message("Could not find included file '" + filename + "'.");
outname = filename;
}
if (external) {
Encoding const * const enc = encodings.fromIconvName(
p.getEncoding(), Encoding::inputenc, true);
if (!enc) {
- cerr << "Unknown bib encoding " << p.getEncoding()
- << ". Ignoring." << std::endl;
+ warning_message("Unknown bib encoding " + p.getEncoding()
+ + ". Ignoring.");
} else
os << "encoding " << '"' << enc->name() << '"' << "\n";
}
Encoding const * const enc = encodings.fromLaTeXName(
preamble.bibencoding, Encoding::inputenc, true);
if (!enc) {
- cerr << "Unknown bib encoding " << preamble.bibencoding
- << ". Ignoring." << std::endl;
+ warning_message("Unknown bib encoding " + preamble.bibencoding
+ + ". Ignoring.");
} else
os << "encoding " << '"' << enc->name() << '"' << "\n";
}
p.setCatcodes(VERBATIM_CATCODES);
string delim = p.get_token().asInput();
if (delim != "{")
- cerr << "Warning: bad delimiter for command " << t.asInput() << endl;
+ warning_message("bad delimiter for command " + t.asInput());
//FIXME: handle error condition
string const arg = p.verbatimStuff("}").second;
Context newcontext(true, context.textclass);
p.setCatcodes(VERBATIM_CATCODES);
string delim = p.get_token().asInput();
if (delim != "{")
- cerr << "Warning: bad delimiter for command " << t.asInput() << endl;
+ warning_message("bad delimiter for command " + t.asInput());
//FIXME: handle error condition
string const arg = p.verbatimStuff("}").second;
Context newcontext(true, context.textclass);
fix_child_filename(name);
copy_file(absname, name);
} else
- cerr << "Warning: Could not find file '"
- << name << "'." << endl;
+ warning_message("Could not find file '" + name + "'.");
// write output
context.check_layout(os);
begin_inset(os, "External\n\ttemplate ");
if (!ss.str().empty())
os << "\trotateOrigin " << ss.str() << '\n';
else
- cerr << "Warning: Ignoring unknown includegraphics origin argument '" << opt << "'\n";
+ warning_message("Ignoring unknown includegraphics origin argument '" + opt + "'");
}
if (opts.find("width") != opts.end())
os << "\twidth "
fix_child_filename(name);
copy_file(absname, name);
} else
- cerr << "Warning: Could not find file '"
- << name << "'." << endl;
+ warning_message("Could not find file '" + name + "'.");
context.check_layout(os);
begin_inset(os, "External\n\ttemplate ");
os << "ChessDiagram\n\tfilename "
for (set<string>::const_iterator it = req.begin(); it != req.end(); ++it)
preamble.registerAutomaticallyLoadedPackage(*it);
}
- //cerr << "#: " << t << " mode: " << mode << endl;
+ //warning_message("#: " + t + " mode: " + mode);
// heuristic: read up to next non-nested space
/*
string s = t.asInput();
string z = p.verbatim_item();
while (p.good() && z != " " && !z.empty()) {
- //cerr << "read: " << z << endl;
+ //warning_message("read: " + z);
s += z;
z = p.verbatim_item();
}
- cerr << "found ERT: " << s << endl;
+ warning_message("found ERT: " + s);
output_ert_inset(os, s + ' ', context);
*/
else {