version 1.26, 2014/04/09 21:50:08 |
version 1.27, 2014/04/10 02:46:21 |
Line 221 mansearch(const struct mansearch *search, |
|
Line 221 mansearch(const struct mansearch *search, |
|
SQL_BIND_BLOB(db, s, j, ep->regexp); |
SQL_BIND_BLOB(db, s, j, ep->regexp); |
} else |
} else |
SQL_BIND_TEXT(db, s, j, ep->substr); |
SQL_BIND_TEXT(db, s, j, ep->substr); |
if (0 == (TYPE_Nd & ep->bits)) |
if (0 == ((TYPE_Nd | TYPE_Nm) & ep->bits)) |
SQL_BIND_INT64(db, s, j, ep->bits); |
SQL_BIND_INT64(db, s, j, ep->bits); |
} |
} |
|
|
Line 504 sql_statement(const struct expr *e) |
|
Line 504 sql_statement(const struct expr *e) |
|
? (NULL == e->substr |
? (NULL == e->substr |
? "desc REGEXP ?" |
? "desc REGEXP ?" |
: "desc MATCH ?") |
: "desc MATCH ?") |
|
: TYPE_Nm == e->bits |
|
? (NULL == e->substr |
|
? "id IN (SELECT pageid FROM names " |
|
"WHERE name REGEXP ?)" |
|
: "id IN (SELECT pageid FROM names " |
|
"WHERE name MATCH ?)") |
: (NULL == e->substr |
: (NULL == e->substr |
? "id IN (SELECT pageid FROM keys " |
? "id IN (SELECT pageid FROM keys " |
"WHERE key REGEXP ? AND bits & ?)" |
"WHERE key REGEXP ? AND bits & ?)" |
Line 525 sql_statement(const struct expr *e) |
|
Line 531 sql_statement(const struct expr *e) |
|
static struct expr * |
static struct expr * |
exprcomp(const struct mansearch *search, int argc, char *argv[]) |
exprcomp(const struct mansearch *search, int argc, char *argv[]) |
{ |
{ |
|
uint64_t mask; |
int i, toopen, logic, igncase, toclose; |
int i, toopen, logic, igncase, toclose; |
struct expr *first, *next, *cur; |
struct expr *first, *prev, *cur, *next; |
|
|
first = cur = NULL; |
first = cur = NULL; |
logic = igncase = toclose = 0; |
logic = igncase = toclose = 0; |
Line 569 exprcomp(const struct mansearch *search, int argc, cha |
|
Line 576 exprcomp(const struct mansearch *search, int argc, cha |
|
first = next; |
first = next; |
else |
else |
cur->next = next; |
cur->next = next; |
|
prev = cur = next; |
|
|
/* |
/* |
* Searching for descriptions must be split out |
* Searching for descriptions must be split out |
Line 576 exprcomp(const struct mansearch *search, int argc, cha |
|
Line 584 exprcomp(const struct mansearch *search, int argc, cha |
|
* not in the keys table. |
* not in the keys table. |
*/ |
*/ |
|
|
if (TYPE_Nd & next->bits && ~TYPE_Nd & next->bits) { |
for (mask = TYPE_Nm; mask <= TYPE_Nd; mask <<= 1) { |
cur = mandoc_calloc(1, sizeof(struct expr)); |
if (mask & cur->bits && ~mask & cur->bits) { |
memcpy(cur, next, sizeof(struct expr)); |
next = mandoc_calloc(1, |
next->open = 1; |
sizeof(struct expr)); |
next->bits = TYPE_Nd; |
memcpy(next, cur, sizeof(struct expr)); |
next->next = cur; |
prev->open = 1; |
cur->bits &= ~TYPE_Nd; |
cur->bits = mask; |
|
cur->next = next; |
|
cur = next; |
|
cur->bits &= ~mask; |
|
} |
|
} |
|
prev->and = (1 == logic); |
|
prev->open += toopen; |
|
if (cur != prev) |
cur->close = 1; |
cur->close = 1; |
} else |
|
cur = next; |
|
next->and = (1 == logic); |
|
next->open += toopen; |
|
toopen = logic = igncase = 0; |
toopen = logic = igncase = 0; |
} |
} |
if (toopen || logic || igncase || toclose) |
if (toopen || logic || igncase || toclose) |