CCL: retain ? for CCL terms
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 24 Aug 2011 19:45:53 +0000 (21:45 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 24 Aug 2011 19:46:34 +0000 (21:46 +0200)
src/cclfind.c
src/cclp.h
src/ccltoken.c

index 30abcbe..d5518df 100644 (file)
@@ -278,8 +278,6 @@ static struct ccl_rpn_node *search_term_x(CCL_parser cclp,
                 if (lookahead->name[i] == ' ')
                     no_spaces++;
             len += 1+lookahead->len+lookahead->ws_prefix_len;
-            left_trunc = lookahead->left_trunc;
-            right_trunc = lookahead->right_trunc;
             lookahead = lookahead->next;
         }
 
@@ -366,7 +364,18 @@ static struct ccl_rpn_node *search_term_x(CCL_parser cclp,
         {
             const char *src_str = cclp->look_token->name;
             size_t src_len = cclp->look_token->len;
-            
+
+            if (i == 0 && src_len > 0 && *src_str == '?')
+            {
+                src_len--;
+                src_str++;
+                left_trunc = 1;
+            }
+            if (i == no - 1 && src_len > 0 && src_str[src_len-1] == '?')
+            {
+                src_len--;
+                right_trunc = 1;
+            }
             if (p->u.t.term[0] && cclp->look_token->ws_prefix_len)
             {
                 size_t len = strlen(p->u.t.term);
index d792742..7c26e19 100644 (file)
@@ -55,8 +55,6 @@ struct ccl_token {
     struct ccl_token *prev;
     const char *ws_prefix_buf;  /* leading white space buf */
     size_t ws_prefix_len;       /* leading white space len */
-    int left_trunc;             /* left truncated */
-    int right_trunc;            /* right truncated */
 };
 
 /** CCL parser structure */
index 538cd56..6c74226 100644 (file)
@@ -81,7 +81,6 @@ struct ccl_token *ccl_parser_tokenize(CCL_parser cclp, const char *command)
             last->next->prev = last;
             last = last->next;
         }
-        last->left_trunc = last->right_trunc = 0;
         last->ws_prefix_buf = (const char *) cp0;
         last->ws_prefix_len = cp - cp0;
         last->next = NULL;
@@ -127,11 +126,6 @@ struct ccl_token *ccl_parser_tokenize(CCL_parser cclp, const char *command)
         default:
             --cp;
             --last->len;
-            if (*cp == '?')
-            {
-                last->left_trunc = 1;
-                cp++;
-            }
             if (*cp == '"')
             {
                 cp++;
@@ -149,7 +143,7 @@ struct ccl_token *ccl_parser_tokenize(CCL_parser cclp, const char *command)
             {
                 last->kind = CCL_TOK_TERM;
                 last->name = (const char *) cp;
-                while (*cp && !strchr("(),%!><=? \t\n\r", *cp))
+                while (*cp && !strchr("(),%!><= \t\n\r", *cp))
                 {
                     ++ last->len;
                     cp++;
@@ -179,11 +173,6 @@ struct ccl_token *ccl_parser_tokenize(CCL_parser cclp, const char *command)
                 if (token_cmp(cclp, aliases, last))
                     last->kind = CCL_TOK_SET;
             }
-            if (*cp == '?')
-            {
-                last->right_trunc = 1;
-                cp++;
-            }
         }
     }
     return first;
@@ -200,7 +189,6 @@ struct ccl_token *ccl_token_add(struct ccl_token *at)
         n->next->prev = n;
 
     n->kind = CCL_TOK_TERM;
-    n->left_trunc = n->right_trunc = 0;
     n->name = 0;
     n->len = 0;
     n->ws_prefix_buf = 0;