I'm porting a piece of C# software that uses System.Text.RegularExpressions.Regex
for parsing out C/C++ includes out of source files. They are fully loaded into memory as a string and then just treated with the regex.
It works perfectly on Windows, but Mono running on Linux fails when trying to parse larger files with a stack overflow exception thrown from deep inside System.Text.RegularExpressions.Interpreter
.
The code is perfectly correct - it works on Windows.
Is there a way to increase the stack size? Or do I really need to break up larger files into smaller chunks?
EDIT: The regex in question looks like this:
/** Regex that matches #include statements. */
static Regex CPPHeaderRegex = new Regex( "(([ \t]*#[ \t]*include[ \t]*[<\"](?<HeaderFile>[^\">]*)[\">][^\n]*\n)|([^\n]*\n))*",
RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.ExplicitCapture );
The sources that cause problems are 300kB (~8k SLOC) and larger.
Mind you that this is not my code, I inherited it.