+ case -1: /* not specified */
+ case 100: /* do not truncate */
+ strcat (term_dict, "(");
+ strcat (term_dict, term_sub);
+ strcat (term_dict, ")");
+ logf (LOG_DEBUG, "dict_lookup_grep: %s", term_dict);
+ r = dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info,
+ &max_pos, grep_handle);
+ if (r)
+ logf (LOG_WARN, "dict_lookup_grep err, trunc=none:%d", r);
+ break;
+ case 1: /* right truncation */
+ strcat (term_dict, term_sub);
+ strcat (term_dict, ".*");
+ dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info,
+ &max_pos, grep_handle);
+ break;
+ case 2: /* left truncation */
+ case 3: /* left&right truncation */
+ zi->errCode = 120;
+ return -1;
+ case 101: /* process # in term */
+ for (j = strlen(term_dict), i = 0; term_sub[i] && i < 2; i++)
+ term_dict[j++] = term_sub[i];
+ for (; term_sub[i]; i++)
+ if (term_sub[i] == '#')
+ {
+ term_dict[j++] = '.';
+ term_dict[j++] = '*';
+ }
+ else
+ term_dict[j++] = term_sub[i];
+ term_dict[j] = '\0';
+ r = dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info,
+ &max_pos, grep_handle);
+ if (r)
+ logf (LOG_WARN, "dict_lookup_grep err, trunc=#: %d",
+ r);
+ break;
+ case 102: /* regular expression */
+ strcat (term_dict, "(");
+ strcat (term_dict, term_sub);
+ strcat (term_dict, ")");
+ logf (LOG_DEBUG, "dict_lookup_grep: %s", term_dict);
+ r = dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info,
+ &max_pos, grep_handle);
+ if (r)
+ logf (LOG_WARN, "dict_lookup_grep err, trunc=regular: %d",
+ r);
+ break;