This probably is annoying me to no end. I have a string that I am
matching against a pattern called 'sql'. My program tests 'sql'
against 14 possible patterns. The patterns are in an array of
strings. EVERYTHING works except for the last pattern. And even
then, only when the 2nd sub-expression is longer than a certain
length. For example,
this works:
insert into test (one,two,three) values ()
Through a lot of testing, I have seen that after the comma
delimitted list in the second sub-expression surpasses a certain
length, then my program gets aborted at the line if(sqlRegex.Match
(sql)) {
I am running the latest version of boost regex++, and I am running
g++ 2.96 on Linux. I ran gdb, and I seemed to have narrowed down the
problem to c_str(), but this is not logical. Here is the part of my
program:
string checks[] = {
/* 0 */ "create table (_ID_) (\\(((\\s*,?\\s*(_ID_)
(_TYPES_)( not null)?( unique)?( default ((\\d+(\\.\\d+)?)|(\"[^\"]
*\")))?( unique)?\\s*)+)\\))",
/* 1 */ "show tables",
/* 2 */ "drop table (_ID_)",
/* 3 */ "show tdb\\.xml",
/* 4 */ "desc( table)? (_ID_)",
/* 5 */ "alter table (_ID_) add( column)? ((_ID_) (_TYPES_)
( not null)?( unique)?( default ((\\d+(\\.\\d+)?)|(\"[^\"]*\")))?(
unique)?( first| after (_ID_))?)",
/* 6 */ "alter table (_ID_) drop( column)? (_ID_)",
/* 7 */ "alter table (_ID_) add( column)? \\(((\\s*,?\\s*
(_ID_) (_TYPES_)( not null)?( unique)?( default ((\\d+(\\.\\d+)?)|
(\"[^\"]*\")))?( unique)?( first| after (_ID_))?\\s*)+)\\)",
/* 8 */ "rename table (_ID_) (to|as) (_ID_)",
/* 9 */ "alter table (_ID_) alter( column)? (_ID_) (set
default ((\\d+(\\.\\d+)?)|(\"[^\"]*\"))|drop default)",
/* 10 */ "alter table (_ID_) modify( column)? ((_ID_)
(_TYPES_)( not null)?( unique)?( default ((\\d+(\\.\\d+)?)|(\"[^\"]
*\")))?( unique)?( first| after (_ID_))?)",
/* 11 */ "alter table (_ID_) change( column)? (_ID_) ((_ID_)
(_TYPES_)( not null)?( unique)?( default ((\\d+(\\.\\d+)?)|(\"[^\"]
*\")))?( unique)?( first| after (_ID_))?)",
/* 12 */ "alter table (_ID_) rename( to| as) (_ID_)",
/* 13 */ "insert( into)? (_ID_)( \\(((\\s*,?\\s*(_ID_)\\s*)+)
\\))? values \\(\\)"
};
int checksLength = sizeof checks / sizeof *checks;
int i;
RegEx sqlRegex;
for(i=0;i