Op 20-6-2012 23:24, Uwe Stöhr schreef:
commit c00fd8f8be2a8478f0ae6c8ed92a232dba269897
Author: Uwe Stöhr<uwesto...@lyx.org>
Date: Wed Jun 20 23:24:35 2012 +0200
tex2lyx/table.cpp: fix bug #8204, also OK for branch or too late?
Please use the commit log to explain what the bug was, how it is solved,
and why this is the correct solution ?
diff --git a/src/tex2lyx/table.cpp b/src/tex2lyx/table.cpp
index 399a555..a0de111 100644
--- a/src/tex2lyx/table.cpp
+++ b/src/tex2lyx/table.cpp
@@ -1164,8 +1164,20 @@ void handle_tabular(Parser& p, ostream& os, string
const& name,
cellinfo[row][col].content += os.str();
// add dummy cells for multicol
- for (size_t i = 0; i< ncells - 1&& col<
colinfo.size(); ++i) {
+ for (size_t i = 0; i + 1< ncells; ++i) {
+ for (size_t i = 0; i + 1< ncells; ++i) {
Why do you prefer "i + 1 < ncells" instead of " i < ncells - 1". I find
the second option better, so why do you want to change it ?
++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;
+ break;
+ }
Is this information useful to be outputted ? In which cases can this
happen ? We already check that col can't be larger or equal to
colinfo.size(). Fixing the bug and adding the error message are two
different issues.
Isn't the problem solved with the following much simpler fix ? :
- for (size_t i = 0; i< ncells - 1&& col<
colinfo.size(); ++i) {
- ++col;
+ for (size_t i = 0; i< ncells - 1&& col<
colinfo.size(); ++i, ++col) {
Vincent