On Fri, Jan 07, 2005 at 07:36:50PM +0100, Georg Baum wrote:
> > Otherwise everything after the & is ignored. The above is valid LaTeX. It
> > can be produced by tex2lyx (because it does not touch formulas at all),
> > and it was created by very old LyX versions. The following patch seems to
> > fix this.
> > I am not sure wether I understood the math parser well enough, so it would
> > be nice if somebody (Andr�?) could comment.
>
> Andr�, can you have a look?
Patch attached. You could commit that if it fixes the problem.
Andre'
Index: math_parser.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_parser.C,v
retrieving revision 1.308
diff -u -p -r1.308 math_parser.C
--- math_parser.C 7 Jan 2005 13:32:26 -0000 1.308
+++ math_parser.C 8 Jan 2005 20:27:26 -0000
@@ -191,7 +191,8 @@ inline CatCode catcode(unsigned char c)
enum {
- FLAG_BRACE_LAST = 1 << 1, // last closing brace ends the parsing
+ FLAG_ALIGN = 1 << 0, // next & ends the parsing process
+ FLAG_BRACE_LAST = 1 << 1, // next closing brace ends the parsing
FLAG_RIGHT = 1 << 2, // next \\right ends the parsing process
FLAG_END = 1 << 3, // next \\end ends the parsing process
FLAG_BRACK_LAST = 1 << 4, // next closing bracket ends the parsing
@@ -757,9 +758,10 @@ void Parser::parse1(MathGridInset & grid
else if (t.cat() == catAlign) {
//lyxerr << " column now " << (cellcol + 1)
// << " max: " << grid.ncols() << endl;
+ if (flags & FLAG_ALIGN)
+ return;
if (addCol(grid, cellcol))
- cell = &grid.cell(grid.index(cellrow,
- cellcol));
+ cell = &grid.cell(grid.index(cellrow, cellcol));
}
else if (t.cat() == catSuper || t.cat() == catSub) {
@@ -1210,25 +1212,33 @@ void Parser::parse1(MathGridInset & grid
if (l) {
if (l->inset == "font") {
cell->push_back(createMathInset(t.cs()));
- parse(cell->back().nucleus()->cell(0),
FLAG_ITEM, asMode(mode, l->extra));
+ parse(cell->back().nucleus()->cell(0),
+ FLAG_ITEM, asMode(mode,
l->extra));
}
else if (l->inset == "oldfont") {
cell->push_back(createMathInset(t.cs()));
- parse(cell->back().nucleus()->cell(0),
flags, asMode(mode, l->extra));
- return;
+ parse(cell->back().nucleus()->cell(0),
+ flags | FLAG_ALIGN,
asMode(mode, l->extra));
+ if (prevToken().cat() != catAlign)
+ return;
+ putback();
}
else if (l->inset == "style") {
cell->push_back(createMathInset(t.cs()));
- parse(cell->back().nucleus()->cell(0),
flags, mode);
- return;
+ parse(cell->back().nucleus()->cell(0),
+ flags | FLAG_ALIGN, mode);
+ if (prevToken().cat() != catAlign)
+ return;
+ putback();
}
else {
MathAtom at = createMathInset(t.cs());
for (MathInset::idx_type i = 0; i <
at->nargs(); ++i)
- parse(at.nucleus()->cell(i),
FLAG_ITEM, asMode(mode, l->extra));
+ parse(at.nucleus()->cell(i),
+ FLAG_ITEM, asMode(mode,
l->extra));
cell->push_back(at);
}
}