Re: r29557 - lyx-devel/trunk/src/tex2lyx

2009-05-11 Thread Jean-Marc Lasgouttes
Abdelrazak Younes writes: > No, you can also use vector::reserve in order to make sure that the > memory is never reallocated. Only if you know in advance how many tokens are going to be read, which can be approximated by file size, but is IMO less clean than returning a copy as I did. I did some

RE: r29557 - lyx-devel/trunk/src/tex2lyx

2009-05-11 Thread Vincent van Ravesteijn - TNW
>> It happens always, and only in a table directly after '\\'. It also >> happens for example \textit{..} instead of \verb". It looks perfectly >> reproducable. >> >> So, the vector only 'reallocates' the tokens when a second token is >> added. >> >> Still, I don't understand this. > >When the

Re: r29557 - lyx-devel/trunk/src/tex2lyx

2009-05-11 Thread Jean-Marc Lasgouttes
"Vincent van Ravesteijn - TNW" writes: > I couldn't reproduce this with a minimal example. > > FYI, I found out that the t.cs() becomes 'crap' after text.cpp:1544. At > this line, there is a call to p.next_token() which will call > tokens_.push_back() somewhere and after this, t.cs() is bogus and

RE: r29557 - lyx-devel/trunk/src/tex2lyx

2009-05-07 Thread Vincent van Ravesteijn - TNW
> Actually, the problem (I understood it by reading your previous > message) is that the tokens_ variable is a vector, and > therefore it can from time to time be reallocated when we do a > push_back(). In this case, the references become stale. I couldn't reproduce this with a minimal example

Re: r29557 - lyx-devel/trunk/src/tex2lyx

2009-05-07 Thread Abdelrazak Younes
Jean-Marc Lasgouttes wrote: Abdelrazak Younes writes: Hum, I withdraw the "perfectly fine". This is not a const method and pos_ is modified. This is a very bad idea and this parser is just severely broken IMO... No, get_token is a "read token and advance position" method, much like <<

Re: r29557 - lyx-devel/trunk/src/tex2lyx

2009-05-07 Thread Jean-Marc Lasgouttes
Abdelrazak Younes writes: > Hum, I withdraw the "perfectly fine". This is not a const method and > pos_ is modified. This is a very bad idea and this parser is just > severely broken IMO... No, get_token is a "read token and advance position" method, much like << for a stream. This is actually a

RE: r29557 - lyx-devel/trunk/src/tex2lyx

2009-05-07 Thread Vincent van Ravesteijn - TNW
>Hum, I withdraw the "perfectly fine". This is not a const method and >pos_ is modified. This is a very bad idea and this parser is just >severely broken IMO... > >So what I would do is this: > >- Token const & Parser::get_token() >+ Token const & Parser::get_token() const >{ > static const Toke

Re: r29557 - lyx-devel/trunk/src/tex2lyx

2009-05-07 Thread Abdelrazak Younes
Abdelrazak Younes wrote: Jean-Marc Lasgouttes wrote: lasgout...@lyx.org writes: Author: lasgouttes Date: Thu May 7 12:09:03 2009 New Revision: 29557 URL: http://www.lyx.org/trac/changeset/29557 Log: (partial?) fix to bug 5935 I am not sure why the fix is really needed, but it works.

Re: r29557 - lyx-devel/trunk/src/tex2lyx

2009-05-07 Thread Abdelrazak Younes
Jean-Marc Lasgouttes wrote: lasgout...@lyx.org writes: Author: lasgouttes Date: Thu May 7 12:09:03 2009 New Revision: 29557 URL: http://www.lyx.org/trac/changeset/29557 Log: (partial?) fix to bug 5935 I am not sure why the fix is really needed, but it works. Basically, the fix is:

Re: r29557 - lyx-devel/trunk/src/tex2lyx

2009-05-07 Thread Jean-Marc Lasgouttes
lasgout...@lyx.org writes: > Author: lasgouttes > Date: Thu May 7 12:09:03 2009 > New Revision: 29557 > URL: http://www.lyx.org/trac/changeset/29557 > > Log: > (partial?) fix to bug 5935 I am not sure why the fix is really needed, but it works. Basically, the fix is: > - Token const