|
a/src/query/wasastringtoquery.cpp |
|
b/src/query/wasastringtoquery.cpp |
1 |
#ifndef lint
|
1 |
#ifndef lint
|
2 |
static char rcsid[] = "@(#$Id: wasastringtoquery.cpp,v 1.9 2008-08-26 13:50:13 dockes Exp $ (C) 2006 J.F.Dockes";
|
2 |
static char rcsid[] = "@(#$Id: wasastringtoquery.cpp,v 1.10 2008-12-16 08:53:49 dockes Exp $ (C) 2006 J.F.Dockes";
|
3 |
#endif
|
3 |
#endif
|
4 |
/*
|
4 |
/*
|
5 |
* This program is free software; you can redistribute it and/or modify
|
5 |
* This program is free software; you can redistribute it and/or modify
|
6 |
* it under the terms of the GNU General Public License as published by
|
6 |
* it under the terms of the GNU General Public License as published by
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
|
... |
|
... |
23 |
#include <string.h>
|
23 |
#include <string.h>
|
24 |
#include <regex.h>
|
24 |
#include <regex.h>
|
25 |
|
25 |
|
26 |
#include "wasastringtoquery.h"
|
26 |
#include "wasastringtoquery.h"
|
27 |
|
27 |
|
28 |
//#define DEB_WASASTRINGTOQ 1
|
28 |
// #define DEB_WASASTRINGTOQ 1
|
29 |
#ifdef DEB_WASASTRINGTOQ
|
29 |
#ifdef DEB_WASASTRINGTOQ
|
30 |
#define DPRINT(X) fprintf X
|
30 |
#define DPRINT(X) fprintf X
|
|
|
31 |
#define DUMPQ(Q) {string D;Q->describe(D);fprintf(stderr, "%s\n", D.c_str());}
|
31 |
#else
|
32 |
#else
|
32 |
#define DPRINT(X)
|
33 |
#define DPRINT(X)
|
|
|
34 |
#define DUMPQ(Q)
|
33 |
#endif
|
35 |
#endif
|
34 |
|
36 |
|
35 |
WasaQuery::~WasaQuery()
|
37 |
WasaQuery::~WasaQuery()
|
36 |
{
|
38 |
{
|
37 |
for (vector<WasaQuery*>::iterator it = m_subs.begin();
|
39 |
for (vector<WasaQuery*>::iterator it = m_subs.begin();
|
|
... |
|
... |
287 |
return 0;
|
289 |
return 0;
|
288 |
}
|
290 |
}
|
289 |
orChain->m_op = WasaQuery::OP_OR;
|
291 |
orChain->m_op = WasaQuery::OP_OR;
|
290 |
}
|
292 |
}
|
291 |
|
293 |
|
292 |
// We need to transfer the previous query from the main vector
|
294 |
// For the first OR, we need to transfer the previous
|
293 |
// to the OR subquery
|
295 |
// query from the main vector to the OR subquery
|
294 |
if (!query->m_subs.empty()) {
|
296 |
if (orChain->m_subs.empty() && !query->m_subs.empty()) {
|
295 |
orChain->m_subs.push_back(query->m_subs.back());
|
297 |
orChain->m_subs.push_back(query->m_subs.back());
|
296 |
query->m_subs.pop_back();
|
298 |
query->m_subs.pop_back();
|
297 |
}
|
299 |
}
|
298 |
prev_or = true;
|
300 |
prev_or = true;
|
299 |
|
301 |
|
|
... |
|
... |
414 |
break;
|
416 |
break;
|
415 |
}
|
417 |
}
|
416 |
|
418 |
|
417 |
if (orChain) {
|
419 |
if (orChain) {
|
418 |
// Getting out of OR. Add the OR subquery to the main one
|
420 |
// Getting out of OR. Add the OR subquery to the main one
|
|
|
421 |
DPRINT((stderr, "Adding OR chain to main.Before: \n"));
|
|
|
422 |
DUMPQ(query);
|
|
|
423 |
DUMPQ(orChain);
|
419 |
query->m_subs.push_back(orChain);
|
424 |
query->m_subs.push_back(orChain);
|
420 |
DPRINT((stderr, "Adding OR chain to main\n"));
|
|
|
421 |
}
|
425 |
}
|
422 |
|
426 |
|
423 |
regfree(&m_rx);
|
427 |
regfree(&m_rx);
|
424 |
m_rxneedsfree = false;
|
428 |
m_rxneedsfree = false;
|
425 |
return query;
|
429 |
return query;
|
|
... |
|
... |
449 |
fprintf(stderr, "stringToQuery failed: %s\n", reason.c_str());
|
453 |
fprintf(stderr, "stringToQuery failed: %s\n", reason.c_str());
|
450 |
exit(1);
|
454 |
exit(1);
|
451 |
}
|
455 |
}
|
452 |
string desc;
|
456 |
string desc;
|
453 |
q->describe(desc);
|
457 |
q->describe(desc);
|
454 |
printf("%s\n", desc.c_str());
|
458 |
fprintf(stderr, "Finally: %s\n", desc.c_str());
|
455 |
exit(0);
|
459 |
exit(0);
|
456 |
}
|
460 |
}
|
457 |
|
461 |
|
458 |
#endif // TEST_WASASTRINGTOQUERY
|
462 |
#endif // TEST_WASASTRINGTOQUERY
|