~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzledump.cc

  • Committer: Andrew Hutchings
  • Date: 2010-09-14 16:14:05 UTC
  • mto: (1792.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1793.
  • Revision ID: andrew@linuxjedi.co.uk-20100914161405-bmh4d80vo5f9e23y
Switch to using boost::regex instead of pcre

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
#include <drizzled/configmake.h>
45
45
#include <drizzled/error.h>
46
46
#include <boost/program_options.hpp>
47
 
#include PCRE_HEADER
 
47
#include <boost/regex.hpp>
48
48
 
49
49
using namespace std;
50
50
using namespace drizzled;
2411
2411
 
2412
2412
int get_server_type()
2413
2413
{
2414
 
  const char *pcre_error;
2415
 
  int32_t pcre_error_offset;
2416
 
  int ovector[9];
2417
 
  int pcre_match;
2418
 
 
2419
 
  pcre *mysql_regex= pcre_compile("5\\.[0-9]+\\.[0-9]+", 0, &pcre_error, &pcre_error_offset, NULL);
2420
 
  if (!mysql_regex)
2421
 
  {
2422
 
    fprintf(stderr, _("Error compiling regex (offset: %d), %s\n"));
2423
 
    exit(-1);
2424
 
  }
2425
 
 
2426
 
  pcre *drizzle_regex= pcre_compile("20[0-9]{2}\\.(0[1-9]|1[012])\\.[0-9]+", 0, &pcre_error, &pcre_error_offset, NULL);
2427
 
  if (!drizzle_regex)
2428
 
  {
2429
 
    fprintf(stderr, _("Error compiling regex (offset: %d), %s\n"));
2430
 
    exit(-1);
2431
 
  }
 
2414
  boost::match_flag_type flags = boost::match_default; 
 
2415
 
 
2416
  boost::regex mysql_regex("(5\\.[0-9]+\\.[0-9]+)");
 
2417
  boost::regex drizzle_regex("(20[0-9]{2}\\.(0[1-9]|1[012])\\.[0-9]+)");
2432
2418
 
2433
2419
  std::string version(drizzle_con_server_version(&dcon));
2434
2420
 
2435
 
  pcre_match= pcre_exec(mysql_regex, 0, version.c_str(), version.length(), 0, 0, ovector, 9);
2436
 
 
2437
 
  if (pcre_match >= 0)
 
2421
  if (regex_search(version, mysql_regex, flags))
2438
2422
    return SERVER_MYSQL_FOUND;
2439
2423
  
2440
 
  pcre_match= pcre_exec(drizzle_regex, 0, version.c_str(), version.length(), 0, 0, ovector, 9);
2441
 
 
2442
 
  if (pcre_match >= 0)
 
2424
  if (regex_search(version, drizzle_regex, flags))
2443
2425
    return SERVER_DRIZZLE_FOUND;
2444
2426
 
2445
2427
  return SERVER_UNKNOWN_FOUND;