Boost logo

Boost Users :

From: eydelber (eydelber_at_[hidden])
Date: 2002-11-25 21:50:34


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<checksLength;i++) {
        sqlRegex.SetExpression(checks[i],true);
        if(sqlRegex.Match(sql)) {
                break;
        }
}

The interesting thing is that the first string, checks[0] is similar
to the insert syntax, and when I use a very long string for the
create table syntax, it works perfectly fine. Also, I tried just
adding another element to checks, just trying, but that didn't
work. Also, I had no such problem for the other 12 cases, it only
happens with this last insert case.

Any help will be greatly appreciated, I have been stuck on this for
days!!

Thanks,
Kevin


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net