Skip to content

Commit

Permalink
print EVERY nodes (and refactor printing)
Browse files Browse the repository at this point in the history
In particular, EMPTY nodes should also be printed, since this is
for debugging porpoises.
  • Loading branch information
wmorgan committed Jun 19, 2011
1 parent fb63f07 commit f437343
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions query.c
Expand Up @@ -113,22 +113,30 @@ static int subquery_to_s(wp_query* q, size_t n, char* buf) {
#define min(a, b) (a < b ? a : b)

size_t wp_query_to_s(wp_query* q, size_t n, char* buf) {
size_t ret;
size_t ret, term_n;
char* orig_buf = buf;

if(q->type == WP_QUERY_EMPTY) {
buf[0] = '\0';
ret = n;
}
else if(q->type == WP_QUERY_TERM) {
size_t term_n = (size_t)snprintf(buf, n, "%s:\"%s\"", q->field, q->word);
/* nodes without children */
switch(q->type) {
case WP_QUERY_TERM:
term_n = (size_t)snprintf(buf, n, "%s:\"%s\"", q->field, q->word);
ret = min(term_n, n);
}
else if(q->type == WP_QUERY_LABEL) {
size_t term_n = (size_t)snprintf(buf, n, "~%s", q->word);
break;
case WP_QUERY_LABEL:
term_n = (size_t)snprintf(buf, n, "~%s", q->word);
ret = min(term_n, n);
}
else {
break;
case WP_QUERY_EMPTY:
term_n = (size_t)snprintf(buf, n, "<EMPTY>");
ret = min(term_n, n);
break;
case WP_QUERY_EVERY:
term_n = (size_t)snprintf(buf, n, "<EVERY>");
ret = min(term_n, n);
break;

/* nodes with children */
default:
switch(q->type) {
case WP_QUERY_CONJ:
if(n >= 4) { // "(AND"
Expand Down

0 comments on commit f437343

Please sign in to comment.