Boost logo

Boost Users :

From: John Maddock (john_maddock_at_[hidden])
Date: 2002-11-27 07:05:24


> 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:

I tried testing using the program below and it checked out fine with VC6,
can you verify that this reproduces the problem? If not can you please
submit one that does? If the issue is occuring in a call to c_str() can you
verify that the argument is actually a valid string, and/or get a stack
backtrace?

John Maddock
http://ourworld.compuserve.com/homepages/john_maddock/index.htm

Here's my test code:

#include <iostream>
#include "boost/cregex.hpp"

int main(int, char**) {
   std::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;

   std::string sql = "insert into test (one,two,three) values (
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ,
cccccccccccccccccccccccccccccccccccccc)";

   boost::RegEx sqlRegex;
   for(i=0;i<checksLength;i++)
   {
      sqlRegex.SetExpression(checks[i],true);
      if(sqlRegex.Match(sql))
      {
         break;
      }
   }
   return 0;
}


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