X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Frecgrs.c;h=ef0acb445b82de059a5a75c6914e9055f183fa64;hb=90d4902e0921f68842031a4aa1e743d5df06047f;hp=10abf8c30397295425ec8a0820fba2a23605ff86;hpb=d82c0efad7971d102220a8824e1ea674db5b7fe2;p=idzebra-moved-to-github.git diff --git a/index/recgrs.c b/index/recgrs.c index 10abf8c..ef0acb4 100644 --- a/index/recgrs.c +++ b/index/recgrs.c @@ -1,8 +1,5 @@ -/* $Id: recgrs.c,v 1.20 2007-10-29 09:25:40 adam Exp $ - Copyright (C) 1995-2007 - Index Data ApS - -This file is part of the Zebra server. +/* This file is part of the Zebra server. + Copyright (C) 1994-2011 Index Data Zebra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -20,6 +17,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#if HAVE_CONFIG_H +#include +#endif #include #include #include @@ -107,12 +107,18 @@ static int sp_range(struct source_parser *sp, data1_node *n, RecWord *wrd) return 0; sp_lex(sp); - if (wrd->term_buf && wrd->term_len) + if (wrd->term_buf) { - wrd->term_buf += start; - wrd->term_len -= start; - if (wrd->term_len > len) - wrd->term_len = len; + if (start >= wrd->term_len) + wrd->term_len = 0; + else + { + wrd->term_len -= start; + wrd->term_buf += start; + + if (wrd->term_len > len) + wrd->term_len = len; + } } return 1; } @@ -450,7 +456,6 @@ data1_termlist *xpath_termlist_by_tagpath(char *tagpath, data1_node *n) xfree(pexpr); if (xpe) { - yaz_log(YLOG_DEBUG, "Got it"); return xpe->termlists; } else { return NULL; @@ -481,20 +486,20 @@ static void index_xpath_attr(char *tag_path, char *name, char *value, RecWord *wrd) { wrd->index_name = ZEBRA_XPATH_ELM_BEGIN; - wrd->index_type = '0'; + wrd->index_type = "0"; wrd->term_buf = tag_path; wrd->term_len = strlen(tag_path); (*p->tokenAdd)(wrd); if (value) { wrd->index_name = ZEBRA_XPATH_ATTR_CDATA; - wrd->index_type = 'w'; + wrd->index_type = "w"; wrd->term_buf = value; wrd->term_len = strlen(value); (*p->tokenAdd)(wrd); } wrd->index_name = ZEBRA_XPATH_ELM_END; - wrd->index_type = '0'; + wrd->index_type = "0"; wrd->term_buf = tag_path; wrd->term_len = strlen(tag_path); (*p->tokenAdd)(wrd); @@ -563,11 +568,11 @@ static void index_xpath(struct source_parser *sp, data1_node *n, { /* need to copy recword because it may be changed */ RecWord wrd_tl; - wrd->index_type = *tl->structure; + wrd->index_type = tl->structure; memcpy(&wrd_tl, wrd, sizeof(*wrd)); if (tl->source) sp_parse(sp, n, &wrd_tl, tl->source); - + /* this is just the old fashioned attribute based index */ wrd_tl.index_name = tl->index_name; if (p->flagShowRecords) @@ -600,14 +605,14 @@ static void index_xpath(struct source_parser *sp, data1_node *n, if (!p->flagShowRecords && !termlist_only) { wrd->index_name = xpath_index; - wrd->index_type = 'w'; + wrd->index_type = "w"; (*p->tokenAdd)(wrd); } break; case DATA1N_tag: mk_tag_path_full(tag_path_full, sizeof(tag_path_full), n); - wrd->index_type = '0'; + wrd->index_type = "0"; wrd->term_buf = tag_path_full; wrd->term_len = strlen(tag_path_full); wrd->index_name = xpath_index; @@ -646,7 +651,7 @@ static void index_xpath(struct source_parser *sp, data1_node *n, if (!termlist_only) { /* attribute (no value) */ - wrd->index_type = '0'; + wrd->index_type = "0"; wrd->index_name = ZEBRA_XPATH_ATTR_NAME; wrd->term_buf = xp->name; wrd->term_len = strlen(xp->name); @@ -664,7 +669,7 @@ static void index_xpath(struct source_parser *sp, data1_node *n, strcat(comb, xp->value); wrd->index_name = ZEBRA_XPATH_ATTR_NAME; - wrd->index_type = '0'; + wrd->index_type = "0"; wrd->term_buf = comb; wrd->term_len = strlen(comb); wrd->seqno--; @@ -700,7 +705,7 @@ static void index_xpath(struct source_parser *sp, data1_node *n, if (xp->value) { wrd->index_name = tl->index_name; - wrd->index_type = *tl->structure; + wrd->index_type = tl->structure; wrd->term_buf = xp->value; wrd->term_len = strlen(xp->value); (*p->tokenAdd)(wrd); @@ -728,8 +733,6 @@ static void index_termlist(struct source_parser *sp, data1_node *par, struct recExtractCtrl *p, int level, RecWord *wrd) { data1_termlist *tlist = 0; - data1_datatype dtype = DATA1K_string; - /* * cycle up towards the root until we find a tag with an att.. * this has the effect of indexing locally defined tags with @@ -741,9 +744,6 @@ static void index_termlist(struct source_parser *sp, data1_node *par, break; if (!par || !(tlist = par->u.tag.element->termlists)) return; - if (par->u.tag.element->tag) - dtype = par->u.tag.element->tag->kind; - for (; tlist; tlist = tlist->next) { /* consider source */ @@ -769,7 +769,7 @@ static void index_termlist(struct source_parser *sp, data1_node *par, } else { - wrd->index_type = *tlist->structure; + wrd->index_type = tlist->structure; wrd->index_name = tlist->index_name; (*p->tokenAdd)(wrd); } @@ -1168,7 +1168,6 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, yaz_log(YLOG_DEBUG, "grs_retrieve: schema mapping"); for (map = node->u.root.absyn->maptabs; map; map = map->next) { - // if (map->target_absyn_ref == requested_schema) if (!oid_oidcmp(map->oid, requested_schema)) { onode = node; @@ -1362,6 +1361,7 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab