Recursive Includes

2010-09-30 Thread Richard Heck
The attached patch is an attempt to get a real start on fixing problems with recursive includes. As you'll note, there are a couple places I know still crash, but I wanted to see if anyone had a better idea. On this approach, we basically have to make sure we NEVER try to recurse via Buffer

Re: Recursive Includes

2010-09-30 Thread Stephan Witt
Am 30.09.2010 um 19:03 schrieb Richard Heck: The attached patch is an attempt to get a real start on fixing problems with recursive includes. As you'll note, there are a couple places I know still crash, but I wanted to see if anyone had a better idea. On this approach, we basically have

Re: Recursive Includes

2010-09-30 Thread Pavel Sanda
Stephan Witt wrote: There is a cool algorithm to detect infinite loops without global state: Use two pointers, start both somewhere at the same point. Increment the first by one, the second by two (if not hitting the end), until one of the conditions is true: 1. Stop if one of the pointers

Re: Recursive Includes

2010-09-30 Thread Pavel Sanda
Pavel Sanda wrote: there is a slight complication that we can branch in each document... so either we have towards beginning or send pointer messenger in all possible branches... actually whats the depth where lyx crashes...? i guess thats posing maximum depth for, say, 100 is enough for any

Re: Recursive Includes (and the Buffer List?)

2010-09-30 Thread Richard Heck
is information about the overall structure, who is whose parent, etc. We basically reconstruct that over and over again, which isn't so bad if recursive includes aren't an issue but becomes serious when they are, because, in that case, what structure the thing seems to have depends upon where

Re: Recursive Includes (and the Buffer List?)

2010-09-30 Thread Jean-Marc Lasgouttes
Le 30/09/2010 23:03, Richard Heck a écrit : It's not so much detecting the recursion. It's what to do about it once you detect it. So, say, we have: A - B - A. What should B.masterBuffer() return? What should A.masterBuffer() return? How do you safely write recursions? I would say the second A

Re: Recursive Includes (and the Buffer List?)

2010-09-30 Thread Richard Heck
something stable. Maybe the place to do this is in Buffer::setParent(). I.e., every time we are asked to set a parent, we check for recursive includes and refuse to set it if doing saw causes recursion. Of course, we'd like to accept: A-B \C-B where B is inserted twice

Re: Recursive Includes (and the Buffer List?)

2010-09-30 Thread Richard Heck
something stable. Maybe the place to do this is in Buffer::setParent(). I.e., every time we are asked to set a parent, we check for recursive includes and refuse to set it if doing saw causes recursion. Of course, we'd like to accept: A-B \C-B where B is inserted twice

Recursive Includes

2010-09-30 Thread Richard Heck
The attached patch is an attempt to get a real start on fixing problems with recursive includes. As you'll note, there are a couple places I know still crash, but I wanted to see if anyone had a better idea. On this approach, we basically have to make sure we NEVER try to recurse via Buffer

Re: Recursive Includes

2010-09-30 Thread Stephan Witt
Am 30.09.2010 um 19:03 schrieb Richard Heck: > > The attached patch is an attempt to get a real start on fixing problems with > recursive includes. As you'll note, there are a couple places I know still > crash, but I wanted to see if anyone had a better idea. On this approach, we

Re: Recursive Includes

2010-09-30 Thread Pavel Sanda
Stephan Witt wrote: > There is a cool algorithm to detect infinite loops without global state: > > Use two pointers, start both somewhere at the same point. > Increment the first by one, the second by two (if not hitting the end), until > one of the conditions is true: > 1. Stop if one of the

Re: Recursive Includes

2010-09-30 Thread Pavel Sanda
Pavel Sanda wrote: > there is a slight complication that we can branch in each document... so > either we have towards beginning or send pointer messenger in all possible > branches... actually whats the depth where lyx crashes...? i guess thats posing maximum depth for, say, 100 is enough for

Re: Recursive Includes (and the Buffer List?)

2010-09-30 Thread Richard Heck
each Buffer, whereas what we seem to need here is information about the overall structure, who is whose parent, etc. We basically reconstruct that over and over again, which isn't so bad if recursive includes aren't an issue but becomes serious when they are, because, in that case, what structu

Re: Recursive Includes (and the Buffer List?)

2010-09-30 Thread Jean-Marc Lasgouttes
Le 30/09/2010 23:03, Richard Heck a écrit : It's not so much detecting the recursion. It's what to do about it once you detect it. So, say, we have: A -> B -> A. What should B.masterBuffer() return? What should A.masterBuffer() return? How do you safely write recursions? I would say the second

Re: Recursive Includes (and the Buffer List?)

2010-09-30 Thread Richard Heck
B->A. We want something stable. Maybe the place to do this is in Buffer::setParent(). I.e., every time we are asked to set a parent, we check for recursive includes and refuse to set it if doing saw causes recursion. Of course, we'd like to accept: A->B \>C->B wher

Re: Recursive Includes (and the Buffer List?)

2010-09-30 Thread Richard Heck
B->A. We want something stable. Maybe the place to do this is in Buffer::setParent(). I.e., every time we are asked to set a parent, we check for recursive includes and refuse to set it if doing saw causes recursion. Of course, we'd like to accept: A->B \>C->B wher