RE: regex/string algorithm problem
Boy! You guys are SPOOKY good. I wrestle with something 'til I give up and then I go to write a report and while I formulate the words you start feeding back answers! The reason the code I sent "hangs" is because it's iterating over a zero length match. which consumes 0 characters of input per loop. I must do that once a year in any language I use, you think I'd learn huh? If I can reproduce the segfault and I can't see why it's my fault, can I post that too? Or can we skip that and have y'all start channeling me the clues now. :) Thanks again for your time. -- Blue Skies
The reason the code I sent "hangs" is because it's iterating over a zero length match. which consumes 0 characters of input per loop. I must do that once a year in any language I use, you think I'd learn huh?
If you'd used regex_iterator or regex_token_iterator then they would have taken care of that special case for you, and it wouldn't have gone round and round (Pavol: any reason why the string lib isn't using these internally?).
If I can reproduce the segfault and I can't see why it's my fault, can I post that too? Or can we skip that and have y'all start channeling me the clues now. :)
Please do, make sure it's not down to referencing temporary objects after they've gone out of scope (that's the most common cause of segfaults around here). John.
On Mon, Feb 21, 2005 at 12:23:03PM -0000, John Maddock wrote:
The reason the code I sent "hangs" is because it's iterating over a zero length match. which consumes 0 characters of input per loop. I must do that once a year in any language I use, you think I'd learn huh?
If you'd used regex_iterator or regex_token_iterator then they would have taken care of that special case for you, and it wouldn't have gone round and round (Pavol: any reason why the string lib isn't using these internally?).
This is probably good idea. Regex support in the StringAlgo is more-less conceptual proof of concept, that the library can be extended to handle complicated finder/formatters. The library does not use the regex_iterator internaly, since it would make no sense. StringAlgo has its own tokenizing facility, that is differnet from the one provided by regex. Regex is used only as a plugable component.
If I can reproduce the segfault and I can't see why it's my fault, can I post that too? Or can we skip that and have y'all start channeling me the clues now. :)
Please do, make sure it's not down to referencing temporary objects after they've gone out of scope (that's the most common cause of segfaults around here).
Anyway, it is possible, that there is indeed a problem in the StringAlgo library. As I said, I'll look at it later on. Regards, Pavol
On Mon, 21 Feb 2005 12:23:03 -0000, John Maddock
The reason the code I sent "hangs" is because it's iterating over a zero length match. which consumes 0 characters of input per loop. I must do that once a year in any language I use, you think I'd learn huh?
If you'd used regex_iterator or regex_token_iterator then they would have taken care of that special case for you, and it wouldn't have gone round and round
Cheers John but I couldn't work out from the docs how to do much with regex at all. I'm afraid the language is too grown up. :) After trawling through the tests and stuff I could see enough to get code to compile but I've got a long way to go before I can wrap my head around the regex description.
If I can reproduce the segfault and I can't see why it's my fault, can I post that too? Or can we skip that and have y'all start channeling me the clues now. :)
Please do, make sure it's not down to referencing temporary objects after they've gone out of scope (that's the most common cause of segfaults around here).
Thanks for the pointer, I don't THINK it was a scope problem because I basically pasted the first loop and tried to change it to use a regex_finder. Once I figured out that, despite the way I read the string algo pages, regex_finder woudln't take a string it confused my that one loop worked and the other segfaulted as soon as it tried to increment the iterator. BTW is there any way to get more concise output from gdb when I'm trying to find myself in a c++/boost session? -- Blue Skies
participants (3)
-
John Maddock
-
Pavol Droba
-
The Grumpiest Man You Know