From aeea139423b8eaf28a4de53b3d7b2ad1f22284e7 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 19 Sep 2012 15:37:24 +0200 Subject: [PATCH] Reformat: delete trailing whitespace --- bfile/bfile.c | 6 +- bfile/cfile.c | 18 +-- bfile/cfile.h | 2 +- bfile/commit.c | 4 +- bfile/mfile.c | 16 +-- bfile/mfile.h | 14 +- bfile/tstbfile1.c | 14 +- bfile/tstbfile2.c | 4 +- bfile/tstmfile1.c | 2 +- data1/d1_absyn.c | 102 +++++++------- data1/d1_attset.c | 8 +- data1/d1_doespec.c | 18 +-- data1/d1_espec.c | 28 ++-- data1/d1_expout.c | 50 +++---- data1/d1_grs.c | 8 +- data1/d1_handle.c | 6 +- data1/d1_if.c | 14 +- data1/d1_map.c | 8 +- data1/d1_marc.c | 26 ++-- data1/d1_read.c | 106 +++++++-------- data1/d1_soif.c | 2 +- data1/d1_tagset.c | 6 +- data1/d1_utils.c | 20 +-- data1/d1_varset.c | 6 +- data1/d1_write.c | 6 +- dfa/agrep.c | 2 +- dfa/bset.c | 8 +- dfa/dfa.c | 48 +++---- dfa/grepper.c | 10 +- dfa/lexer.c | 2 +- dfa/readfile.c | 4 +- dfa/states.c | 4 +- dfa/test_dfa.c | 2 +- dict/close.c | 2 +- dict/dclose.c | 2 +- dict/dcompact.c | 6 +- dict/delete.c | 20 +-- dict/dict-p.h | 8 +- dict/dicttest.c | 8 +- dict/dopen.c | 2 +- dict/drdwr.c | 8 +- dict/insert.c | 14 +- dict/lookgrep.c | 20 +-- dict/lookup.c | 2 +- dict/lookupec.c | 12 +- dict/open.c | 4 +- dict/scan.c | 16 +-- include/charmap.h | 2 +- include/d1_absyn.h | 4 +- include/idzebra/api.h | 72 +++++----- include/idzebra/bfile.h | 6 +- include/idzebra/data1.h | 28 ++-- include/idzebra/dict.h | 24 ++-- include/idzebra/flock.h | 2 +- include/idzebra/isam.h | 50 +++---- include/idzebra/isamb.h | 2 +- include/idzebra/recctrl.h | 10 +- include/rset.h | 30 ++--- index/attribute.c | 16 +-- index/check_res.c | 6 +- index/dir.c | 2 +- index/dirs.c | 10 +- index/extract.c | 150 ++++++++++----------- index/index.h | 14 +- index/inline.c | 10 +- index/invstat.c | 6 +- index/kcontrol.c | 2 +- index/kdump.c | 6 +- index/key_block.c | 66 ++++----- index/kinput.c | 40 +++--- index/limit.c | 2 +- index/marcomp.c | 68 +++++----- index/marcomp.h | 6 +- index/mod_alvis.c | 92 ++++++------- index/mod_dom.c | 254 +++++++++++++++++------------------ index/mod_grs_marc.c | 128 +++++++++--------- index/mod_grs_regx.c | 96 ++++++------- index/mod_grs_sgml.c | 4 +- index/mod_grs_xml.c | 20 +-- index/mod_safari.c | 6 +- index/mod_text.c | 6 +- index/rank.h | 2 +- index/rank1.c | 26 ++-- index/ranksimilarity.c | 126 +++++++++--------- index/rankstatic.c | 14 +- index/recctrl.c | 12 +- index/recgrs.c | 156 +++++++++++----------- index/recindex.c | 32 ++--- index/recindex.h | 12 +- index/reckeys.c | 20 +-- index/reckeys.h | 2 +- index/records.c | 30 ++--- index/retrieve.c | 136 +++++++++---------- index/rpnscan.c | 58 ++++---- index/rpnsearch.c | 274 +++++++++++++++++++------------------- index/rset_isam.c | 2 +- index/sortidx.c | 18 +-- index/stream.c | 2 +- index/trunc.c | 10 +- index/untrans.c | 6 +- index/update_file.c | 20 +-- index/update_path.c | 14 +- index/zebraapi.c | 196 +++++++++++++-------------- index/zebraidx.c | 6 +- index/zebrash.c | 176 ++++++++++++------------ index/zebrasrv.c | 42 +++--- index/zinfo.c | 104 +++++++-------- index/zinfo.h | 12 +- index/zsets.c | 100 +++++++------- isamb/benchindex1.c | 30 ++--- isamb/benchisamb.c | 18 +-- isamb/isamb.c | 106 +++++++-------- isamb/tstisamb.c | 36 ++--- isamc/isamc-p.h | 10 +- isamc/isamc.c | 24 ++-- isamc/merge.c | 24 ++-- isams/isams.c | 8 +- rset/rsbetween.c | 40 +++--- rset/rsbool.c | 26 ++-- rset/rset.c | 64 ++++----- rset/rsisamb.c | 10 +- rset/rsisamc.c | 2 +- rset/rsisams.c | 2 +- rset/rsmultiandor.c | 78 +++++------ rset/rsnull.c | 2 +- rset/rsprox.c | 34 ++--- rset/rstemp.c | 22 +-- test/api/test_create_databases.c | 4 +- test/api/test_icu_indexing.c | 12 +- test/api/test_insert_fetch.c | 12 +- test/api/test_private_attset.c | 10 +- test/api/test_rank.c | 8 +- test/api/test_resources.c | 12 +- test/api/test_result_sets.c | 8 +- test/api/test_safari.c | 12 +- test/api/test_scan.c | 2 +- test/api/test_search.c | 54 ++++---- test/api/test_sort3.c | 8 +- test/api/test_sort_set.c | 10 +- test/api/test_sortidx.c | 10 +- test/api/test_special_elements.c | 40 +++--- test/api/test_start_stop.c | 4 +- test/api/test_trunc.c | 4 +- test/api/test_update_record.c | 4 +- test/api/test_zebra_fork.c | 8 +- test/api/testclient.c | 4 +- test/api/testlib.c | 38 +++--- test/api/testlib.h | 42 +++--- test/charmap/charmap1.c | 10 +- test/codec/tstcodec.c | 8 +- test/filters/grs.xml.idzebra.c | 2 +- test/marcxml/t1.c | 2 +- test/marcxml/t2.c | 2 +- test/mbox/mbox1.c | 4 +- test/rusmarc/t1.c | 2 +- test/xpath/xpath3.c | 2 +- test/xpath/xpath4.c | 16 +-- test/xpath/xpath5.c | 2 +- test/xpath/xpath6.c | 4 +- test/xslt/dom1.c | 18 +-- test/xslt/xslt1.c | 4 +- test/xslt/xslt2.c | 6 +- test/xslt/xslt3.c | 8 +- test/xslt/xslt4.c | 4 +- test/xslt/xslt5.c | 6 +- util/attrfind.c | 8 +- util/charmap.c | 40 +++--- util/dirent.c | 2 +- util/flock.c | 22 +-- util/it_key.c | 4 +- util/passwddb.c | 6 +- util/res.c | 30 ++--- util/snippet.c | 14 +- util/strmap.c | 6 +- util/test_strmap.c | 4 +- util/tstflock.c | 12 +- util/tstlockscope.c | 2 +- util/tstpass.c | 2 +- util/tstres.c | 2 +- util/xpath.c | 14 +- util/zebra-lock.c | 4 +- util/zebramap.c | 32 ++--- 182 files changed, 2346 insertions(+), 2346 deletions(-) diff --git a/bfile/bfile.c b/bfile/bfile.c index 07af217..44f4d1e 100644 --- a/bfile/bfile.c +++ b/bfile/bfile.c @@ -177,7 +177,7 @@ BFile bf_xopen(BFiles bfs, const char *name, int block_size, int wrflag, bf->alloc_buf_size = HEADER_SIZE; else bf->alloc_buf_size = bf->block_size; - + hbuf = bf->alloc_buf = xmalloc(bf->alloc_buf_size); /* fill-in default values */ @@ -243,7 +243,7 @@ int bf_xclose(BFile bf, int version, const char *more_info) zint pos = 0; assert(bf->alloc_buf); assert(bf->magic); - sprintf(bf->alloc_buf, "%s %d " ZINT_FORMAT " " ZINT_FORMAT " ", + sprintf(bf->alloc_buf, "%s %d " ZINT_FORMAT " " ZINT_FORMAT " ", bf->magic, version, bf->last_block, bf->free_list); if (more_info) strcat(bf->alloc_buf, more_info); @@ -337,7 +337,7 @@ int bf_read2(BFile bf, zint no, int offset, int nbytes, void *buf) if ((ret = cf_read(bf->cf, no, offset, nbytes, buf)) == 0) ret = mf_read(bf->mf, no, offset, nbytes, buf); } - else + else ret = mf_read(bf->mf, no, offset, nbytes, buf); zebra_lock_rdwr_runlock(&bf->rdwr_lock); return ret; diff --git a/bfile/cfile.c b/bfile/cfile.c index d9e901e..2d39e04 100644 --- a/bfile/cfile.c +++ b/bfile/cfile.c @@ -90,10 +90,10 @@ CFile cf_open(MFile mf, MFile_area area, const char *fname, memset(cf, 'Z', sizeof(*cf)); yaz_log(YLOG_DEBUG, "cf: open %s %s", fname, wflag ? "rdwr" : "rd"); - + cf->block_mf = 0; cf->hash_mf = 0; - cf->rmf = mf; + cf->rmf = mf; assert(firstp); @@ -138,7 +138,7 @@ CFile cf_open(MFile mf, MFile_area area, const char *fname, cf->head.block_size = block_size; cf->head.hash_size = 199; hash_bytes = cf->head.hash_size * sizeof(zint); - cf->head.flat_bucket = cf->head.next_bucket = cf->head.first_bucket = + cf->head.flat_bucket = cf->head.next_bucket = cf->head.first_bucket = (hash_bytes+sizeof(cf->head))/HASH_BSIZE + 2; cf->head.next_block = 1; cf->array = (zint *) xmalloc(hash_bytes); @@ -205,7 +205,7 @@ static void release_bucket(CFile cf, struct CFile_hash_bucket *p) *p->h_prev = p->h_next; if (p->h_next) p->h_next->h_prev = p->h_prev; - + --(cf->bucket_in_memory); xfree(p); } @@ -254,7 +254,7 @@ static struct CFile_hash_bucket *alloc_bucket(CFile cf, zint block_no, int hno) cf->bucket_lru_front->lru_next = p; else cf->bucket_lru_back = p; - cf->bucket_lru_front = p; + cf->bucket_lru_front = p; pp = cf->parray + hno; p->h_next = *pp; @@ -396,7 +396,7 @@ static int cf_moveto_flat(CFile cf) yaz_log(YLOG_DEBUG, "cf: Moving to flat shadow: %s", cf->rmf->name); yaz_log(YLOG_DEBUG, "cf: hits=%d miss=%d bucket_in_memory=" ZINT_FORMAT " total=" ZINT_FORMAT, - cf->no_hits, cf->no_miss, cf->bucket_in_memory, + cf->no_hits, cf->no_miss, cf->bucket_in_memory, cf->head.next_bucket - cf->head.first_bucket); assert(cf->head.state == CFILE_STATE_HASH); if (flush_bucket(cf, -1)) @@ -449,10 +449,10 @@ static zint cf_new_hash(CFile cf, zint no) { int hno = cf_hash(cf, no); struct CFile_hash_bucket *hbprev = NULL, *hb = cf->parray[hno]; - zint *bucketpp = &cf->array[hno]; + zint *bucketpp = &cf->array[hno]; int i; zint vno = (cf->head.next_block)++; - + for (hb = cf->parray[hno]; hb; hb = hb->h_next) if (!hb->ph.vno[HASH_BUCKET-1]) for (i = 0; imutex); ret = cf_lookup(cf, no, &block); diff --git a/bfile/cfile.h b/bfile/cfile.h index 8ebceb7..8752555 100644 --- a/bfile/cfile.h +++ b/bfile/cfile.h @@ -68,7 +68,7 @@ struct CFile_head { typedef struct CFile_struct { struct CFile_head head; - + MFile block_mf; /**< block meta file */ MFile hash_mf; /**< hash or index file (depending on state) */ zint *array; /**< array for hash */ diff --git a/bfile/commit.c b/bfile/commit.c index 680b706..d934dd2 100644 --- a/bfile/commit.c +++ b/bfile/commit.c @@ -98,7 +98,7 @@ static int map_cache_flush(struct map_cache *m_p) if (mf_write(m_p->cf->rmf, m_p->map[i].to, 0, 0, m_p->buf + m_p->map[i].from * m_p->cf->head.block_size)) return -1; - } + } m_p->no = 0; return 0; } @@ -128,7 +128,7 @@ static int map_cache_add(struct map_cache *m_p, int from, int to) #endif static int cf_commit_hash (CFile cf) -{ +{ int r = 0; int i; zint bucket_no; diff --git a/bfile/mfile.c b/bfile/mfile.c index 674687a..5df5d97 100644 --- a/bfile/mfile.c +++ b/bfile/mfile.c @@ -45,7 +45,7 @@ static int scan_areadef(MFile_area ma, const char *ad, const char *base) /* * If no definition is given, use current directory, unlimited. */ - char dirname[FILENAME_MAX+1]; + char dirname[FILENAME_MAX+1]; mf_dir **dp = &ma->dirs, *dir = *dp; if (!ad) @@ -134,7 +134,7 @@ static int scan_areadef(MFile_area ma, const char *ad, const char *base) \retval -1 ERROR \retval -2 OK, but file does not created (read-only) */ - + static zint file_position(MFile mf, zint pos, int offset) { zint off = 0, ps; @@ -203,7 +203,7 @@ MFile_area mf_init(const char *name, const char *spec, const char *base, struct dirent *dent; int fd, number; char metaname[FILENAME_MAX+1], tmpnam[FILENAME_MAX+1]; - + yaz_log(YLOG_DEBUG, "mf_init(%s)", name); strcpy(ma->name, name); ma->mfiles = 0; @@ -544,9 +544,9 @@ int mf_write(MFile mf, zint no, int offset, int nbytes, const void *buf) yaz_log(YLOG_FATAL, "mf_write: %s error (4) no more space", mf->name); for (dp = mf->ma->dirs; dp ; dp = dp->next) { - yaz_log(YLOG_FATAL,"%s: max=" ZINT_FORMAT - " used=" ZINT_FORMAT " available=" ZINT_FORMAT, - dp->name, (zint)dp->max_bytes, + yaz_log(YLOG_FATAL,"%s: max=" ZINT_FORMAT + " used=" ZINT_FORMAT " available=" ZINT_FORMAT, + dp->name, (zint)dp->max_bytes, (zint)(dp->max_bytes - dp->avail_bytes), (zint)dp->avail_bytes ); } yaz_log(YLOG_FATAL,"Adjust the limits in your zebra.cfg"); @@ -573,7 +573,7 @@ int mf_write(MFile mf, zint no, int offset, int nbytes, const void *buf) yaz_log(YLOG_FATAL, "mf_write: %s error (5)", mf->name); ret = -1; goto out; - } + } } else { @@ -597,7 +597,7 @@ int mf_write(MFile mf, zint no, int offset, int nbytes, const void *buf) return ret; } -/** \brief metafile area statistics +/** \brief metafile area statistics \param ma metafile area handle \param no area number (0=first, 1=second, ..) \param directory holds directory upon completion (if non-NULL) diff --git a/bfile/mfile.h b/bfile/mfile.h index cf41225..fc96af5 100644 --- a/bfile/mfile.h +++ b/bfile/mfile.h @@ -109,7 +109,7 @@ struct MFile_area_struct MFile_area mf_init(const char *name, const char *spec, const char *base, int only_shadow_files) ZEBRA_GCC_ATTR((warn_unused_result)); - + /** \brief destroys metafile area handle \param ma metafile area handle */ @@ -124,7 +124,7 @@ void mf_destroy(MFile_area ma); */ MFile mf_open(MFile_area ma, const char *name, int block_size, int wflag) ZEBRA_GCC_ATTR((warn_unused_result)); - + /** \brief closes metafile \param mf metafile handle \retval 0 OK @@ -143,7 +143,7 @@ int mf_close(MFile mf); */ int mf_read(MFile mf, zint no, int offset, int nbytes, void *buf) ZEBRA_GCC_ATTR((warn_unused_result)); - + /** \brief writes block to metafile \param mf metafile handle \param no block position @@ -154,8 +154,8 @@ int mf_read(MFile mf, zint no, int offset, int nbytes, void *buf) \retval -1 error (block not written) */ int mf_write(MFile mf, zint no, int offset, int nbytes, const void *buf) - ZEBRA_GCC_ATTR((warn_unused_result)); - + ZEBRA_GCC_ATTR((warn_unused_result)); + /** \brief reset all files in a metafile area (optionally delete them as well) \param ma metafile area \param unlink_flag if unlink_flag=1 all files are removed from FS @@ -175,10 +175,10 @@ void mf_reset(MFile_area ma, int unlink_flag); on same platform depending on whether 64-bit is enabled or not. Note that if an area has unlimited size, that is represented as max_bytes = -1. -*/ +*/ int mf_area_directory_stat(MFile_area ma, int no, const char **directory, double *bytes_used, double *bytes_max); - + YAZ_END_CDECL #endif diff --git a/bfile/tstbfile1.c b/bfile/tstbfile1.c index 3f972a5..81f3209 100644 --- a/bfile/tstbfile1.c +++ b/bfile/tstbfile1.c @@ -32,16 +32,16 @@ void tst1(BFiles bfs) const char *more_info = 0; bf_reset(bfs); - bf = bf_xopen(bfs, "tst", /* block size */ 32, + bf = bf_xopen(bfs, "tst", /* block size */ 32, /* wr */ 1, "tstmagic", &version, 0 /* more_info */); YAZ_CHECK(bf); if (!bf) return; bf_xclose(bf, version, "more info"); - - bf = bf_xopen(bfs, "tst", /* block size */ 32, + + bf = bf_xopen(bfs, "tst", /* block size */ 32, /* wr */ 1, "tstmagic", &version, &more_info); - + YAZ_CHECK(bf); if (!bf) return; @@ -58,7 +58,7 @@ void tst2(BFiles bfs) BFile bf; bf_reset(bfs); - bf = bf_xopen(bfs, "tst", /* block size */ 32, + bf = bf_xopen(bfs, "tst", /* block size */ 32, /* wr */ 1, "tstmagic", &version, 0 /* more_info */); YAZ_CHECK(bf); if (!bf) @@ -98,7 +98,7 @@ void tst3(BFiles bfs) for(i = 0; iar[data1_hash_calc(ht, str)]; - + for (; *he && yaz_matchstr(str, (*he)->str); he = &(*he)->next) ; if (*he) @@ -130,14 +130,14 @@ struct data1_systag { struct data1_systag *next; }; -struct data1_absyn_cache_info +struct data1_absyn_cache_info { char *name; data1_absyn *absyn; data1_absyn_cache next; }; -struct data1_attset_cache_info +struct data1_attset_cache_info { char *name; data1_attset *attset; @@ -169,14 +169,14 @@ data1_absyn *data1_absyn_search (data1_handle dh, const char *name) return 0; } /* *ostrich* - We need to destroy DFAs, in xp_element (xelm) definitions + We need to destroy DFAs, in xp_element (xelm) definitions pop, 2002-12-13 */ void data1_absyn_destroy (data1_handle dh) { data1_absyn_cache p = *data1_absyn_cache_get (dh); - + while (p) { data1_absyn *abs = p->absyn; @@ -185,7 +185,7 @@ void data1_absyn_destroy (data1_handle dh) data1_xpelement *xpe = abs->xp_elements; while (xpe) { yaz_log (YLOG_DEBUG,"Destroy xp element %s",xpe->xpath_expr); - if (xpe->dfa) + if (xpe->dfa) dfa_delete (&xpe->dfa); xpe = xpe->next; } @@ -267,7 +267,7 @@ data1_attset *data1_attset_add (data1_handle dh, const char *name) { NMEM mem = data1_nmem_get (dh); data1_attset *attset; - + attset = data1_read_attset (dh, name); if (!attset) yaz_log (YLOG_WARN|YLOG_ERRNO, "Couldn't load attribute set %s", name); @@ -276,7 +276,7 @@ data1_attset *data1_attset_add (data1_handle dh, const char *name) data1_attset_cache p = (data1_attset_cache) nmem_malloc (mem, sizeof(*p)); data1_attset_cache *pp = data1_attset_cache_get (dh); - + attset->name = p->name = nmem_strdup(mem, name); p->attset = attset; p->next = *pp; @@ -337,7 +337,7 @@ data1_element *data1_getelementbytagname (data1_handle dh, data1_absyn *abs, for (; r; r = r->next) { data1_name *n; - + for (n = r->tag->names; n; n = n->next) data1_hash_insert(ht, n->name, r, 0); } @@ -419,7 +419,7 @@ void fix_element_ref (data1_handle dh, data1_absyn *absyn, data1_element *e) */ -static const char * mk_xpath_regexp (data1_handle dh, const char *expr) +static const char * mk_xpath_regexp (data1_handle dh, const char *expr) { const char *p = expr; int abs = 1; @@ -427,12 +427,12 @@ static const char * mk_xpath_regexp (data1_handle dh, const char *expr) char *stack[32]; char *res_p, *res = 0; size_t res_size = 1; - + if (*p != '/') return (""); p++; - if (*p == '/') - { + if (*p == '/') + { abs =0; p++; } @@ -453,10 +453,10 @@ static const char * mk_xpath_regexp (data1_handle dh, const char *expr) is_predicate=1; else if (*pp == ']') is_predicate=0; - else + else { if (!is_predicate) { - if (*pp == '*') + if (*pp == '*') *s++ = '.'; *s++ = *pp; } @@ -480,7 +480,7 @@ static const char * mk_xpath_regexp (data1_handle dh, const char *expr) } if (!abs) { - sprintf(res_p, ".*"); + sprintf(res_p, ".*"); res_p += 2; } sprintf (res_p, "$"); @@ -543,7 +543,7 @@ static int parse_termlists(data1_handle dh, data1_termlist ***tpp, *tp = (data1_termlist *) nmem_malloc(data1_nmem_get(dh), sizeof(**tp)); (*tp)->next = 0; - + if (*attname == '!') { if (!xpelement && element_name) @@ -568,10 +568,10 @@ static int parse_termlists(data1_handle dh, data1_termlist ***tpp, source = "data"; /* ok: default is leaf data */ (*tp)->source = (char *) nmem_strdup (data1_nmem_get (dh), source); - + if (r < 2) /* is the structure qualified? */ (*tp)->structure = "w"; - else + else (*tp)->structure = (char *) nmem_strdup (data1_nmem_get (dh), structure); tp = &(*tp)->next; @@ -600,7 +600,7 @@ static int melm2xpath(char *melm, char *buf) else fieldtype = "datafield"; sprintf(buf, "/*/%s[@tag=\"%s\"]", fieldtype, field); - if (*subfield) + if (*subfield) sprintf(buf + strlen(buf), "/subfield[@code=\"%s\"]", subfield); else if (field[0] != '0' || field[1] != '0') strcat(buf, "/subfield"); @@ -626,7 +626,7 @@ int read_absyn_line(FILE *f, int *lineno, char *line, int len, char *p; int argc; int quoted = 0; - + while ((p = fgets(line, len, f))) { (*lineno)++; @@ -637,7 +637,7 @@ int read_absyn_line(FILE *f, int *lineno, char *line, int len, } if (!p) return 0; - + for (argc = 0; *p ; argc++) { if (*p == '#') /* trailing comment */ @@ -697,13 +697,13 @@ static data1_absyn *data1_read_absyn(data1_handle dh, const char *file, char *argv[50], line[512]; f = data1_path_fopen(dh, file, "r"); - + res = (data1_absyn *) nmem_malloc(data1_nmem_get(dh), sizeof(*res)); res->name = 0; res->oid = 0; res->tagset = 0; res->encoding = 0; - res->xpath_indexing = + res->xpath_indexing = (f ? DATA1_XPATH_INDEXING_DISABLE : default_xpath); res->systags = 0; systagsp = &res->systags; @@ -749,7 +749,7 @@ static data1_absyn *data1_read_absyn(data1_handle dh, const char *file, cur_elements->elements = NULL; cur_elements->name = "main"; res->sub_elements = cur_elements; - + level = 0; ppl[level] = &cur_elements->elements; } @@ -771,17 +771,17 @@ static data1_absyn *data1_read_absyn(data1_handle dh, const char *file, } level = i; new_element = *ppl[level-1] = data1_mk_element(dh); - + tp = &new_element->termlists; ppl[level-1] = &new_element->next; ppl[level] = &new_element->children; - + /* consider subtree (if any) ... */ if ((sub_p = strchr (p, ':')) && sub_p[1]) { *sub_p++ = '\0'; new_element->sub_name = - nmem_strdup (data1_nmem_get(dh), sub_p); + nmem_strdup (data1_nmem_get(dh), sub_p); } /* well-defined tag */ if (sscanf(p, "(%d,%d)", &type, &value) == 2) @@ -811,7 +811,7 @@ static data1_absyn *data1_read_absyn(data1_handle dh, const char *file, nt->which = DATA1T_string; nt->value.string = nmem_strdup(data1_nmem_get (dh), p); nt->names = (data1_name *) - nmem_malloc(data1_nmem_get(dh), + nmem_malloc(data1_nmem_get(dh), sizeof(*new_element->tag->names)); nt->names->name = nt->value.string; nt->names->next = 0; @@ -842,9 +842,9 @@ static data1_absyn *data1_read_absyn(data1_handle dh, const char *file, /* *ostrich* New code to support xelm directive for each xelm a dfa is built. xelms are stored in res->xp_elements - + maybe we should use a simple sscanf instead of dfa? - + pop, 2002-12-13 Now [] predicates are supported. regexps and xpath structure is @@ -863,7 +863,7 @@ static data1_absyn *data1_read_absyn(data1_handle dh, const char *file, char melm_xpath[128]; data1_xpelement *xp_ele = 0; data1_xpelement *last_match = 0; - + if (argc != 3) { yaz_log(YLOG_WARN, "%s:%d: Bad # of args to %s", @@ -909,23 +909,23 @@ static data1_absyn *data1_read_absyn(data1_handle dh, const char *file, #if OPTIMIZE_MELM (*cur_xpelement)->regexp = regexp; #endif - (*cur_xpelement)->xpath_expr = nmem_strdup(data1_nmem_get (dh), - xpath_expr); - + (*cur_xpelement)->xpath_expr = nmem_strdup(data1_nmem_get (dh), + xpath_expr); + if (dfa) dfa_mkstate (dfa); (*cur_xpelement)->dfa = dfa; - -#ifdef ENHANCED_XELM + +#ifdef ENHANCED_XELM (*cur_xpelement)->xpath_len = zebra_parse_xpath_str( - xpath_expr, + xpath_expr, (*cur_xpelement)->xpath, XPATH_STEP_COUNT, data1_nmem_get(dh)); #endif (*cur_xpelement)->termlists = 0; tp = &(*cur_xpelement)->termlists; - + /* parse termList definitions */ p = termlists; if (*p != '-') @@ -943,7 +943,7 @@ static data1_absyn *data1_read_absyn(data1_handle dh, const char *file, else if (!strcmp(cmd, "section")) { char *name; - + if (argc < 2) { yaz_log(YLOG_WARN, "%s:%d: Bad # of args to section", @@ -951,14 +951,14 @@ static data1_absyn *data1_read_absyn(data1_handle dh, const char *file, continue; } name = argv[1]; - + cur_elements = (data1_sub_elements *) nmem_malloc(data1_nmem_get(dh), sizeof(*cur_elements)); cur_elements->next = res->sub_elements; cur_elements->elements = NULL; cur_elements->name = nmem_strdup (data1_nmem_get(dh), name); res->sub_elements = cur_elements; - + level = 0; ppl[level] = &cur_elements->elements; } @@ -1015,7 +1015,7 @@ static data1_absyn *data1_read_absyn(data1_handle dh, const char *file, else if (!strcmp(cmd, "reference")) { char *name; - + if (argc != 2) { yaz_log(YLOG_WARN, "%s:%d: Bad # of args to reference", @@ -1024,11 +1024,11 @@ static data1_absyn *data1_read_absyn(data1_handle dh, const char *file, } name = argv[1]; res->oid = yaz_string_to_oid_nmem(yaz_oid_std(), - CLASS_SCHEMA, name, + CLASS_SCHEMA, name, data1_nmem_get(dh)); if (!res->oid) { - yaz_log(YLOG_WARN, "%s:%d: Unknown tagset ref '%s'", + yaz_log(YLOG_WARN, "%s:%d: Unknown tagset ref '%s'", file, lineno, name); continue; } @@ -1037,7 +1037,7 @@ static data1_absyn *data1_read_absyn(data1_handle dh, const char *file, { char *name; data1_attset *attset; - + if (argc != 2) { yaz_log(YLOG_WARN, "%s:%d: Bad # of args to attset", @@ -1109,7 +1109,7 @@ static data1_absyn *data1_read_absyn(data1_handle dh, const char *file, } name = argv[1]; fname = argv[2]; - + *esetpp = (data1_esetname *) nmem_malloc(data1_nmem_get(dh), sizeof(**esetpp)); (*esetpp)->name = nmem_strdup(data1_nmem_get(dh), name); @@ -1127,7 +1127,7 @@ static data1_absyn *data1_read_absyn(data1_handle dh, const char *file, else if (!strcmp(cmd, "maptab")) { char *name; - + if (argc != 2) { yaz_log(YLOG_WARN, "%s:%d: Bad # of args for maptab", @@ -1146,7 +1146,7 @@ static data1_absyn *data1_read_absyn(data1_handle dh, const char *file, else if (!strcmp(cmd, "marc")) { char *name; - + if (argc != 2) { yaz_log(YLOG_WARN, "%s:%d: Bad # or args for marc", @@ -1188,14 +1188,14 @@ static data1_absyn *data1_read_absyn(data1_handle dh, const char *file, } else { - yaz_log(YLOG_WARN, "%s:%d: Unknown directive '%s'", file, + yaz_log(YLOG_WARN, "%s:%d: Unknown directive '%s'", file, lineno, cmd); continue; } } if (f) fclose(f); - + for (cur_elements = res->sub_elements; cur_elements; cur_elements = cur_elements->next) { diff --git a/data1/d1_attset.c b/data1/d1_attset.c index e745292..291acd9 100644 --- a/data1/d1_attset.c +++ b/data1/d1_attset.c @@ -32,7 +32,7 @@ data1_att *data1_getattbyname(data1_handle dh, data1_attset *s, const char *name { data1_att *r; data1_attset_child *c; - + /* scan local set */ for (r = s->atts; r; r = r->next) if (!data1_matchstr(r->name, name)) @@ -87,7 +87,7 @@ data1_attset *data1_read_attset(data1_handle dh, const char *file) char *name; char *endptr; data1_att *t; - + if (argc < 3) { yaz_log(YLOG_WARN, "%s:%d: Bad # of args to att", file, lineno); @@ -106,7 +106,7 @@ data1_attset *data1_read_attset(data1_handle dh, const char *file) continue; } name = argv[2]; - + t = *attp = (data1_att *)nmem_malloc(mem, sizeof(*t)); t->parent = res; t->name = nmem_strdup(mem, name); @@ -167,7 +167,7 @@ data1_attset *data1_read_attset(data1_handle dh, const char *file) yaz_log(YLOG_WARN, "%s:%d: Include of attset %s failed", file, lineno, name); continue; - + } *childp = (data1_attset_child *) nmem_malloc (mem, sizeof(**childp)); diff --git a/data1/d1_doespec.c b/data1/d1_doespec.c index c6dc0c6..b47acd9 100644 --- a/data1/d1_doespec.c +++ b/data1/d1_doespec.c @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA /** \file d1_doespec.c * \brief handle Z39.50 variant-1 specs - * + * * See http://www.loc.gov/z3950/agency/defns/variant1.html */ #if HAVE_CONFIG_H @@ -60,7 +60,7 @@ static Z_Triple *find_triple(Z_Variant *var, const Odr_oid *universal_oid, const Odr_oid *cur_oid = var->triples[i]->variantSetId; if (!cur_oid) cur_oid = var->globalVariantSetId; - if (cur_oid && var_oid + if (cur_oid && var_oid && !oid_oidcmp(var_oid, cur_oid) && *var->triples[i]->type == type) return var->triples[i]; } @@ -121,9 +121,9 @@ static void match_triple(data1_handle dh, Z_Variant *vreq, { int remove_flag = 0; Z_Triple *r; - + assert ((*c)->which == DATA1N_variant); - + if ((*c)->u.variant.type->zclass->zclass == 4 && (*c)->u.variant.type->type == 1) { @@ -160,7 +160,7 @@ static int match_node_and_attr (data1_node *c, const char *spec) data1_tag *tag = 0; if (c->u.tag.element) tag = c->u.tag.element->tag; - + *predicate = '\0'; sscanf(spec, "%63[^[]%c%63[^]]", elem, &dummy_ch, predicate); if (data1_matchstr(elem, tag ? tag->value.string : c->u.tag.tag)) @@ -190,7 +190,7 @@ static int match_node_and_attr (data1_node *c, const char *spec) } return 0; } - + static int match_children_here (data1_handle dh, data1_node *n, Z_Espec1 *e, int i, Z_ETagUnit **t, int num, @@ -237,7 +237,7 @@ static int match_children_here (data1_handle dh, data1_node *n, #if 1 if (!match_node_and_attr(c, str_val)) continue; -#else +#else if (data1_matchstr(str_val, tag ? tag->value.string : c->u.tag.tag)) continue; @@ -294,7 +294,7 @@ static int match_children_here (data1_handle dh, data1_node *n, /* * 6,5: meta-data requested, variant list. */ - if (find_triple(vreq, e->defaultVariantSetId, + if (find_triple(vreq, e->defaultVariantSetId, var_oid, 6, 5)) show_variantlist = 1; /* @@ -360,7 +360,7 @@ int data1_doespec1 (data1_handle dh, data1_node *n, Z_Espec1 *e) n = data1_get_root_tag (dh, n); if (n && n->which == DATA1N_tag) n->u.tag.node_selected = 1; - + for (i = 0; i < e->num_elements; i++) { if (e->elements[i]->which != Z_ERequest_simpleElement) diff --git a/data1/d1_espec.c b/data1/d1_espec.c index ea73ee4..fc68007 100644 --- a/data1/d1_espec.c +++ b/data1/d1_espec.c @@ -87,7 +87,7 @@ static Z_Occurrences *read_occurrences(char *occ, NMEM nmem, { Z_Occurrences *op = (Z_Occurrences *)nmem_malloc(nmem, sizeof(*op)); char *p; - + if (!occ) { op->which = Z_Occurrences_values; @@ -109,7 +109,7 @@ static Z_Occurrences *read_occurrences(char *occ, NMEM nmem, else { Z_OccurValues *ov = (Z_OccurValues *)nmem_malloc(nmem, sizeof(*ov)); - + if (!d1_isdigit(*occ)) { yaz_log(YLOG_WARN, "%s:%d: Bad occurrences-spec %s", @@ -135,7 +135,7 @@ static Z_ETagUnit *read_tagunit(char *buf, NMEM nmem, int terms; int type; char value[512], occ[512]; - + if (*buf == '*') { u->which = Z_ETagUnit_wildPath; @@ -156,7 +156,7 @@ static Z_ETagUnit *read_tagunit(char *buf, NMEM nmem, Z_SpecificTag *t; char *valp = value; int force_string = 0; - + if (*valp == '\'') { valp++; @@ -218,10 +218,10 @@ Z_Espec1 *data1_read_espec1 (data1_handle dh, const char *file) int argc, size_esn = 0; char *argv[50], line[512]; Z_Espec1 *res = (Z_Espec1 *)nmem_malloc(nmem, sizeof(*res)); - + if (!(f = data1_path_fopen(dh, file, "r"))) return 0; - + res->num_elementSetNames = 0; res->elementSetNames = 0; res->defaultVariantSetId = 0; @@ -229,19 +229,19 @@ Z_Espec1 *data1_read_espec1 (data1_handle dh, const char *file) res->defaultTagType = 0; res->num_elements = 0; res->elements = 0; - + while ((argc = readconf_line(f, &lineno, line, 512, argv, 50))) if (!strcmp(argv[0], "elementsetnames")) { int nnames = argc-1, i; - + if (!nnames) { yaz_log(YLOG_WARN, "%s:%d: Empty elementsetnames directive", file, lineno); continue; } - + res->elementSetNames = (char **)nmem_malloc(nmem, sizeof(char**)*nnames); for (i = 0; i < nnames; i++) @@ -294,7 +294,7 @@ Z_Espec1 *data1_read_espec1 (data1_handle dh, const char *file) char *path = argv[1]; char *ep; int num, i = 0; - + if (!res->elements) res->elements = (Z_ElementRequest **) nmem_malloc(nmem, size_esn = 24*sizeof(er)); @@ -312,7 +312,7 @@ Z_Espec1 *data1_read_espec1 (data1_handle dh, const char *file) file, lineno, argv[0]); continue; } - + res->elements[res->num_elements++] = er = (Z_ElementRequest *)nmem_malloc(nmem, sizeof(*er)); er->which = Z_ERequest_simpleElement; @@ -328,14 +328,14 @@ Z_Espec1 *data1_read_espec1 (data1_handle dh, const char *file) ; tp->tags = (Z_ETagUnit **) nmem_malloc(nmem, sizeof(Z_ETagUnit*)*num); - + for ((ep = strchr(path, '/')) ; path ; (void)((path = ep) && (ep = strchr(path, '/')))) { Z_ETagUnit *tagunit; if (ep) ep++; - + assert(itags[tp->num_tags++] = tagunit; } - + if (argc > 2 && !strcmp(argv[2], "variant")) se->variantRequest= read_variant(argc-3, argv+3, nmem, file, lineno); diff --git a/data1/d1_expout.c b/data1/d1_expout.c index 9b82aa7..c48330d 100644 --- a/data1/d1_expout.c +++ b/data1/d1_expout.c @@ -18,7 +18,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* - * This module converts data1 tree to Z39.50 Explain records + * This module converts data1 tree to Z39.50 Explain records */ #if HAVE_CONFIG_H @@ -116,7 +116,7 @@ static Odr_oid *f_oid(ExpHandle *eh, data1_node *c, oid_class oclass) c = c->child; if (!is_data_tag (eh, c) || c->u.data.len > 63) return 0; - yaz_snprintf(oidstr, sizeof(oidstr)-1, + yaz_snprintf(oidstr, sizeof(oidstr)-1, "%.*s", c->u.data.len, c->u.data.data); return yaz_string_to_oid_odr(yaz_oid_std(), @@ -190,7 +190,7 @@ Odr_oid **f_oid_seq (ExpHandle *eh, data1_node *n, int *num, oid_class oclass) res[i++] = f_oid (eh, c, oclass); return res; } - + char **f_string_seq (ExpHandle *eh, data1_node *n, int *num) { char **res; @@ -402,7 +402,7 @@ static Odr_int *f_recordCount(ExpHandle *eh, data1_node *c, int *which) *wp = Z_DatabaseInfo_approxNumber; else return 0; - if (!c->child || c->child->which != DATA1N_data || + if (!c->child || c->child->which != DATA1N_data || c->child->u.data.len >= sizeof(intbuf)) return 0; sprintf(intbuf, "%.*s", c->child->u.data.len, c->child->u.data.data); @@ -414,13 +414,13 @@ static Z_ContactInfo *f_contactInfo(ExpHandle *eh, data1_node *n) Z_ContactInfo *res = (Z_ContactInfo *) odr_malloc (eh->o, sizeof(*res)); data1_node *c; - + res->name = 0; res->description = 0; res->address = 0; res->email = 0; res->phone = 0; - + for (c = n->child; c; c = c->next) { switch (is_numeric_tag (eh, c)) @@ -440,10 +440,10 @@ static Z_DatabaseList *f_databaseList(ExpHandle *eh, data1_node *n) data1_node *c; Z_DatabaseList *res; int i = 0; - + for (c = n->child; c; c = c->next) { - if (!is_numeric_tag (eh, c) != 102) + if (!is_numeric_tag (eh, c) != 102) continue; ++i; } @@ -451,7 +451,7 @@ static Z_DatabaseList *f_databaseList(ExpHandle *eh, data1_node *n) return NULL; res = (Z_DatabaseList *)odr_malloc (eh->o, sizeof(*res)); - + res->num_databases = i; res->databases = (char **)odr_malloc (eh->o, sizeof(*res->databases) * i); i = 0; @@ -469,7 +469,7 @@ static Z_NetworkAddressIA *f_networkAddressIA(ExpHandle *eh, data1_node *n) Z_NetworkAddressIA *res = (Z_NetworkAddressIA *) odr_malloc (eh->o, sizeof(*res)); data1_node *c; - + res->hostAddress = 0; res->port = 0; @@ -505,13 +505,13 @@ static Z_NetworkAddressOther *f_networkAddressOther(ExpHandle *eh, return res; } -static Z_NetworkAddress **f_networkAddresses(ExpHandle *eh, data1_node *n, +static Z_NetworkAddress **f_networkAddresses(ExpHandle *eh, data1_node *n, int *num) { Z_NetworkAddress **res = NULL; data1_node *c; int i = 0; - + *num = 0; for (c = n->child; c; c = c->next) { @@ -526,7 +526,7 @@ static Z_NetworkAddress **f_networkAddresses(ExpHandle *eh, data1_node *n, if (*num) res = (Z_NetworkAddress **) odr_malloc (eh->o, sizeof(*res) * (*num)); - + for (c = n->child; c; c = c->next) { switch (is_numeric_tag (eh, c)) @@ -595,7 +595,7 @@ static Z_CategoryList *f_categoryList(ExpHandle *eh, data1_node *n) } if (res->num_categories) res->categories = - (Z_CategoryInfo **)odr_malloc (eh->o, res->num_categories + (Z_CategoryInfo **)odr_malloc (eh->o, res->num_categories * sizeof(*res->categories)); for (n = c->child; n; n = n->next) { @@ -640,7 +640,7 @@ static Z_TargetInfo *f_targetInfo(ExpHandle *eh, data1_node *n) res->num_languages = 0; res->languages = NULL; res->commonAccessInfo = 0; - + for (c = n->child; c; c = c->next) { int i = 0; @@ -660,7 +660,7 @@ static Z_TargetInfo *f_targetInfo(ExpHandle *eh, data1_node *n) case 111: res->welcomeMessage = f_humstring(eh, c); break; case 112: res->contactInfo = f_contactInfo(eh, c); break; case 113: res->description = f_humstring(eh, c); break; - case 114: + case 114: res->num_nicknames = 0; for (n = c->child; n; n = n->next) { @@ -670,7 +670,7 @@ static Z_TargetInfo *f_targetInfo(ExpHandle *eh, data1_node *n) } if (res->num_nicknames) res->nicknames = - (char **)odr_malloc (eh->o, res->num_nicknames + (char **)odr_malloc (eh->o, res->num_nicknames * sizeof(*res->nicknames)); for (n = c->child; n; n = n->next) { @@ -701,7 +701,7 @@ static Z_TargetInfo *f_targetInfo(ExpHandle *eh, data1_node *n) res->dbCombinations[i++] = f_databaseList (eh, n); } break; - case 119: + case 119: res->addresses = f_networkAddresses (eh, c, &res->num_addresses); break; @@ -771,7 +771,7 @@ static Z_DatabaseInfo *f_databaseInfo(ExpHandle *eh, data1_node *n) res->supplierContactInfo = 0; res->submissionContactInfo = 0; res->accessInfo = 0; - + for (c = n->child; c; c = c->next) { int i = 0; @@ -792,7 +792,7 @@ static Z_DatabaseInfo *f_databaseInfo(ExpHandle *eh, data1_node *n) } if (res->num_nicknames) res->nicknames = - (char **)odr_malloc (eh->o, res->num_nicknames + (char **)odr_malloc (eh->o, res->num_nicknames * sizeof(*res->nicknames)); for (n = c->child; n; n = n->next) { @@ -816,7 +816,7 @@ static Z_DatabaseInfo *f_databaseInfo(ExpHandle *eh, data1_node *n) } if (res->num_keywords) res->keywords = - (Z_HumanString **)odr_malloc (eh->o, res->num_keywords + (Z_HumanString **)odr_malloc (eh->o, res->num_keywords * sizeof(*res->keywords)); for (n = c->child; n; n = n->next) { @@ -889,7 +889,7 @@ Z_AttributeDescription *f_attributeDescription ( odr_malloc(eh->o, sizeof(*res)); data1_node *c; int i = 0; - + res->name = 0; res->description = 0; res->attributeValue = 0; @@ -1142,7 +1142,7 @@ Z_AttributeSetDetails *f_attributeSetDetails (ExpHandle *eh, data1_node *n) Z_AttributeSetDetails *res = (Z_AttributeSetDetails *) odr_malloc(eh->o, sizeof(*res)); data1_node *c; - + res->attributeSet = 0; res->num_attributesByType = 0; res->attributesByType = 0; @@ -1374,7 +1374,7 @@ Z_ExplainRecord *data1_nodetoexplain (data1_handle dh, data1_node *n, res->which = Z_Explain_categoryList; if (!(res->u.categoryList = f_categoryList(&eh, n))) return 0; - return res; + return res; case 2: res->which = Z_Explain_targetInfo; if (!(res->u.targetInfo = f_targetInfo(&eh, n))) @@ -1389,7 +1389,7 @@ Z_ExplainRecord *data1_nodetoexplain (data1_handle dh, data1_node *n, res->which = Z_Explain_attributeSetInfo; if (!(res->u.attributeSetInfo = f_attributeSetInfo(&eh, n))) return 0; - return res; + return res; case 10: res->which = Z_Explain_attributeDetails; if (!(res->u.attributeDetails = f_attributeDetails(&eh, n))) diff --git a/data1/d1_grs.c b/data1/d1_grs.c index fe816b4..e9a6a6b 100644 --- a/data1/d1_grs.c +++ b/data1/d1_grs.c @@ -107,7 +107,7 @@ static int traverse_triples(data1_node *n, int level, Z_ElementMetaData *m, ODR o) { data1_node *c; - + for (c = n->child; c; c = c->next) if (c->which == DATA1N_data && level) { @@ -235,7 +235,7 @@ static int is_empty_data (data1_node *n) || n->u.data.what == DATA1I_xmltext)) { int i = n->u.data.len; - + while (i > 0 && d1_isspace(n->u.data.data[i-1])) i--; if (i == 0) @@ -306,9 +306,9 @@ static Z_TaggedElement *nodetotaggedelement(data1_handle dh, data1_node *n, { char *tagstr; - if (n->which == DATA1N_tag) + if (n->which == DATA1N_tag) tagstr = n->u.tag.tag; /* tag at node */ - else if (tag) + else if (tag) tagstr = tag->value.string; /* no take from well-known */ else return 0; diff --git a/data1/d1_handle.c b/data1/d1_handle.c index 43b7ba8..4e48a13 100644 --- a/data1/d1_handle.c +++ b/data1/d1_handle.c @@ -82,9 +82,9 @@ void data1_destroy (data1_handle dh) { if (!dh) return; - + /* *ostrich* - We need to destroy DFAs, in xp_element (xelm) definitions + We need to destroy DFAs, in xp_element (xelm) definitions pop, 2002-12-13 */ data1_absyn_destroy(dh); @@ -99,7 +99,7 @@ void data1_destroy (data1_handle dh) if (dh->map_buf) xfree (dh->map_buf); nmem_destroy (dh->mem); - + xfree (dh); } diff --git a/data1/d1_if.c b/data1/d1_if.c index 2ec128c..33f11a3 100644 --- a/data1/d1_if.c +++ b/data1/d1_if.c @@ -66,10 +66,10 @@ char data1_ScanNextToken(char* pBuffer, return(**pPosInBuffer); } -/* +/* * Attempt to find a string value given the specified tagpath - * - * Need to make this safe by passing in a buffer..... + * + * Need to make this safe by passing in a buffer..... * */ char *data1_getNodeValue(data1_node* node, char* pTagPath) @@ -109,7 +109,7 @@ char *data1_getNodeValue(data1_node* node, char* pTagPath) /* Max length of a tag */ #define MAX_TAG_SIZE 50 -/* +/* * data1_LookupNode : Try and find a node as specified by a tagpath */ data1_node *data1_LookupNode(data1_node* node, char* pTagPath) @@ -193,11 +193,11 @@ data1_node *data1_LookupNode(data1_node* node, char* pTagPath) /* See if we can find the . at the end of this clause */ sepchr = data1_ScanNextToken(pTagPath, &pCurrCharInPath, "."," ", Buffer); } - + } yaz_log(YLOG_DEBUG,"search node for child like [%d,%d,%s,%d]",iTagType,iTagValue,StringTagVal,iOccurences); - + /* OK.. We have extracted tagtype, Value and Occurence, see if we can find a node */ /* Under the current parent matching that description */ @@ -248,7 +248,7 @@ data1_node *data1_LookupNode(data1_node* node, char* pTagPath) /** \brief Count the number of occurences of the last instance on a tagpath. \param node : The root of the tree we wish to look for occurences in - \param pTagPath : The tagpath we want to count the occurences of... + \param pTagPath : The tagpath we want to count the occurences of... */ int data1_CountOccurences(data1_node* node, char* pTagPath) { diff --git a/data1/d1_map.c b/data1/d1_map.c index 3f766e4..bd9b8ed 100644 --- a/data1/d1_map.c +++ b/data1/d1_map.c @@ -167,7 +167,7 @@ data1_maptab *data1_read_maptab (data1_handle dh, const char *file) } mapp = &(*mapp)->next; } - else + else yaz_log(YLOG_WARN, "%s:%d: Unknown directive '%s'", file, lineno, argv[0]); @@ -234,7 +234,7 @@ static data1_node *dup_child (data1_handle dh, data1_node *n, { *last = *m = (data1_node *) nmem_malloc (mem, sizeof(**m)); memcpy (*m, n, sizeof(**m)); - + (*m)->parent = parent; (*m)->root = parent->root; (*m)->child = dup_child(dh, n->child, &(*m)->last_child, mem, *m); @@ -289,11 +289,11 @@ static int map_children(data1_handle dh, data1_node *n, data1_maptab *map, { cur = data1_mk_tag ( dh, mem, tag->names->name, 0, pn); - + } } } - + if (mt->next) pn = cur; else if (!m->no_data) diff --git a/data1/d1_marc.c b/data1/d1_marc.c index a332b2a..3f26289 100644 --- a/data1/d1_marc.c +++ b/data1/d1_marc.c @@ -42,7 +42,7 @@ data1_marctab *data1_read_marctab (data1_handle dh, const char *file) char line[512], *argv[50]; int lineno = 0; int argc; - + if (!(f = data1_path_fopen(dh, file, "r"))) return 0; @@ -61,7 +61,7 @@ data1_marctab *data1_read_marctab (data1_handle dh, const char *file) res->force_indicator_length = -1; res->force_identifier_length = -1; strcpy(res->user_systems, "z "); - + while ((argc = readconf_line(f, &lineno, line, 512, argv, 50))) if (!strcmp(*argv, "name")) { @@ -82,7 +82,7 @@ data1_marctab *data1_read_marctab (data1_handle dh, const char *file) continue; } res->oid = yaz_string_to_oid_nmem(yaz_oid_std(), - CLASS_TAGSET, argv[1], + CLASS_TAGSET, argv[1], mem); if (!res->oid) { @@ -197,7 +197,7 @@ static void get_data2(data1_node *n, int *len, char *dst, size_t max) else if (n->which == DATA1N_data) n = n->next; else - break; + break; } } @@ -260,11 +260,11 @@ static int nodetomarc(data1_handle dh, continue; if (selected && !field->u.tag.node_selected) continue; - + subf = field->child; if (!subf) continue; - + if (!yaz_matchstr(field->u.tag.tag, "mc?")) continue; else if (!strcmp(field->u.tag.tag, "leader")) @@ -300,13 +300,13 @@ static int nodetomarc(data1_handle dh, + p->length_implementation; if (!control_field) - len += p->indicator_length; + len += p->indicator_length; /* we'll allow no indicator if length is not 2 */ /* select when old XML format, since indicator is an element */ if (marc_xml == 0 && is_indicator (p, subf)) subf = subf->child; - + for (; subf; subf = subf->next) { if (!control_field) @@ -324,7 +324,7 @@ static int nodetomarc(data1_handle dh, *buf = (char *)xmalloc(*size = len); else if (*size <= len) *buf = (char *)xrealloc(*buf, *size = len); - + op = *buf; /* we know the base address now */ @@ -333,7 +333,7 @@ static int nodetomarc(data1_handle dh, /* copy temp leader to real output buf op */ memcpy (op, leader, 24); memint (op, len, 5); - + entry_p = 24; data_p = base_address; @@ -358,7 +358,7 @@ static int nodetomarc(data1_handle dh, subf = field->child; if (!subf) continue; - + if (!yaz_matchstr(field->u.tag.tag, "mc?")) continue; else if (!strcmp(field->u.tag.tag, "leader")) @@ -419,7 +419,7 @@ static int nodetomarc(data1_handle dh, if (strcmp(subf->u.tag.tag, "subfield")) yaz_log(YLOG_WARN, "Unhandled tag %s", subf->u.tag.tag); - + for (xa = subf->u.tag.attributes; xa; xa = xa->next) if (!strcmp(xa->name, "code")) identifier = xa->value; @@ -450,7 +450,7 @@ static int nodetomarc(data1_handle dh, if (!tag || strlen(tag) != 3) tag = "000"; memcpy (op + entry_p, tag, 3); - + entry_p += 3; memint (op + entry_p, data_p - data_0, p->length_data_entry); entry_p += p->length_data_entry; diff --git a/data1/d1_read.c b/data1/d1_read.c index 54f7525..f4d1142 100644 --- a/data1/d1_read.c +++ b/data1/d1_read.c @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA /* - * This module reads "loose" SGML and converts it to data1 tree + * This module reads "loose" SGML and converts it to data1 tree */ #if HAVE_CONFIG_H @@ -44,7 +44,7 @@ data1_node *data1_get_root_tag (data1_handle dh, data1_node *n) } return n; } - + /* * get the tag which is the immediate parent of this node (this may mean * traversing intermediate things like variants and stuff. @@ -153,7 +153,7 @@ data1_node *data1_insert_node (data1_handle dh, NMEM m, int type, { data1_node *r = (data1_node *)nmem_malloc(m, sizeof(*r)); r->next = r->child = r->last_child = 0; - + if (!parent) r->root = r; else @@ -178,7 +178,7 @@ data1_node *data1_mk_root (data1_handle dh, NMEM nmem, const char *name) if (!absyn) { yaz_log(YLOG_WARN, "Unable to acquire abstract syntax " "for '%s'", - name); + name); /* It's now OK for a record not to have an absyn */ } res = data1_mk_node2 (dh, nmem, DATA1N_root, 0); @@ -214,7 +214,7 @@ void data1_add_attrs(data1_handle dh, NMEM nmem, const char **attr, } *p = 0; } - + data1_node *data1_mk_preprocess (data1_handle dh, NMEM nmem, const char *target, const char **attr, data1_node *at) @@ -230,7 +230,7 @@ data1_node *data1_mk_preprocess_n (data1_handle dh, NMEM nmem, data1_node *res = data1_mk_node2 (dh, nmem, DATA1N_preprocess, at); res->u.preprocess.target = data1_insert_string_n (dh, res, nmem, target, len); - + data1_add_attrs(dh, nmem, attr, &res->u.preprocess.attributes); return res; } @@ -250,21 +250,21 @@ data1_node *data1_insert_preprocess_n (data1_handle dh, NMEM nmem, data1_node *res = data1_insert_node (dh, nmem, DATA1N_preprocess, at); res->u.preprocess.target = data1_insert_string_n (dh, res, nmem, target, len); - + data1_add_attrs(dh, nmem, attr, &res->u.preprocess.attributes); return res; } -data1_node *data1_mk_tag_n (data1_handle dh, NMEM nmem, +data1_node *data1_mk_tag_n (data1_handle dh, NMEM nmem, const char *tag, size_t len, const char **attr, data1_node *at) { data1_node *partag = get_parent_tag(dh, at); data1_node *res = data1_mk_node2 (dh, nmem, DATA1N_tag, at); data1_element *e = 0; - + res->u.tag.tag = data1_insert_string_n (dh, res, nmem, tag, len); - + if (!partag) /* top tag? */ e = data1_getelementbytagname (dh, at->root->u.root.absyn, 0 /* index as local */, @@ -292,7 +292,7 @@ void data1_tag_add_attr (data1_handle dh, NMEM nmem, } data1_node *data1_mk_tag (data1_handle dh, NMEM nmem, - const char *tag, const char **attr, data1_node *at) + const char *tag, const char **attr, data1_node *at) { return data1_mk_tag_n (dh, nmem, tag, strlen(tag), attr, at); } @@ -316,7 +316,7 @@ data1_node *data1_search_tag (data1_handle dh, data1_node *n, return 0; } -data1_node *data1_mk_tag_uni (data1_handle dh, NMEM nmem, +data1_node *data1_mk_tag_uni (data1_handle dh, NMEM nmem, const char *tag, data1_node *at) { data1_node *node = data1_search_tag (dh, at->child, tag); @@ -333,7 +333,7 @@ data1_node *data1_mk_text_n (data1_handle dh, NMEM mem, data1_node *res = data1_mk_node2 (dh, mem, DATA1N_data, parent); res->u.data.what = DATA1I_text; res->u.data.len = len; - + res->u.data.data = data1_insert_string_n (dh, res, mem, buf, len); return res; } @@ -359,7 +359,7 @@ data1_node *data1_mk_comment_n (data1_handle dh, NMEM mem, data1_node *res = data1_mk_node2 (dh, mem, DATA1N_comment, parent); res->u.data.what = DATA1I_text; res->u.data.len = len; - + res->u.data.data = data1_insert_string_n (dh, res, mem, buf, len); return res; } @@ -403,7 +403,7 @@ static data1_node *data1_add_insert_taggeddata(data1_handle dh, if (!partag) e = data1_getelementbytagname (dh, root->u.root.absyn, 0, tagname); - else + else { e = partag->u.tag.element; if (e) @@ -459,7 +459,7 @@ data1_node *data1_mk_tag_data_zint (data1_handle dh, data1_node *at, NMEM nmem) { data1_node *node_data; - + node_data = data1_mk_tag_data (dh, at, tag, nmem); if (!node_data) return 0; @@ -484,11 +484,11 @@ data1_node *data1_mk_tag_data_oid (data1_handle dh, data1_node *at, data1_node *node_data; char str[128], *p = str; Odr_oid *ii; - + node_data = data1_mk_tag_data (dh, at, tag, nmem); if (!node_data) return 0; - + for (ii = oid; *ii >= 0; ii++) { if (ii != oid) @@ -508,7 +508,7 @@ data1_node *data1_mk_tag_data_text (data1_handle dh, data1_node *at, NMEM nmem) { data1_node *node_data; - + node_data = data1_mk_tag_data (dh, at, tag, nmem); if (!node_data) return 0; @@ -551,14 +551,14 @@ static int ampr (int (*get_byte)(void *fh), void *fh, int *amp) { char ent[20]; int i = 0; - + while (1) { c = (*get_byte)(fh); if (c == ';') { ent[i] = 0; - + c = ' '; if (!strcmp (ent, "quot")) c = '"'; @@ -602,7 +602,7 @@ data1_xattr *data1_read_xattr (data1_handle dh, NMEM m, pp = &p->next; p->value = 0; p->what = DATA1I_xmltext; - + wrbuf_rewind(wrbuf); while (c && c != '=' && c != '>' && c != '/' && !d1_isspace(c)) { @@ -615,7 +615,7 @@ data1_xattr *data1_read_xattr (data1_handle dh, NMEM m, c = ampr (get_byte, fh, amp); if (*amp == 0 && c == '"') { - c = ampr (get_byte, fh, amp); + c = ampr (get_byte, fh, amp); wrbuf_rewind(wrbuf); while (*amp || (c && c != '"')) { @@ -627,7 +627,7 @@ data1_xattr *data1_read_xattr (data1_handle dh, NMEM m, } else if (*amp == 0 && c == '\'') { - c = ampr (get_byte, fh, amp); + c = ampr (get_byte, fh, amp); wrbuf_rewind(wrbuf); while (*amp || (c && c != '\'')) { @@ -706,7 +706,7 @@ data1_node *data1_read_nodex (data1_handle dh, NMEM m, break; } } - else + else { if (amp == 0 && c == quote_mode) quote_mode = 0; @@ -717,19 +717,19 @@ data1_node *data1_read_nodex (data1_handle dh, NMEM m, else if (amp == 0 && c == '!') { int c0, amp0; - + wrbuf_rewind(wrbuf); - + c0 = ampr (get_byte, fh, &0); if (amp0 == 0 && c0 == '\0') break; c = ampr (get_byte, fh, &); - + if (amp0 == 0 && c0 == '-' && amp == 0 && c == '-') { /* COMMENT: */ int no_dash = 0; - + c = ampr (get_byte, fh, &); while (amp || c) { @@ -738,7 +738,7 @@ data1_node *data1_read_nodex (data1_handle dh, NMEM m, else if (amp == 0 && c == '>' && no_dash >= 2) { if (level > 0) - d1_stack[level] = + d1_stack[level] = data1_mk_comment_n ( dh, m, wrbuf_buf(wrbuf), wrbuf_len(wrbuf)-2, @@ -755,7 +755,7 @@ data1_node *data1_read_nodex (data1_handle dh, NMEM m, } else { /* DIRECTIVE: */ - + int blevel = 0; while (amp || c) { @@ -795,7 +795,7 @@ data1_node *data1_read_nodex (data1_handle dh, NMEM m, c = ampr (get_byte, fh, &); /* End tag? */ - if (end_tag) + if (end_tag) { if (*tag == '\0') --level; /* */ @@ -832,10 +832,10 @@ data1_node *data1_read_nodex (data1_handle dh, NMEM m, return d1_stack[0]; } continue; - } - else if (!strcmp(tag, "var") + } + else if (!strcmp(tag, "var") && xattr && xattr->next && xattr->next->next - && xattr->value == 0 + && xattr->value == 0 && xattr->next->value == 0 && xattr->next->next->value == 0) { @@ -844,7 +844,7 @@ data1_node *data1_read_nodex (data1_handle dh, NMEM m, const char *type = xattr->next->name; const char *value = xattr->next->name; data1_vartype *tp; - + yaz_log(YLOG_LOG, "Variant class=%s type=%s value=%s", tclass, type, value); if (!(tp = @@ -853,7 +853,7 @@ data1_node *data1_read_nodex (data1_handle dh, NMEM m, tclass, type))) continue; /* - * If we're the first variant in this group, create a parent + * If we're the first variant in this group, create a parent * variant, and insert it before the current variant. */ if (parent->which != DATA1N_variant) @@ -879,9 +879,9 @@ data1_node *data1_read_nodex (data1_handle dh, NMEM m, data1_insert_string (dh, res, m, value); } } - else + else { - + /* tag .. acquire our element in the abstract syntax */ if (level == 0) { @@ -909,7 +909,7 @@ data1_node *data1_read_nodex (data1_handle dh, NMEM m, else /* != '<'... this is a body of text */ { int len; - + if (level == 0) { c = ampr (get_byte, fh, &); @@ -919,7 +919,7 @@ data1_node *data1_read_nodex (data1_handle dh, NMEM m, res->u.data.what = DATA1I_xmltext; res->u.data.formatted_text = 0; d1_stack[level] = res; - + wrbuf_rewind(wrbuf); while (amp || (c && c != '<')) @@ -934,7 +934,7 @@ data1_node *data1_read_nodex (data1_handle dh, NMEM m, res->u.data.data = (char*) nmem_malloc (m, len); else res->u.data.data = res->lbuf; - + if (len) memcpy (res->u.data.data, wrbuf_buf(wrbuf), len); else @@ -974,10 +974,10 @@ data1_node *data1_read_record(data1_handle dh, char **buf = data1_get_read_buf (dh, &size); const char *bp; int rd = 0, res; - + if (!*buf) *buf = (char *)xmalloc(*size = 4096); - + for (;;) { if (rd + 2048 >= *size && !(*buf =(char *)xrealloc(*buf, *size *= 2))) @@ -1004,7 +1004,7 @@ data1_node *data1_read_sgml (data1_handle dh, NMEM m, const char *buf) } -static int conv_item(NMEM m, yaz_iconv_t t, +static int conv_item(NMEM m, yaz_iconv_t t, WRBUF wrbuf, char *inbuf, size_t inlen) { wrbuf_rewind(wrbuf); @@ -1035,7 +1035,7 @@ static void data1_iconv_s (data1_handle dh, NMEM m, data1_node *n, == 0) { n->u.tag.tag = - data1_insert_string_n (dh, n, m, + data1_insert_string_n (dh, n, m, wrbuf->buf, wrbuf->pos); } if (n->u.tag.attributes) @@ -1086,7 +1086,7 @@ const char *data1_get_encoding (data1_handle dh, data1_node *n) } int data1_iconv (data1_handle dh, NMEM m, data1_node *n, - const char *tocode, + const char *tocode, const char *fromcode) { if (yaz_matchstr (tocode, fromcode)) @@ -1111,24 +1111,24 @@ void data1_chop_text(data1_handle dh, NMEM m, data1_node *n) { if (n->which == DATA1N_data) { - + int sz = n->u.data.len; const char *ndata = n->u.data.data; int off = 0; - + for (off = 0; off < sz; off++) if (!d1_isspace(ndata[off])) break; sz = sz - off; ndata += off; - + while (sz && d1_isspace(ndata[sz - 1])) sz--; n->u.data.data = nmem_malloc(m, sz); n->u.data.len = sz; memcpy(n->u.data.data, ndata, sz); - + } data1_chop_text(dh, m, n->child); } @@ -1138,7 +1138,7 @@ void data1_concat_text(data1_handle dh, NMEM m, data1_node *n) { for (; n; n = n->next) { - if (n->which == DATA1N_data && n->next && + if (n->which == DATA1N_data && n->next && n->next->which == DATA1N_data) { int sz = 0; @@ -1158,7 +1158,7 @@ void data1_concat_text(data1_handle dh, NMEM m, data1_node *n) n->next = np; if (!np && n->parent) n->parent->last_child = n; - + } data1_concat_text(dh, m, n->child); } diff --git a/data1/d1_soif.c b/data1/d1_soif.c index 94abb62..fa814c5 100644 --- a/data1/d1_soif.c +++ b/data1/d1_soif.c @@ -78,7 +78,7 @@ char *data1_nodetosoif (data1_handle dh, data1_node *n, int select, int *len) char buf[128]; wrbuf_rewind(b); - + if (n->which != DATA1N_root) return 0; sprintf(buf, "@%s{\n", n->u.root.type); diff --git a/data1/d1_tagset.c b/data1/d1_tagset.c index d970101..d4ca559 100644 --- a/data1/d1_tagset.c +++ b/data1/d1_tagset.c @@ -65,7 +65,7 @@ data1_tag *data1_gettagbynum (data1_handle dh, data1_tagset *s, int type, int value) { data1_tag *r; - + for (; s; s = s->next) { /* scan local set */ @@ -173,7 +173,7 @@ data1_tagset *data1_read_tagset (data1_handle dh, const char *file, int type) fclose(f); return 0; } - + /* read namelist */ nm = names; npp = &rr->names; @@ -204,7 +204,7 @@ data1_tagset *data1_read_tagset (data1_handle dh, const char *file, int type) else if (!strcmp(cmd, "reference")) { char *name; - + if (argc != 2) { yaz_log(YLOG_WARN, "%s:%d: Bad # args to reference", diff --git a/data1/d1_utils.c b/data1/d1_utils.c index b714d87..69db13f 100644 --- a/data1/d1_utils.c +++ b/data1/d1_utils.c @@ -37,20 +37,20 @@ void data1_remove_node (data1_handle dh, data1_node *n) /* n is the only child */ if(! n->next){ - n->parent->last_child = 0; + n->parent->last_child = 0; } - } + } /* n is one of the following childrens */ else { data1_node * before; - + /* need to find sibling before me */ before = n->parent->child; while (before->next != n) before = before->next; - + before->next = n->next; - + /* n is last child of many */ if ( n->parent->last_child == n){ n->parent->last_child = before; @@ -74,16 +74,16 @@ void data1_remove_idzebra_subtree (data1_handle dh, data1_node *n) if (!strcmp(n->u.tag.tag, "idzebra")){ if (n->u.tag.attributes){ data1_xattr *xattr = n->u.tag.attributes; - + for (; xattr; xattr = xattr->next){ - if (!strcmp(xattr->name, "xmlns") - & !strcmp(xattr->value, + if (!strcmp(xattr->name, "xmlns") + & !strcmp(xattr->value, "http://www.indexdata.dk/zebra/")) data1_remove_node (dh, n); } } } - + break; /* case DATA1N_data: @@ -110,7 +110,7 @@ void data1_remove_idzebra_subtree (data1_handle dh, data1_node *n) n->parent->last_child, n); } */ - + } diff --git a/data1/d1_varset.c b/data1/d1_varset.c index 843b271..70e89ec 100644 --- a/data1/d1_varset.c +++ b/data1/d1_varset.c @@ -77,7 +77,7 @@ data1_varset *data1_read_varset (data1_handle dh, const char *file) if (!strcmp(argv[0], "class")) { data1_varclass *r; - + if (argc != 3) { yaz_log(YLOG_WARN, "%s:%d: Bad # or args to class", @@ -151,10 +151,10 @@ data1_varset *data1_read_varset (data1_handle dh, const char *file) continue; } } - else + else yaz_log(YLOG_WARN, "%s:%d: Unknown directive '%s'", file, lineno, argv[0]); - + fclose(f); return res; } diff --git a/data1/d1_write.c b/data1/d1_write.c index 003bc15..69e6f8d 100644 --- a/data1/d1_write.c +++ b/data1/d1_write.c @@ -175,7 +175,7 @@ static int nodetoidsgml(data1_node *n, int select, WRBUF b, int col, while (l) { int wlen; - + while (l && d1_isspace(*p)) p++, l--; if (!l) @@ -230,9 +230,9 @@ static int nodetoidsgml(data1_node *n, int select, WRBUF b, int col, char *data1_nodetoidsgml (data1_handle dh, data1_node *n, int select, int *len) { WRBUF b = data1_get_wrbuf (dh); - + wrbuf_rewind(b); - + if (!data1_is_xmlmode (dh)) { wrbuf_puts (b, "<"); diff --git a/dfa/agrep.c b/dfa/agrep.c index 0d671ef..504b50a 100644 --- a/dfa/agrep.c +++ b/dfa/agrep.c @@ -184,7 +184,7 @@ static int go (int fd, struct DFA_state **dfaar) break; } for (t=s->trans, i=s->tran_no; --i >= 0; t++) - if ((unsigned) *p >= t->ch[0] + if ((unsigned) *p >= t->ch[0] && (unsigned) *p <= t->ch[1]) break; p++; diff --git a/dfa/bset.c b/dfa/bset.c index 065526d..6ca49e4 100644 --- a/dfa/bset.c +++ b/dfa/bset.c @@ -31,17 +31,17 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include "imalloc.h" -#define GET_BIT(s,m) (s[(m)/(sizeof(BSetWord)*8)]&(1<<(m&(sizeof(BSetWord)*8-1)))) +#define GET_BIT(s,m) (s[(m)/(sizeof(BSetWord)*8)]&(1<<(m&(sizeof(BSetWord)*8-1)))) #define SET_BIT(s,m) (s[(m)/(sizeof(BSetWord)*8)]|=(1<<(m&(sizeof(BSetWord)*8-1)))) BSetHandle *mk_BSetHandle (int size, int chunk) { - int wsize = 1+size/(sizeof(BSetWord)*8); + int wsize = 1+size/(sizeof(BSetWord)*8); BSetHandle *sh; if (chunk <= 1) chunk = 32; - sh = (BSetHandle *) imalloc (sizeof(BSetHandle) + + sh = (BSetHandle *) imalloc (sizeof(BSetHandle) + chunk*sizeof(BSetWord)*wsize); sh->size = size; @@ -94,7 +94,7 @@ BSet mk_BSet (BSetHandle **shp) off = sh->offset; if ((off + sh->wsize) > sh->chunk) { - sh1 = (BSetHandle *) imalloc (sizeof(BSetHandle) + + sh1 = (BSetHandle *) imalloc (sizeof(BSetHandle) + sh->chunk*sizeof(BSetWord)); sh1->size = sh->size; sh1->wsize = sh->wsize; diff --git a/dfa/dfa.c b/dfa/dfa.c index b20650f..3246ffd 100644 --- a/dfa/dfa.c +++ b/dfa/dfa.c @@ -71,9 +71,9 @@ static struct Tnode *mk_Tnode_cset (struct DFA_parse *parse_info, BSet charset); static void term_Tnode (struct DFA_parse *parse_info); -static void - del_followpos (struct DFA_parse *parse_info), - init_pos (struct DFA_parse *parse_info), +static void + del_followpos (struct DFA_parse *parse_info), + init_pos (struct DFA_parse *parse_info), del_pos (struct DFA_parse *parse_info), mk_dfa_tran (struct DFA_parse *parse_info, struct DFA_states *dfas), add_follow (struct DFA_parse *parse_info, DFASet lastpos, DFASet firstpos), @@ -89,7 +89,7 @@ static int nextchar (struct DFA_parse *parse_info, int *esc), read_charset (struct DFA_parse *parse_info); -static const char +static const char *str_char (unsigned c); #define L_LP 1 @@ -113,7 +113,7 @@ static struct Tnode *expr_1 (struct DFA_parse *parse_info), *expr_4 (struct DFA_parse *parse_info); static struct Tnode *expr_1 (struct DFA_parse *parse_info) -{ +{ struct Tnode *t1, *t2, *tn; if (!(t1 = expr_2 (parse_info))) @@ -123,7 +123,7 @@ static struct Tnode *expr_1 (struct DFA_parse *parse_info) lex (parse_info); if (!(t2 = expr_2 (parse_info))) return t2; - + tn = mk_Tnode (parse_info); tn->pos = OR; tn->u.p[0] = t1; @@ -136,7 +136,7 @@ static struct Tnode *expr_1 (struct DFA_parse *parse_info) static struct Tnode *expr_2 (struct DFA_parse *parse_info) { struct Tnode *t1, *t2, *tn; - + if (!(t1 = expr_3 (parse_info))) return t1; while (parse_info->lookahead == L_WILD || @@ -148,7 +148,7 @@ static struct Tnode *expr_2 (struct DFA_parse *parse_info) { if (!(t2 = expr_3 (parse_info))) return t2; - + tn = mk_Tnode (parse_info); tn->pos = CAT; tn->u.p[0] = t1; @@ -272,13 +272,13 @@ static void do_parse (struct DFA_parse *parse_info, const char **s, t2 = mk_Tnode (parse_info); t2->pos = ++parse_info->position; t2->u.ch[1] = t2->u.ch[0] = '\n'; - + tn = mk_Tnode (parse_info); tn->pos = CAT; tn->u.p[0] = t1; tn->u.p[1] = t2; t1 = tn; - + lex (parse_info); } } @@ -288,7 +288,7 @@ static void do_parse (struct DFA_parse *parse_info, const char **s, t2->pos = ++parse_info->position; t2->u.ch[0] = -(++parse_info->rule); t2->u.ch[1] = start_anchor_flag ? 0 : -(parse_info->rule); - + *tnp = mk_Tnode(parse_info); (*tnp)->pos = CAT; (*tnp)->u.p[0] = t1; @@ -366,8 +366,8 @@ static int read_charset (struct DFA_parse *parse_info) ch0 = nextchar_set (parse_info, &esc0); } /** - ch0 is last met character - ch1 is "next" char + ch0 is last met character + ch1 is "next" char */ while (ch0 != 0) { @@ -462,7 +462,7 @@ static int map_l_char (struct DFA_parse *parse_info) mapto = (*parse_info->cmap) (parse_info->cmap_data, &cp0, len); assert (mapto); - + parse_info->expr_ptr = (const unsigned char *) cp0; parse_info->look_ch = ((unsigned char **) mapto)[i][0]; yaz_log (YLOG_DEBUG, "map from %c to %d", parse_info->expr_ptr[-1], parse_info->look_ch); @@ -483,7 +483,7 @@ static int lex_sub(struct DFA_parse *parse_info) return map_l_char (parse_info); else if (parse_info->look_ch == '[') return read_charset(parse_info); - else + else { const int *cc; for (cc = parse_info->charMap; *cc; cc += 2) @@ -624,7 +624,7 @@ static void del_followpos (struct DFA_parse *parse_info) static void init_pos (struct DFA_parse *parse_info) { - parse_info->posar = (struct Tnode **) imalloc (sizeof(struct Tnode*) + parse_info->posar = (struct Tnode **) imalloc (sizeof(struct Tnode*) * (1+parse_info->position)); } @@ -638,18 +638,18 @@ static void add_follow (struct DFA_parse *parse_info, { while (lastpos) { - parse_info->followpos[lastpos->value] = + parse_info->followpos[lastpos->value] = union_DFASet (parse_info->poset, parse_info->followpos[lastpos->value], firstpos); lastpos = lastpos->next; - } + } } static void dfa_trav (struct DFA_parse *parse_info, struct Tnode *n) { struct Tnode **posar = parse_info->posar; DFASetType poset = parse_info->poset; - + switch (n->pos) { case CAT: @@ -788,7 +788,7 @@ static void mk_dfa_tran (struct DFA_parse *parse_info, struct DFA_states *dfas) pos_i = pos; j = i = 0; for (tran_set = dfa_from->set; tran_set; tran_set = tran_set->next) - if ((c = posar[tran_set->value]->u.ch[0]) >= 0 && c <= max_char) + if ((c = posar[tran_set->value]->u.ch[0]) >= 0 && c <= max_char) *pos_i++ = tran_set->value; else if (c < 0) { @@ -806,7 +806,7 @@ static void mk_dfa_tran (struct DFA_parse *parse_info, struct DFA_states *dfas) { char_0 = max_char+1; for (pos_i = pos; (i = *pos_i) != -1; ++pos_i) - if (posar[i]->u.ch[1] >= char_1 + if (posar[i]->u.ch[1] >= char_1 && (c=posar[i]->u.ch[0]) < char_0) { if (c < char_1) @@ -819,7 +819,7 @@ static void mk_dfa_tran (struct DFA_parse *parse_info, struct DFA_states *dfas) break; char_1 = max_char; - + tran_set = mk_DFASet (poset); for (pos_i = pos; (i = *pos_i) != -1; ++pos_i) { @@ -966,7 +966,7 @@ void dfa_parse_cmap_del (struct DFA *d, int from) { while ((cc[0] = cc[2])) { - cc[1] = cc[3]; + cc[1] = cc[3]; cc += 2; } break; @@ -1024,7 +1024,7 @@ void dfa_parse_cmap_thompson (struct DFA *d) static struct DFA_parse *dfa_parse_init (void) { - struct DFA_parse *parse_info = + struct DFA_parse *parse_info = (struct DFA_parse *) imalloc (sizeof (struct DFA_parse)); parse_info->charset = mk_BSetHandle (255, 20); diff --git a/dfa/grepper.c b/dfa/grepper.c index 8524fd1..d078430 100644 --- a/dfa/grepper.c +++ b/dfa/grepper.c @@ -46,7 +46,7 @@ typedef struct { #define INFBUF_SIZE 16384 -#define INLINE +#define INLINE static INLINE void set_bit (MatchContext *mc, MatchWord *m, int ch, int state) { @@ -82,7 +82,7 @@ static MatchContext *mk_MatchContext (struct DFA *dfa, int range) mc->n = (dfa->no_states+WORD_BITS) / WORD_BITS; mc->range = range; mc->Sc = icalloc (sizeof(*mc->Sc) * 256 * mc->n); - + for (i=0; ino_states; i++) { int j; @@ -94,7 +94,7 @@ static MatchContext *mk_MatchContext (struct DFA *dfa, int range) int ch0 = state->trans[j].ch[0]; int ch1 = state->trans[j].ch[1]; assert (ch0 >= 0 && ch1 >= 0); - + for (ch = ch0; ch <= ch1; ch++) set_bit (mc, mc->Sc, ch, i); } @@ -260,7 +260,7 @@ static int go (MatchContext *mc, struct DFA *dfa, FILE *inf) while ((ch = getc (inf)) != EOF) { MatchWord *Rj_t; - + infbuf[inf_ptr] = ch; if (ch == '\n') { @@ -336,7 +336,7 @@ static int grep_file (struct DFA *dfa, const char *fname, int range) } else inf = stdin; - + mc = mk_MatchContext (dfa, range); go (mc, dfa, inf); diff --git a/dfa/lexer.c b/dfa/lexer.c index 578081d..ebf3b36 100644 --- a/dfa/lexer.c +++ b/dfa/lexer.c @@ -115,7 +115,7 @@ int main (int argc, char **argv) if (**++argv != '-' && **argv) { ++no; - + i = read_file (*argv, dfa); if (i) return i; diff --git a/dfa/readfile.c b/dfa/readfile.c index 458ea25..186c9db 100644 --- a/dfa/readfile.c +++ b/dfa/readfile.c @@ -101,9 +101,9 @@ static void read_rules (struct DFA *dfa) /* copy rest of line to output */ fputs (s, outf); else - { + { /* preprocess regular expression */ - prep (&s); + prep (&s); /* now parse regular expression */ sc = s; i = dfa_parse (dfa, &sc); diff --git a/dfa/states.c b/dfa/states.c index 76b3e76..5981935 100644 --- a/dfa/states.c +++ b/dfa/states.c @@ -38,7 +38,7 @@ int init_DFA_states (struct DFA_states **dfasp, DFASetType st, int hash) struct DFA_states *dfas; struct DFA_trans *tm; int i; - + dfas = (struct DFA_states *) imalloc (sizeof(struct DFA_states)); assert (dfas); dfas->hasharray = (struct DFA_state **) @@ -117,7 +117,7 @@ int add_DFA_state (struct DFA_states *dfas, DFASet *s, struct DFA_state **sp) sb = (DFA_stateb *) imalloc (sizeof(*sb)); sb->next = dfas->statemem; dfas->statemem = sb; - sb->state_block = si = dfas->freelist = + sb->state_block = si = dfas->freelist = (struct DFA_state *) imalloc (sizeof(struct DFA_state)*DFA_CHUNK); for (i = 0; inext = si+1; diff --git a/dfa/test_dfa.c b/dfa/test_dfa.c index 7caef43..27cb00e 100644 --- a/dfa/test_dfa.c +++ b/dfa/test_dfa.c @@ -30,7 +30,7 @@ int test_parse(struct DFA *dfa, const char *pattern) i = dfa_parse(dfa, &cp); return i; } - + static void tst(int argc, char **argv) { struct DFA *dfa = dfa_init(); diff --git a/dict/close.c b/dict/close.c index 971c2de..012f036 100644 --- a/dict/close.c +++ b/dict/close.c @@ -39,7 +39,7 @@ int dict_close(Dict dict) void *head_buf; dict_bf_readp(dict->dbf, 0, &head_buf); memcpy(head_buf, &dict->head, sizeof(dict->head)); - dict_bf_touch(dict->dbf, 0); + dict_bf_touch(dict->dbf, 0); } dict_bf_close(dict->dbf); xfree(dict); diff --git a/dict/dclose.c b/dict/dclose.c index 4dcdb10..c09528e 100644 --- a/dict/dclose.c +++ b/dict/dclose.c @@ -32,7 +32,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA int dict_bf_close(Dict_BFile dbf) { dict_bf_flush_blocks(dbf, -1); - + xfree(dbf->all_blocks); xfree(dbf->all_data); xfree(dbf->hash_array); diff --git a/dict/dcompact.c b/dict/dcompact.c index 1c792b3..13b4396 100644 --- a/dict/dcompact.c +++ b/dict/dcompact.c @@ -34,7 +34,7 @@ static void dict_copy_page(Dict dict, char *to_p, char *from_p, int *map) int i, slen, no = 0; short *from_indxp, *to_indxp; char *from_info, *to_info; - + from_indxp = (short*) ((char*) from_p+DICT_bsize(from_p)); to_indxp = (short*) ((char*) to_p+DICT_bsize(to_p)); to_info = (char*) to_p + DICT_infoffset; @@ -70,7 +70,7 @@ static void dict_copy_page(Dict dict, char *to_p, char *from_p, int *map) from_info += sizeof(Dict_ptr); memcpy(&subchar, from_info, sizeof(subchar)); from_info += sizeof(Dict_char); - + memcpy(to_info, &subptr, sizeof(Dict_ptr)); to_info += sizeof(Dict_ptr); memcpy(to_info, &subchar, sizeof(Dict_char)); @@ -103,7 +103,7 @@ int dict_copy_compact(BFiles bfs, const char *from_name, const char *to_name) return -1; map[0] = 0; map[1] = dict_from->head.page_size; - + for (i = 1; i < (int) (dict_from->head.last); i++) { void *buf; diff --git a/dict/delete.c b/dict/delete.c index d81c384..74eccda 100644 --- a/dict/delete.c +++ b/dict/delete.c @@ -28,16 +28,16 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "dict-p.h" static void dict_del_subtree(Dict dict, Dict_ptr ptr, - void *client, + void *client, int (*f)(const char *, void *)) { void *p = 0; short *indxp; int i, hi; - + if (!ptr) return; - + dict_bf_readp(dict->dbf, ptr, &p); indxp = (short*) ((char*) p+DICT_bsize(p)-sizeof(short)); hi = DICT_nodir(p)-1; @@ -56,14 +56,14 @@ static void dict_del_subtree(Dict dict, Dict_ptr ptr, else { Dict_ptr subptr; - + /* Dict_ptr subptr */ /* Dict_char sub char */ /* unsigned char length of information */ /* char * information */ char *info = (char*)p - indxp[-i]; memcpy(&subptr, info, sizeof(Dict_ptr)); - + if (info[sizeof(Dict_ptr)+sizeof(Dict_char)]) { if (f) @@ -72,7 +72,7 @@ static void dict_del_subtree(Dict dict, Dict_ptr ptr, if (subptr) { dict_del_subtree(dict, subptr, client, f); - + /* page may be gone. reread it .. */ dict_bf_readp(dict->dbf, ptr, &p); indxp = (short*) ((char*) p+DICT_bsize(p)-sizeof(short)); @@ -85,7 +85,7 @@ static void dict_del_subtree(Dict dict, Dict_ptr ptr, } static int dict_del_string(Dict dict, const Dict_char *str, Dict_ptr ptr, - int sub_flag, void *client, + int sub_flag, void *client, int (*f)(const char *, void *)) { int mid, lo, hi; @@ -101,7 +101,7 @@ static int dict_del_string(Dict dict, const Dict_char *str, Dict_ptr ptr, dict_bf_readp(dict->dbf, ptr, &p); mid = lo = 0; hi = DICT_nodir(p)-1; - indxp = (short*) ((char*) p+DICT_bsize(p)-sizeof(short)); + indxp = (short*) ((char*) p+DICT_bsize(p)-sizeof(short)); while (lo <= hi) { mid = (lo+hi)/2; @@ -135,7 +135,7 @@ static int dict_del_string(Dict dict, const Dict_char *str, Dict_ptr ptr, mid = lo = 0; r = 1; /* signal deleted */ /* start again (may not be the most efficient way to go)*/ - continue; + continue; } } else @@ -213,7 +213,7 @@ static int dict_del_string(Dict dict, const Dict_char *str, Dict_ptr ptr, subptr = 0; /* avoid dict_del_subtree (end of function)*/ if (r == 2) { /* subptr page became empty and is removed */ - + /* see if this entry is a real one or if it just serves as pointer to subptr */ if (info[sizeof(Dict_ptr)+sizeof(Dict_char)]) diff --git a/dict/dict-p.h b/dict/dict-p.h index 53cb830..f0e06d7 100644 --- a/dict/dict-p.h +++ b/dict/dict-p.h @@ -54,15 +54,15 @@ typedef struct Dict_file_struct { int cache; BFile bf; - + struct Dict_file_block *all_blocks; struct Dict_file_block *free_list; struct Dict_file_block **hash_array; - + struct Dict_file_block *lru_back, *lru_front; int hash_size; void *all_data; - + int block_size; int hits; int misses; @@ -120,7 +120,7 @@ int dict_strlen (const Dict_char *s); dir[0..nodir-1] ptr,info,string */ - + YAZ_END_CDECL #endif diff --git a/dict/dicttest.c b/dict/dicttest.c index a5e12d6..0340ff3 100644 --- a/dict/dicttest.c +++ b/dict/dicttest.c @@ -71,7 +71,7 @@ int main (int argc, char **argv) int no_of_new = 0, no_of_same = 0, no_of_change = 0; int no_of_hits = 0, no_of_misses = 0, no_not_found = 0, no_of_deleted = 0; int max_pos; - + prog = argv[0]; if (argc < 2) { @@ -193,7 +193,7 @@ int main (int argc, char **argv) yaz_log (YLOG_FATAL|YLOG_ERRNO, "cannot open %s", inputfile); exit (1); } - + while (fgets (ipf_buf, 1023, ipf)) { char *ipf_ptr = ipf_buf; @@ -285,7 +285,7 @@ int main (int argc, char **argv) } if (rw) { - yaz_log (YLOG_LOG, "Iterations.... %d", no_of_iterations); + yaz_log (YLOG_LOG, "Iterations.... %d", no_of_iterations); if (do_delete) { yaz_log (YLOG_LOG, "No of deleted. %d", no_of_deleted); @@ -306,7 +306,7 @@ int main (int argc, char **argv) if (scan_the_thing) { char term_dict[1024]; - + int before = 1000000; int after = 1000000; yaz_log (YLOG_LOG, "dict_scan"); diff --git a/dict/dopen.c b/dict/dopen.c index e95c59a..28cec1c 100644 --- a/dict/dopen.c +++ b/dict/dopen.c @@ -76,7 +76,7 @@ Dict_BFile dict_bf_open(BFiles bfs, const char *name, int block_size, int cache, int rw) { Dict_BFile dbf; - + dbf = (Dict_BFile) xmalloc(sizeof(*dbf)); dbf->bf = bf_open(bfs, name, block_size, rw); if (!dbf->bf) diff --git a/dict/drdwr.c b/dict/drdwr.c index 670ed45..b7ae8bf 100644 --- a/dict/drdwr.c +++ b/dict/drdwr.c @@ -59,7 +59,7 @@ static void release_block(Dict_BFile bf, struct Dict_file_block *p) { assert(p); - /* remove from lru queue */ + /* remove from lru queue */ if (p->lru_prev) p->lru_prev->lru_next = p->lru_next; else @@ -106,7 +106,7 @@ void dict_bf_flush_blocks(Dict_BFile bf, int no_to_flush) effective_block, effective_offset, p->nbytes); #endif - + } else { @@ -158,7 +158,7 @@ static struct Dict_file_block *alloc_block(Dict_BFile bf, int no) if (*pp) (*pp)->h_prev = &p->h_next; *pp = p; - + return p; } @@ -166,7 +166,7 @@ static void move_to_front(Dict_BFile bf, struct Dict_file_block *p) { /* Already at front? */ if (!p->lru_next) - return ; + return ; /* Remove */ if (p->lru_prev) diff --git a/dict/insert.c b/dict/insert.c index ff9aca1..dfed594 100644 --- a/dict/insert.c +++ b/dict/insert.c @@ -99,7 +99,7 @@ static int split_page(Dict dict, Dict_ptr ptr, void *p) best_indxp = indxp; } } - else + else { /* new char prefix. restore */ prev_char = dc; no_current = 1; @@ -145,7 +145,7 @@ static int split_page(Dict dict, Dict_ptr ptr, void *p) } static void clean_page(Dict dict, Dict_ptr ptr, void *p, Dict_char *out, - Dict_ptr subptr, char *userinfo) + Dict_ptr subptr, char *userinfo) { char *np = (char *) xmalloc(dict->head.page_size); int i, slen, no = 0; @@ -180,8 +180,8 @@ static void clean_page(Dict dict, Dict_ptr ptr, void *p, Dict_char *out, info2 += *userinfo + 1; } else - *info2++ = 0; - subptr = 0; + *info2++ = 0; + subptr = 0; ++no; continue; } @@ -211,7 +211,7 @@ static void clean_page(Dict dict, Dict_ptr ptr, void *p, Dict_char *out, ++no; } #if 1 - memcpy((char*)p+DICT_infoffset, + memcpy((char*)p+DICT_infoffset, (char*)np+DICT_infoffset, info2 - ((char*)np+DICT_infoffset)); memcpy((char*)p + ((char*)indxp2 - (char*)np), @@ -243,7 +243,7 @@ static int dict_ins(Dict dict, const Dict_char *str, void *p; dict_bf_readp(dict->dbf, ptr, &p); - + assert(p); assert(ptr); @@ -341,7 +341,7 @@ static int dict_ins(Dict dict, const Dict_char *str, return dict_ins(dict, str-1, ptr, userlen, userinfo); } - if (split_page(dict, ptr, p)) + if (split_page(dict, ptr, p)) { yaz_log(YLOG_FATAL, "Unable to split page %d\n", ptr); assert(0); diff --git a/dict/lookgrep.c b/dict/lookgrep.c index f480029..efbadc4 100644 --- a/dict/lookgrep.c +++ b/dict/lookgrep.c @@ -34,11 +34,11 @@ typedef unsigned MatchWord; #define WORD_BITS 32 #define MAX_LENGTH 1024 -/* This code is based +/* This code is based * Sun Wu and Udi Manber: Fast Text Searching Allowing Errors. * Communications of the ACM, pp. 83-91, Vol. 35, No. 10, Oct. 1992, USA. * PostScript version of the paper in its submitted form: agrep1.ps) - * recommended reading to understand AGREP ! + * recommended reading to understand AGREP ! * * http://www.tgries.de/agrep/#AGREP1PS * http://www.tgries.de/agrep/doc/agrep1ps.zip @@ -51,13 +51,13 @@ typedef struct { MatchWord *match_mask; /* match_mask */ } MatchContext; -#define INLINE +#define INLINE static INLINE void set_bit(MatchContext *mc, MatchWord *m, int ch, int state) { int off = state & (WORD_BITS-1); int wno = state / WORD_BITS; - + m[mc->n * ch + wno] |= 1<range; d++) { or(mc, Rtmp, Rj, Rj1); /* 2,3 */ - + shift(mc, Rtmp_2, Rtmp, dfa); mask_shift(mc, Rtmp, Rj+mc->n, dfa, ch); /* 1 */ - + or(mc, Rtmp, Rtmp_2, Rtmp); /* 1,2,3*/ Rj1 += mc->n; - + or(mc, Rj1, Rtmp, Rj); /* 1,2,3,4 */ Rj += mc->n; @@ -283,7 +283,7 @@ static int grep(Dict dict, Dict_ptr ptr, MatchContext *mc, { if (was_match) { - int ret = userfunc((char*) prefix, + int ret = userfunc((char*) prefix, info+(j+1)*sizeof(Dict_char), client); if (ret) return ret; @@ -323,7 +323,7 @@ static int grep(Dict dict, Dict_ptr ptr, MatchContext *mc, info = (char*)p - indxp[-lo]; memcpy(&ch, info+sizeof(Dict_ptr), sizeof(Dict_char)); prefix[pos] = ch; - + if (pos > *max_pos) *max_pos = pos; if (pos >= init_pos) @@ -398,7 +398,7 @@ int dict_lookup_grep(Dict dict, const char *pattern, int range, void *client, yaz_log(YLOG_DEBUG, " %2d %3d %c", i, pattern[i], (pattern[i] > ' ' && pattern[i] < 127) ? pattern[i] : '?'); } - + dfa_set_cmap(dfa, dict->grep_cmap_data, dict->grep_cmap); i = dfa_parse(dfa, &this_pattern); diff --git a/dict/lookup.c b/dict/lookup.c index 6a45359..9f26996 100644 --- a/dict/lookup.c +++ b/dict/lookup.c @@ -40,7 +40,7 @@ static char *dict_look(Dict dict, const Dict_char *str, Dict_ptr ptr) dict_bf_readp(dict->dbf, ptr, &p); mid = lo = 0; hi = DICT_nodir(p)-1; - indxp = (short*) ((char*) p+DICT_bsize(p)-sizeof(short)); + indxp = (short*) ((char*) p+DICT_bsize(p)-sizeof(short)); while (lo <= hi) { mid = (lo+hi)/2; diff --git a/dict/lookupec.c b/dict/lookupec.c index 237cab0..88a5ccd 100644 --- a/dict/lookupec.c +++ b/dict/lookupec.c @@ -50,7 +50,7 @@ static int lookup_ec(Dict dict, Dict_ptr ptr, dict_bf_readp(dict->dbf, ptr, &p); lo = 0; hi = DICT_nodir(p)-1; - indxp = (short*) ((char*) p+DICT_bsize(p)-sizeof(short)); + indxp = (short*) ((char*) p+DICT_bsize(p)-sizeof(short)); while (lo <= hi) { if (indxp[-lo] > 0) @@ -98,7 +98,7 @@ static int lookup_ec(Dict dict, Dict_ptr ptr, info = (char*)p - indxp[-lo]; memcpy(&ch, info+sizeof(Dict_ptr), sizeof(Dict_char)); prefix[pos] = ch; - + sc = mi->s[ch & 255]; ri[1+range] = SH(ri[0]) & sc; for (i=1; i<=range; i++) @@ -120,7 +120,7 @@ static int lookup_ec(Dict dict, Dict_ptr ptr, lookup_ec(dict, subptr, mi, ri, pos+1, userfunc, range, prefix); dict_bf_readp(dict->dbf, ptr, &p); - indxp = (short*) ((char*) p + + indxp = (short*) ((char*) p + DICT_bsize(p)-sizeof(short)); } } @@ -156,14 +156,14 @@ int dict_lookup_ec(Dict dict, char *pattern, int range, if (!dict->head.root) return 0; - + mi = prepare_match((Dict_char*) pattern); - + ri = (MatchWord *) xmalloc((dict_strlen((Dict_char*) pattern)+range+2) * (range+1)*sizeof(*ri)); for (i = 0; i <= range; i++) ri[i] = (2<head.root, mi, ri, 0, userfunc, range, prefix); xfree(ri); diff --git a/dict/open.c b/dict/open.c index d31252f..1df9d98 100644 --- a/dict/open.c +++ b/dict/open.c @@ -41,9 +41,9 @@ void dict_clean(Dict dict) dict->head.freelist = 0; dict->head.page_size = page_size; dict->head.compact_flag = compact_flag; - + /* create header with information (page 0) */ - if (dict->rw) + if (dict->rw) dict_bf_newp(dict->dbf, 0, &head_buf, page_size); } diff --git a/dict/scan.c b/dict/scan.c index 76032f3..41fd1cc 100644 --- a/dict/scan.c +++ b/dict/scan.c @@ -28,7 +28,7 @@ #include "dict-p.h" -static void scan_direction(Dict dict, Dict_ptr ptr, int pos, Dict_char *str, +static void scan_direction(Dict dict, Dict_ptr ptr, int pos, Dict_char *str, int start, int *count, void *client, int (*userfunc)(char *, const char *, int, void *), int dir) @@ -49,7 +49,7 @@ static void scan_direction(Dict dict, Dict_ptr ptr, int pos, Dict_char *str, else lo = 0; } - indxp = (short*) ((char*) p+DICT_bsize(p)-sizeof(short)); + indxp = (short*) ((char*) p+DICT_bsize(p)-sizeof(short)); while (lo <= hi && lo >= 0 && *count > 0) { @@ -99,10 +99,10 @@ static void scan_direction(Dict dict, Dict_ptr ptr, int pos, Dict_char *str, } if (*count>0 && subptr) { - scan_direction(dict, subptr, pos+1, str, -1, count, + scan_direction(dict, subptr, pos+1, str, -1, count, client, userfunc, dir); dict_bf_readp(dict->dbf, ptr, &p); - indxp = (short*) ((char*) p+DICT_bsize(p)-sizeof(short)); + indxp = (short*) ((char*) p+DICT_bsize(p)-sizeof(short)); } if (*count>0 && dir<0 && info[sizeof(Dict_ptr)+sizeof(Dict_char)]) { @@ -121,7 +121,7 @@ static void scan_direction(Dict dict, Dict_ptr ptr, int pos, Dict_char *str, } } -void dict_scan_r(Dict dict, Dict_ptr ptr, int pos, Dict_char *str, +void dict_scan_r(Dict dict, Dict_ptr ptr, int pos, Dict_char *str, int *before, int *after, void *client, int (*userfunc)(char *, const char *, int, void *)) { @@ -152,7 +152,7 @@ void dict_scan_r(Dict dict, Dict_ptr ptr, int pos, Dict_char *str, { if ((*userfunc)((char *) str, info+ (dict_strlen((Dict_char*) info)+1) - *sizeof(Dict_char), + *sizeof(Dict_char), *after, client)) { *after = 0; @@ -196,7 +196,7 @@ void dict_scan_r(Dict dict, Dict_ptr ptr, int pos, Dict_char *str, } } if (*after && subptr) - scan_direction(dict, subptr, pos+1, str, -1, + scan_direction(dict, subptr, pos+1, str, -1, after, client, userfunc, 1); } else @@ -235,7 +235,7 @@ void dict_scan_r(Dict dict, Dict_ptr ptr, int pos, Dict_char *str, scan_direction(dict, ptr, pos, str, cmp ? mid : mid+1, after, client, userfunc, 1); if (*before && mid > 0) - scan_direction(dict, ptr, pos, str, mid-1, before, + scan_direction(dict, ptr, pos, str, mid-1, before, client, userfunc, -1); } diff --git a/include/charmap.h b/include/charmap.h index da1e6ef..fbbad3d 100644 --- a/include/charmap.h +++ b/include/charmap.h @@ -46,7 +46,7 @@ YAZ_EXPORT const char **chr_map_input_x(chrmaptab t, const char **from, int *len, int first); YAZ_EXPORT const char **chr_map_q_input(chrmaptab maptab, const char **from, int len, int first); - + YAZ_EXPORT const char *chr_map_output(chrmaptab t, const char **from, int len); YAZ_END_CDECL diff --git a/include/d1_absyn.h b/include/d1_absyn.h index b5fe8cf..44a3a03 100644 --- a/include/d1_absyn.h +++ b/include/d1_absyn.h @@ -30,11 +30,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA typedef struct data1_xpelement { char *xpath_expr; -#ifdef ENHANCED_XELM +#ifdef ENHANCED_XELM struct xpath_location_step xpath[XPATH_STEP_COUNT]; int xpath_len; #endif - struct DFA *dfa; + struct DFA *dfa; data1_termlist *termlists; struct data1_xpelement *next; #if OPTIMIZE_MELM diff --git a/include/idzebra/api.h b/include/idzebra/api.h index 0b8b612..5b3af1d 100644 --- a/include/idzebra/api.h +++ b/include/idzebra/api.h @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA /** \file api.h \brief Zebra API - + Return codes: Most functions has return type ZEBRA_RES, where ZEBRA_FAIL indicates failure; ZEBRA_OK indicates success. @@ -53,7 +53,7 @@ typedef struct { char *buf; /* record buffer (void pointer really) */ int len; /* length */ const Odr_oid *format; /* record syntax */ - char *base; + char *base; zint sysno; int score; } ZebraRetrievalRecord; @@ -77,7 +77,7 @@ typedef struct zebra_service *ZebraService; /** \brief Creates a Zebra Service. \param configName name of configuration file - + This function is a simplified version of zebra_start_res. */ YAZ_EXPORT @@ -88,7 +88,7 @@ ZebraService zebra_start(const char *configName \param configName name of configuration file \param def_res default resources \param over_res overriding resources - + This function typically called once in a program. A Zebra Service acts as a factory for Zebra session handles. */ @@ -99,7 +99,7 @@ ZebraService zebra_start_res(const char *configName, /** \brief stops a Zebra service. \param zs service handle - + Frees resources used by the service. */ YAZ_EXPORT @@ -118,10 +118,10 @@ void zebra_filter_info(ZebraService zs, void *cd, /** \brief Creates a Zebra session handle within service. \param zs service handle. \param res resources to be used for the service (NULL for none) - + There should be one handle for each thread doing something - with zebra, be that searching or indexing. In simple apps - one handle is sufficient + with zebra, be that searching or indexing. In simple apps + one handle is sufficient */ YAZ_EXPORT ZebraHandle zebra_open(ZebraService zs, Res res @@ -170,7 +170,7 @@ const char *zebra_get_encoding(ZebraHandle zh); /** \brief Set limit before Zebra does approx hit count \param zh session handle \param approx_limit the limit - + Results will be approximiate if hit count is greater than the limit specified. By default there is a high-limit (no limit). */ @@ -229,7 +229,7 @@ ZEBRA_RES zebra_records_retrieve(ZebraHandle zh, ODR stream, const Odr_oid *input_format, int num_recs, ZebraRetrievalRecord *recs); -/** \brief Deletes one or more resultsets +/** \brief Deletes one or more resultsets \param zh session handle \param function Z_DeleteResultSetRequest_{list,all} \param num_setnames number of result sets @@ -246,7 +246,7 @@ int zebra_deleteResultSet(ZebraHandle zh, int function, \param zh session handle \param setname result set name \param num_terms number of terms returned in this integer - + This function is used in conjunction with zebra_result_set_term_info. If operation was successful, ZEBRA_OK is returned; otherwise ZEBRA_FAIL is returned (typically non-existing setname) @@ -259,12 +259,12 @@ ZEBRA_RES zebra_result_set_term_no(ZebraHandle zh, const char *setname, \param zh session handle \param setname result set name \param no the term we want to know about (0=first, 1=second,..) - \param count the number of occurrences of this term, aka hits (output) + \param count the number of occurrences of this term, aka hits (output) \param approx about hits: 0=exact,1=approx (output) \param termbuf buffer for term string (intput, output) \param termlen size of termbuf (input=max, output=actual length) \param term_ref_id if non-NULL *term_ref_id holds term reference - + Returns information about one search term associated with result set. Use zebra_result_set_term_no to read total number of terms associated with result set. If this function can not return information, @@ -286,7 +286,7 @@ ZEBRA_RES zebra_result_set_term_info(ZebraHandle zh, const char *setname, \param zapt Attribute plus Term (start term) \param attributeset Attributeset for Attribute plus Term \param position input/output position - \param num_entries number of terms requested / returned + \param num_entries number of terms requested / returned \param entries list of resulting terms (ODR allocated) \param is_partial upon return 1=partial, 0=complete \param setname limit scan by this set (NULL means no limit) @@ -304,7 +304,7 @@ YAZ_EXPORT ZEBRA_RES zebra_scan(ZebraHandle zh, ODR stream, \param stream ODR handle for result \param query PQF scan query \param position input/output position - \param num_entries number of terms requested / returned + \param num_entries number of terms requested / returned \param entries list of resulting terms (ODR allocated) \param is_partial upon return 1=partial, 0=complete \param setname limit scan by this set (NULL means no limit) @@ -333,7 +333,7 @@ ZEBRA_RES zebra_auth(ZebraHandle zh, const char *user, const char *pass); */ YAZ_EXPORT int zebra_string_norm(ZebraHandle zh, const char *index_type, - const char *input_str, + const char *input_str, int input_len, char *output_str, int output_len); /** \brief Creates a database @@ -363,14 +363,14 @@ YAZ_EXPORT ZEBRA_RES zebra_admin_import_begin(ZebraHandle zh, const char *database, const char *record_type); -YAZ_EXPORT +YAZ_EXPORT ZEBRA_RES zebra_admin_import_segment(ZebraHandle zh, Z_Segment *segment); -YAZ_EXPORT +YAZ_EXPORT ZEBRA_RES zebra_admin_import_end(ZebraHandle zh); -YAZ_EXPORT +YAZ_EXPORT ZEBRA_RES zebra_begin_trans(ZebraHandle zh, int rw ) ZEBRA_GCC_ATTR((warn_unused_result)); @@ -394,17 +394,17 @@ ZEBRA_RES zebra_init(ZebraHandle zh); YAZ_EXPORT ZEBRA_RES zebra_compact(ZebraHandle zh); -YAZ_EXPORT +YAZ_EXPORT ZEBRA_RES zebra_repository_index(ZebraHandle zh, const char *path, enum zebra_recctrl_action_t action); -YAZ_EXPORT +YAZ_EXPORT ZEBRA_RES zebra_repository_update(ZebraHandle zh, const char *path); -YAZ_EXPORT +YAZ_EXPORT ZEBRA_RES zebra_repository_delete(ZebraHandle zh, const char *path); -YAZ_EXPORT +YAZ_EXPORT ZEBRA_RES zebra_repository_show(ZebraHandle zh, const char *path); /** \brief Simple update record @@ -415,9 +415,9 @@ ZEBRA_RES zebra_repository_show(ZebraHandle zh, const char *path); This function is a simple wrapper or zebra_update_record with action=action_update (insert or replace) . */ -YAZ_EXPORT +YAZ_EXPORT ZEBRA_RES zebra_add_record(ZebraHandle zh, const char *buf, int buf_size); - + /** \brief Updates record \param zh session handle \param action (insert,replace,delete or update (replace/insert) @@ -429,24 +429,24 @@ ZEBRA_RES zebra_add_record(ZebraHandle zh, const char *buf, int buf_size); \param buf_size record buffer size */ YAZ_EXPORT -ZEBRA_RES zebra_update_record(ZebraHandle zh, +ZEBRA_RES zebra_update_record(ZebraHandle zh, enum zebra_recctrl_action_t action, const char *recordType, zint *sysno, const char *match, const char *fname, const char *buf, int buf_size); -YAZ_EXPORT +YAZ_EXPORT ZEBRA_RES zebra_sort(ZebraHandle zh, ODR stream, int num_input_setnames, const char **input_setnames, const char *output_setname, Z_SortKeySpecList *sort_sequence, int *sort_status - ) ZEBRA_GCC_ATTR((warn_unused_result)); + ) ZEBRA_GCC_ATTR((warn_unused_result)); YAZ_EXPORT -ZEBRA_RES zebra_select_databases(ZebraHandle zh, int num_bases, +ZEBRA_RES zebra_select_databases(ZebraHandle zh, int num_bases, const char **basenames ) ZEBRA_GCC_ATTR((warn_unused_result)); @@ -470,7 +470,7 @@ ZEBRA_RES zebra_octet_term_encoding(ZebraHandle zh, const char *encoding); YAZ_EXPORT void zebra_set_resource(ZebraHandle zh, const char *name, const char *value); YAZ_EXPORT -const char *zebra_get_resource(ZebraHandle zh, +const char *zebra_get_resource(ZebraHandle zh, const char *name, const char *defaultvalue); @@ -492,28 +492,28 @@ ZebraMetaRecord *zebra_meta_records_create(ZebraHandle zh, YAZ_EXPORT ZebraMetaRecord *zebra_meta_records_create_range(ZebraHandle zh, - const char *name, + const char *name, zint start, int num); YAZ_EXPORT void zebra_meta_records_destroy(ZebraHandle zh, ZebraMetaRecord *records, int num); -YAZ_EXPORT +YAZ_EXPORT struct BFiles_struct *zebra_get_bfs(ZebraHandle zh); YAZ_EXPORT ZEBRA_RES zebra_set_limit(ZebraHandle zh, int complement_flag, zint *ids); YAZ_EXPORT -ZEBRA_RES zebra_set_break_handler(ZebraHandle zh, +ZEBRA_RES zebra_set_break_handler(ZebraHandle zh, int (*f)(void *client_data), void *client_data); YAZ_EXPORT ZEBRA_RES zebra_register_check(ZebraHandle zh, const char *spec); -YAZ_END_CDECL +YAZ_END_CDECL /** \mainpage Zebra * @@ -534,7 +534,7 @@ YAZ_END_CDECL * * \section res Resources * - * The resources system (res.h) is a manager of configuration + * The resources system (res.h) is a manager of configuration * resources. The resources can be viewed as a simple database. * Resources can be read from a configurtion file, they can be * read or written by an application. Resources can also be written, @@ -563,7 +563,7 @@ YAZ_END_CDECL * * Zebra has more than one ISAM system. The old and stable ISAM system * is named isamc (see isamc.h). Another version isams is a write-once - * isam system that is quite compact - suitable for CD-ROMs (isams.h). + * isam system that is quite compact - suitable for CD-ROMs (isams.h). * The newest ISAM system, isamb, is implemented as a B-Tree (see isamb.h). * * \section data1 Data-1 diff --git a/include/idzebra/bfile.h b/include/idzebra/bfile.h index bd9f79f..8870563 100644 --- a/include/idzebra/bfile.h +++ b/include/idzebra/bfile.h @@ -51,7 +51,7 @@ BFiles bfs_create (const char *spec, const char *base); /** \brief destroys a block files handle \param bfiles block files handle - + The files in the block files collection are not deleted. Only the handle is freed. */ @@ -77,7 +77,7 @@ int bf_close2(BFile bf); \param more_info more information to be stored in file (header) \retval 0 success \retval -1 failure (can never happen as the code is now) -*/ +*/ YAZ_EXPORT int bf_xclose(BFile bf, int version, const char *more_info); @@ -249,7 +249,7 @@ int bfs_register_directory_stat(BFiles bfs, int no, const char **directory, on same platform depending on whether 64-bit is enabled or not. Note that if a shadow area has unlimited size, that is represented as max_bytes = -1. -*/ +*/ YAZ_EXPORT int bfs_shadow_directory_stat(BFiles bfs, int no, const char **directory, double *used_bytes, double *max_bytes); diff --git a/include/idzebra/data1.h b/include/idzebra/data1.h index e70258c..c52eaff 100644 --- a/include/idzebra/data1.h +++ b/include/idzebra/data1.h @@ -48,7 +48,7 @@ YAZ_BEGIN_CDECL struct data1_attset; -typedef struct data1_attset data1_attset; +typedef struct data1_attset data1_attset; typedef struct data1_att data1_att; typedef struct data1_attset_child data1_attset_child; @@ -152,7 +152,7 @@ typedef struct data1_marctab int force_indicator_length; int force_identifier_length; - char leader[24]; /* Fixme! Need linear access to LEADER of MARC record */ + char leader[24]; /* Fixme! Need linear access to LEADER of MARC record */ struct data1_marctab *next; } data1_marctab; @@ -271,9 +271,9 @@ typedef struct data1_xattr { typedef struct data1_node { /* the root of a record (containing global data) */ -#define DATA1N_root 1 +#define DATA1N_root 1 /* a tag */ -#define DATA1N_tag 2 +#define DATA1N_tag 2 /* some data under a leaf tag or variant */ #define DATA1N_data 3 /* variant specification (a triple, actually) */ @@ -291,7 +291,7 @@ typedef struct data1_node struct data1_absyn *absyn; /* abstract syntax for this type */ } root; - struct + struct { char *tag; data1_element *element; @@ -311,7 +311,7 @@ typedef struct data1_node /* binary data inclusion */ #define DATA1I_incbin 2 /* text data */ -#define DATA1I_text 3 +#define DATA1I_text 3 /* numerical data */ #define DATA1I_num 4 /* object identifier */ @@ -359,7 +359,7 @@ YAZ_EXPORT data1_node *data1_read_node(data1_handle dh, const char **buf, YAZ_EXPORT data1_node *data1_read_nodex (data1_handle dh, NMEM m, int (*get_byte)(void *fh), void *fh, WRBUF wrbuf); -YAZ_EXPORT data1_node *data1_read_record(data1_handle dh, +YAZ_EXPORT data1_node *data1_read_record(data1_handle dh, int (*rf)(void *, char *, size_t), void *fh, NMEM m); @@ -369,10 +369,10 @@ YAZ_EXPORT data1_tag *data1_gettagbynum(data1_handle dh, data1_tagset *s, int type, int value); YAZ_EXPORT data1_tagset *data1_empty_tagset (data1_handle dh); -YAZ_EXPORT data1_tagset *data1_read_tagset(data1_handle dh, +YAZ_EXPORT data1_tagset *data1_read_tagset(data1_handle dh, const char *file, int type); -YAZ_EXPORT data1_element *data1_getelementbytagname(data1_handle dh, +YAZ_EXPORT data1_element *data1_getelementbytagname(data1_handle dh, data1_absyn *abs, data1_element *parent, const char *tagname); @@ -399,7 +399,7 @@ YAZ_EXPORT data1_vartype *data1_getvartypeby_absyn(data1_handle dh, char *zclass, char *type); YAZ_EXPORT Z_Espec1 *data1_read_espec1(data1_handle dh, const char *file); YAZ_EXPORT int data1_doespec1(data1_handle dh, data1_node *n, Z_Espec1 *e); -YAZ_EXPORT data1_esetname *data1_getesetbyname(data1_handle dh, +YAZ_EXPORT data1_esetname *data1_getesetbyname(data1_handle dh, data1_absyn *a, const char *name); YAZ_EXPORT data1_element *data1_getelementbyname(data1_handle dh, @@ -408,7 +408,7 @@ YAZ_EXPORT data1_element *data1_getelementbyname(data1_handle dh, YAZ_EXPORT data1_node *data1_mk_node2(data1_handle dh, NMEM m, int type, data1_node *parent); -YAZ_EXPORT data1_node *data1_mk_tag (data1_handle dh, NMEM nmem, +YAZ_EXPORT data1_node *data1_mk_tag (data1_handle dh, NMEM nmem, const char *tag, const char **attr, data1_node *at); YAZ_EXPORT data1_node *data1_mk_tag_n (data1_handle dh, NMEM nmem, @@ -484,7 +484,7 @@ YAZ_EXPORT data1_absyn *data1_get_absyn (data1_handle dh, const char *name, YAZ_EXPORT data1_node *data1_search_tag (data1_handle dh, data1_node *n, const char *tag); -YAZ_EXPORT data1_node *data1_mk_tag_uni (data1_handle dh, NMEM nmem, +YAZ_EXPORT data1_node *data1_mk_tag_uni (data1_handle dh, NMEM nmem, const char *tag, data1_node *at); YAZ_EXPORT data1_attset *data1_get_attset (data1_handle dh, const char *name); YAZ_EXPORT data1_maptab *data1_read_maptab(data1_handle dh, const char *file); @@ -503,7 +503,7 @@ YAZ_EXPORT char *data1_nodetoidsgml(data1_handle dh, data1_node *n, YAZ_EXPORT Z_ExplainRecord *data1_nodetoexplain(data1_handle dh, data1_node *n, int select, ODR o); -YAZ_EXPORT Z_BriefBib *data1_nodetosummary(data1_handle dh, +YAZ_EXPORT Z_BriefBib *data1_nodetosummary(data1_handle dh, data1_node *n, int select, ODR o); YAZ_EXPORT char *data1_nodetosoif(data1_handle dh, data1_node *n, int select, @@ -559,7 +559,7 @@ YAZ_EXPORT data1_node *data1_add_taggeddata (data1_handle dh, data1_node *root, YAZ_EXPORT data1_node *data1_get_root_tag (data1_handle dh, data1_node *n); YAZ_EXPORT int data1_iconv (data1_handle dh, NMEM m, data1_node *n, - const char *tocode, + const char *tocode, const char *fromcode); YAZ_EXPORT const char *data1_get_encoding (data1_handle dh, data1_node *n); diff --git a/include/idzebra/dict.h b/include/idzebra/dict.h index 9b6f9d4..c7dd8ef 100644 --- a/include/idzebra/dict.h +++ b/include/idzebra/dict.h @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA /** \file dict.h \brief Zebra dictionary - + The dictionary is a hash that maps a string to a value. The value is opaque and is defined as a sequence of bytes with a length in the range 0 to 255. @@ -49,7 +49,7 @@ typedef struct Dict_struct *Dict; \param page_size page size of disc block \returns dictionary handle */ -YAZ_EXPORT +YAZ_EXPORT Dict dict_open(BFiles bfs, const char *name, int cache, int rw, int compact_flag, int page_size); @@ -116,7 +116,7 @@ int dict_delete_subtree(Dict dict, const char *p, void *client, \param f function be called for each match (NULL for no call of f) \retval 0 OK \retval -1 error - + Function f is called for each item matched. */ YAZ_EXPORT @@ -133,9 +133,9 @@ int dict_lookup_ec(Dict dict, char *p, int range, int (*f)(char *name)); \retval 0 Operation complete. Function f returned zero value always \retval >0 Operation incomplete. Function f returned a non-zero value \retval -1 error (such as bad regular expression) - + The function f is called for each match. If function f returns - non-zero value the grep operation is stopped and the returned + non-zero value the grep operation is stopped and the returned non-zero value is also returned by dict_lookup_ec. */ YAZ_EXPORT @@ -158,7 +158,7 @@ int dict_lookup_grep(Dict dict, const char *p, int range, void *client, the scan operation is cancelled. */ YAZ_EXPORT -int dict_scan(Dict dict, char *str, +int dict_scan(Dict dict, char *str, int *before, int *after, void *client, int (*f)(char *name, const char *info, int pos, void *client)); @@ -167,11 +167,11 @@ int dict_scan(Dict dict, char *str, \param dict dictionary handle \param vp client data to be passed to cmap function handler \param cmap function be called for each character - + This function must be called prior to using dict_grep_lookup. If vp is NULL, no character mapping takes place for dict_lookup_grep. */ -YAZ_EXPORT +YAZ_EXPORT void dict_grep_cmap(Dict dict, void *vp, const char **(*cmap)(void *vp, const char **from, int len)); @@ -190,21 +190,21 @@ int dict_copy_compact(BFiles bfs, const char *from, const char *to); YAZ_EXPORT void dict_clean(Dict dict); -/** \brief get number of lookup operations, since dict_open +/** \brief get number of lookup operations, since dict_open \param dict dictionary handle \returns number of operatons */ YAZ_EXPORT zint dict_get_no_lookup(Dict dict); -/** \brief get number of insert operations, since dict_open +/** \brief get number of insert operations, since dict_open \param dict dictionary handle \returns number of operatons */ YAZ_EXPORT zint dict_get_no_insert(Dict dict); -/** \brief get number of page split operations, since dict_open +/** \brief get number of page split operations, since dict_open \param dict dictionary handle \returns number of operatons */ @@ -212,7 +212,7 @@ YAZ_EXPORT zint dict_get_no_split(Dict dict); YAZ_END_CDECL - + #endif /* * Local variables: diff --git a/include/idzebra/flock.h b/include/idzebra/flock.h index 132d1ef..7614156 100644 --- a/include/idzebra/flock.h +++ b/include/idzebra/flock.h @@ -42,7 +42,7 @@ int zebra_lock_w (ZebraLockHandle h); YAZ_EXPORT int zebra_lock_r (ZebraLockHandle h); -YAZ_EXPORT +YAZ_EXPORT void zebra_flock_init(void); YAZ_END_CDECL diff --git a/include/idzebra/isam.h b/include/idzebra/isam.h index f59cd53..043b770 100644 --- a/include/idzebra/isam.h +++ b/include/idzebra/isam.h @@ -20,33 +20,33 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA /** isam.h - a generalized interface to the isam systems -The isam system consists of a number of isam lists. Physically it is -stored in a file, or a group of related files. It is typically used -for storing all the occurrences of a given word, storing the document -number and position for each occurrence. +The isam system consists of a number of isam lists. Physically it is +stored in a file, or a group of related files. It is typically used +for storing all the occurrences of a given word, storing the document +number and position for each occurrence. An isam list is indentified by an isam_position. This is a number (zint). It can be seen as a mapping from an isam_position to an ordered list of isam_ entries. -An isam list consists of one or more isam entries. We do not know the +An isam list consists of one or more isam entries. We do not know the structure of those entries, but we know the (maximum) size of such, and that they can be memcpy'ed around. -The entries can be seen to consist of a key and a value, although we +The entries can be seen to consist of a key and a value, although we have no idea of their internal structure. We know that we have a compare -function that can look at a part (or whole) of the isam entry (the 'key'). -The part not looked at (if any) will count as 'value' or 'payload'. +function that can look at a part (or whole) of the isam entry (the 'key'). +The part not looked at (if any) will count as 'value' or 'payload'. The entries are stored in increasing order (as defined by the compare function), and no duplicates are allowed. -There is an effective mass-insert routine that takes a stream of values, +There is an effective mass-insert routine that takes a stream of values, each accompanied by an insert/delete flag. -For reading we have cursors, that can read through an isam list in order. +For reading we have cursors, that can read through an isam list in order. They have a fast-forward function to skip values we are not interested in. - + */ @@ -64,25 +64,25 @@ extern "C" { * key_control contains all there is to know about the keys (entries) stored * in an isam, (and therefore operated by the rsets). Other than this info, * all we assume is that all keys are the same size, and they can be - * memcpy'd around. + * memcpy'd around. */ struct key_control { /** (max) size of a key */ int key_size; - /** Default for what level we operate on (book/chapter/verse). - * for typical zebra, this is always 2 (sysno/seqno). Not used in + /** Default for what level we operate on (book/chapter/verse). + * for typical zebra, this is always 2 (sysno/seqno). Not used in * isam context, but the rsets make use of this. */ - int scope; + int scope; - /** Compare function, returning -1,0,1, if p1 is less/equal/greater + /** Compare function, returning -1,0,1, if p1 is less/equal/greater * than p2 */ int (*cmp) (const void *p1, const void *p2); /** Debug function to write a key in the log, with a message */ void (*key_logdump_txt) (int logmask, const void *p, const char *txt); - /** Return the sequence number of a key, to see if we are on the same + /** Return the sequence number of a key, to see if we are on the same * record. FIXME - this makes less sense with higher-scope keys. */ zint (*getseq)(const void *p); @@ -96,7 +96,7 @@ const KEY_CONTROL *default_key_control(); /* FIXME - in zrpn.c, time being. Needs to be moved out */ -/** isam_data_stream is a callback function for the mass-insert (merge) +/** isam_data_stream is a callback function for the mass-insert (merge) * it provides another item to insert/delete, in proper order */ struct isam_data_stream { int (*read_item)(void *clientData, char **dst, int *insertMode); @@ -120,7 +120,7 @@ struct isam_conrol { /** text description of the type, for debugging */ char *desc; /** default filename, if none given to isam_open */ - const char *def_filename; + const char *def_filename; /* there is an isam_open function, but it is not part of this */ /* dynamic table, as it is what provides this table */ @@ -128,7 +128,7 @@ struct isam_conrol { /** close the isam system */ void (*f_close)(ISAM i); - /** Insert an entry into the isam identified by pos. If pos==0, + /** Insert an entry into the isam identified by pos. If pos==0, * create a new isam list */ ISAM_POS (*f_put)(ISAM is, ISAM_POS pos, const void *buf); @@ -136,15 +136,15 @@ struct isam_conrol { * do nothing, and return 0*/ int (*f_del)(ISAM is, ISAM_POS pos, const void *buf); - /** Find an entry in the isam list. return 0 if not found. buf must + /** Find an entry in the isam list. return 0 if not found. buf must * contain enough to identify the item, and will be overwritten by it */ int (*f_get)(ISAM is, ISAM_POS pos, void *buf ); /** Mass-insert data from incoming stream into the isam */ - ISAM_POS (*f_merge)(ISAM is, ISAM_POS pos, ISAM_DATA_STREAM *data); + ISAM_POS (*f_merge)(ISAM is, ISAM_POS pos, ISAM_DATA_STREAM *data); /** Open a cursor to the isam list identified by pos */ - ISAM_CUR (*f_cur_open)(ISAM is, ISAM_POS pos); + ISAM_CUR (*f_cur_open)(ISAM is, ISAM_POS pos); /** Read an item at the cursor (and forward to next). return 0 at eof */ int (*f_read)(ISAM_CUR cur, void *buf); @@ -160,7 +160,7 @@ struct isam_conrol { /** Delete the isam list from the isam system.*/ int (*f_unlink)(ISAM is, ISAM_POS pos); - + }; /** ISAM_s is the generic isam structure */ @@ -180,7 +180,7 @@ struct ISAM_CUR { /** Open the isam system */ -ISAM isam_open (BFiles bfs, +ISAM isam_open (BFiles bfs, const char *isamtype, /* usually "b" */ const char *filename, /* optional, use default from control ?? */ int flags, /* FIXME - define read/write, and some special ones */ diff --git a/include/idzebra/isamb.h b/include/idzebra/isamb.h index 7825f9b..5c8743e 100644 --- a/include/idzebra/isamb.h +++ b/include/idzebra/isamb.h @@ -39,7 +39,7 @@ ISAMB isamb_open2(BFiles bfs, const char *name, int writeflag, ISAMC_M *method, YAZ_EXPORT void isamb_close(ISAMB isamb); -YAZ_EXPORT +YAZ_EXPORT void isamb_merge(ISAMB b, ISAM_P *pos, ISAMC_I *data); YAZ_EXPORT diff --git a/include/idzebra/recctrl.h b/include/idzebra/recctrl.h index e8f88c3..c916d75 100644 --- a/include/idzebra/recctrl.h +++ b/include/idzebra/recctrl.h @@ -68,15 +68,15 @@ typedef struct { /** \brief record reader stream */ struct ZebraRecStream { /** client data */ - void *fh; + void *fh; /** \brief read function */ int (*readf)(struct ZebraRecStream *s, char *buf, size_t count); /** \brief seek function */ off_t (*seekf)(struct ZebraRecStream *s, off_t offset); /** \brief tell function */ - off_t (*tellf)(struct ZebraRecStream *s); + off_t (*tellf)(struct ZebraRecStream *s); /** \brief set and get of record position */ - off_t (*endf)(struct ZebraRecStream *s, off_t *offset); + off_t (*endf)(struct ZebraRecStream *s, off_t *offset); /** \brief close and destroy stream */ void (*destroy)(struct ZebraRecStream *s); }; @@ -127,14 +127,14 @@ struct recRetrieveCtrl { int recordSize; /* size of record in bytes */ char *fname; /* name of file (or NULL if internal) */ data1_handle dh; - + /* response */ const Odr_oid * output_format; /* output format OID */ void * rec_buf; int rec_len; int diagnostic; char * addinfo; - + /* special fetch to be included in retrieved response (say snippets) */ void *handle; int (*special_fetch)(void *handle, const char *esn, diff --git a/include/rset.h b/include/rset.h index f6d4bc1..82b2fcd 100644 --- a/include/rset.h +++ b/include/rset.h @@ -23,9 +23,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include /* unfortunately we need the isam includes here, for the arguments for */ /* rsisamX_create */ -#include -#include -#include +#include +#include +#include YAZ_BEGIN_CDECL @@ -42,8 +42,8 @@ struct ord_list *ord_list_append(NMEM nmem, struct ord_list *list, int ord); struct ord_list *ord_list_dup(NMEM nmem, struct ord_list *list); void ord_list_print(struct ord_list *list); -/** - * rset_term is all we need to know of a term to do ranking etc. +/** + * rset_term is all we need to know of a term to do ranking etc. * As far as the rsets are concerned, it is just a dummy pointer to * be passed around. */ @@ -64,7 +64,7 @@ struct rset_term { struct ord_list *ol; }; -typedef struct rset_term *TERMID; +typedef struct rset_term *TERMID; TERMID rset_term_create (const char *name, int length, const char *flags, int type, NMEM nmem, struct ord_list *ol, int reg_type, zint hits_limit, const char *ref_id); @@ -79,7 +79,7 @@ struct rsfd { /* the stuff common to all rsfd's. */ }; -/** +/** * rset_control has function pointers to all the important functions * of a rset. Each type of rset will have its own control block, pointing * to the functions for that type. They all have their own create function @@ -89,7 +89,7 @@ struct rsfd { /* the stuff common to all rsfd's. */ struct rset_control { /** text description of set type (for debugging) */ - char *desc; + char *desc; /* RSET rs_something_create(const struct rset_control *sel, ...); */ void (*f_delete)(RSET ct); @@ -118,7 +118,7 @@ int rset_default_read(RSFD rfd, void *buf, TERMID *term); void rset_get_one_term(RSET ct,TERMID *terms,int maxterms,int *curterm); /** - * key_control contains all there is to know about the keys stored in + * key_control contains all there is to know about the keys stored in * an isam, and therefore operated by the rsets. Other than this info, * all we assume is that all keys are the same size, and they can be * memcpy'd around @@ -163,9 +163,9 @@ typedef struct rset zint hits_limit; zint hits_count; zint hits_round; - int hits_approx; + int hits_approx; } rset; -/* rset is a "virtual base class", which will never exist on its own +/* rset is a "virtual base class", which will never exist on its own * all instances are rsets of some specific type, like rsisamb, or rsbool * They keep their own stuff behind the priv pointer. */ @@ -175,8 +175,8 @@ typedef struct rset * In more complex isams we can specify on what level we wish to do the * matching and counting of hits. For example, we can have book / chapter / * verse, and a seqno. Scope 2 means then "give me all verses that match", - * 3 would be chapters, 4 books. - * The resolution tells how much of the occurences we need to return. If we + * 3 would be chapters, 4 books. + * The resolution tells how much of the occurences we need to return. If we * are doing some sort of proximity, we need to get the seqnos of all * occurences, whereas if we are only counting hits, we do not need anything * below the scope. Again 1 is seqnos, 2 sysnos (or verses), 3 books, etc. @@ -185,7 +185,7 @@ typedef struct rset RSFD rfd_create_base(RSET rs); int rfd_is_last(RSFD rfd); -RSET rset_create_base(const struct rset_control *sel, +RSET rset_create_base(const struct rset_control *sel, NMEM nmem, struct rset_key_control *kcontrol, int scope, @@ -234,7 +234,7 @@ RSET rset_create_not(NMEM nmem, struct rset_key_control *kcontrol, int scope, RSET rset_l, RSET rset_r); RSET rset_create_between(NMEM nmem, struct rset_key_control *kcontrol, - int scope, RSET rset_l, RSET rset_m, RSET rset_r, + int scope, RSET rset_l, RSET rset_m, RSET rset_r, RSET rset_attr); RSET rset_create_or(NMEM nmem, struct rset_key_control *kcontrol, diff --git a/index/attribute.c b/index/attribute.c index 785ff8a..477e2ae 100644 --- a/index/attribute.c +++ b/index/attribute.c @@ -89,7 +89,7 @@ ZEBRA_RES zebra_attr_list_get_ord(ZebraHandle zh, { /* we have a use attribute and attribute set */ int r; - + r = att_getentbyatt(zh, curAttributeSet, use_value, &use_string); if (r == -2) { @@ -107,12 +107,12 @@ ZEBRA_RES zebra_attr_list_get_ord(ZebraHandle zh, zebra_setError(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, 0); return ZEBRA_FAIL; } - *ord = zebraExplain_lookup_attr_str(zh->reg->zei, cat, + *ord = zebraExplain_lookup_attr_str(zh->reg->zei, cat, index_type, use_string); if (*ord == -1) { - /* attribute 14=1 does not issue a diagnostic even - 1) the attribute is numeric but listed in .att + /* attribute 14=1 does not issue a diagnostic even + 1) the attribute is numeric but listed in .att 2) the use attribute is string */ AttrType unsup; @@ -149,7 +149,7 @@ ZEBRA_RES zebra_apt_get_ord(ZebraHandle zh, if (relation_value == 103) /* always matches */ cat = zinfo_index_category_alwaysmatches; - + if (!xpath_use) { res = zebra_attr_list_get_ord(zh, zapt->attributes, @@ -158,10 +158,10 @@ ZEBRA_RES zebra_apt_get_ord(ZebraHandle zh, /* use attribute not found. But it the relation is always matches and the regulare index attribute is found return a different diagnostic */ - if (res != ZEBRA_OK && + if (res != ZEBRA_OK && relation_value == 103 && zebra_attr_list_get_ord( - zh, zapt->attributes, + zh, zapt->attributes, zinfo_index_category_index, index_type, curAttributeSet, ord) == ZEBRA_OK) zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_RELATION_ATTRIBUTE, 103); @@ -181,7 +181,7 @@ ZEBRA_RES zebra_apt_get_ord(ZebraHandle zh, { yaz_log(YLOG_LOG, "zebra_apt_get_ord OK xpath=%s index_type=%s", xpath_use, index_type); - + } } return res; diff --git a/index/check_res.c b/index/check_res.c index f5315a0..337e216 100644 --- a/index/check_res.c +++ b/index/check_res.c @@ -31,7 +31,7 @@ int zebra_check_res(Res res) { int errors = 0; Res v = res_open(0, 0); - + res_add(v, "attset", ""); res_add(v, "chdir", ""); res_add(v, "dbaccess", ""); @@ -74,9 +74,9 @@ int zebra_check_res(Res res) res_add(v, "openRW", "p"); res_add(v, "facetNumRecs", ""); res_add(v, "facetMaxChunks", ""); - + errors = res_check(res, v); - + res_close(v); return errors; } diff --git a/index/dir.c b/index/dir.c index c3c0f62..965ec8c 100644 --- a/index/dir.c +++ b/index/dir.c @@ -140,7 +140,7 @@ void dir_sort(struct dir_entry *e) size_t nmemb = 0; while (e[nmemb].name) nmemb++; - qsort(e, nmemb, sizeof(*e), dir_cmp); + qsort(e, nmemb, sizeof(*e), dir_cmp); } void dir_free(struct dir_entry **e_p) diff --git a/index/dirs.c b/index/dirs.c index 674fb91..58eb522 100644 --- a/index/dirs.c +++ b/index/dirs.c @@ -62,13 +62,13 @@ static int dirs_client_proc(char *name, const char *info, int pos, entry = ci->entries + ci->no_cur; if (info[0] == sizeof(entry->sysno)+sizeof(entry->mtime)) { - strcpy(entry->path, name + ci->prelen); + strcpy(entry->path, name + ci->prelen); entry->kind = dirs_file; memcpy(&entry->sysno, info+1, sizeof(entry->sysno)); - memcpy(&entry->mtime, info+1+sizeof(entry->sysno), + memcpy(&entry->mtime, info+1+sizeof(entry->sysno), sizeof(entry->mtime)); ci->no_cur++; - } + } else if (info[0] == sizeof(entry->mtime)) { strcpy(entry->path, name + ci->prelen); @@ -120,10 +120,10 @@ struct dirs_info *dirs_fopen(Dict dict, const char *path, int rw) info = dict_lookup(dict, path); if (info && info[0] == sizeof(entry->sysno)+sizeof(entry->mtime)) { - strcpy(entry->path, path); + strcpy(entry->path, path); entry->kind = dirs_file; memcpy(&entry->sysno, info+1, sizeof(entry->sysno)); - memcpy(&entry->mtime, info+1+sizeof(entry->sysno), + memcpy(&entry->mtime, info+1+sizeof(entry->sysno), sizeof(entry->mtime)); p->no_cur++; } diff --git a/index/extract.c b/index/extract.c index a93373c..cbd4973 100644 --- a/index/extract.c +++ b/index/extract.c @@ -110,8 +110,8 @@ static void logRecord(ZebraHandle zh) if (!(zh->records_processed % 1000)) { yaz_log(YLOG_LOG, "Records: "ZINT_FORMAT" i/u/d " - ZINT_FORMAT"/"ZINT_FORMAT"/"ZINT_FORMAT, - zh->records_processed, zh->records_inserted, + ZINT_FORMAT"/"ZINT_FORMAT"/"ZINT_FORMAT, + zh->records_processed, zh->records_inserted, zh->records_updated, zh->records_deleted); } } @@ -122,7 +122,7 @@ static void init_extractCtrl(ZebraHandle zh, struct recExtractCtrl *ctrl) } -static void extract_add_index_string(RecWord *p, +static void extract_add_index_string(RecWord *p, zinfo_index_category_t cat, const char *str, int length); @@ -203,7 +203,7 @@ static void snippet_add_incomplete_field(RecWord *p, int ord, zebra_map_t zm) return ; if (first) - { + { first = 0; if (zebra_maps_is_first_in_field(zm)) { @@ -287,14 +287,14 @@ void extract_snippet(ZebraHandle zh, zebra_snippets *sn, assert(zh->reg->dh); extractCtrl.dh = zh->reg->dh; - + info.zh = zh; info.snippets = sn; extractCtrl.handle = &info; extractCtrl.match_criteria[0] = '\0'; extractCtrl.staticrank = 0; extractCtrl.action = action_insert; - + init_extractCtrl(zh, &extractCtrl); extractCtrl.setStoreData = 0; @@ -336,11 +336,11 @@ static void searchRecordKey(ZebraHandle zh, assert(key.len <= IT_KEY_LEVEL_MAX && key.len > 2); seqno = key.mem[key.len-1]; - + if (key.mem[0] == ch) { zint woff; - + if (startSeq == -1) startSeq = seqno; woff = seqno - startSeq; @@ -373,15 +373,15 @@ static char *get_match_from_spec(ZebraHandle zh, char attset_str[64], attname_str[64]; int i; int first = 1; - + for (s++; strchr(FILE_MATCH_BLANK, *s); s++) ; - for (i = 0; *s && *s != ',' && *s != ')' && + for (i = 0; *s && *s != ',' && *s != ')' && !strchr(FILE_MATCH_BLANK, *s); s++) if (i+1 < sizeof(attset_str)) attset_str[i++] = *s; attset_str[i] = '\0'; - + for (; strchr(FILE_MATCH_BLANK, *s); s++) ; if (*s != ',') @@ -390,7 +390,7 @@ static char *get_match_from_spec(ZebraHandle zh, { for (s++; strchr(FILE_MATCH_BLANK, *s); s++) ; - for (i = 0; *s && *s != ')' && + for (i = 0; *s && *s != ')' && !strchr(FILE_MATCH_BLANK, *s); s++) if (i+1 < sizeof(attname_str)) attname_str[i++] = *s; @@ -406,7 +406,7 @@ static char *get_match_from_spec(ZebraHandle zh, searchRecordKey(zh, reckeys, attname_str, ws, 32); if (0) /* for debugging */ - { + { for (i = 0; i<32; i++) { if (ws[i]) @@ -461,7 +461,7 @@ static char *get_match_from_spec(ZebraHandle zh, } else if (!strcmp(special, "type")) spec_src = zh->m_record_type; - else + else spec_src = NULL; if (spec_src) { @@ -522,7 +522,7 @@ struct recordLogInfo { \param ctrl record control \param record_id custom record ID \param sysno system record ID - + This function serves two purposes.. It adds the always matches entry and makes a pointer from the custom record ID (if defined) back to the system record ID (sysno) @@ -546,7 +546,7 @@ static void all_matches_add(struct recExtractCtrl *ctrl, zint record_id, } /* forward declaration */ -ZEBRA_RES zebra_extract_records_stream(ZebraHandle zh, +ZEBRA_RES zebra_extract_records_stream(ZebraHandle zh, struct ZebraRecStream *stream, enum zebra_recctrl_action_t action, const char *recordType, @@ -557,7 +557,7 @@ ZEBRA_RES zebra_extract_records_stream(ZebraHandle zh, void *recTypeClientData); -ZEBRA_RES zebra_extract_file(ZebraHandle zh, zint *sysno, const char *fname, +ZEBRA_RES zebra_extract_file(ZebraHandle zh, zint *sysno, const char *fname, enum zebra_recctrl_action_t action) { ZEBRA_RES r = ZEBRA_OK; @@ -576,7 +576,7 @@ ZEBRA_RES zebra_extract_file(ZebraHandle zh, zint *sysno, const char *fname, *gprefix = '\0'; else sprintf(gprefix, "%s.", zh->m_group); - + yaz_log(log_level_extract, "zebra_extract_file %s", fname); /* determine file extension */ @@ -643,7 +643,7 @@ ZEBRA_RES zebra_extract_file(ZebraHandle zh, zint *sysno, const char *fname, } else strcpy(full_rep, fname); - + if ((fd = open(full_rep, O_BINARY|O_RDONLY)) == -1) { yaz_log(YLOG_WARN|YLOG_ERRNO, "open %s", full_rep); @@ -670,10 +670,10 @@ ZEBRA_RES zebra_extract_file(ZebraHandle zh, zint *sysno, const char *fname, If sysno is provided, then it's used to identify the reocord. If not, and match_criteria is provided, then sysno is guessed If not, and a record is provided, then sysno is got from there - + */ -ZEBRA_RES zebra_buffer_extract_record(ZebraHandle zh, +ZEBRA_RES zebra_buffer_extract_record(ZebraHandle zh, const char *buf, size_t buf_size, enum zebra_recctrl_action_t action, const char *recordType, @@ -692,7 +692,7 @@ ZEBRA_RES zebra_buffer_extract_record(ZebraHandle zh, "Record type explicitly specified: %s", recordType); recType = recType_byName(zh->reg->recTypes, zh->res, recordType, &clientData); - } + } else { if (!(zh->m_record_type)) @@ -706,7 +706,7 @@ ZEBRA_RES zebra_buffer_extract_record(ZebraHandle zh, zh->m_record_type, &clientData); recordType = zh->m_record_type; } - + if (!recType) { yaz_log(YLOG_WARN, "No such record type: %s", recordType); @@ -726,7 +726,7 @@ ZEBRA_RES zebra_buffer_extract_record(ZebraHandle zh, return res; } -static ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, +static ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, struct ZebraRecStream *stream, enum zebra_recctrl_action_t action, const char *recordType, @@ -736,7 +736,7 @@ static ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, RecType recType, void *recTypeClientData, int *more) - + { zint sysno0 = 0; RecordAttr *recordAttr; @@ -746,7 +746,7 @@ static ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, Record rec; off_t start_offset = 0, end_offset = 0; const char *pr_fname = fname; /* filename to print .. */ - int show_progress = zh->records_processed + zh->records_skipped + int show_progress = zh->records_processed + zh->records_skipped < zh->m_file_verbose_limit ? 1:0; zebra_init_log_level(); @@ -759,7 +759,7 @@ static ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, if (zebraExplain_curDatabase(zh->reg->zei, zh->basenames[0])) { - if (zebraExplain_newDatabase(zh->reg->zei, zh->basenames[0], + if (zebraExplain_newDatabase(zh->reg->zei, zh->basenames[0], zh->m_explain_database)) return ZEBRA_FAIL; } @@ -772,7 +772,7 @@ static ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, start_offset = stream->tellf(stream); extractCtrl.first_record = start_offset ? 0 : 1; - + stream->endf(stream, &null_offset);; extractCtrl.init = extract_init; @@ -787,14 +787,14 @@ static ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, init_extractCtrl(zh, &extractCtrl); extract_set_store_data_prepare(&extractCtrl); - + r = (*recType->extract)(recTypeClientData, &extractCtrl); if (action == action_update) { action = extractCtrl.action; } - + switch (r) { case RECCTRL_EXTRACT_EOF: @@ -812,7 +812,7 @@ static ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, yaz_log(YLOG_LOG, "skip %s %s " ZINT_FORMAT, recordType, pr_fname, (zint) start_offset); *more = 1; - + end_offset = stream->endf(stream, 0); if (end_offset) stream->seekf(stream, end_offset); @@ -843,18 +843,18 @@ static ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, /* test mode .. Do not perform match */ return ZEBRA_OK; } - + if (!sysno) { sysno = &sysno0; - + if (match_criteria && *match_criteria) matchStr = match_criteria; else { if (zh->m_record_id && *zh->m_record_id) { - matchStr = get_match_from_spec(zh, zh->reg->keys, pr_fname, + matchStr = get_match_from_spec(zh, zh->reg->keys, pr_fname, zh->m_record_id); if (!matchStr) { @@ -875,13 +875,13 @@ static ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, } } } - if (matchStr) + if (matchStr) { int db_ord = zebraExplain_get_database_ord(zh->reg->zei); char *rinfo = dict_lookup_ord(zh->reg->matchDict, db_ord, matchStr); - + if (log_level_extract) { WRBUF w = wrbuf_hex_str(matchStr); @@ -961,7 +961,7 @@ static ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, #endif recordAttr->staticrank = extractCtrl.staticrank; zh->records_inserted++; - } + } else { /* record already exists */ @@ -969,7 +969,7 @@ static ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, zebra_rec_keys_t sortKeys = zebra_rec_keys_open(); if (action == action_insert) { - yaz_log(YLOG_LOG, "skipped %s %s " ZINT_FORMAT, + yaz_log(YLOG_LOG, "skipped %s %s " ZINT_FORMAT, recordType, pr_fname, (zint) start_offset); logRecord(zh); return ZEBRA_FAIL; @@ -984,7 +984,7 @@ static ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, zebra_rec_keys_get_custom_record_id(zh->reg->keys), *sysno); } - + recordAttr = rec_init_attr(zh->reg->zei, rec); /* decrease total size */ @@ -1011,7 +1011,7 @@ static ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, #if FLUSH2 extract_flush_record_keys2(zh, *sysno, 0, recordAttr->staticrank, delkeys, recordAttr->staticrank); -#endif +#endif if (zebra_rec_keys_empty(delkeys)) { yaz_log(YLOG_LOG, "delete %s %s " ZINT_FORMAT, recordType, @@ -1050,7 +1050,7 @@ static ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, zh->reg->keys, extractCtrl.staticrank, delkeys, recordAttr->staticrank); #else - extract_flush_record_keys(zh, *sysno, 1, + extract_flush_record_keys(zh, *sysno, 1, zh->reg->keys, extractCtrl.staticrank); #endif recordAttr->staticrank = extractCtrl.staticrank; @@ -1131,11 +1131,11 @@ static ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, /* update database name */ xfree(rec->info[recInfo_databaseName]); rec->info[recInfo_databaseName] = - rec_strdup(zh->basenames[0], &rec->size[recInfo_databaseName]); + rec_strdup(zh->basenames[0], &rec->size[recInfo_databaseName]); /* update offset */ recordAttr->recordOffset = start_offset; - + /* commit this record */ rec_put(zh->reg->records, &rec); logRecord(zh); @@ -1154,7 +1154,7 @@ static ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh, \param recTypeClientData client data for record type \returns ZEBRA_OK for success; ZEBRA_FAIL for failure */ -ZEBRA_RES zebra_extract_records_stream(ZebraHandle zh, +ZEBRA_RES zebra_extract_records_stream(ZebraHandle zh, struct ZebraRecStream *stream, enum zebra_recctrl_action_t action, const char *recordType, @@ -1219,7 +1219,7 @@ ZEBRA_RES zebra_extract_explain(void *handle, Record rec, data1_node *n) extractCtrl.handle = handle; extractCtrl.first_record = 1; - + extract_set_store_data_prepare(&extractCtrl); if (n) @@ -1228,14 +1228,14 @@ ZEBRA_RES zebra_extract_explain(void *handle, Record rec, data1_node *n) if (rec->size[recInfo_delKeys]) { zebra_rec_keys_t delkeys = zebra_rec_keys_open(); - + zebra_rec_keys_t sortkeys = zebra_rec_keys_open(); zebra_rec_keys_set_buf(delkeys, rec->info[recInfo_delKeys], rec->size[recInfo_delKeys], 0); #if FLUSH2 - extract_flush_record_keys2(zh, rec->sysno, + extract_flush_record_keys2(zh, rec->sysno, zh->reg->keys, 0, delkeys, 0); #else extract_flush_record_keys(zh, rec->sysno, 0, delkeys, 0); @@ -1255,14 +1255,14 @@ ZEBRA_RES zebra_extract_explain(void *handle, Record rec, data1_node *n) #if FLUSH2 extract_flush_record_keys2(zh, rec->sysno, zh->reg->keys, 0, 0, 0); #else - extract_flush_record_keys(zh, rec->sysno, 1, zh->reg->keys, 0); + extract_flush_record_keys(zh, rec->sysno, 1, zh->reg->keys, 0); #endif } extract_flush_sort_keys(zh, rec->sysno, 1, zh->reg->sortKeys); - + xfree(rec->info[recInfo_delKeys]); zebra_rec_keys_get_buf(zh->reg->keys, - &rec->info[recInfo_delKeys], + &rec->info[recInfo_delKeys], &rec->size[recInfo_delKeys]); xfree(rec->info[recInfo_sortKeys]); @@ -1281,7 +1281,7 @@ void zebra_it_key_str_dump(ZebraHandle zh, struct it_key *key, const char *index_type; int i; const char *string_index; - + zebraExplain_lookup_ord(zh->reg->zei, ord, &index_type, 0/* db */, &string_index); assert(index_type); @@ -1292,14 +1292,14 @@ void zebra_it_key_str_dump(ZebraHandle zh, struct it_key *key, { sprintf(keystr + strlen(keystr), ZINT_FORMAT " ", key->mem[i]); } - + if (*str < CHR_BASE_CHAR) { int i; char dst_buf[200]; /* room for special chars */ - + strcpy(dst_buf , "?"); - + if (!strcmp(str, "")) strcpy(dst_buf, "alwaysmatches"); if (!strcmp(str, FIRST_IN_FIELD_STR)) @@ -1308,14 +1308,14 @@ void zebra_it_key_str_dump(ZebraHandle zh, struct it_key *key, strcpy(dst_buf, "unknown"); else if (!strcmp(str, CHR_SPACE)) strcpy(dst_buf, "space"); - + for (i = 0; ireg->key_block, sysno, + key_block_write(zh->reg->key_block, sysno, &del_key_in, 0, del_str, del_slen, del_rank, zh->m_staticrank); if (ins) - key_block_write(zh->reg->key_block, sysno, + key_block_write(zh->reg->key_block, sysno, &ins_key_in, 1, ins_str, ins_slen, ins_rank, zh->m_staticrank); } @@ -1505,7 +1505,7 @@ static void extract_flush_record_keys( struct it_key key_in; while(zebra_rec_keys_read(reckeys, &str, &slen, &key_in)) { - key_block_write(zh->reg->key_block, sysno, + key_block_write(zh->reg->key_block, sysno, &key_in, cmd, str, slen, staticrank, zh->m_staticrank); } @@ -1518,7 +1518,7 @@ ZEBRA_RES zebra_rec_keys_to_snippets1(ZebraHandle zh, zebra_snippets *snippets) { NMEM nmem = nmem_create(); - if (zebra_rec_keys_rewind(reckeys)) + if (zebra_rec_keys_rewind(reckeys)) { const char *str; size_t slen; @@ -1533,7 +1533,7 @@ ZEBRA_RES zebra_rec_keys_to_snippets1(ZebraHandle zh, assert(key.len <= IT_KEY_LEVEL_MAX && key.len > 2); seqno = key.mem[key.len-1]; ord = CAST_ZINT_TO_INT(key.mem[0]); - + zebraExplain_lookup_ord(zh->reg->zei, ord, &index_type, 0/* db */, 0 /* string_index */); assert(index_type); @@ -1565,13 +1565,13 @@ void print_rec_keys(ZebraHandle zh, zebra_rec_keys_t reckeys) assert(key.len <= IT_KEY_LEVEL_MAX && key.len > 2); zebraExplain_lookup_ord(zh->reg->zei, ord, &index_type, &db, 0); - + seqno = key.mem[key.len-1]; - + zebra_term_untrans(zh, index_type, dst_buf, str); - - yaz_log(YLOG_LOG, "ord=%d seqno=" ZINT_FORMAT - " term=%s", ord, seqno, dst_buf); + + yaz_log(YLOG_LOG, "ord=%d seqno=" ZINT_FORMAT + " term=%s", ord, seqno, dst_buf); } } } @@ -1645,7 +1645,7 @@ static void extract_add_string(RecWord *p, zebra_map_t zm, { WRBUF w = wrbuf_alloc(); - + wrbuf_write_escaped(w, string, length); yaz_log(log_level_details, "extract_add_string: %s", wrbuf_cstr(w)); wrbuf_destroy(w); @@ -1680,7 +1680,7 @@ static void extract_add_incomplete_field(RecWord *p, zebra_map_t zm) int remain = p->term_len; int first = 1; const char **map = 0; - + if (remain > 0) map = zebra_maps_input(zm, &b, remain, 0); @@ -1717,7 +1717,7 @@ static void extract_add_incomplete_field(RecWord *p, zebra_map_t zm) return; if (first) - { + { first = 0; if (zebra_maps_is_first_in_field(zm)) { @@ -1816,13 +1816,13 @@ static void extract_add_icu(RecWord *p, zebra_map_t zm) extract_token_add extract_add_{in}_complete / extract_add_icu extract_add_string - + extract_add_index_string or extract_add_sort_string or extract_add_staticrank_string - + */ static void extract_token_add(RecWord *p) { @@ -1833,7 +1833,7 @@ static void extract_token_add(RecWord *p) { yaz_log(log_level_details, "extract_token_add " "type=%s index=%s seqno=" ZINT_FORMAT " s=%.*s", - p->index_type, p->index_name, + p->index_type, p->index_name, p->seqno, p->term_len, p->term_buf); } if (zebra_maps_is_icu(zm)) @@ -1927,7 +1927,7 @@ void extract_flush_sort_keys(ZebraHandle zh, zint sysno, (*e)->sysno = filter_sysno ? filter_sysno : sysno; (*e)->section_id = section_id; } - + wrbuf_write((*e)->wrbuf, str, slen); wrbuf_putc((*e)->wrbuf, '\0'); } diff --git a/index/index.h b/index/index.h index b78b7be..fe4c42f 100644 --- a/index/index.h +++ b/index/index.h @@ -68,7 +68,7 @@ struct dirs_entry { }; void getFnameTmp(Res res, char *fname, int no); - + struct dirs_info *dirs_open(Dict dict, const char *rep, int rw); struct dirs_info *dirs_fopen(Dict dict, const char *path, int rw); struct dirs_entry *dirs_read(struct dirs_info *p); @@ -125,7 +125,7 @@ typedef struct zebra_rank_class { struct zebra_register { char *name; - + ISAMS isams; ISAMC isamc; ISAMB isamb; @@ -198,7 +198,7 @@ struct zebra_session { int partial_result; #if HAVE_SYS_TIMES_H struct tms tms1; - struct tms tms2; + struct tms tms2; #endif int shadow_enable; @@ -307,7 +307,7 @@ ZEBRA_RES resultSetRank(ZebraHandle zh, ZebraSet zebraSet, RSET rset, void resultSetInvalidate(ZebraHandle zh); int zebra_record_fetch(ZebraHandle zh, const char *setname, - zint sysno, int score, + zint sysno, int score, ODR stream, const Odr_oid *input_format, Z_RecordComposition *comp, const Odr_oid **output_format, char **rec_bufp, @@ -325,7 +325,7 @@ int zebra_get_rec_snippets(ZebraHandle zh, zint sysno, void zebra_index_merge(ZebraHandle zh); -ZEBRA_RES zebra_buffer_extract_record(ZebraHandle zh, +ZEBRA_RES zebra_buffer_extract_record(ZebraHandle zh, const char *buf, size_t buf_size, enum zebra_recctrl_action_t action, const char *recordType, @@ -362,7 +362,7 @@ Dict dict_open_res(BFiles bfs, const char *name, int cache, int rw, void zebra_setError(ZebraHandle zh, int code, const char *addinfo); void zebra_setError_zint(ZebraHandle zh, int code, zint i); -int zebra_term_untrans_iconv(ZebraHandle zh, NMEM stream, +int zebra_term_untrans_iconv(ZebraHandle zh, NMEM stream, const char *index_type, char **dst, const char *src); @@ -422,7 +422,7 @@ ZEBRA_RES zebra_term_limits_APT(ZebraHandle zh, const char **term_ref_id_str, NMEM nmem); -ZEBRA_RES zebra_result_recid_to_sysno(ZebraHandle zh, +ZEBRA_RES zebra_result_recid_to_sysno(ZebraHandle zh, const char *setname, zint recid, zint *sysnos, int *no_sysnos); diff --git a/index/inline.c b/index/inline.c index ace801b..6f70c03 100644 --- a/index/inline.c +++ b/index/inline.c @@ -58,7 +58,7 @@ void inline_destroy_field(inline_field *p) static inline_subfield *inline_mk_subfield(inline_subfield *parent) { inline_subfield *p = (inline_subfield *)xmalloc(sizeof(*p)); - + if (p) { memset(p, 0, sizeof(*p)); @@ -98,10 +98,10 @@ int inline_parse(inline_field *pif, const char *tag, const char *s) { inline_field *pf = pif; char *p = (char *)s; - + if (!pf) return -1; - + if (pf->name[0] == '\0') { if ((sscanf(p, "%3s", pf->name)) != 1) @@ -123,10 +123,10 @@ int inline_parse(inline_field *pif, const char *tag, const char *s) else { inline_subfield *psf = inline_mk_subfield(0); - + sscanf(tag, "%1s", psf->name); psf->data = xstrdup(p); - + if (!pf->list) { pf->list = psf; diff --git a/index/invstat.c b/index/invstat.c index dede37f..1a5db57 100644 --- a/index/invstat.c +++ b/index/invstat.c @@ -42,7 +42,7 @@ struct inv_stat_info { int dumpwords; }; -#define SINGLETON_TYPE 8 /* the type to use for singletons that */ +#define SINGLETON_TYPE 8 /* the type to use for singletons that */ /* have no block and no block type */ static void print_dict_item (ZebraHandle zh, const char *s, zint count, @@ -124,7 +124,7 @@ static int inv_stat_handle (char *name, const char *info, int pos, int level; zint size; zint blocks; - + pp = isamb_pp_open_x(stat_info->zh->reg->isamb, isam_p, &level, 0); while (isamb_pp_read(pp, &key)) @@ -295,7 +295,7 @@ int zebra_register_statistics (ZebraHandle zh, int dumpdict) fprintf (stdout, "%7d- %7d\n", prev, stat_info.isam_occurrences[i]); rec_prstat(zh->reg->records, 0); - xmalloc_trav("unfreed"); /*! while hunting memory leaks */ + xmalloc_trav("unfreed"); /*! while hunting memory leaks */ zebra_end_read (zh); return 0; } diff --git a/index/kcontrol.c b/index/kcontrol.c index 58309a0..ce413f5 100644 --- a/index/kcontrol.c +++ b/index/kcontrol.c @@ -76,7 +76,7 @@ struct rset_key_control *zebra_key_control_create(ZebraHandle zh) kc->get_segment = 0; } - zebra_limit_for_rset(zh->m_limit, + zebra_limit_for_rset(zh->m_limit, &kc->filter_func, &cp->filter_destroy, &kc->filter_data); diff --git a/index/kdump.c b/index/kdump.c index beb91ce..8fa5549 100644 --- a/index/kdump.c +++ b/index/kdump.c @@ -49,7 +49,7 @@ int key_file_decode (FILE *f) int c, d; c = getc (f); - switch (c & 192) + switch (c & 192) { case 0: d = c; @@ -172,7 +172,7 @@ int main (int argc, char **argv) op = key_info[0]; memcpy (&k, 1+key_info, sizeof(k)); - from += 2; + from += 2; while (*from) { const char *res = zebra_maps_output (zm, reg_type, &from); @@ -194,7 +194,7 @@ int main (int argc, char **argv) } exit (0); } -#endif +#endif /* * Local variables: * c-basic-offset: 4 diff --git a/index/key_block.c b/index/key_block.c index d127d55..87c13ce 100644 --- a/index/key_block.c +++ b/index/key_block.c @@ -75,11 +75,11 @@ static void shellsort(void *ar, int r, size_t s, char v[100]; int h, i, j, k; static const int incs[16] = { 1391376, 463792, 198768, 86961, 33936, - 13776, 4592, 1968, 861, 336, + 13776, 4592, 1968, 861, 336, 112, 48, 21, 7, 3, 1 }; for ( k = 0; k < 16; k++) for (h = incs[k], i = h; i < r; i++) - { + { memcpy (v, a+s*i, s); j = i; while (j > h && (*cmp)(a + s*(j-h), v) > 0) @@ -88,7 +88,7 @@ static void shellsort(void *ar, int r, size_t s, j -= h; } memcpy (a+s*j, v, s); - } + } } #endif @@ -105,7 +105,7 @@ static void encode_key_write(const char *k, struct encode_info *i, FILE *outf) char *bp = i->buf, *bp0; const char *src = (char *) &key; size_t klen = strlen(k); - + if (fwrite (k, klen+1, 1, outf) != 1) { yaz_log (YLOG_FATAL|YLOG_ERRNO, "fwrite"); @@ -150,7 +150,7 @@ static void encode_key_write(const char *k, struct encode_info *i, FILE *outf) } static void encode_key_flush (struct encode_info *i, FILE *outf) -{ +{ iscz1_stop(i->encode_handle); iscz1_stop(i->decode_handle); } @@ -165,22 +165,22 @@ static void *thread_func(void *vp) while (1) { pthread_mutex_lock(&p->mutex); - + while (!p->is_sorting && !p->exit_flag) pthread_cond_wait(&p->work_available, &p->mutex); if (p->exit_flag) break; - + pthread_mutex_unlock(&p->mutex); - - key_block_flush_int(p, p->thread_key_buf, + + key_block_flush_int(p, p->thread_key_buf, p->thread_ptr_top, p->thread_ptr_i); - + pthread_mutex_lock(&p->mutex); p->is_sorting = 0; pthread_cond_signal(&p->cond_sorting); - pthread_mutex_unlock(&p->mutex); + pthread_mutex_unlock(&p->mutex); } pthread_mutex_unlock(&p->mutex); return 0; @@ -231,20 +231,20 @@ void key_block_destroy(zebra_key_block_t *pp) { #if YAZ_POSIX_THREADS pthread_mutex_lock(&p->mutex); - + while (p->is_sorting) pthread_cond_wait(&p->cond_sorting, &p->mutex); - + p->exit_flag = 1; - + pthread_cond_broadcast(&p->work_available); - + pthread_mutex_unlock(&p->mutex); pthread_join(p->thread_id, 0); pthread_cond_destroy(&p->work_available); pthread_cond_destroy(&p->cond_sorting); pthread_mutex_destroy(&p->mutex); - + #endif xfree(p->alt_buf); } @@ -269,30 +269,30 @@ void key_block_write(zebra_key_block_t p, zint sysno, struct it_key *key_in, assert(p->ptr_i > 0); (p->key_buf)[p->ptr_top - p->ptr_i] = (char*)p->key_buf + p->key_buf_used; - + /* key_in->mem[0] ord/ch */ /* key_in->mem[1] filter specified record ID */ - + /* encode the ordinal value (field/use/attribute) .. */ ch = CAST_ZINT_TO_INT(key_in->mem[0]); p->key_buf_used += key_SU_encode(ch, (char*)p->key_buf + p->key_buf_used); - + /* copy the 0-terminated stuff from str to output */ memcpy((char*)p->key_buf + p->key_buf_used, str_buf, str_len); p->key_buf_used += str_len; ((char*)p->key_buf)[(p->key_buf_used)++] = '\0'; - + /* the delete/insert indicator */ ((char*)p->key_buf)[(p->key_buf_used)++] = cmd; - + if (static_rank_enable) { assert(staticrank >= 0); key_out.mem[j++] = staticrank; } - + if (key_in->mem[1]) /* filter specified record ID */ key_out.mem[j++] = key_in->mem[1]; else @@ -300,7 +300,7 @@ void key_block_write(zebra_key_block_t p, zint sysno, struct it_key *key_in, for (i = 2; i < key_in->len; i++) key_out.mem[j++] = key_in->mem[i]; key_out.len = j; - + memcpy((char*)p->key_buf + p->key_buf_used, &key_out, sizeof(key_out)); (p->key_buf_used) += sizeof(key_out); @@ -317,7 +317,7 @@ void key_block_flush_int(zebra_key_block_t p, if (ptr_i == 0) return ; - + (p->key_file_no)++; yaz_log(YLOG_DEBUG, "sorting section %d", (p->key_file_no)); @@ -339,10 +339,10 @@ void key_block_flush_int(zebra_key_block_t p, } yaz_log(YLOG_DEBUG, "writing section %d", p->key_file_no); prevcp = cp = (key_buf)[ptr_top - ptr_i]; - + encode_key_init (&encode_info); encode_key_write (cp, &encode_info, outf); - + while (--ptr_i > 0) { cp = (key_buf)[ptr_top - ptr_i]; @@ -374,24 +374,24 @@ void key_block_flush(zebra_key_block_t p, int is_final) { #if YAZ_POSIX_THREADS char **tmp; - + pthread_mutex_lock(&p->mutex); - + while (p->is_sorting) pthread_cond_wait(&p->cond_sorting, &p->mutex); - + p->is_sorting = 1; - + p->thread_ptr_top = p->ptr_top; p->thread_ptr_i = p->ptr_i; p->thread_key_buf = p->key_buf; - + tmp = p->key_buf; p->key_buf = p->alt_buf; p->alt_buf = tmp; - + pthread_cond_signal(&p->work_available); - + if (is_final) { while (p->is_sorting) diff --git a/index/kinput.c b/index/kinput.c index 851c13e..b249c50 100644 --- a/index/kinput.c +++ b/index/kinput.c @@ -16,7 +16,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - + #if HAVE_CONFIG_H #include #endif @@ -69,7 +69,7 @@ static void pkey(const char *b, int mode) void getFnameTmp(Res res, char *fname, int no) { const char *pre; - + pre = res_get_def(res, "keyTmpDir", "."); sprintf(fname, "%s/key%d.tmp", pre, no); } @@ -77,7 +77,7 @@ void getFnameTmp(Res res, char *fname, int no) void extract_get_fname_tmp(ZebraHandle zh, char *fname, int no) { const char *pre; - + pre = res_get_def(zh->res, "keyTmpDir", "."); sprintf(fname, "%s/key%d.tmp", pre, no); } @@ -313,7 +313,7 @@ static void key_heap_delete(struct heap_info *hi) child++; if ((*hi->cmp)(&hi->info.buf[hi->ptr[cur]], &hi->info.buf[hi->ptr[child]]) > 0) - { + { key_heap_swap(hi, cur, child); cur = child; child = 2*cur; @@ -505,7 +505,7 @@ int heap_cread_item2(void *vp, char **dst, int *insertMode) (*dst) += p->sz_1; return 1; } - + int heap_cread_item(void *vp, char **dst, int *insertMode) { struct heap_cread_info *p = (struct heap_cread_info *) vp; @@ -568,14 +568,14 @@ int heap_inpc(struct heap_cread_info *hci, struct heap_info *hi) if (!dict_delete(hi->reg->dict, this_name)) abort(); } - else + else { hi->no_updates++; if (isamc_p2 != isamc_p) dict_insert(hi->reg->dict, this_name, sizeof(ISAM_P), &isamc_p2); } - } + } else { isamc_p = 0; @@ -588,7 +588,7 @@ int heap_inpc(struct heap_cread_info *hci, struct heap_info *hi) } xfree(isamc_i); return 0; -} +} int heap_inpb(struct heap_cread_info *hci, struct heap_info *hi) { @@ -622,14 +622,14 @@ int heap_inpb(struct heap_cread_info *hci, struct heap_info *hi) if (!dict_delete(hi->reg->dict, this_name)) abort(); } - else + else { hi->no_updates++; if (isamc_p2 != isamc_p) dict_insert(hi->reg->dict, this_name, sizeof(ISAM_P), &isamc_p2); } - } + } else { isamc_p = 0; @@ -642,7 +642,7 @@ int heap_inpb(struct heap_cread_info *hci, struct heap_info *hi) } xfree(isamc_i); return 0; -} +} int heap_inps(struct heap_cread_info *hci, struct heap_info *hi) { @@ -674,7 +674,7 @@ int heap_inps(struct heap_cread_info *hci, struct heap_info *hi) } xfree(isams_i); return 0; -} +} struct progressInfo { time_t startTime; @@ -722,7 +722,7 @@ void zebra_index_merge(ZebraHandle zh) if (nkeys == 0) return; - + if (nkeys < 0) { char fname[1024]; @@ -752,7 +752,7 @@ void zebra_index_merge(ZebraHandle zh) } hi = key_heap_init_file(zh, nkeys, key_qsort_compare); hi->reg = zh->reg; - + for (i = 1; i<=nkeys; i++) if ((r = key_file_read(kf[i], rbuf))) key_heap_insert(hi, rbuf, r, kf[i]); @@ -760,7 +760,7 @@ void zebra_index_merge(ZebraHandle zh) if (1) { struct heap_cread_info hci; - + hci.key = (char *) xmalloc(KEY_SIZE); hci.key_1 = (char *) xmalloc(KEY_SIZE); hci.key_2 = (char *) xmalloc(KEY_SIZE); @@ -768,20 +768,20 @@ void zebra_index_merge(ZebraHandle zh) hci.first_in_list = 1; hci.hi = hi; hci.look_level = 0; - hci.more = heap_read_one(hi, hci.cur_name, hci.key); - + hci.more = heap_read_one(hi, hci.cur_name, hci.key); + if (zh->reg->isams) heap_inps(&hci, hi); if (zh->reg->isamc) heap_inpc(&hci, hi); if (zh->reg->isamb) heap_inpb(&hci, hi); - + xfree(hci.key); xfree(hci.key_1); xfree(hci.key_2); } - + for (i = 1; i<=nkeys; i++) { extract_get_fname_tmp (zh, rbuf, i); @@ -792,7 +792,7 @@ void zebra_index_merge(ZebraHandle zh) xfree(kf); if (hi->no_iterations) { /* do not log if nothing happened */ - yaz_log(YLOG_LOG, "Iterations: isam/dict " + yaz_log(YLOG_LOG, "Iterations: isam/dict " ZINT_FORMAT "/" ZINT_FORMAT, hi->no_iterations, hi->no_diffs); yaz_log(YLOG_LOG, "Dict: inserts/updates/deletions: " diff --git a/index/limit.c b/index/limit.c index 1647600..bd32a2e 100644 --- a/index/limit.c +++ b/index/limit.c @@ -120,7 +120,7 @@ void zebra_limit_for_rset(struct zebra_limit *zl, *filter_destroy = 0; } } - + /* * Local variables: * c-basic-offset: 4 diff --git a/index/marcomp.c b/index/marcomp.c index 3c6ef15..1f4dc90 100644 --- a/index/marcomp.c +++ b/index/marcomp.c @@ -66,21 +66,21 @@ const char *mc_error(mc_errcode no) mc_context *mc_mk_context(const char *s) { mc_context *p=0; - + if (s && strlen(s)) { p = (mc_context*) xmalloc(sizeof(*p)); - + if (!p) return 0; - + memset(p, 0, sizeof(*p)); p->errcode = EMCOK; p->data = s; p->len = strlen(s); p->crrtok = NOP; } - + return p; } void mc_destroy_context(mc_context *c) @@ -104,7 +104,7 @@ mc_token mc_gettoken(mc_context *c) case '[': c->crrtok = LINTERVAL; break; case ']': c->crrtok = RINTERVAL; break; default: - if (isspace(*(unsigned char *) (c->data+c->offset)) + if (isspace(*(unsigned char *) (c->data+c->offset)) || *(c->data+c->offset) == '\n') { c->crrtok = NOP; @@ -136,7 +136,7 @@ int mc_getval(mc_context *c) int mc_getdata(mc_context *c, char *s, int sz) { int i; - + for (i=0; iinterval.start = p->interval.end = -1; } return p; -} +} void mc_destroy_field(mc_field *p) { if (!p) return; - if (p->name) xfree(p->name); - if (p->ind1) xfree(p->ind1); + if (p->name) xfree(p->name); + if (p->ind1) xfree(p->ind1); if (p->ind2) xfree(p->ind2); if (p->list) mc_destroy_subfields_recursive(p->list); xfree(p); @@ -216,7 +216,7 @@ mc_field *mc_getfield(mc_context *c) mc_field *pf; pf = mc_mk_field(); - + if (!pf) { c->errcode = EMCNOMEM; @@ -226,9 +226,9 @@ mc_field *mc_getfield(mc_context *c) if (mc_getdata(c, pf->name, SZ_FNAME) == SZ_FNAME) { mc_token nexttok = mc_gettoken(c); - + mc_ungettoken(c); - + if (nexttok == LINTERVAL) { mc_getinterval(c, &pf->interval.start, &pf->interval.end); @@ -237,7 +237,7 @@ mc_field *mc_getfield(mc_context *c) pf->interval.end); #endif } - + if ((mc_getdata(c, pf->ind1, SZ_IND) == SZ_IND) && (mc_getdata(c, pf->ind2, SZ_IND) == SZ_IND)) { @@ -250,7 +250,7 @@ mc_field *mc_getfield(mc_context *c) mc_destroy_field(pf); return 0; } - + return pf; } mc_subfield *mc_mk_subfield(mc_subfield *parent) @@ -276,7 +276,7 @@ void mc_destroy_subfield(mc_subfield *p) { if (!p) return; - + if (p->which == MC_SFGROUP || p->which == MC_SFVARIANT) { if (p->u.child) @@ -287,8 +287,8 @@ void mc_destroy_subfield(mc_subfield *p) if (p->u.in_line) mc_destroy_field(p->u.in_line); } - if (p->name) xfree(p->name); - if (p->prefix) xfree(p->prefix); + if (p->name) xfree(p->name); + if (p->prefix) xfree(p->prefix); if (p->suffix) xfree(p->suffix); if (p->parent) p->parent->next = p->next; xfree(p); @@ -299,7 +299,7 @@ void mc_destroy_subfields_recursive(mc_subfield *p) return; mc_destroy_subfields_recursive(p->next); - + if (p->which == MC_SFGROUP || p->which == MC_SFVARIANT) { if (p->u.child) @@ -310,7 +310,7 @@ void mc_destroy_subfields_recursive(mc_subfield *p) if (p->u.in_line) mc_destroy_field(p->u.in_line); } - + if (p->name) xfree(p->name); if (p->prefix) xfree(p->prefix); if (p->suffix) xfree(p->suffix); @@ -321,10 +321,10 @@ mc_subfield *mc_getsubfields(mc_context *c, mc_subfield *parent) { mc_subfield *psf=0; mc_token tok = mc_gettoken(c); - + if (tok == NOP) return 0; - + if (tok == LGROUP) { if (!(psf = mc_mk_subfield(parent))) @@ -335,7 +335,7 @@ mc_subfield *mc_getsubfields(mc_context *c, mc_subfield *parent) psf->which = MC_SFGROUP; psf->u.child = mc_getsubfields(c, psf); - + if (mc_gettoken(c) == RGROUP) psf->next = mc_getsubfields(c, psf); else @@ -355,7 +355,7 @@ mc_subfield *mc_getsubfields(mc_context *c, mc_subfield *parent) psf->which = MC_SFVARIANT; psf->u.child = mc_getsubfields(c, psf); - + if (mc_gettoken(c) == RVARIANT) psf->next = mc_getsubfields(c, psf); else @@ -387,7 +387,7 @@ mc_subfield *mc_getsubfields(mc_context *c, mc_subfield *parent) mc_token tok = mc_gettoken(c); mc_ungettoken(c); - + if (tok == LINTERVAL) { mc_getinterval(c, &psf->interval.start, &psf->interval.end); @@ -403,7 +403,7 @@ mc_subfield *mc_getsubfields(mc_context *c, mc_subfield *parent) return 0; } } - + if (mc_getdata(c, psf->suffix, SZ_SUFFIX) == SZ_SUFFIX) { psf->which = MC_SF; @@ -416,7 +416,7 @@ mc_subfield *mc_getsubfields(mc_context *c, mc_subfield *parent) return 0; } } - } + } return psf; } /* diff --git a/index/marcomp.h b/index/marcomp.h index dc205a7..6d9f217 100644 --- a/index/marcomp.h +++ b/index/marcomp.h @@ -92,12 +92,12 @@ typedef enum typedef struct mc_context { int offset; - + int crrval; mc_token crrtok; - + mc_errcode errcode; - + int len; const char *data; } mc_context; diff --git a/index/mod_alvis.c b/index/mod_alvis.c index 15212e2..f9313f9 100644 --- a/index/mod_alvis.c +++ b/index/mod_alvis.c @@ -135,7 +135,7 @@ static void *filter_init(Res res, RecType recType) tinfo->schemas = 0; #if YAZ_HAVE_EXSLT - exsltRegisterAll(); + exsltRegisterAll(); #endif #if ENABLE_INPUT_CALLBACK @@ -151,7 +151,7 @@ static void *filter_init(Res res, RecType recType) static int attr_content(struct _xmlAttr *attr, const char *name, const char **dst_content) { - if (!XML_STRCMP(attr->name, name) && attr->children + if (!XML_STRCMP(attr->name, name) && attr->children && attr->children->type == XML_TEXT_NODE) { *dst_content = (const char *)(attr->children->content); @@ -174,7 +174,7 @@ static void destroy_schemas(struct filter_info *tinfo) tinfo->schemas = 0; xfree(tinfo->fname); if (tinfo->doc) - xmlFreeDoc(tinfo->doc); + xmlFreeDoc(tinfo->doc); tinfo->doc = 0; } @@ -183,33 +183,33 @@ static ZEBRA_RES create_schemas(struct filter_info *tinfo, const char *fname) char tmp_full_name[1024]; xmlNodePtr ptr; tinfo->fname = xstrdup(fname); - - if (yaz_filepath_resolve(tinfo->fname, tinfo->profile_path, + + if (yaz_filepath_resolve(tinfo->fname, tinfo->profile_path, NULL, tmp_full_name)) tinfo->full_name = xstrdup(tmp_full_name); else tinfo->full_name = xstrdup(tinfo->fname); - + yaz_log(YLOG_LOG, "alvis filter: loading config file %s", tinfo->full_name); - + tinfo->doc = xmlParseFile(tinfo->full_name); - + if (!tinfo->doc) { - yaz_log(YLOG_WARN, "alvis filter: could not parse config file %s", + yaz_log(YLOG_WARN, "alvis filter: could not parse config file %s", tinfo->full_name); - + return ZEBRA_FAIL; } - + ptr = xmlDocGetRootElement(tinfo->doc); - if (!ptr || ptr->type != XML_ELEMENT_NODE + if (!ptr || ptr->type != XML_ELEMENT_NODE || XML_STRCMP(ptr->name, "schemaInfo")) { - yaz_log(YLOG_WARN, - "alvis filter: config file %s :" - " expected root element ", - tinfo->full_name); + yaz_log(YLOG_WARN, + "alvis filter: config file %s :" + " expected root element ", + tinfo->full_name); return ZEBRA_FAIL; } @@ -218,7 +218,7 @@ static ZEBRA_RES create_schemas(struct filter_info *tinfo, const char *fname) if (ptr->type != XML_ELEMENT_NODE) continue; if (!XML_STRCMP(ptr->name, "schema")) - { + { struct _xmlAttr *attr; struct filter_schema *schema = xmalloc(sizeof(*schema)); schema->name = 0; @@ -235,7 +235,7 @@ static ZEBRA_RES create_schemas(struct filter_info *tinfo, const char *fname) attr_content(attr, "stylesheet", &schema->stylesheet); attr_content(attr, "default", &schema->default_schema); } - /*yaz_log(YLOG_LOG, "XSLT add %s %s %s", + /*yaz_log(YLOG_LOG, "XSLT add %s %s %s", schema->name, schema->identifier, schema->stylesheet); */ /* find requested schema */ @@ -243,20 +243,20 @@ static ZEBRA_RES create_schemas(struct filter_info *tinfo, const char *fname) if (schema->stylesheet) { char tmp_xslt_full_name[1024]; - if (!yaz_filepath_resolve(schema->stylesheet, tinfo->profile_path, - NULL, tmp_xslt_full_name)) + if (!yaz_filepath_resolve(schema->stylesheet, tinfo->profile_path, + NULL, tmp_xslt_full_name)) { - yaz_log(YLOG_WARN, + yaz_log(YLOG_WARN, "alvis filter: stylesheet %s not found in path %s", schema->stylesheet, tinfo->profile_path); return ZEBRA_FAIL; } - schema->stylesheet_xsp + schema->stylesheet_xsp = xsltParseStylesheetFile((const xmlChar*) tmp_xslt_full_name); if (!schema->stylesheet_xsp) { - yaz_log(YLOG_WARN, - "alvis filter: could not parse xslt stylesheet %s", + yaz_log(YLOG_WARN, + "alvis filter: could not parse xslt stylesheet %s", tmp_xslt_full_name); return ZEBRA_FAIL; } @@ -269,7 +269,7 @@ static ZEBRA_RES create_schemas(struct filter_info *tinfo, const char *fname) { const char *split_level_str = 0; attr_content(attr, "level", &split_level_str); - tinfo->split_level = + tinfo->split_level = split_level_str ? atoi(split_level_str) : 0; } } @@ -288,16 +288,16 @@ static struct filter_schema *lookup_schema(struct filter_info *tinfo, struct filter_schema *schema; for (schema = tinfo->schemas; schema; schema = schema->next) - { + { /* find requested schema */ - if (est) - { + if (est) + { if (schema->identifier && !strcmp(schema->identifier, est)) return schema; - + if (schema->name && !strcmp(schema->name, est)) return schema; - } + } /* or return default schema if defined */ else if (schema->default_schema) return schema; @@ -306,7 +306,7 @@ static struct filter_schema *lookup_schema(struct filter_info *tinfo, /* return first schema if no default schema defined */ if (tinfo->schemas) return tinfo->schemas; - + return 0; } @@ -321,7 +321,7 @@ static ZEBRA_RES filter_config(void *clientData, Res res, const char *args) if (tinfo->fname && !strcmp(args, tinfo->fname)) return ZEBRA_OK; - + tinfo->profile_path = res_get(res, "profilePath"); yaz_log(YLOG_LOG, "alvis filter: profilePath %s", tinfo->profile_path); @@ -432,10 +432,10 @@ static void index_record(struct filter_info *tinfo,struct recExtractCtrl *ctrl, else if (!strcmp("delete", type_str)) yaz_log(YLOG_WARN, "alvis filter delete: to be implemented"); else - yaz_log(YLOG_WARN, "alvis filter: unknown record type '%s'", + yaz_log(YLOG_WARN, "alvis filter: unknown record type '%s'", type_str); } - + static int extract_doc(struct filter_info *tinfo, struct recExtractCtrl *p, xmlDocPtr doc) { @@ -454,7 +454,7 @@ static int extract_doc(struct filter_info *tinfo, struct recExtractCtrl *p, if (schema && schema->stylesheet_xsp) { xmlNodePtr root_ptr; - xmlDocPtr resDoc = + xmlDocPtr resDoc = xsltApplyStylesheet(schema->stylesheet_xsp, doc, params); if (p->flagShowRecords) @@ -480,7 +480,7 @@ static int extract_doc(struct filter_info *tinfo, struct recExtractCtrl *p, if (p->setStoreData) (*p->setStoreData)(p, buf_out, len_out); xmlFree(buf_out); - + xmlFreeDoc(doc); return RECCTRL_EXTRACT_OK; } @@ -495,7 +495,7 @@ static int extract_split(struct filter_info *tinfo, struct recExtractCtrl *p) xmlFreeTextReader(tinfo->reader); tinfo->reader = xmlReaderForIO(ioread_ex, ioclose_ex, p /* I/O handler */, - 0 /* URL */, + 0 /* URL */, 0 /* encoding */, XML_PARSE_XINCLUDE | XML_PARSE_NOENT @@ -516,9 +516,9 @@ static int extract_split(struct filter_info *tinfo, struct recExtractCtrl *p) { xmlNodePtr ptr2 = xmlCopyNode(ptr, 1); xmlDocPtr doc = xmlNewDoc((const xmlChar*) "1.0"); - + xmlDocSetRootElement(doc, ptr2); - + return extract_doc(tinfo, p, doc); } else @@ -552,7 +552,7 @@ static int extract_full(struct filter_info *tinfo, struct recExtractCtrl *p) if (!root) return RECCTRL_EXTRACT_ERROR_GENERIC; } */ - + return extract_doc(tinfo, p, doc); } else @@ -598,7 +598,7 @@ static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p) { esn = p->comp->u.simple->u.generic; } - else if (p->comp->which == Z_RecordComp_complex + else if (p->comp->which == Z_RecordComp_complex && p->comp->u.complex->generic->elementSpec && p->comp->u.complex->generic->elementSpec->which == Z_ElementSpec_elementSetName) @@ -657,7 +657,7 @@ static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p) { p->diagnostic = YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS; } - else if (!p->input_format + else if (!p->input_format || !oid_oidcmp(p->input_format, yaz_oid_recsyn_xml)) { xmlChar *buf_out; @@ -665,9 +665,9 @@ static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p) if (schema->stylesheet_xsp) xsltSaveResultToString(&buf_out, &len_out, resDoc, - schema->stylesheet_xsp); + schema->stylesheet_xsp); else - xmlDocDumpMemory(resDoc, &buf_out, &len_out); + xmlDocDumpMemory(resDoc, &buf_out, &len_out); p->output_format = yaz_oid_recsyn_xml; p->rec_len = len_out; @@ -684,13 +684,13 @@ static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p) xsltSaveResultToString(&buf_out, &len_out, resDoc, schema->stylesheet_xsp); else - xmlDocDumpMemory(resDoc, &buf_out, &len_out); + xmlDocDumpMemory(resDoc, &buf_out, &len_out); p->output_format = yaz_oid_recsyn_sutrs; p->rec_len = len_out; p->rec_buf = odr_malloc(p->odr, p->rec_len); memcpy(p->rec_buf, buf_out, p->rec_len); - + xmlFree(buf_out); } else diff --git a/index/mod_dom.c b/index/mod_dom.c index de2a872..66ee4f0 100644 --- a/index/mod_dom.c +++ b/index/mod_dom.c @@ -112,7 +112,7 @@ struct filter_input { } u; struct filter_input *next; }; - + struct filter_info { char *fname; char *full_name; @@ -152,7 +152,7 @@ static void dom_log(int level, struct filter_info *tinfo, xmlNodePtr ptr, yaz_vsnprintf(buf, sizeof(buf)-1, fmt, ap); if (ptr) { - yaz_log(level, "%s:%ld: %s", tinfo->fname ? tinfo->fname : "none", + yaz_log(level, "%s:%ld: %s", tinfo->fname ? tinfo->fname : "none", xmlGetLineNo(ptr), buf); } else @@ -203,7 +203,7 @@ static void *filter_init(Res res, RecType recType) tinfo->record_info_invoked = 0; #if YAZ_HAVE_EXSLT - exsltRegisterAll(); + exsltRegisterAll(); #endif return tinfo; @@ -212,7 +212,7 @@ static void *filter_init(Res res, RecType recType) static int attr_content(struct _xmlAttr *attr, const char *name, const char **dst_content) { - if (!XML_STRCMP(attr->name, name) && attr->children + if (!XML_STRCMP(attr->name, name) && attr->children && attr->children->type == XML_TEXT_NODE) { *dst_content = (const char *)(attr->children->content); @@ -291,12 +291,12 @@ static ZEBRA_RES parse_convert(struct filter_info *tinfo, xmlNodePtr ptr, { struct _xmlAttr *attr; struct convert_s *p = nmem_malloc(tinfo->nmem_config, sizeof(*p)); - + p->next = 0; p->which = convert_xslt_type; p->u.xslt.stylesheet = 0; p->u.xslt.stylesheet_xsp = 0; - + for (attr = ptr->properties; attr; attr = attr->next) if (attr_content(attr, "stylesheet", &p->u.xslt.stylesheet)) ; @@ -308,21 +308,21 @@ static ZEBRA_RES parse_convert(struct filter_info *tinfo, xmlNodePtr ptr, if (p->u.xslt.stylesheet) { char tmp_xslt_full_name[1024]; - if (!yaz_filepath_resolve(p->u.xslt.stylesheet, + if (!yaz_filepath_resolve(p->u.xslt.stylesheet, tinfo->profile_path, - NULL, + NULL, tmp_xslt_full_name)) { dom_log(YLOG_WARN, tinfo, 0, "stylesheet %s not found in " "path %s", - p->u.xslt.stylesheet, + p->u.xslt.stylesheet, tinfo->profile_path); return ZEBRA_FAIL; } - + p->u.xslt.stylesheet_xsp - = xsltParseStylesheetFile((const xmlChar*) + = xsltParseStylesheetFile((const xmlChar*) tmp_xslt_full_name); if (!p->u.xslt.stylesheet_xsp) { @@ -345,10 +345,10 @@ static ZEBRA_RES parse_convert(struct filter_info *tinfo, xmlNodePtr ptr, { struct _xmlAttr *attr; struct convert_s *p = nmem_malloc(tinfo->nmem_config, sizeof(*p)); - + p->next = 0; p->which = convert_meta_type; - + for (attr = ptr->properties; attr; attr = attr->next) dom_log(YLOG_WARN, tinfo, ptr, "bad attribute @%s", attr->name); @@ -365,7 +365,7 @@ static ZEBRA_RES parse_convert(struct filter_info *tinfo, xmlNodePtr ptr, return ZEBRA_OK; } -static int process_meta(struct filter_info *tinfo, xmlDocPtr doc, xmlNodePtr node, +static int process_meta(struct filter_info *tinfo, xmlDocPtr doc, xmlNodePtr node, struct recRetrieveCtrl *retctr) { @@ -375,8 +375,8 @@ static int process_meta(struct filter_info *tinfo, xmlDocPtr doc, xmlNodePtr nod if (0 == XML_STRCMP(node->name, "meta")) { const char *element_set_name = 0; - - struct _xmlAttr *attr; + + struct _xmlAttr *attr; for (attr = node->properties; attr; attr = attr->next) { if (attr_content(attr, "name", &element_set_name)) @@ -394,14 +394,14 @@ static int process_meta(struct filter_info *tinfo, xmlDocPtr doc, xmlNodePtr nod const Odr_oid *input_format = yaz_oid_recsyn_xml; const Odr_oid *output_format = 0; int ret; - + ret = retctr->special_fetch(retctr->handle, element_set_name, input_format, &output_format, result, addinfo); if (ret == 0) { - xmlDocPtr sub_doc = + xmlDocPtr sub_doc = xmlParseMemory(wrbuf_buf(result), wrbuf_len(result)); if (sub_doc) { @@ -420,7 +420,7 @@ static int process_meta(struct filter_info *tinfo, xmlDocPtr doc, xmlNodePtr nod return 0; } -static ZEBRA_RES perform_convert(struct filter_info *tinfo, +static ZEBRA_RES perform_convert(struct filter_info *tinfo, struct recExtractCtrl *extctr, struct recRetrieveCtrl *retctr, struct convert_s *convert, @@ -438,27 +438,27 @@ static ZEBRA_RES perform_convert(struct filter_info *tinfo, *doc, params); if (last_xsp) *last_xsp = convert->u.xslt.stylesheet_xsp; - + if (!res_doc) break; - + /* now saving into buffer and re-reading into DOM to avoid annoing XSLT problem with thrown-out indentation text nodes */ xsltSaveResultToString(&buf_out, &len_out, res_doc, - convert->u.xslt.stylesheet_xsp); + convert->u.xslt.stylesheet_xsp); xmlFreeDoc(res_doc); - + xmlFreeDoc(*doc); - + *doc = xmlParseMemory((const char *) buf_out, len_out); - + /* writing debug info out */ if (extctr && extctr->flagShowRecords) - yaz_log(YLOG_LOG, "%s: XSLT %s\n %.*s", - tinfo->fname ? tinfo->fname : "(none)", + yaz_log(YLOG_LOG, "%s: XSLT %s\n %.*s", + tinfo->fname ? tinfo->fname : "(none)", convert->u.xslt.stylesheet, len_out, buf_out); - + xmlFree(buf_out); } else if (convert->which == convert_meta_type) @@ -500,7 +500,7 @@ static ZEBRA_RES parse_input(struct filter_info *tinfo, xmlNodePtr ptr, yaz_iconv_t iconv = 0; const char *input_charset = "marc-8"; struct _xmlAttr *attr; - + for (attr = ptr->properties; attr; attr = attr->next) { if (attr_content(attr, "inputcharset", &input_charset)) @@ -515,21 +515,21 @@ static ZEBRA_RES parse_input(struct filter_info *tinfo, xmlNodePtr ptr, iconv = yaz_iconv_open("utf-8", input_charset); if (!iconv) { - dom_log(YLOG_WARN, tinfo, ptr, + dom_log(YLOG_WARN, tinfo, ptr, "unsupported @charset '%s'", input_charset); return ZEBRA_FAIL; } else { - struct filter_input *p + struct filter_input *p = new_input(tinfo, DOM_INPUT_MARC); p->u.marc.handle = yaz_marc_create(); p->u.marc.iconv = iconv; - + yaz_marc_iconv(p->u.marc.handle, p->u.marc.iconv); - + ptr = ptr->next; - + parse_convert(tinfo, ptr, &p->convert); } break; @@ -537,7 +537,7 @@ static ZEBRA_RES parse_input(struct filter_info *tinfo, xmlNodePtr ptr, } else if (!XML_STRCMP(ptr->name, "xmlreader")) { - struct filter_input *p + struct filter_input *p = new_input(tinfo, DOM_INPUT_XMLREADER); struct _xmlAttr *attr; const char *level_str = 0; @@ -558,7 +558,7 @@ static ZEBRA_RES parse_input(struct filter_info *tinfo, xmlNodePtr ptr, } if (level_str) p->u.xmlreader.split_level = atoi(level_str); - + ptr = ptr->next; parse_convert(tinfo, ptr, &p->convert); @@ -582,13 +582,13 @@ static ZEBRA_RES parse_dom(struct filter_info *tinfo, const char *fname) xmlDocPtr doc; tinfo->fname = nmem_strdup(tinfo->nmem_config, fname); - - if (yaz_filepath_resolve(tinfo->fname, tinfo->profile_path, + + if (yaz_filepath_resolve(tinfo->fname, tinfo->profile_path, NULL, tmp_full_name)) tinfo->full_name = nmem_strdup(tinfo->nmem_config, tmp_full_name); else tinfo->full_name = nmem_strdup(tinfo->nmem_config, tinfo->fname); - + yaz_log(YLOG_LOG, "%s dom filter: " "loading config file %s", tinfo->fname, tinfo->full_name); @@ -600,16 +600,16 @@ static ZEBRA_RES parse_dom(struct filter_info *tinfo, const char *fname) tinfo->fname, tinfo->full_name); return ZEBRA_FAIL; } - /* save because we store ptrs to the content */ + /* save because we store ptrs to the content */ tinfo->doc_config = doc; - + ptr = xmlDocGetRootElement(doc); - if (!ptr || ptr->type != XML_ELEMENT_NODE + if (!ptr || ptr->type != XML_ELEMENT_NODE || XML_STRCMP(ptr->name, "dom")) { dom_log(YLOG_WARN, tinfo, ptr, - "bad root element <%s>, expected root element ", - ptr->name); + "bad root element <%s>, expected root element ", + ptr->name); return ZEBRA_FAIL; } @@ -626,7 +626,7 @@ static ZEBRA_RES parse_dom(struct filter_info *tinfo, const char *fname) struct _xmlAttr *attr; struct filter_extract *f = nmem_malloc(tinfo->nmem_config, sizeof(*f)); - + tinfo->extract = f; f->name = 0; f->convert = 0; @@ -644,8 +644,8 @@ static ZEBRA_RES parse_dom(struct filter_info *tinfo, const char *fname) parse_convert(tinfo, ptr->children, &f->convert); } else if (!XML_STRCMP(ptr->name, "retrieve")) - { - /* + { + /* @@ -655,7 +655,7 @@ static ZEBRA_RES parse_dom(struct filter_info *tinfo, const char *fname) struct filter_retrieve **fp = &tinfo->retrieve_list; struct filter_retrieve *f = nmem_malloc(tinfo->nmem_config, sizeof(*f)); - + while (*fp) fp = &(*fp)->next; @@ -667,7 +667,7 @@ static ZEBRA_RES parse_dom(struct filter_info *tinfo, const char *fname) for (attr = ptr->properties; attr; attr = attr->next) { - if (attr_content(attr, "identifier", + if (attr_content(attr, "identifier", &f->identifier)) ; else if (attr_content(attr, "name", &f->name)) @@ -691,7 +691,7 @@ static ZEBRA_RES parse_dom(struct filter_info *tinfo, const char *fname) */ struct filter_store *f = nmem_malloc(tinfo->nmem_config, sizeof(*f)); - + tinfo->store = f; f->convert = 0; parse_convert(tinfo, ptr->children, &f->convert); @@ -735,7 +735,7 @@ static ZEBRA_RES parse_dom(struct filter_info *tinfo, const char *fname) } if (!tinfo->input_list) { - struct filter_input *p + struct filter_input *p = new_input(tinfo, DOM_INPUT_XMLREADER); p->u.xmlreader.split_level = 0; p->u.xmlreader.reader = 0; @@ -752,15 +752,15 @@ static struct filter_retrieve *lookup_retrieve(struct filter_info *tinfo, if (!est) return f; for (; f; f = f->next) - { + { /* find requested schema */ - if (est) - { + if (est) + { if (f->identifier && !strcmp(f->identifier, est)) return f; if (f->name && !strcmp(f->name, est)) return f; - } + } } return 0; } @@ -776,7 +776,7 @@ static ZEBRA_RES filter_config(void *clientData, Res res, const char *args) if (tinfo->fname && !strcmp(args, tinfo->fname)) return ZEBRA_OK; - + tinfo->profile_path = res_get(res, "profilePath"); destroy_dom(tinfo); @@ -806,27 +806,27 @@ static int ioclose_ex(void *context) /* DOM filter style indexing */ -static void index_value_of(struct filter_info *tinfo, +static void index_value_of(struct filter_info *tinfo, struct recExtractCtrl *extctr, - RecWord* recword, - xmlNodePtr node, + RecWord* recword, + xmlNodePtr node, const char *index_p) { if (tinfo->record_info_invoked == 1) { xmlChar *text = xmlNodeGetContent(node); size_t text_len = strlen((const char *)text); - + /* if there is no text, we do not need to proceed */ if (text_len) - { + { /* keep seqno base so that all text will have identical seqno's for multiple fields , e.g .. */ - + zint seqno_base = recword->seqno; zint seqno_max = recword->seqno; - + const char *look = index_p; const char *bval; @@ -846,7 +846,7 @@ static void index_value_of(struct filter_info *tinfo, /* setting name and type to zero */ *index = '\0'; *type = '\0'; - + /* parsing one index name */ bval = look; while (*look && ':' != *look && ' ' != *look) @@ -856,13 +856,13 @@ static void index_value_of(struct filter_info *tinfo, eval = look; strncpy((char *)index, (const char *)bval, eval - bval); index[eval - bval] = '\0'; - - + + /* parsing one index type, if existing */ if (':' == *look) { look++; - + bval = look; while (*look && ' ' != *look) { @@ -882,12 +882,12 @@ static void index_value_of(struct filter_info *tinfo, /* writing debug out */ if (extctr->flagShowRecords) - dom_log(YLOG_LOG, tinfo, 0, - "INDEX '%s:%s' '%s'", + dom_log(YLOG_LOG, tinfo, 0, + "INDEX '%s:%s' '%s'", (const char *) index, - (const char *) type, + (const char *) type, (const char *) text); - + (extctr->tokenAdd)(recword); if (seqno_max < recword->seqno) @@ -897,31 +897,31 @@ static void index_value_of(struct filter_info *tinfo, if (*look && ' ' == *look) { look++; - } + } } recword->seqno = seqno_max; } - xmlFree(text); + xmlFree(text); } } /* DOM filter style indexing */ -static void set_record_info(struct filter_info *tinfo, - struct recExtractCtrl *extctr, - xmlNodePtr node, - const char * id_p, - const char * rank_p, +static void set_record_info(struct filter_info *tinfo, + struct recExtractCtrl *extctr, + xmlNodePtr node, + const char * id_p, + const char * rank_p, const char * type_p) { /* writing debug info out */ if (extctr && extctr->flagShowRecords) dom_log(YLOG_LOG, tinfo, node, - "RECORD id=%s rank=%s type=%s", + "RECORD id=%s rank=%s type=%s", id_p ? (const char *) id_p : "(null)", rank_p ? (const char *) rank_p : "(null)", type_p ? (const char *) type_p : "(null)"); - + if (id_p && *id_p) { @@ -962,9 +962,9 @@ static void set_record_info(struct filter_info *tinfo, /* DOM filter style indexing */ -static void process_xml_element_zebra_node(struct filter_info *tinfo, - struct recExtractCtrl *extctr, - RecWord* recword, +static void process_xml_element_zebra_node(struct filter_info *tinfo, + struct recExtractCtrl *extctr, + RecWord* recword, xmlNodePtr node) { if (node->type == XML_ELEMENT_NODE && node->ns && node->ns->href @@ -974,13 +974,13 @@ static void process_xml_element_zebra_node(struct filter_info *tinfo, { const char *index_p = 0; - struct _xmlAttr *attr; + struct _xmlAttr *attr; for (attr = node->properties; attr; attr = attr->next) { if (attr_content(attr, "name", &index_p)) { index_value_of(tinfo, extctr, recword, node, index_p); - } + } else { dom_log(YLOG_WARN, tinfo, node, @@ -1012,7 +1012,7 @@ static void process_xml_element_zebra_node(struct filter_info *tinfo, } } set_record_info(tinfo, extctr, node, id_p, rank_p, type_p); - } + } else { dom_log(YLOG_WARN, tinfo, node, @@ -1051,8 +1051,8 @@ static int attr_content_pi(const char **c_ptr, const char *name, } /* DOM filter style indexing */ -static void process_xml_pi_node(struct filter_info *tinfo, - struct recExtractCtrl *extctr, +static void process_xml_pi_node(struct filter_info *tinfo, + struct recExtractCtrl *extctr, xmlNodePtr node, const char **index_pp) { @@ -1061,14 +1061,14 @@ static void process_xml_pi_node(struct filter_info *tinfo, { xmlChar *pi_p = node->content; const char *look = (const char *) node->content; - + /* parsing PI record instructions */ if (0 == strncmp((const char *)look, "record", 6)) { char id[256]; char rank[256]; char type[256]; - + *id = '\0'; *rank = '\0'; *type = '\0'; @@ -1095,20 +1095,20 @@ static void process_xml_pi_node(struct filter_info *tinfo, } } set_record_info(tinfo, extctr, node, id, rank, type); - } + } /* parsing index instruction */ else if (0 == strncmp((const char *)look, "index", 5)) { look += 5; - + /* eat whitespace */ while (*look && ' ' == *look) look++; /* export index instructions to outside */ *index_pp = look; - } - else + } + else { dom_log(YLOG_WARN, tinfo, node, "content '%s', can not parse '%s'", @@ -1118,18 +1118,18 @@ static void process_xml_pi_node(struct filter_info *tinfo, } /* DOM filter style indexing */ -static void process_xml_element_node(struct filter_info *tinfo, - struct recExtractCtrl *extctr, - RecWord* recword, +static void process_xml_element_node(struct filter_info *tinfo, + struct recExtractCtrl *extctr, + RecWord* recword, xmlNodePtr node) { /* remember indexing instruction from PI to next element node */ const char *index_p = 0; - /* check if we are an element node in the special zebra namespace + /* check if we are an element node in the special zebra namespace and either set record data or index value-of node content*/ process_xml_element_zebra_node(tinfo, extctr, recword, node); - + /* loop through kid nodes */ for (node = node->children; node; node = node->next) { @@ -1155,8 +1155,8 @@ static void process_xml_element_node(struct filter_info *tinfo, /* DOM filter style indexing */ -static void extract_dom_doc_node(struct filter_info *tinfo, - struct recExtractCtrl *extctr, +static void extract_dom_doc_node(struct filter_info *tinfo, + struct recExtractCtrl *extctr, xmlDocPtr doc) { /* only need to do the initialization once, reuse recword for all terms */ @@ -1167,9 +1167,9 @@ static void extract_dom_doc_node(struct filter_info *tinfo, } -static int convert_extract_doc(struct filter_info *tinfo, +static int convert_extract_doc(struct filter_info *tinfo, struct filter_input *input, - struct recExtractCtrl *p, + struct recExtractCtrl *p, xmlDocPtr doc) { xmlChar *buf_out; @@ -1193,7 +1193,7 @@ static int convert_extract_doc(struct filter_info *tinfo, xmlChar *buf_out; int len_out; xmlDocDumpMemory(doc, &buf_out, &len_out); -#if 0 +#if 0 FILE *outf = fopen("extract.xml", "w"); fwrite(buf_out, 1, len_out, outf); fclose(outf); @@ -1207,7 +1207,7 @@ static int convert_extract_doc(struct filter_info *tinfo, /* input conversion */ perform_convert(tinfo, p, 0, input->convert, params, &doc, 0); - + if (tinfo->store) { /* store conversion */ @@ -1215,14 +1215,14 @@ static int convert_extract_doc(struct filter_info *tinfo, perform_convert(tinfo, p, 0, tinfo->store->convert, params, &store_doc, &last_xsp); } - + /* saving either store doc or original doc in case no store doc exists */ if (last_xsp) - xsltSaveResultToString(&buf_out, &len_out, + xsltSaveResultToString(&buf_out, &len_out, store_doc ? store_doc : doc, last_xsp); else xmlDocDumpMemory(store_doc ? store_doc : doc, &buf_out, &len_out); - + if (p->setStoreData) (*p->setStoreData)(p, buf_out, len_out); xmlFree(buf_out); @@ -1240,7 +1240,7 @@ static int convert_extract_doc(struct filter_info *tinfo, extract_dom_doc_node(tinfo, p, doc); xmlFreeDoc(doc); } - + /* there was nothing to index, so there is no inserted/updated record */ if (tinfo->record_info_invoked == 0) return RECCTRL_EXTRACT_SKIP; @@ -1260,7 +1260,7 @@ static int extract_xml_split(struct filter_info *tinfo, xmlFreeTextReader(input->u.xmlreader.reader); input->u.xmlreader.reader = xmlReaderForIO(ioread_ex, ioclose_ex, p /* I/O handler */, - 0 /* URL */, + 0 /* URL */, 0 /* encoding */, XML_PARSE_XINCLUDE | XML_PARSE_NOENT @@ -1275,14 +1275,14 @@ static int extract_xml_split(struct filter_info *tinfo, int type = xmlTextReaderNodeType(input->u.xmlreader.reader); int depth = xmlTextReaderDepth(input->u.xmlreader.reader); - if (type == XML_READER_TYPE_ELEMENT && + if (type == XML_READER_TYPE_ELEMENT && input->u.xmlreader.split_level == depth) { xmlNodePtr ptr; /* per default do not ingest record */ tinfo->record_info_invoked = 0; - + ptr = xmlTextReaderExpand(input->u.xmlreader.reader); if (ptr) { @@ -1290,21 +1290,21 @@ static int extract_xml_split(struct filter_info *tinfo, xmlNodePtr ptr2 = xmlCopyNode(ptr, 1); xmlDocPtr doc = xmlNewDoc((const xmlChar*) "1.0"); - + xmlDocSetRootElement(doc, ptr2); - + /* writing debug info out */ if (p->flagShowRecords) { xmlChar *buf_out = 0; int len_out = 0; xmlDocDumpMemory(doc, &buf_out, &len_out); - yaz_log(YLOG_LOG, "%s: XMLREADER level: %i\n%.*s", + yaz_log(YLOG_LOG, "%s: XMLREADER level: %i\n%.*s", tinfo->fname ? tinfo->fname : "(none)", - depth, len_out, buf_out); + depth, len_out, buf_out); xmlFree(buf_out); } - + return convert_extract_doc(tinfo, input, p, doc); } else @@ -1321,13 +1321,13 @@ static int extract_xml_split(struct filter_info *tinfo, return RECCTRL_EXTRACT_EOF; } -static int extract_xml_full(struct filter_info *tinfo, +static int extract_xml_full(struct filter_info *tinfo, struct filter_input *input, struct recExtractCtrl *p) { if (p->first_record) /* only one record per stream */ { - xmlDocPtr doc = xmlReadIO(ioread_ex, ioclose_ex, + xmlDocPtr doc = xmlReadIO(ioread_ex, ioclose_ex, p /* I/O handler */, 0 /* URL */, 0 /* encoding */, @@ -1393,11 +1393,11 @@ static int extract_iso2709(struct filter_info *tinfo, { xmlDocPtr rdoc; xmlNode *root_ptr; - yaz_marc_write_xml(input->u.marc.handle, &root_ptr, + yaz_marc_write_xml(input->u.marc.handle, &root_ptr, "http://www.loc.gov/MARC21/slim", 0, 0); rdoc = xmlNewDoc((const xmlChar*) "1.0"); xmlDocSetRootElement(rdoc, root_ptr); - return convert_extract_doc(tinfo, input, p, rdoc); + return convert_extract_doc(tinfo, input, p, rdoc); } return RECCTRL_EXTRACT_OK; } @@ -1409,7 +1409,7 @@ static int filter_extract(void *clientData, struct recExtractCtrl *p) if (!input) return RECCTRL_EXTRACT_ERROR_GENERIC; - + nmem_reset(tinfo->nmem_record); if (p->setStoreData == 0) @@ -1457,7 +1457,7 @@ static int filter_retrieve(void *clientData, struct recRetrieveCtrl *p) { esn = p->comp->u.simple->u.generic; } - else if (p->comp->which == Z_RecordComp_complex + else if (p->comp->which == Z_RecordComp_complex && p->comp->u.complex->generic->elementSpec && p->comp->u.complex->generic->elementSpec->which == Z_ElementSpec_elementSetName) @@ -1520,7 +1520,7 @@ static int filter_retrieve(void *clientData, struct recRetrieveCtrl *p) if (last_xsp) xsltSaveResultToString(&buf_out, &len_out, doc, last_xsp); else - xmlDocDumpMemory(doc, &buf_out, &len_out); + xmlDocDumpMemory(doc, &buf_out, &len_out); p->output_format = yaz_oid_recsyn_xml; p->rec_len = len_out; @@ -1536,13 +1536,13 @@ static int filter_retrieve(void *clientData, struct recRetrieveCtrl *p) if (last_xsp) xsltSaveResultToString(&buf_out, &len_out, doc, last_xsp); else - xmlDocDumpMemory(doc, &buf_out, &len_out); - + xmlDocDumpMemory(doc, &buf_out, &len_out); + p->output_format = yaz_oid_recsyn_sutrs; p->rec_len = len_out; p->rec_buf = odr_malloc(p->odr, p->rec_len); memcpy(p->rec_buf, buf_out, p->rec_len); - + xmlFree(buf_out); } else diff --git a/index/mod_grs_marc.c b/index/mod_grs_marc.c index 06fe9f5..88626bb 100644 --- a/index/mod_grs_marc.c +++ b/index/mod_grs_marc.c @@ -118,7 +118,7 @@ static data1_node *grs_read_iso2709 (struct grs_read_info *p, int marc_xml) { data1_node *lead; const char *attr[] = { "xmlns", "http://www.loc.gov/MARC21/slim", 0}; - + res_top = data1_mk_tag (p->dh, p->mem, "record", attr, res_root); lead = data1_mk_tag(p->dh, p->mem, "leader", 0, res_top); @@ -194,7 +194,7 @@ static data1_node *grs_read_iso2709 (struct grs_read_info *p, int marc_xml) res = parent; else res = data1_mk_tag_n (p->dh, p->mem, tag, 3, 0 /* attr */, parent); - + #if MARC_DEBUG fprintf (outf, "%s ", tag); #endif @@ -210,7 +210,7 @@ static data1_node *grs_read_iso2709 (struct grs_read_info *p, int marc_xml) yaz_log(YLOG_WARN, "MARC: Bad offsets in data. Skipping rest"); break; } - + if (memcmp (tag, "00", 2) && indicator_length) { /* generate indicator node */ @@ -234,7 +234,7 @@ static data1_node *grs_read_iso2709 (struct grs_read_info *p, int marc_xml) attr[0] = str1; attr[1] = str2; - + data1_tag_add_attr (p->dh, p->mem, res, attr); } } @@ -243,7 +243,7 @@ static data1_node *grs_read_iso2709 (struct grs_read_info *p, int marc_xml) #if MARC_DEBUG int j; #endif - res = data1_mk_tag_n (p->dh, p->mem, + res = data1_mk_tag_n (p->dh, p->mem, buf+i, indicator_length, 0 /* attr */, res); #if MARC_DEBUG for (j = 0; jdh, p->mem, "controlfield", attr, res); } } @@ -278,7 +278,7 @@ static data1_node *grs_read_iso2709 (struct grs_read_info *p, int marc_xml) int j; const char *attr[3]; char code[10]; - + for (j = 1; jdh, p->mem, - buf+i+1, identifier_length-1, + buf+i+1, identifier_length-1, 0 /* attr */, parent); } #if MARC_DEBUG - fprintf (outf, " $"); + fprintf (outf, " $"); for (j = 1; jwhich == DATA1N_data) n = n->next; else - break; + break; } r = ""; *len = strlen(r); @@ -375,7 +375,7 @@ static char *get_data(data1_node *n, int *len) static data1_node *lookup_subfield(data1_node *node, const char *name) { data1_node *p; - + for (p=node; p; p=p->next) { if (!yaz_matchstr(p->u.tag.tag, name)) @@ -388,7 +388,7 @@ static inline_subfield *lookup_inline_subfield(inline_subfield *pisf, const char *name) { inline_subfield *p; - + for (p=pisf; p; p=p->next) { if (!yaz_matchstr(p->name, name)) @@ -401,13 +401,13 @@ static inline_subfield *cat_inline_subfield(mc_subfield *psf, WRBUF buf, inline_subfield *pisf) { mc_subfield *p; - + for (p = psf; p && pisf; p = p->next) { if (p->which == MC_SF) { inline_subfield *found = lookup_inline_subfield(pisf, p->name); - + if (found) { if (strcmp(p->prefix, "_")) @@ -432,14 +432,14 @@ static inline_subfield *cat_inline_subfield(mc_subfield *psf, WRBUF buf, } #if MARCOMP_DEBUG yaz_log(YLOG_LOG, "cat_inline_subfield(): add subfield $%s", found->name); -#endif +#endif pisf = found->next; } } else if (p->which == MC_SFVARIANT) { inline_subfield *next; - + do { next = cat_inline_subfield(p->u.child, buf, pisf); if (next == pisf) @@ -451,7 +451,7 @@ static inline_subfield *cat_inline_subfield(mc_subfield *psf, WRBUF buf, { mc_subfield *pp; int found; - + for (pp = p->u.child, found = 0; pp; pp = pp->next) { if (!yaz_matchstr(pisf->name, p->name)) @@ -468,11 +468,11 @@ static inline_subfield *cat_inline_subfield(mc_subfield *psf, WRBUF buf, } } } - return pisf; + return pisf; } static void cat_inline_field(mc_field *pf, WRBUF buf, data1_node *subfield) -{ +{ if (!pf || !subfield) return; @@ -481,13 +481,13 @@ static void cat_inline_field(mc_field *pf, WRBUF buf, data1_node *subfield) int len; inline_field *pif=NULL; data1_node *psubf; - + if (yaz_matchstr(subfield->u.tag.tag, "1")) { subfield = subfield->next; continue; } - + psubf = subfield; pif = inline_mk_field(); do @@ -498,13 +498,13 @@ static void cat_inline_field(mc_field *pf, WRBUF buf, data1_node *subfield) yaz_log(YLOG_WARN, "inline subfield ($%s): parse error", psubf->u.tag.tag); inline_destroy_field(pif); - return; + return; } psubf = psubf->next; } while (psubf && yaz_matchstr(psubf->u.tag.tag, "1")); - + subfield = psubf; - + if (pif && !yaz_matchstr(pif->name, pf->name)) { if (!pf->list && pif->list) @@ -521,12 +521,12 @@ static void cat_inline_field(mc_field *pf, WRBUF buf, data1_node *subfield) ind1 = (pif->ind1[0] == ' ') ? '_':pif->ind1[0]; ind2 = (pif->ind2[0] == ' ') ? '_':pif->ind2[0]; - + if (((pf->ind1[0] == '.') || (ind1 == pf->ind1[0])) && ((pf->ind2[0] == '.') || (ind2 == pf->ind2[0]))) { cat_inline_subfield(pf->list, buf, pif->list); - + /* add separator for inline fields */ @@ -543,7 +543,7 @@ static void cat_inline_field(mc_field *pf, WRBUF buf, data1_node *subfield) } inline_destroy_field(pif); } -#if MARCOMP_DEBUG +#if MARCOMP_DEBUG yaz_log(YLOG_LOG, "cat_inline_field(): got buffer {%s}", buf); #endif } @@ -552,23 +552,23 @@ static data1_node *cat_subfield(mc_subfield *psf, WRBUF buf, data1_node *subfield) { mc_subfield *p; - + for (p = psf; p && subfield; p = p->next) { if (p->which == MC_SF) { data1_node *found = lookup_subfield(subfield, p->name); - + if (found) { int len; - + if (strcmp(p->prefix, "_")) { wrbuf_puts(buf, " "); wrbuf_puts(buf, p->prefix); } - + if (p->u.in_line) { cat_inline_field(p->u.in_line, buf, found); @@ -588,9 +588,9 @@ static data1_node *cat_subfield(mc_subfield *psf, WRBUF buf, wrbuf_puts(buf, p->suffix); wrbuf_puts(buf, " "); } -#if MARCOMP_DEBUG +#if MARCOMP_DEBUG yaz_log(YLOG_LOG, "cat_subfield(): add subfield $%s", found->u.tag.tag); -#endif +#endif subfield = found->next; } } @@ -608,7 +608,7 @@ static data1_node *cat_subfield(mc_subfield *psf, WRBUF buf, { mc_subfield *pp; int found; - + for (pp = p->u.child, found = 0; pp; pp = pp->next) { if (!yaz_matchstr(subfield->u.tag.tag, pp->name)) @@ -633,27 +633,27 @@ static data1_node *cat_field(struct grs_read_info *p, mc_field *pf, { data1_node *subfield; int ind1, ind2; - + if (!pf || !field) return 0; - + if (yaz_matchstr(field->u.tag.tag, pf->name)) return field->next; subfield = field->child; - + if (!subfield) return field->next; /* check subfield without indicators */ - + if (!pf->list && subfield->which == DATA1N_data) { int len; - + if (pf->interval.start == -1) { wrbuf_puts(buf, get_data(field, &len)); @@ -669,14 +669,14 @@ static data1_node *cat_field(struct grs_read_info *p, mc_field *pf, #endif return field->next; } - + /* check indicators */ ind1 = (subfield->u.tag.tag[0] == ' ') ? '_':subfield->u.tag.tag[0]; ind2 = (subfield->u.tag.tag[1] == ' ') ? '_':subfield->u.tag.tag[1]; - + if (!( ((pf->ind1[0] == '.') || (ind1 == pf->ind1[0])) && ((pf->ind2[0] == '.') || (ind2 == pf->ind2[0])) @@ -687,25 +687,25 @@ static data1_node *cat_field(struct grs_read_info *p, mc_field *pf, #endif return field->next; } - + subfield = subfield->child; - + if (!subfield) return field->next; cat_subfield(pf->list, buf, subfield); -#if MARCOMP_DEBUG +#if MARCOMP_DEBUG yaz_log(YLOG_LOG, "cat_field(): got buffer {%s}", buf); #endif - - return field->next; + + return field->next; } static int is_empty(char *s) { char *p = s; - + for (p = s; *p; p++) { if (!isspace(*(unsigned char *)p)) @@ -723,21 +723,21 @@ static void parse_data1_tree(struct grs_read_info *p, const char *mc_stmnt, mc_context *c; mc_field *pf; WRBUF buf; - + c = mc_mk_context(mc_stmnt+3); - + if (!c) return; - + pf = mc_getfield(c); - + if (!pf) { mc_destroy_context(c); return; } buf = wrbuf_alloc(); -#if MARCOMP_DEBUG +#if MARCOMP_DEBUG yaz_log(YLOG_LOG, "parse_data1_tree(): statement -{%s}", mc_stmnt); #endif if (!yaz_matchstr(pf->name, "ldr")) @@ -746,7 +746,7 @@ static void parse_data1_tree(struct grs_read_info *p, const char *mc_stmnt, #if MARCOMP_DEBUG yaz_log(YLOG_LOG,"parse_data1_tree(): try LEADER from {%d} to {%d} positions", pf->interval.start, pf->interval.end); -#endif +#endif if (marctab) { new = data1_mk_tag_n(p->dh, p->mem, mc_stmnt, strlen(mc_stmnt), 0, top); @@ -757,21 +757,21 @@ static void parse_data1_tree(struct grs_read_info *p, const char *mc_stmnt, else { field=top->child; - + while(field) { if (!yaz_matchstr(field->u.tag.tag, pf->name)) { data1_node *new; char *pb; -#if MARCOMP_DEBUG +#if MARCOMP_DEBUG yaz_log(YLOG_LOG, "parse_data1_tree(): try field {%s}", field->u.tag.tag); -#endif +#endif wrbuf_rewind(buf); wrbuf_puts(buf, ""); field = cat_field(p, pf, buf, field); - + wrbuf_cstr(buf); pb = wrbuf_buf(buf); for (pb = strtok(pb, "\n"); pb; pb = strtok(NULL, "\n")) @@ -801,11 +801,11 @@ data1_node *grs_read_marcxml(struct grs_read_info *p) if (!root) return 0; - + for (e = data1_absyn_getelements(p->dh, root); e; e=e->next) { data1_tag *tag = e->tag; - + if (tag && tag->which == DATA1T_string && !yaz_matchstr(tag->value.string, "mc?")) parse_data1_tree(p, tag->value.string, root); @@ -820,11 +820,11 @@ data1_node *grs_read_marc(struct grs_read_info *p) if (!root) return 0; - + for (e = data1_absyn_getelements(p->dh, root); e; e=e->next) { data1_tag *tag = e->tag; - + if (tag && tag->which == DATA1T_string && !yaz_matchstr(tag->value.string, "mc?")) parse_data1_tree(p, tag->value.string, root); @@ -906,7 +906,7 @@ idzebra_filter &marcxml_type, 0, }; - + /* * Local variables: * c-basic-offset: 4 diff --git a/index/mod_grs_regx.c b/index/mod_grs_regx.c index 7c6e28e..e62aae7 100644 --- a/index/mod_grs_regx.c +++ b/index/mod_grs_regx.c @@ -61,7 +61,7 @@ struct regxCode { }; struct lexRuleAction { - int which; + int which; union { struct { struct DFA *dfa; /* REGX_PATTERN */ @@ -130,7 +130,7 @@ struct lexSpec { data1_node **d1_stack; int d1_level; int stop_flag; - + int *arg_start; int *arg_end; int arg_no; @@ -184,7 +184,7 @@ static int f_win_advance (struct lexSpec *spec, int *pos) { int size; char *buf; - + if (*pos >= spec->f_win_start && *pos < spec->f_win_end) return spec->f_win_buf[(*pos)++ - spec->f_win_start]; if (*pos == F_WIN_EOF) @@ -208,7 +208,7 @@ static void regxCodeDel (struct regxCode **pp) if (p->tcl_obj) Tcl_DecrRefCount (p->tcl_obj); #endif - xfree (p->str); + xfree (p->str); xfree (p); *pp = NULL; } @@ -302,7 +302,7 @@ static struct lexSpec *lexSpecCreate (const char *name, data1_handle dh) { struct lexSpec *p; int i; - + p = (struct lexSpec *) xmalloc (sizeof(*p)); p->name = (char *) xmalloc (strlen(name)+1); strcpy (p->name, name); @@ -528,7 +528,7 @@ int readOneSpec (struct lexSpec *spec, const char *s) } if (!spec->context) spec->context = lexContextCreate ("main"); - + switch (tok) { case REGX_BEGIN: @@ -623,7 +623,7 @@ int readFileSpec (struct lexSpec *spec) else { int addLine = 0; - + while (1) { int c1 = c; @@ -661,7 +661,7 @@ int readFileSpec (struct lexSpec *spec) } if (errors) return -1; - + return 0; } @@ -688,10 +688,10 @@ static void execData (struct lexSpec *spec, } else if (elen > 0) yaz_log (YLOG_LOG, "data(%d bytes) %.*s", elen, elen, ebuf); - else + else yaz_log (YLOG_LOG, "data(%d bytes)", elen); #endif - + if (spec->d1_level <= 1) return; @@ -732,22 +732,22 @@ static void execData (struct lexSpec *spec, nv[strlen(nv)+elen] = '\0'; (*ap)->value = nv; } - } - else + } + else { - if ((res = spec->d1_stack[spec->d1_level]) && + if ((res = spec->d1_stack[spec->d1_level]) && res->which == DATA1N_data) org_len = res->u.data.len; else { org_len = 0; - + res = data1_mk_node2 (spec->dh, spec->m, DATA1N_data, parent); res->u.data.what = DATA1I_text; res->u.data.len = 0; res->u.data.formatted_text = formatted_text; res->u.data.data = 0; - + if (spec->d1_stack[spec->d1_level]) spec->d1_stack[spec->d1_level]->next = res; spec->d1_stack[spec->d1_level] = res; @@ -755,7 +755,7 @@ static void execData (struct lexSpec *spec, if (org_len + elen >= spec->concatBuf[spec->d1_level].max) { char *old_buf, *new_buf; - + spec->concatBuf[spec->d1_level].max = org_len + elen + 256; new_buf = (char *) xmalloc (spec->concatBuf[spec->d1_level].max); if ((old_buf = spec->concatBuf[spec->d1_level].buf)) @@ -779,9 +779,9 @@ static void execDataP (struct lexSpec *spec, static void tagDataRelease (struct lexSpec *spec) { data1_node *res; - + if ((res = spec->d1_stack[spec->d1_level]) && - res->which == DATA1N_data && + res->which == DATA1N_data && res->u.data.what == DATA1I_text) { assert (!res->u.data.data); @@ -795,7 +795,7 @@ static void tagDataRelease (struct lexSpec *spec) } } -static void variantBegin (struct lexSpec *spec, +static void variantBegin (struct lexSpec *spec, const char *class_str, int class_len, const char *type_str, int type_len, const char *value_str, int value_len) @@ -821,7 +821,7 @@ static void variantBegin (struct lexSpec *spec, memcpy (ttype, type_str, type_len); ttype[type_len] = '\0'; -#if REGX_DEBUG +#if REGX_DEBUG yaz_log (YLOG_LOG, "variant begin(%s,%s,%d)", tclass, ttype, spec->d1_level); #endif @@ -830,7 +830,7 @@ static void variantBegin (struct lexSpec *spec, data1_getvartypeby_absyn(spec->dh, parent->root->u.root.absyn, tclass, ttype))) return; - + if (parent->which != DATA1N_variant) { res = data1_mk_node2 (spec->dh, spec->m, DATA1N_variant, parent); @@ -846,7 +846,7 @@ static void variantBegin (struct lexSpec *spec, break; } -#if REGX_DEBUG +#if REGX_DEBUG yaz_log (YLOG_LOG, "variant node(%d)", spec->d1_level); #endif parent = spec->d1_stack[spec->d1_level-1]; @@ -859,7 +859,7 @@ static void variantBegin (struct lexSpec *spec, res->lbuf[value_len] = '\0'; res->u.variant.value = res->lbuf; - + if (spec->d1_stack[spec->d1_level]) tagDataRelease (spec); spec->d1_stack[spec->d1_level] = res; @@ -879,7 +879,7 @@ static void tagStrip (const char **tag, int *len) *len -= i; } -static void tagBegin (struct lexSpec *spec, +static void tagBegin (struct lexSpec *spec, const char *tag, int len) { if (spec->d1_level == 0) @@ -891,7 +891,7 @@ static void tagBegin (struct lexSpec *spec, if (spec->d1_stack[spec->d1_level]) tagDataRelease (spec); -#if REGX_DEBUG +#if REGX_DEBUG yaz_log (YLOG_LOG, "begin tag(%.*s, %d)", len, tag, spec->d1_level); #endif @@ -1093,7 +1093,7 @@ static int cmd_tcl_begin (ClientData clientData, Tcl_Interp *interp, yaz_log (YLOG_LOG, "begin record %s", absynName); #endif res = data1_mk_root (spec->dh, spec->m, absynName); - + spec->d1_level = 0; spec->d1_stack[spec->d1_level++] = res; @@ -1140,7 +1140,7 @@ static int cmd_tcl_end (ClientData clientData, Tcl_Interp *interp, struct lexSpec *spec = (struct lexSpec *) clientData; if (argc < 2) return TCL_ERROR; - + if (!strcmp (argv[1], "record")) { while (spec->d1_level) @@ -1196,7 +1196,7 @@ static int cmd_tcl_data (ClientData clientData, Tcl_Interp *interp, const char *element = 0; const char *attribute = 0; struct lexSpec *spec = (struct lexSpec *) clientData; - + while (argi < argc) { if (!strcmp("-text", argv[argi])) @@ -1227,7 +1227,7 @@ static int cmd_tcl_data (ClientData clientData, Tcl_Interp *interp, #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 0) Tcl_DString ds; char *native = Tcl_UtfToExternalDString(0, argv[argi], -1, &ds); - execData (spec, native, strlen(native), textFlag, attribute, + execData (spec, native, strlen(native), textFlag, attribute, attribute ? strlen(attribute) : 0); Tcl_DStringFree (&ds); #else @@ -1248,7 +1248,7 @@ static int cmd_tcl_unread (ClientData clientData, Tcl_Interp *interp, int argi = 1; int offset = 0; int no; - + while (argi < argc) { if (!strcmp("-offset", argv[argi])) @@ -1273,17 +1273,17 @@ static int cmd_tcl_unread (ClientData clientData, Tcl_Interp *interp, } static void execTcl (struct lexSpec *spec, struct regxCode *code) -{ +{ int i; int ret; for (i = 0; i < spec->arg_no; i++) { char var_name[10], *var_buf; int var_len, ch; - + sprintf (var_name, "%d", i); var_buf = f_win_get (spec, spec->arg_start[i], spec->arg_end[i], - &var_len); + &var_len); if (var_buf) { ch = var_buf[var_len]; @@ -1300,7 +1300,7 @@ static void execTcl (struct lexSpec *spec, struct regxCode *code) if (ret != TCL_OK) { const char *err = Tcl_GetVar(spec->tcl_interp, "errorInfo", 0); - yaz_log(YLOG_FATAL, "Tcl error, line=%d, \"%s\"\n%s", + yaz_log(YLOG_FATAL, "Tcl error, line=%d, \"%s\"\n%s", spec->tcl_interp->errorLine, spec->tcl_interp->result, err ? err : "[NO ERRORINFO]"); @@ -1314,12 +1314,12 @@ static void execCode (struct lexSpec *spec, struct regxCode *code) const char *s = code->str; int cmd_len, r; const char *cmd_str; - + r = execTok (spec, &s, &cmd_str, &cmd_len); while (r) { char *p, ptmp[64]; - + if (r == 1) { r = execTok (spec, &s, &cmd_str, &cmd_len); @@ -1353,7 +1353,7 @@ static void execCode (struct lexSpec *spec, struct regxCode *code) yaz_log (YLOG_LOG, "begin record %s", absynName); #endif res = data1_mk_root (spec->dh, spec->m, absynName); - + spec->d1_level = 0; spec->d1_stack[spec->d1_level++] = res; @@ -1373,7 +1373,7 @@ static void execCode (struct lexSpec *spec, struct regxCode *code) continue; tagBegin (spec, cmd_str, cmd_len); r = execTok (spec, &s, &cmd_str, &cmd_len); - } + } else if (!strcmp (p, "variant")) { int class_len; @@ -1401,8 +1401,8 @@ static void execCode (struct lexSpec *spec, struct regxCode *code) variantBegin (spec, class_str, class_len, type_str, type_len, value_str, value_len); - - + + r = execTok (spec, &s, &cmd_str, &cmd_len); } else if (!strcmp (p, "context")) @@ -1421,7 +1421,7 @@ static void execCode (struct lexSpec *spec, struct regxCode *code) spec->context_stack[++(spec->context_stack_top)] = lc; else yaz_log (YLOG_WARN, "unknown context %s", p); - + } r = execTok (spec, &s, &cmd_str, &cmd_len); } @@ -1484,7 +1484,7 @@ static void execCode (struct lexSpec *spec, struct regxCode *code) if (spec->context_stack_top) (spec->context_stack_top)--; r = execTok (spec, &s, &cmd_str, &cmd_len); - } + } else yaz_log (YLOG_WARN, "bad keyword '%s' after end", p); } @@ -1495,7 +1495,7 @@ static void execCode (struct lexSpec *spec, struct regxCode *code) const char *element_str = NULL; int attribute_len; const char *attribute_str = NULL; - + while ((r = execTok (spec, &s, &cmd_str, &cmd_len)) == 3) { if (cmd_len==5 && !memcmp ("-text", cmd_str, cmd_len)) @@ -1506,14 +1506,14 @@ static void execCode (struct lexSpec *spec, struct regxCode *code) if (r < 2) break; } - else if (cmd_len==10 && !memcmp ("-attribute", cmd_str, + else if (cmd_len==10 && !memcmp ("-attribute", cmd_str, cmd_len)) { r = execTok (spec, &s, &attribute_str, &attribute_len); if (r < 2) break; } - else + else yaz_log (YLOG_WARN, "bad data option: %.*s", cmd_len, cmd_str); } @@ -1577,7 +1577,7 @@ static void execCode (struct lexSpec *spec, struct regxCode *code) struct lexContext *lc = spec->context; r = execTok (spec, &s, &cmd_str, &cmd_len); p = regxStrz (cmd_str, cmd_len, ptmp); - + while (lc && strcmp (p, lc->name)) lc = lc->next; if (lc) @@ -1800,7 +1800,7 @@ int lexNode (struct lexSpec *spec, int *ptr) { last_rule = state->rule_no; last_ptr = *ptr; - } + } else if (state->rule_nno) { last_rule = state->rule_nno; @@ -1825,7 +1825,7 @@ static data1_node *lexRoot (struct lexSpec *spec, off_t offset, spec->stop_flag = 0; spec->d1_level = 0; - spec->context_stack_top = 0; + spec->context_stack_top = 0; while (lt) { if (!strcmp (lt->name, context_name)) diff --git a/index/mod_grs_sgml.c b/index/mod_grs_sgml.c index 82d719d..0a44e5b 100644 --- a/index/mod_grs_sgml.c +++ b/index/mod_grs_sgml.c @@ -40,7 +40,7 @@ int sgml_getc (void *clientData) { struct sgml_getc_info *p = (struct sgml_getc_info *) clientData; int res; - + if (p->off < p->size) return p->buf[(p->off)++]; if (p->size < p->buf_size) @@ -62,7 +62,7 @@ static data1_node *grs_read_sgml (struct grs_read_info *p) struct sgml_getc_info *sgi = (struct sgml_getc_info *) p->clientData; data1_node *node; int res; - + sgi->moffset = p->stream->tellf(p->stream); sgi->stream = p->stream; sgi->off = 0; diff --git a/index/mod_grs_xml.c b/index/mod_grs_xml.c index 7df0f32..ba4a671 100644 --- a/index/mod_grs_xml.c +++ b/index/mod_grs_xml.c @@ -102,7 +102,7 @@ static void cb_decl (void *user, const char *version, const char *encoding, attr_list[5] = standalone ? "yes" : "no"; attr_list[6] = 0; - + data1_mk_preprocess (ui->dh, ui->nmem, "xml", attr_list, ui->d1_stack[ui->level-1]); #if 0 @@ -111,7 +111,7 @@ static void cb_decl (void *user, const char *version, const char *encoding, encoding ? encoding : "null"); #endif } - + static void cb_processing (void *user, const char *target, const char *data) { @@ -120,7 +120,7 @@ static void cb_processing (void *user, const char *target, data1_mk_preprocess (ui->dh, ui->nmem, target, 0, ui->d1_stack[ui->level-1]); data1_mk_text_nf (ui->dh, ui->nmem, data, strlen(data), res); - + yaz_log (ui->loglevel, "decl processing target=%s data=%s", target ? target : "null", data ? data : "null"); @@ -161,7 +161,7 @@ static void cb_entity_decl (void *userData, const char *entityName, " publicId=%s notationName=%s", entityName, is_parameter_entity, value_length, value, base, systemId, publicId, notationName); - + } static int cb_external_entity(XML_Parser pparser, @@ -261,7 +261,7 @@ static int cb_encoding_handler (void *userData, const char *name, iconv_t t = iconv_open ("UNICODE", name); if (t == (iconv_t) (-1)) return 0; - + info->data = 0; /* signal that multibyte is not in use */ yaz_log (ui->loglevel, "Encoding handler of %s", name); for (i = 0; i<256; i++) @@ -290,7 +290,7 @@ static int cb_encoding_handler (void *userData, const char *name, int len = 2; int j = 0; info->map[i] = -1; - + while (len <= 4) { char sbuf[80]; @@ -413,9 +413,9 @@ data1_node *zebra_read_xml(data1_handle dh, uinfo.nmem = m; uinfo.d1_stack[0] = data1_mk_node2 (dh, m, DATA1N_root, 0); uinfo.d1_stack[1] = 0; /* indicate no children (see end of routine) */ - + parser = XML_ParserCreate (0 /* encoding */); - + XML_SetElementHandler (parser, cb_start, cb_end); XML_SetCharacterDataHandler (parser, cb_chardata); XML_SetXmlDeclHandler (parser, cb_decl); @@ -475,7 +475,7 @@ data1_node *zebra_read_xml(data1_handle dh, attr_list[3] = "UTF-8"; /* encoding */ attr_list[4] = 0; - + data1_insert_preprocess (uinfo.dh, uinfo.nmem, "xml", attr_list, uinfo.d1_stack[0]); } @@ -538,7 +538,7 @@ idzebra_filter &filter_type, 0, }; - + #endif /* diff --git a/index/mod_safari.c b/index/mod_safari.c index d36c450..05b49e1 100644 --- a/index/mod_safari.c +++ b/index/mod_safari.c @@ -151,9 +151,9 @@ static int filter_extract(void *clientData, struct recExtractCtrl *p) recWord.index_type = type_cstr; if (tinfo->segments) { - if (sscanf(cp, ZINT_FORMAT " " ZINT_FORMAT " " ZINT_FORMAT + if (sscanf(cp, ZINT_FORMAT " " ZINT_FORMAT " " ZINT_FORMAT ZINT_FORMAT " %39s %n", - &recWord.record_id, &recWord.section_id, + &recWord.record_id, &recWord.section_id, &recWord.segment, &recWord.seqno, field, &nor) < 5) @@ -277,7 +277,7 @@ static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p) } p->output_format = yaz_oid_recsyn_sutrs; p->rec_buf = filter_buf; - p->rec_len = filter_ptr; + p->rec_len = filter_ptr; return 0; } diff --git a/index/mod_text.c b/index/mod_text.c index 3ff6c3b..94131cc 100644 --- a/index/mod_text.c +++ b/index/mod_text.c @@ -120,12 +120,12 @@ static int filter_extract(void *clientData, struct recExtractCtrl *p) do { int i = 0; - + r = buf_getchar(tinfo, fi, w); while (r > 0 && i < 511 && w[i] != '\n' && w[i] != '\r') { i++; - r = buf_getchar(tinfo, fi, w + i); + r = buf_getchar(tinfo, fi, w + i); } if (i) { @@ -232,7 +232,7 @@ static int filter_retrieve(void *clientData, struct recRetrieveCtrl *p) } p->output_format = yaz_oid_recsyn_sutrs; p->rec_buf = filter_buf; - p->rec_len = filter_ptr; + p->rec_len = filter_ptr; return 0; } diff --git a/index/rank.h b/index/rank.h index 530da63..ffae49a 100644 --- a/index/rank.h +++ b/index/rank.h @@ -28,7 +28,7 @@ struct rank_control { char *name; void *(*create)(ZebraHandle zh); void (*destroy)(struct zebra_register *reg, void *class_handle); - void *(*begin)(struct zebra_register *reg, + void *(*begin)(struct zebra_register *reg, void *class_handle, RSET rset, NMEM nmem, TERMID *terms, int numterms); /* ### Could add parameters to begin: diff --git a/index/rank1.c b/index/rank1.c index a9da489..b4f9be8 100644 --- a/index/rank1.c +++ b/index/rank1.c @@ -68,12 +68,12 @@ static int log2_int(zint g) } /* - * create: Creates/Initialises this rank handler. This routine is + * create: Creates/Initialises this rank handler. This routine is * called exactly once. The routine returns the class_handle. */ static void *create(ZebraHandle zh) { - struct rank_class_info *ci = + struct rank_class_info *ci = (struct rank_class_info *) xmalloc(sizeof(*ci)); if (!log_initialized) @@ -104,11 +104,11 @@ static void destroy(struct zebra_register *reg, void *class_handle) * each result set. The returned handle is a "set handle" and * will be used in each of the handlers below. */ -static void *begin(struct zebra_register *reg, +static void *begin(struct zebra_register *reg, void *class_handle, RSET rset, NMEM nmem, TERMID *terms, int numterms) { - struct rank_set_info *si = + struct rank_set_info *si = (struct rank_set_info *) nmem_malloc(nmem,sizeof(*si)); int i; @@ -117,13 +117,13 @@ static void *begin(struct zebra_register *reg, si->no_rank_entries = 0; si->nmem=nmem; si->entries = (struct rank_term_info *) - nmem_malloc(si->nmem, sizeof(*si->entries)*numterms); + nmem_malloc(si->nmem, sizeof(*si->entries)*numterms); for (i = 0; i < numterms; i++) { zint g = rset_count(terms[i]->rset); - yaz_log(log_level, "i=%d flags=%s '%s'", i, + yaz_log(log_level, "i=%d flags=%s '%s'", i, terms[i]->flags, terms[i]->name ); - if (!strncmp(terms[i]->flags, "rank,", 5)) + if (!strncmp(terms[i]->flags, "rank,", 5)) { const char *cp = strstr(terms[i]->flags+4, ",w="); si->entries[i].rank_flag = 1; @@ -140,7 +140,7 @@ static void *begin(struct zebra_register *reg, si->entries[i].local_occur = 0; /* FIXME */ si->entries[i].global_occur = g; si->entries[i].global_inv = 32 - log2_int(g); - yaz_log(log_level, " global_inv = %d g = " ZINT_FORMAT, + yaz_log(log_level, " global_inv = %d g = " ZINT_FORMAT, (int) (32-log2_int(g)), g); si->entries[i].term = terms[i]; si->entries[i].term_index=i; @@ -179,12 +179,12 @@ static void add(void *set_handle, int seqno, TERMID term) assert(ti); si->last_pos = seqno; ti->local_occur++; - yaz_log(log_level, "rank-1 add seqno=%d term=%s count=%d", + yaz_log(log_level, "rank-1 add seqno=%d term=%s count=%d", seqno, term->name,ti->local_occur); } /* - * calc: Called for each document in a result. This handler should + * calc: Called for each document in a result. This handler should * produce a score based on previous call(s) to the add handler. The * score should be between 0 and 1000. If score cannot be obtained * -1 should be returned. @@ -195,7 +195,7 @@ static int calc_1(void *set_handle, zint sysno, zint staticrank, int i, lo, divisor, score = 0; struct rank_set_info *si = (struct rank_set_info *) set_handle; - if (!si->no_rank_entries) + if (!si->no_rank_entries) return -1; /* ranking not enabled for any terms */ for (i = 0; i < si->no_entries; i++) @@ -252,7 +252,7 @@ static struct rank_control rank_1_control = { add, }; struct rank_control *rank_1_class = &rank_1_control; - + static struct rank_control rank_2_control = { "rank-2", create, @@ -262,7 +262,7 @@ static struct rank_control rank_2_control = { calc_2, add, }; - + struct rank_control *rank_2_class = &rank_2_control; /* * Local variables: diff --git a/index/ranksimilarity.c b/index/ranksimilarity.c index 883c9ce..b8035e0 100644 --- a/index/ranksimilarity.c +++ b/index/ranksimilarity.c @@ -97,7 +97,7 @@ struct ranksimilarity_set_info { static void ranksimilar_rec_reset(struct ranksimilarity_set_info *si) { int i; - + for (i = 0; i < si->no_terms_query; i++) { si->entries[i].freq_term_docfield = 0; @@ -106,12 +106,12 @@ static void ranksimilar_rec_reset(struct ranksimilarity_set_info *si) /* - * create: Creates/Initialises this rank handler. This routine is + * create: Creates/Initialises this rank handler. This routine is * called exactly once. The routine returns the class_handle. */ static void *create (ZebraHandle zh) { - struct ranksimilarity_class_info *ci = + struct ranksimilarity_class_info *ci = (struct ranksimilarity_class_info *) xmalloc (sizeof(*ci)); if (!log_initialized) @@ -130,7 +130,7 @@ static void *create (ZebraHandle zh) */ static void destroy (struct zebra_register *reg, void *class_handle) { - struct ranksimilarity_class_info *ci + struct ranksimilarity_class_info *ci = (struct ranksimilarity_class_info *) class_handle; yaz_log(log_level, "destroy()"); xfree (ci); @@ -142,16 +142,16 @@ static void destroy (struct zebra_register *reg, void *class_handle) * each result set. The returned handle is a "set handle" and * will be used in each of the handlers below. */ -static void *begin (struct zebra_register *reg, +static void *begin (struct zebra_register *reg, void *class_handle, RSET rset, NMEM nmem, TERMID *terms, int numterms) { - struct ranksimilarity_set_info *si = + struct ranksimilarity_set_info *si = (struct ranksimilarity_set_info *) nmem_malloc (nmem, sizeof(*si)); int i; - + yaz_log(log_level, "begin() numterms=%d", numterms); - + /* setting database global statistics */ si->no_docs_database = -1; /* TODO */ si->no_terms_database = -1; /* TODO */ @@ -163,7 +163,7 @@ static void *begin (struct zebra_register *reg, /* setting internal data structures */ si->nmem=nmem; si->entries = (struct ranksimilarity_term_info *) - nmem_malloc (si->nmem, sizeof(*si->entries)*numterms); + nmem_malloc (si->nmem, sizeof(*si->entries)*numterms); /* reset the counts for the next term */ ranksimilar_rec_reset(si); @@ -176,27 +176,27 @@ static void *begin (struct zebra_register *reg, /* adding to number of rank entries */ - if (strncmp (terms[i]->flags, "rank,", 5)) + if (strncmp (terms[i]->flags, "rank,", 5)) { si->entries[i].rank_flag = 0; - yaz_log(log_level, "begin() terms[%d]: '%s' flags=%s not ranked", + yaz_log(log_level, "begin() terms[%d]: '%s' flags=%s not ranked", i, terms[i]->name, terms[i]->flags); - } - else + } + else { const char *cp = strstr(terms[i]->flags+4, ",w="); zint no_docs_fieldindex = 0; zint no_terms_fieldindex = 0; - - yaz_log(log_level, "begin() terms[%d]: '%s' flags=%s", + + yaz_log(log_level, "begin() terms[%d]: '%s' flags=%s", i, terms[i]->name, terms[i]->flags); (si->no_ranked_terms_query)++; ol = terms[i]->ol; si->entries[i].rank_flag = 1; - /* notice that the call to rset_count(rset) has he side-effect + /* notice that the call to rset_count(rset) has he side-effect of setting rset->hits_limit = rset_count(rset) ??? */ si->entries[i].freq_term_resset = rset_count(terms[i]->rset); si->entries[i].no_docs_resset = terms[i]->rset->hits_count; @@ -209,20 +209,20 @@ static void *begin (struct zebra_register *reg, /* - yaz_log(log_level, "begin() rset_count(terms[%d]->rset) = " - ZINT_FORMAT, i, rset_count(terms[i]->rset)); + yaz_log(log_level, "begin() rset_count(terms[%d]->rset) = " + ZINT_FORMAT, i, rset_count(terms[i]->rset)); yaz_log(log_level, "begin() terms[%d]->rset->hits_limit = " - ZINT_FORMAT, i, terms[i]->rset->hits_limit); + ZINT_FORMAT, i, terms[i]->rset->hits_limit); yaz_log(log_level, "begin() terms[%d]->rset->hits_count = " - ZINT_FORMAT, i, terms[i]->rset->hits_count); + ZINT_FORMAT, i, terms[i]->rset->hits_count); yaz_log(log_level, "begin() terms[%d]->rset->hits_round = " - ZINT_FORMAT, i, terms[i]->rset->hits_round); - yaz_log(log_level, "begin() terms[%d]->rset->hits_approx = %d", + ZINT_FORMAT, i, terms[i]->rset->hits_round); + yaz_log(log_level, "begin() terms[%d]->rset->hits_approx = %d", i, terms[i]->rset->hits_approx); */ - + /* looping indexes where term terms[i] is found */ - + for (; ol; ol = ol->next) { const char *index_type = 0; @@ -232,33 +232,33 @@ static void *begin (struct zebra_register *reg, zebraExplain_lookup_ord(reg->zei, ol->ord, &index_type, &db, &string_index); - - no_docs_fieldindex + + no_docs_fieldindex += zebraExplain_ord_get_doc_occurrences(reg->zei, ol->ord); - no_terms_fieldindex + no_terms_fieldindex += zebraExplain_ord_get_term_occurrences(reg->zei, ol->ord); if (string_index) - yaz_log(log_level, + yaz_log(log_level, "begin() index: ord=%d type=%s db=%s str-index=%s", ol->ord, index_type, db, string_index); else - yaz_log(log_level, + yaz_log(log_level, "begin() index: ord=%d type=%s db=%s", ol->ord, index_type, db); } - + si->entries[i].no_docs_fieldindex = no_docs_fieldindex; si->entries[i].no_terms_fieldindex = no_terms_fieldindex; } - + si->entries[i].term = terms[i]; si->entries[i].term_index=i; - + /* setting next entry in term */ terms[i]->rankpriv = &(si->entries[i]); } - + return si; } @@ -280,9 +280,9 @@ static void end (struct zebra_register *reg, void *set_handle) */ static void add (void *set_handle, int seqno, TERMID term) { - struct ranksimilarity_set_info *si + struct ranksimilarity_set_info *si = (struct ranksimilarity_set_info *) set_handle; - struct ranksimilarity_term_info *ti; + struct ranksimilarity_term_info *ti; assert(si); if (!term) { @@ -294,12 +294,12 @@ static void add (void *set_handle, int seqno, TERMID term) assert(ti); si->last_pos = seqno; ti->freq_term_docfield++; - /*yaz_log(log_level, "add() seqno=%d term=%s freq_term_docfield=%d", + /*yaz_log(log_level, "add() seqno=%d term=%s freq_term_docfield=%d", seqno, term->name, ti->freq_term_docfield); */ } /* - * calc: Called for each document in a result. This handler should + * calc: Called for each document in a result. This handler should * produce a score based on previous call(s) to the add handler. The * score should be between 0 and 1000. If score cannot be obtained * -1 should be returned. @@ -308,27 +308,27 @@ static int calc (void *set_handle, zint sysno, zint staticrank, int *stop_flag) { int i, score = 0; - struct ranksimilarity_set_info *si + struct ranksimilarity_set_info *si = (struct ranksimilarity_set_info *) set_handle; - - + + yaz_log(log_level, "calc() sysno = " ZINT_FORMAT, sysno); yaz_log(log_level, "calc() staticrank = " ZINT_FORMAT, staticrank); - - yaz_log(log_level, "calc() si->no_terms_query = %d", + + yaz_log(log_level, "calc() si->no_terms_query = %d", si->no_terms_query); - yaz_log(log_level, "calc() si->no_ranked_terms_query = %d", + yaz_log(log_level, "calc() si->no_ranked_terms_query = %d", si->no_ranked_terms_query); - yaz_log(log_level, "calc() si->no_docs_database = " ZINT_FORMAT, - si->no_docs_database); - yaz_log(log_level, "calc() si->no_terms_database = " ZINT_FORMAT, - si->no_terms_database); + yaz_log(log_level, "calc() si->no_docs_database = " ZINT_FORMAT, + si->no_docs_database); + yaz_log(log_level, "calc() si->no_terms_database = " ZINT_FORMAT, + si->no_terms_database); + - if (!si->no_ranked_terms_query) return -1; /* ranking not enabled for any terms */ - + /* if we set *stop_flag = 1, we stop processing (of result set list) */ @@ -336,34 +336,34 @@ static int calc (void *set_handle, zint sysno, zint staticrank, /* you may use all the gathered statistics here */ for (i = 0; i < si->no_terms_query; i++) { - yaz_log(log_level, "calc() entries[%d] termid %p", + yaz_log(log_level, "calc() entries[%d] termid %p", i, si->entries[i].term); if (si->entries[i].term){ - yaz_log(log_level, "calc() entries[%d] term '%s' flags=%s", + yaz_log(log_level, "calc() entries[%d] term '%s' flags=%s", i, si->entries[i].term->name, si->entries[i].term->flags); - yaz_log(log_level, "calc() entries[%d] rank_flag %d", + yaz_log(log_level, "calc() entries[%d] rank_flag %d", i, si->entries[i].rank_flag ); - yaz_log(log_level, "calc() entries[%d] fieldindex_weight %d", + yaz_log(log_level, "calc() entries[%d] fieldindex_weight %d", i, si->entries[i].fieldindex_weight ); - yaz_log(log_level, "calc() entries[%d] freq_term_docfield %d", + yaz_log(log_level, "calc() entries[%d] freq_term_docfield %d", i, si->entries[i].freq_term_docfield ); yaz_log(log_level, "calc() entries[%d] freq_term_resset " ZINT_FORMAT, i, si->entries[i].freq_term_resset ); - yaz_log(log_level, "calc() entries[%d] no_docs_resset " ZINT_FORMAT, + yaz_log(log_level, "calc() entries[%d] no_docs_resset " ZINT_FORMAT, i, si->entries[i].no_docs_resset ); - yaz_log(log_level, "calc() entries[%d] no_docs_fieldindex " - ZINT_FORMAT, + yaz_log(log_level, "calc() entries[%d] no_docs_fieldindex " + ZINT_FORMAT, i, si->entries[i].no_docs_fieldindex ); - yaz_log(log_level, "calc() entries[%d] no_terms_fieldindex " - ZINT_FORMAT, + yaz_log(log_level, "calc() entries[%d] no_terms_fieldindex " + ZINT_FORMAT, i, si->entries[i].no_terms_fieldindex ); } } - + /* reset the counts for the next term */ ranksimilar_rec_reset(si); - + /* staticrank = 0 is highest, MAXINT lowest */ if (staticrank >= INT_MAX) @@ -375,7 +375,7 @@ static int calc (void *set_handle, zint sysno, zint staticrank, /* debugging statistics output */ - yaz_log(log_level, "calc() statistics: score = %d", score); + yaz_log(log_level, "calc() statistics: score = %d", score); return score; } @@ -407,7 +407,7 @@ static struct rank_control rank_control = { calc, add, }; - + struct rank_control *rank_similarity_class = &rank_control; /* * Local variables: diff --git a/index/rankstatic.c b/index/rankstatic.c index 09f593e..f3c7bed 100644 --- a/index/rankstatic.c +++ b/index/rankstatic.c @@ -41,7 +41,7 @@ struct rank_set_info { }; /* - * create: Creates/Initialises this rank handler. This routine is + * create: Creates/Initialises this rank handler. This routine is * called exactly once. The routine returns the class_handle. */ static void *create (ZebraHandle zh) @@ -71,11 +71,11 @@ static void destroy (struct zebra_register *reg, void *class_handle) * each result set. The returned handle is a "set handle" and * will be used in each of the handlers below. */ -static void *begin (struct zebra_register *reg, +static void *begin (struct zebra_register *reg, void *class_handle, RSET rset, NMEM nmem, TERMID *terms, int numterms) { - struct rank_set_info *si = + struct rank_set_info *si = (struct rank_set_info *) nmem_malloc (nmem, sizeof(*si)); int i; @@ -86,7 +86,7 @@ static void *begin (struct zebra_register *reg, { struct ord_list *ol = terms[i]->ol; - yaz_log(log_level, "i=%d flags=%s '%s'", i, + yaz_log(log_level, "i=%d flags=%s '%s'", i, terms[i]->flags, terms[i]->name ); for (; ol; ol = ol->next) @@ -107,7 +107,7 @@ static void *begin (struct zebra_register *reg, yaz_log(log_level, " ord=%d index_type=%s db=%s set=%d use=%d", ol->ord, index_type, db, set, use); } - if (!strncmp (terms[i]->flags, "rank,", 5)) + if (!strncmp (terms[i]->flags, "rank,", 5)) (si->no_rank_entries)++; } return si; @@ -133,7 +133,7 @@ static void add (void *set_handle, int seqno, TERMID term) } /* - * calc: Called for each document in a result. This handler should + * calc: Called for each document in a result. This handler should * produce a score based on previous call(s) to the add handler. The * score should be between 0 and 1000. If score cannot be obtained * -1 should be returned. @@ -181,7 +181,7 @@ static struct rank_control rank_control = { calc, add, }; - + struct rank_control *rank_static_class = &rank_control; /* * Local variables: diff --git a/index/recctrl.c b/index/recctrl.c index f24395e..3d2f929 100644 --- a/index/recctrl.c +++ b/index/recctrl.c @@ -134,7 +134,7 @@ static void load_from_dir(RecTypeClass *rts, NMEM nmem, const char *dirname) if (dir) { struct dirent *de; - + while ((de = readdir(dir))) { size_t dlen = strlen(de->d_name); @@ -165,7 +165,7 @@ static void load_from_dir(RecTypeClass *rts, NMEM nmem, const char *dirname) const char *err = dlerror(); yaz_log(YLOG_WARN, "dlopen failed %s %s", fname, err ? err : "none"); - + } } } @@ -182,11 +182,11 @@ void recTypeClass_load_modules(RecTypeClass *rts, NMEM nmem, const char *comp_ptr; char comp[FILENAME_MAX+1]; size_t len; - + len = yaz_filepath_comp(&module_path, &comp_ptr); if (!len || len >= FILENAME_MAX) break; - + memcpy(comp, comp_ptr, len); comp[len] = '\0'; @@ -201,7 +201,7 @@ static void recTypeClass_add(struct recTypeClass **rts, RecType *rt, { struct recTypeClass *r = (struct recTypeClass *) nmem_malloc (nmem, sizeof(*r)); - + r->next = *rts; *rts = r; @@ -236,7 +236,7 @@ RecTypes recTypes_init(RecTypeClass rtc, data1_handle dh) RecTypes rts = (RecTypes) nmem_malloc(data1_nmem_get(dh), sizeof(*rts)); struct recTypeInstance **rti = &rts->entries; - + rts->dh = dh; for (; rtc; rtc = rtc->next) diff --git a/index/recgrs.c b/index/recgrs.c index ef0acb4..ea2eed2 100644 --- a/index/recgrs.c +++ b/index/recgrs.c @@ -70,30 +70,30 @@ static int sp_range(struct source_parser *sp, data1_node *n, RecWord *wrd) { int start, len; RecWord tmp_w; - + /* ( */ sp_lex(sp); if (sp->lookahead != '(') return 0; sp_lex(sp); /* skip ( */ - + /* 1st arg: string */ if (!sp_expr(sp, n, wrd)) return 0; - + if (sp->lookahead != ',') - return 0; + return 0; sp_lex(sp); /* skip , */ - + /* 2nd arg: start */ if (!sp_expr(sp, n, &tmp_w)) return 0; start = atoi_n(tmp_w.term_buf, tmp_w.term_len); - + if (sp->lookahead == ',') { sp_lex(sp); /* skip , */ - + /* 3rd arg: length */ if (!sp_expr(sp, n, &tmp_w)) return 0; @@ -101,12 +101,12 @@ static int sp_range(struct source_parser *sp, data1_node *n, RecWord *wrd) } else len = wrd->term_len; - + /* ) */ if (sp->lookahead != ')') - return 0; + return 0; sp_lex(sp); - + if (wrd->term_buf) { if (start >= wrd->term_len) @@ -138,7 +138,7 @@ static int sp_first(struct source_parser *sp, data1_node *n, RecWord *wrd) RecWord search_w; int i; sp_lex(sp); /* skip , */ - + if (!sp_expr(sp, n, &search_w)) return 0; for (i = 0; iterm_len; i++) @@ -182,7 +182,7 @@ static int sp_expr(struct source_parser *sp, data1_node *n, RecWord *wrd) else if (sp->len == 3 && !memcmp(sp->tok, "tag", sp->len)) { if (n->which == DATA1N_tag) - { + { wrd->term_buf = n->u.tag.tag; wrd->term_len = strlen(n->u.tag.tag); } @@ -198,13 +198,13 @@ static int sp_expr(struct source_parser *sp, data1_node *n, RecWord *wrd) if (!sp_expr(sp, n, &tmp_w)) return 0; - + wrd->term_buf = ""; wrd->term_len = 0; if (n->which == DATA1N_tag) { data1_xattr *p = n->u.tag.attributes; - while (p && strlen(p->name) != tmp_w.term_len && + while (p && strlen(p->name) != tmp_w.term_len && memcmp (p->name, tmp_w.term_buf, tmp_w.term_len)) p = p->next; if (p) @@ -243,7 +243,7 @@ static int sp_expr(struct source_parser *sp, data1_node *n, RecWord *wrd) wrd->term_buf = b; sp_lex(sp); } - else + else { wrd->term_buf = ""; wrd->term_len = 0; @@ -267,8 +267,8 @@ static void source_parser_destroy(struct source_parser *sp) nmem_destroy(sp->nmem); xfree(sp); } - -static int sp_parse(struct source_parser *sp, + +static int sp_parse(struct source_parser *sp, data1_node *n, RecWord *wrd, const char *src) { sp->len = 0; @@ -286,14 +286,14 @@ int d1_check_xpath_predicate(data1_node *n, struct xpath_predicate *p) int res = 1; char *attname; data1_xattr *attr; - + if (!p) { return 1; } else { if (p->which == XPATH_PREDICATE_RELATION) { if (p->u.relation.name[0]) { if (*p->u.relation.name != '@') { - yaz_log(YLOG_WARN, + yaz_log(YLOG_WARN, " Only attributes (@) are supported in xelm xpath predicates"); yaz_log(YLOG_WARN, "predicate %s ignored", p->u.relation.name); return 1; @@ -305,14 +305,14 @@ int d1_check_xpath_predicate(data1_node *n, struct xpath_predicate *p) if (!strcmp(attr->name, attname)) { if (p->u.relation.op[0]) { if (*p->u.relation.op != '=') { - yaz_log(YLOG_WARN, + yaz_log(YLOG_WARN, "Only '=' relation is supported (%s)",p->u.relation.op); yaz_log(YLOG_WARN, "predicate %s ignored", p->u.relation.name); res = 1; break; } else { if (!strcmp(attr->value, p->u.relation.value)) { res = 1; break; - } + } } } else { /* attribute exists, no value specified */ @@ -324,15 +324,15 @@ int d1_check_xpath_predicate(data1_node *n, struct xpath_predicate *p) } else { return 1; } - } + } else if (p->which == XPATH_PREDICATE_BOOLEAN) { if (!strcmp(p->u.boolean.op,"and")) { - return d1_check_xpath_predicate(n, p->u.boolean.left) - && d1_check_xpath_predicate(n, p->u.boolean.right); + return d1_check_xpath_predicate(n, p->u.boolean.left) + && d1_check_xpath_predicate(n, p->u.boolean.right); } else if (!strcmp(p->u.boolean.op,"or")) { - return (d1_check_xpath_predicate(n, p->u.boolean.left) - || d1_check_xpath_predicate(n, p->u.boolean.right)); + return (d1_check_xpath_predicate(n, p->u.boolean.left) + || d1_check_xpath_predicate(n, p->u.boolean.right)); } else { yaz_log(YLOG_WARN, "Unknown boolean relation %s, ignored",p->u.boolean.op); return 1; @@ -350,7 +350,7 @@ static int dfa_match_first(struct DFA_state **dfaar, const char *text) int i; const char *p = text; unsigned char c; - + for (c = *p++, t = s->trans, i = s->tran_no; --i >= 0; t++) { if (c >= t->ch[0] && c <= t->ch[1]) @@ -375,7 +375,7 @@ static int dfa_match_first(struct DFA_state **dfaar, const char *text) } /* *ostrich* - + New function, looking for xpath "element" definitions in abs, by tagpath, using a kind of ugly regxp search.The DFA was built while parsing abs, so here we just go trough them and try to match @@ -397,11 +397,11 @@ data1_termlist *xpath_termlist_by_tagpath(char *tagpath, data1_node *n) data1_xpelement *xpe = 0; data1_node *nn; -#ifdef ENHANCED_XELM +#ifdef ENHANCED_XELM struct xpath_location_step *xp; #endif char *pexpr = xmalloc(strlen(tagpath)+5); - + sprintf(pexpr, "/%s\n", tagpath); for (xpe = abs->xp_elements; xpe; xpe = xpe->next) @@ -426,14 +426,14 @@ data1_termlist *xpath_termlist_by_tagpath(char *tagpath, data1_node *n) } assert(ok == 0 || ok == 1); if (ok) { -#ifdef ENHANCED_XELM +#ifdef ENHANCED_XELM /* we have to check the perdicates up to the root node */ xp = xpe->xpath; - + /* find the first tag up in the node structure */ for (nn = n; nn && nn->which != DATA1N_tag; nn = nn->parent) ; - + /* go from inside out in the node structure, while going backwards trough xpath location steps ... */ for (i = xpe->xpath_len - 1; i>0; i--) @@ -443,7 +443,7 @@ data1_termlist *xpath_termlist_by_tagpath(char *tagpath, data1_node *n) ok = 0; break; } - + if (nn->which == DATA1N_tag) nn = nn->parent; } @@ -451,10 +451,10 @@ data1_termlist *xpath_termlist_by_tagpath(char *tagpath, data1_node *n) if (ok) break; } - } - + } + xfree(pexpr); - + if (xpe) { return xpe->termlists; } else { @@ -474,7 +474,7 @@ data1_termlist *xpath_termlist_by_tagpath(char *tagpath, data1_node *n) *ostrich* Now, if there is a matching xelm described in abs, for the - indexed element or the attribute, then the data is handled according + indexed element or the attribute, then the data is handled according to those definitions... modified by pop, 2002-12-13 @@ -490,7 +490,7 @@ static void index_xpath_attr(char *tag_path, char *name, char *value, 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"; @@ -529,7 +529,7 @@ static void mk_tag_path_full(char *tag_path_full, size_t max, data1_node *n) } tag_path_full[flen] = 0; } - + static void index_xpath(struct source_parser *sp, data1_node *n, struct recExtractCtrl *p, @@ -543,8 +543,8 @@ static void index_xpath(struct source_parser *sp, data1_node *n, int termlist_only = 1; data1_termlist *tl; - if (!n->root->u.root.absyn - || + if (!n->root->u.root.absyn + || n->root->u.root.absyn->xpath_indexing == DATA1_XPATH_INDEXING_ENABLE) { termlist_only = 0; @@ -558,9 +558,9 @@ static void index_xpath(struct source_parser *sp, data1_node *n, wrd->term_len = n->u.data.len; mk_tag_path_full(tag_path_full, sizeof(tag_path_full), n); - + /* If we have a matching termlist... */ - if (n->root->u.root.absyn && + if (n->root->u.root.absyn && (tl = xpath_termlist_by_tagpath(tag_path_full, n))) { zint max_seqno = 0; @@ -598,9 +598,9 @@ static void index_xpath(struct source_parser *sp, data1_node *n, } if (max_seqno) wrd->seqno = max_seqno; - + } - /* xpath indexing is done, if there was no termlist given, + /* xpath indexing is done, if there was no termlist given, or no ! in the termlist, and default indexing is enabled... */ if (!p->flagShowRecords && !termlist_only) { @@ -631,23 +631,23 @@ static void index_xpath(struct source_parser *sp, data1_node *n, if (!termlist_only) (*p->tokenAdd)(wrd); /* index element pag (AKA tag path) */ - + if (xpath_is_start == 1) /* only for the starting tag... */ { #define MAX_ATTR_COUNT 50 data1_termlist *tll[MAX_ATTR_COUNT]; - + int i = 0; for (xp = n->u.tag.attributes; xp; xp = xp->next) { char comb[512]; - char attr_tag_path_full[1024]; - + char attr_tag_path_full[1024]; + /* this could be cached as well */ sprintf(attr_tag_path_full, "@%s/%s", xp->name, tag_path_full); tll[i] = xpath_termlist_by_tagpath(attr_tag_path_full,n); - + if (!termlist_only) { /* attribute (no value) */ @@ -655,11 +655,11 @@ static void index_xpath(struct source_parser *sp, data1_node *n, wrd->index_name = ZEBRA_XPATH_ATTR_NAME; wrd->term_buf = xp->name; wrd->term_len = strlen(xp->name); - + wrd->seqno--; (*p->tokenAdd)(wrd); - - if (xp->value + + if (xp->value && strlen(xp->name) + strlen(xp->value) < sizeof(comb)-2) { @@ -667,25 +667,25 @@ static void index_xpath(struct source_parser *sp, data1_node *n, strcpy(comb, xp->name); strcat(comb, "="); strcat(comb, xp->value); - + wrd->index_name = ZEBRA_XPATH_ATTR_NAME; wrd->index_type = "0"; wrd->term_buf = comb; wrd->term_len = strlen(comb); wrd->seqno--; - + (*p->tokenAdd)(wrd); } - } + } i++; } - + i = 0; for (xp = n->u.tag.attributes; xp; xp = xp->next) { data1_termlist *tl; char attr_tag_path_full[1024]; int xpdone = 0; - + sprintf(attr_tag_path_full, "@%s/%s", xp->name, tag_path_full); if ((tl = tll[i])) @@ -702,7 +702,7 @@ static void index_xpath(struct source_parser *sp, data1_node *n, xpdone = 1; } else { /* index attribute value (only path/@attr) */ - if (xp->value) + if (xp->value) { wrd->index_name = tl->index_name; wrd->index_type = tl->structure; @@ -713,8 +713,8 @@ static void index_xpath(struct source_parser *sp, data1_node *n, } } } - /* if there was no termlist for the given path, - or the termlist didn't have a ! element, index + /* if there was no termlist for the given path, + or the termlist didn't have a ! element, index the attribute as "w" */ if (!xpdone && !termlist_only) { @@ -738,7 +738,7 @@ static void index_termlist(struct source_parser *sp, data1_node *par, * this has the effect of indexing locally defined tags with * the attribute of their ancestor in the record. */ - + while (!par->u.tag.element) if (!par->parent || !(par=get_parent_tag(p->dh, par->parent))) break; @@ -825,7 +825,7 @@ static int dumpkeys_r(struct source_parser *sp, index_termlist(sp, n, n, p, level, wrd); /* index start tag */ if (n->root->u.root.absyn) - index_xpath(sp, n, p, level, wrd, ZEBRA_XPATH_ELM_BEGIN, + index_xpath(sp, n, p, level, wrd, ZEBRA_XPATH_ELM_BEGIN, 1 /* is start */); } @@ -854,14 +854,14 @@ static int dumpkeys_r(struct source_parser *sp, if (par) index_termlist(sp, par, n, p, level, wrd); - index_xpath(sp, n, p, level, wrd, ZEBRA_XPATH_CDATA, + index_xpath(sp, n, p, level, wrd, ZEBRA_XPATH_CDATA, 0 /* is start */); } if (n->which == DATA1N_tag) { /* index end tag */ - index_xpath(sp, n, p, level, wrd, ZEBRA_XPATH_ELM_END, + index_xpath(sp, n, p, level, wrd, ZEBRA_XPATH_ELM_END, 0 /* is start */); } @@ -889,7 +889,7 @@ int grs_extract_tree(struct recExtractCtrl *p, data1_node *n) (*p->schemaAdd)(p, n->u.root.absyn->oid); (*p->init)(p, &wrd); - /* data1_pr_tree(p->dh, n, stdout); */ + /* data1_pr_tree(p->dh, n, stdout); */ return dumpkeys(n, p, &wrd); } @@ -1021,7 +1021,7 @@ static int process_comp(data1_handle dh, data1_node *n, Z_RecordComposition *c, } /* Add Zebra info in separate namespace ... - 359 @@ -1050,7 +1050,7 @@ static void zebra_xml_metadata(struct recRetrieveCtrl *p, data1_node *top, data1_mk_text(p->dh, mem, "\n", top); data1_mk_text(p->dh, mem, i4, n); - + data1_mk_tag_data_int(p->dh, n, "size", p->recordSize, mem); if (p->score != -1) @@ -1082,7 +1082,7 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, const Odr_oid *requested_schema = 0; data1_marctab *marctab; int dummy; - + mem = nmem_create(); gri.stream = p->stream; gri.mem = mem; @@ -1116,7 +1116,7 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, sprintf(dnew->u.data.data, "%d", p->recordSize); dnew->u.data.len = strlen(dnew->u.data.data); } - + tagname = data1_systag_lookup(node->u.root.absyn, "rank", "rank"); if (tagname && p->score >= 0 && (dnew = data1_mk_tag_data_wd(p->dh, top, tagname, mem))) @@ -1136,7 +1136,7 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, yaz_log(YLOG_DEBUG, "grs_retrieve: %s", tagname); dnew->u.data.what = DATA1I_text; dnew->u.data.data = dnew->lbuf; - + sprintf(dnew->u.data.data, ZINT_FORMAT, p->localno); dnew->u.data.len = strlen(dnew->u.data.data); } @@ -1161,7 +1161,7 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, requested_schema = p->comp->u.complex->generic->schema.oid; } /* If schema has been specified, map if possible, then check that - * we got the right one + * we got the right one */ if (requested_schema) { @@ -1180,7 +1180,7 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, break; } } - if (node->u.root.absyn + if (node->u.root.absyn && oid_oidcmp(requested_schema, node->u.root.absyn->oid)) { p->diagnostic = YAZ_BIB1_RECORD_NOT_AVAILABLE_IN_REQUESTED_SYNTAX; @@ -1210,13 +1210,13 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, } } yaz_log(YLOG_DEBUG, "grs_retrieve: schemaIdentifier"); - if (node->u.root.absyn && node->u.root.absyn->oid + if (node->u.root.absyn && node->u.root.absyn->oid && !oid_oidcmp(p->input_format, yaz_oid_recsyn_grs_1)) { char oid_str[OID_STR_MAX]; char *dot_str = oid_oid_to_dotstring(node->u.root.absyn->oid, oid_str); - - if (dot_str && (dnew = data1_mk_tag_data_wd(p->dh, top, + + if (dot_str && (dnew = data1_mk_tag_data_wd(p->dh, top, "schemaIdentifier", mem))) { dnew->u.data.what = DATA1I_oid; @@ -1278,7 +1278,7 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, { /* ensure our data1 tree is UTF-8 */ data1_iconv(p->dh, mem, node, "UTF-8", data1_get_encoding(p->dh, node)); - + if (!(p->rec_buf = data1_nodetoexplain(p->dh, node, selected, p->odr))) p->diagnostic = YAZ_BIB1_RECORD_NOT_AVAILABLE_IN_REQUESTED_SYNTAX; diff --git a/index/recindex.c b/index/recindex.c index 8aa0c85..c0b694c 100644 --- a/index/recindex.c +++ b/index/recindex.c @@ -59,7 +59,7 @@ static void rect_log_item(int level, const void *b, const char *txt) memcpy(&ent, (const char *)b + sizeof(sys) + 1, len); yaz_log(YLOG_LOG, "%s " ZINT_FORMAT " next=" ZINT_FORMAT " sz=%d", txt, sys, ent.next, ent.size); - + } else yaz_log(YLOG_LOG, "%s " ZINT_FORMAT, txt, sys); @@ -136,7 +136,7 @@ recindex_t recindex_open(BFiles bfs, int rw, int use_isamb) recindex_t p = xmalloc(sizeof(*p)); p->index_BFile = 0; p->isamb = 0; - + p->index_fname = "reci"; p->index_BFile = bf_open(bfs, p->index_fname, RIDX_CHUNK, rw); if (p->index_BFile == NULL) @@ -145,7 +145,7 @@ recindex_t recindex_open(BFiles bfs, int rw, int use_isamb) xfree(p); return 0; } - + if (use_isamb) { int isam_block_size = 4096; @@ -212,7 +212,7 @@ ZEBRA_RES recindex_write_head(recindex_t p, const void *buf, size_t len) assert(p); assert(p->index_BFile); - + r = bf_write(p->index_BFile, 0, 0, len, buf); if (r) { @@ -222,7 +222,7 @@ ZEBRA_RES recindex_write_head(recindex_t p, const void *buf, size_t len) return ZEBRA_OK; } -int recindex_read_indx(recindex_t p, zint sysno, void *buf, int itemsize, +int recindex_read_indx(recindex_t p, zint sysno, void *buf, int itemsize, int ignoreError) { int r = 0; @@ -233,17 +233,17 @@ int recindex_read_indx(recindex_t p, zint sysno, void *buf, int itemsize, char item[256]; char *st = item; char untilbuf[sizeof(zint) + 1]; - + ISAMB_PP isam_pp = isamb_pp_open(p->isamb, p->isam_p, 1); - + memcpy(untilbuf, &sysno, sizeof(sysno)); untilbuf[sizeof(sysno)] = 0; r = isamb_pp_forward(isam_pp, st, untilbuf); - + isamb_pp_close(isam_pp); if (!r) return 0; - + if (item[sizeof(sysno)] != itemsize) { yaz_log(YLOG_WARN, "unexpected entry size %d != %d", @@ -258,10 +258,10 @@ int recindex_read_indx(recindex_t p, zint sysno, void *buf, int itemsize, zint pos = (sysno-1)*itemsize; int off = CAST_ZINT_TO_INT(pos%RIDX_CHUNK); int sz1 = RIDX_CHUNK - off; /* sz1 is size of buffer to read.. */ - + if (sz1 > itemsize) sz1 = itemsize; /* no more than itemsize bytes */ - + r = bf_read(p->index_BFile, 1+pos/RIDX_CHUNK, off, sz1, buf); if (r == 1 && sz1 < itemsize) /* boundary? - must read second part */ r = bf_read(p->index_BFile, 2+pos/RIDX_CHUNK, 0, itemsize - sz1, @@ -275,7 +275,7 @@ int recindex_read_indx(recindex_t p, zint sysno, void *buf, int itemsize, #if 0 { struct record_index_entry *ep = buf; - yaz_log(YLOG_LOG, "read r=%d sysno=" ZINT_FORMAT " next=" ZINT_FORMAT + yaz_log(YLOG_LOG, "read r=%d sysno=" ZINT_FORMAT " next=" ZINT_FORMAT " sz=%d", r, sysno, ep->next, ep->size); } #endif @@ -293,12 +293,12 @@ struct code_read_data { int bt_code_read(void *vp, char **dst, int *insertMode) { struct code_read_data *s = (struct code_read_data *) vp; - + if (s->no == 0) return 0; (s->no)--; - + memcpy(*dst, &s->sysno, sizeof(zint)); *dst += sizeof(zint); **dst = s->itemsize; @@ -335,10 +335,10 @@ void recindex_write_indx(recindex_t p, zint sysno, void *buf, int itemsize) zint pos = (sysno-1)*itemsize; int off = CAST_ZINT_TO_INT(pos%RIDX_CHUNK); int sz1 = RIDX_CHUNK - off; /* sz1 is size of buffer to read.. */ - + if (sz1 > itemsize) sz1 = itemsize; /* no more than itemsize bytes */ - + bf_write(p->index_BFile, 1+pos/RIDX_CHUNK, off, sz1, buf); if (sz1 < itemsize) /* boundary? must write second part */ bf_write(p->index_BFile, 2+pos/RIDX_CHUNK, 0, itemsize - sz1, diff --git a/index/recindex.h b/index/recindex.h index 1ce50fc..0ad5fad 100644 --- a/index/recindex.h +++ b/index/recindex.h @@ -90,7 +90,7 @@ ZEBRA_RES rec_close (Records *p); /** \brief opens records system \param bfs block file storage \param rw read-write flag(0=read only, 1=write) - \param compression_method REC_COMPRESS_ type + \param compression_method REC_COMPRESS_ type */ Records rec_open(BFiles bfs, int rw, int compression_method); @@ -115,10 +115,10 @@ zint rec_sysno_to_int(zint sysno); #define REC_COMPRESS_ZLIB 2 -enum { - recInfo_fileType, - recInfo_filename, - recInfo_delKeys, +enum { + recInfo_fileType, + recInfo_filename, + recInfo_delKeys, recInfo_databaseName, recInfo_storeData, recInfo_attr, @@ -141,7 +141,7 @@ void recindex_close(recindex_t p); int recindex_read_head(recindex_t p, void *buf); const char *recindex_get_fname(recindex_t p); ZEBRA_RES recindex_write_head(recindex_t p, const void *buf, size_t len); -int recindex_read_indx(recindex_t p, zint sysno, void *buf, int itemsize, +int recindex_read_indx(recindex_t p, zint sysno, void *buf, int itemsize, int ignoreError); void recindex_write_indx(recindex_t p, zint sysno, void *buf, int itemsize); diff --git a/index/reckeys.c b/index/reckeys.c index 39a3f4a..e5174ab 100644 --- a/index/reckeys.c +++ b/index/reckeys.c @@ -94,7 +94,7 @@ zebra_rec_keys_t zebra_rec_keys_open(void) p->buf = 0; p->owner_of_buffer = 1; p->encode_handle = iscz1_start(); - p->decode_handle = iscz1_start(); + p->decode_handle = iscz1_start(); p->custom_record_id = 0; p->nmem = nmem_create(); @@ -129,7 +129,7 @@ void zebra_rec_keys_set_buf(zebra_rec_keys_t p, char *buf, size_t sz, } p->owner_of_buffer = copy_buf; } - + void zebra_rec_keys_get_buf(zebra_rec_keys_t p, char **buf, size_t *sz) { *buf = p->buf; @@ -144,7 +144,7 @@ void zebra_rec_keys_close(zebra_rec_keys_t p) { if (!p) return; - + if (p->owner_of_buffer) xfree(p->buf); if (p->encode_handle) @@ -155,7 +155,7 @@ void zebra_rec_keys_close(zebra_rec_keys_t p) xfree(p); } -int zebra_rec_keys_add_hash(zebra_rec_keys_t keys, +int zebra_rec_keys_add_hash(zebra_rec_keys_t keys, const char *str, size_t slen, const struct it_key *key) { @@ -185,13 +185,13 @@ int zebra_rec_keys_add_hash(zebra_rec_keys_t keys, return 1; } -void zebra_rec_keys_write(zebra_rec_keys_t keys, +void zebra_rec_keys_write(zebra_rec_keys_t keys, const char *str, size_t slen, const struct it_key *key) { char *dst; const char *src = (char*) key; - + assert(keys->owner_of_buffer); if (key->mem[1]) /* record_id custom */ @@ -231,7 +231,7 @@ void zebra_rec_keys_reset(zebra_rec_keys_t keys) { assert(keys); keys->buf_used = 0; - + iscz1_reset(keys->encode_handle); init_hash(keys); @@ -267,17 +267,17 @@ int zebra_rec_keys_read(zebra_rec_keys_t keys, { const char *src = keys->buf + keys->fetch_offset; char *dst = (char*) key; - + assert (keys->fetch_offset < keys->buf_used); /* store the destination key */ iscz1_decode(keys->decode_handle, &dst, &src); - + /* store pointer to string and length of it */ *str = src; *slen = strlen(src); src += *slen + 1; - + keys->fetch_offset = src - keys->buf; } return 1; diff --git a/index/reckeys.h b/index/reckeys.h index e655adc..20e8fab 100644 --- a/index/reckeys.h +++ b/index/reckeys.h @@ -31,7 +31,7 @@ zebra_rec_keys_t zebra_rec_keys_open(void); void zebra_rec_keys_close(zebra_rec_keys_t p); -void zebra_rec_keys_write(zebra_rec_keys_t keys, +void zebra_rec_keys_write(zebra_rec_keys_t keys, const char *str, size_t slen, const struct it_key *key); void zebra_rec_keys_reset(zebra_rec_keys_t keys); diff --git a/index/records.c b/index/records.c index 490c358..95170b2 100644 --- a/index/records.c +++ b/index/records.c @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * ref_count (2 bytes) * block (500 bytes) * - * Format of subsequent blocks + * Format of subsequent blocks * next (8 bytes) * block (502 bytes) * @@ -189,7 +189,7 @@ static ZEBRA_RES rec_release_blocks(Records p, zint sysno) /* the list of blocks can all be removed (ref == 0) */ first = 0; } - + if (bf_write(p->data_BFile[dst_type], freeblock, 0, sizeof(freeblock), &p->head.block_free[dst_type])) { @@ -271,7 +271,7 @@ static ZEBRA_RES rec_write_tmp_buf(Records p, int size, zint *sysnos) cptr = p->tmp_buf + no_written; } block_prev = block_free; - no_written += CAST_ZINT_TO_INT(p->head.block_size[dst_type]) + no_written += CAST_ZINT_TO_INT(p->head.block_size[dst_type]) - sizeof(zint); p->head.block_used[dst_type]++; } @@ -347,7 +347,7 @@ Records rec_open(BFiles bfs, int rw, int compression_method) } if (rw) { - if (recindex_write_head(p->recindex, + if (recindex_write_head(p->recindex, &p->head, sizeof(p->head)) != ZEBRA_OK) ret = ZEBRA_FAIL; } @@ -480,7 +480,7 @@ static void rec_cache_flush_block1(Records p, Record rec, Record last_rec, } if (i == 0) { - rec_encode_zint(rec_sysno_to_int(rec->sysno), + rec_encode_zint(rec_sysno_to_int(rec->sysno), (unsigned char *) *out_buf + *out_offset, &len); (*out_offset) += len; } @@ -547,13 +547,13 @@ static ZEBRA_RES rec_flush_shared(Records p, short ref_count, zint *sysnos, #endif break; case REC_COMPRESS_BZIP2: -#if HAVE_BZLIB_H +#if HAVE_BZLIB_H csize = out_offset + (out_offset >> 6) + 620; rec_tmp_expand(p, csize); #ifdef BZ_CONFIG_ERROR - i = BZ2_bzBuffToBuffCompress + i = BZ2_bzBuffToBuffCompress #else - i = bzBuffToBuffCompress + i = bzBuffToBuffCompress #endif (p->tmp_buf+sizeof(zint)+sizeof(short)+ sizeof(char), @@ -568,7 +568,7 @@ static ZEBRA_RES rec_flush_shared(Records p, short ref_count, zint *sysnos, case REC_COMPRESS_NONE: break; } - if (!csize) + if (!csize) { /* either no compression or compression not supported ... */ csize = out_offset; @@ -581,7 +581,7 @@ static ZEBRA_RES rec_flush_shared(Records p, short ref_count, zint *sysnos, memcpy(p->tmp_buf + sizeof(zint), &ref_count, sizeof(ref_count)); memcpy(p->tmp_buf + sizeof(zint)+sizeof(short), &compression_method, sizeof(compression_method)); - + /* -------- compression */ if (rec_write_tmp_buf(p, csize + sizeof(short) + sizeof(char), sysnos) != ZEBRA_OK) @@ -661,7 +661,7 @@ static ZEBRA_RES rec_cache_flush(Records p, int saveCount) { struct record_cache_entry *e = p->record_cache + i; rec_free(&e->rec); - } + } /* i still being used ... */ for (j = 0; jrecord_cache+j, p->record_cache+i, @@ -779,7 +779,7 @@ static Record rec_get_int(Records p, zint sysno) freeblock = entry.next / 8; assert(freeblock > 0); - + rec_tmp_expand(p, entry.size); cptr = p->tmp_buf; @@ -793,7 +793,7 @@ static Record rec_get_int(Records p, zint sysno) zint tmp; cptr += p->head.block_size[dst_type] - sizeof(freeblock); - + memcpy(&tmp, cptr, sizeof(tmp)); r = bf_read(p->data_BFile[dst_type], freeblock, 0, 0, cptr); if (r < 0) @@ -823,7 +823,7 @@ static Record rec_get_int(Records p, zint sysno) (const Bytef *) in_buf, in_size); if (i == Z_OK) { - bz_size = destLen; + bz_size = destLen; break; } yaz_log(YLOG_LOG, "failed"); @@ -1093,7 +1093,7 @@ void rec_prstat(Records records, int verbose) { int i; zint total_bytes = 0; - + yaz_log (YLOG_LOG, "Total records %8" ZINT_FORMAT0, records->head.no_records); diff --git a/index/retrieve.c b/index/retrieve.c index c9c8184..96c1e0d 100644 --- a/index/retrieve.c +++ b/index/retrieve.c @@ -51,13 +51,13 @@ struct special_fetch_s { NMEM nmem; }; -static int zebra_create_record_stream(ZebraHandle zh, +static int zebra_create_record_stream(ZebraHandle zh, Record *rec, struct ZebraRecStream *stream) { RecordAttr *recordAttr = rec_init_attr(zh->reg->zei, *rec); - if ((*rec)->size[recInfo_storeData] > 0 + if ((*rec)->size[recInfo_storeData] > 0 || (*rec)->info[recInfo_filename] == 0) zebra_create_stream_mem(stream, (*rec)->info[recInfo_storeData], (*rec)->size[recInfo_storeData]); @@ -65,7 +65,7 @@ static int zebra_create_record_stream(ZebraHandle zh, { char full_rep[1024]; int fd; - + if (zh->path_reg && !yaz_is_abspath((*rec)->info[recInfo_filename])){ strcpy(full_rep, zh->path_reg); strcat(full_rep, "/"); @@ -73,7 +73,7 @@ static int zebra_create_record_stream(ZebraHandle zh, } else strcpy(full_rep, (*rec)->info[recInfo_filename]); - + if ((fd = open(full_rep, O_BINARY|O_RDONLY)) == -1){ yaz_log(YLOG_WARN|YLOG_ERRNO, "Retrieve fail; missing file: %s", full_rep); @@ -84,7 +84,7 @@ static int zebra_create_record_stream(ZebraHandle zh, } return 0; } - + struct index_spec { const char *index_name; @@ -129,7 +129,7 @@ struct index_spec *parse_index_spec(const char *elem, NMEM nmem, { cp++; cp0 = cp; - + while (*cp != '\0' && *cp != ',' && *cp != ':') cp++; spec->index_type = nmem_strdupn(nmem, cp0, cp - cp0); @@ -138,7 +138,7 @@ struct index_spec *parse_index_spec(const char *elem, NMEM nmem, { cp++; cp0 = cp; - + while (*cp != '\0' && *cp != ',' && *cp != ':') cp++; spec->extra = nmem_strdupn(nmem, cp0, cp - cp0); @@ -185,7 +185,7 @@ static int sort_fetch( WRBUF wrbuf_result = result; int off = 0; - zebraExplain_lookup_ord(zh->reg->zei, ord, &index_type, &db, + zebraExplain_lookup_ord(zh->reg->zei, ord, &index_type, &db, &string_index); if (!oid_oidcmp(input_format, yaz_oid_recsyn_xml)) { @@ -201,7 +201,7 @@ static int sort_fetch( } else { - yaz_log(YLOG_WARN, "unsupported format for element set zebra::%s", + yaz_log(YLOG_WARN, "unsupported format for element set zebra::%s", elemsetname); *output_format = 0; wrbuf_destroy(wrbuf_str); @@ -217,10 +217,10 @@ static int sort_fetch( assert(off < wrbuf_len(wrbuf_str)); zebra_term_untrans(zh, index_type, dst_buf, wrbuf_buf(wrbuf_str)+off); - + if (!oid_oidcmp(input_format, yaz_oid_recsyn_xml)) { - wrbuf_printf(wrbuf_result, " ", index_type); wrbuf_xmlputs(wrbuf_result, dst_buf); @@ -241,7 +241,7 @@ static int sort_fetch( return 0; } } - + static int special_index_fetch( struct special_fetch_s *fi, const char *elemsetname, const Odr_oid *input_format, @@ -254,7 +254,7 @@ static int special_index_fetch( ZebraHandle zh = fi->zh; struct index_spec *spec, *spec_list; int error; - + /* set output variables before processing possible error states */ /* *rec_lenp = 0; */ @@ -262,7 +262,7 @@ static int special_index_fetch( if (oid_oidcmp(input_format, yaz_oid_recsyn_xml) && oid_oidcmp(input_format, yaz_oid_recsyn_sutrs)) { - yaz_log(YLOG_WARN, "unsupported format for element set zebra::%s", + yaz_log(YLOG_WARN, "unsupported format for element set zebra::%s", elemsetname); *output_format = 0; return YAZ_BIB1_NO_SYNTAXES_AVAILABLE_FOR_THIS_REQUEST; @@ -318,7 +318,7 @@ static int special_index_fetch( const char *string_index = 0; char dst_buf[IT_MAX_WORD]; int match = 0; - + zebraExplain_lookup_ord(zh->reg->zei, ord, &index_type, &db, &string_index); if (!spec_list) @@ -338,31 +338,31 @@ static int special_index_fetch( { if (zebra_term_untrans(zh, index_type, dst_buf, str)) *dst_buf = '\0'; /* untrans failed */ - + if (!oid_oidcmp(input_format, yaz_oid_recsyn_xml)) { - wrbuf_printf(wrbuf, " ", + + wrbuf_printf(wrbuf, " seq=\"" ZINT_FORMAT "\">", key_in.mem[key_in.len -1]); wrbuf_xmlputs(wrbuf, dst_buf); wrbuf_printf(wrbuf, "\n"); } - else + else { wrbuf_printf(wrbuf, "%s ", string_index); - + wrbuf_printf(wrbuf, "%s", index_type); - + for (i = 1; i < key_in.len; i++) - wrbuf_printf(wrbuf, " " ZINT_FORMAT, + wrbuf_printf(wrbuf, " " ZINT_FORMAT, key_in.mem[i]); - + wrbuf_printf(wrbuf, " %s", dst_buf); - + wrbuf_printf(wrbuf, "\n"); } } @@ -423,8 +423,8 @@ static void snippet_check_fields(ZebraHandle zh, WRBUF wrbuf, const char *index_type; const char *db = 0; const char *string_index = 0; - - zebraExplain_lookup_ord(zh->reg->zei, w->ord, + + zebraExplain_lookup_ord(zh->reg->zei, w->ord, &index_type, &db, &string_index); /* only report for same index type */ if (!strcmp(w_index_type, index_type)) @@ -455,12 +455,12 @@ static void snippet_xml_record(ZebraHandle zh, WRBUF wrbuf, zebra_snippets *doc) const char *db = 0; const char *string_index = 0; - zebraExplain_lookup_ord(zh->reg->zei, doc_w->ord, + zebraExplain_lookup_ord(zh->reg->zei, doc_w->ord, &index_type, &db, &string_index); if (mark_state == 0) { - + wrbuf_printf(wrbuf, " match) wrbuf_puts(wrbuf, ""); /* not printing leading ws */ - if (mark_state || !doc_w->ws || doc_w->match) + if (mark_state || !doc_w->ws || doc_w->match) wrbuf_xmlputs(wrbuf, doc_w->term); if (doc_w->match) wrbuf_puts(wrbuf, ""); @@ -549,18 +549,18 @@ static int snippet_fetch( yaz_log(YLOG_LOG, "HIT SNIPPET:"); zebra_snippets_log(hit_snippet, YLOG_LOG, 1); #endif - + zebra_snippets_ring(rec_snippets, hit_snippet, 5, 5); - + #if 0 yaz_log(YLOG_LOG, "---------------------------"); yaz_log(YLOG_LOG, "RING SNIPPET:"); zebra_snippets_log(rec_snippets, YLOG_LOG, 1); #endif snippet_xml_record(zh, wrbuf, rec_snippets); - + *output_format = yaz_oid_recsyn_xml; - + zebra_snippets_destroy(hit_snippet); } zebra_snippets_destroy(rec_snippets); @@ -581,19 +581,19 @@ static zint freq_term(ZebraHandle zh, int ord, const char *term, RSET rset_set) char *info; zint hits = 0; NMEM nmem = nmem_create(); - + strcpy(ord_buf + ord_len, term); - + info = dict_lookup(zh->reg->dict, ord_buf); if (info) { ISAM_P isam_p; RSET rsets[2], rset; memcpy(&isam_p, info+1, sizeof(ISAM_P)); - + rsets[0] = zebra_create_rset_isam(zh, nmem, kc, kc->scope, isam_p, 0); rsets[1] = rset_dup(rset_set); - + rset = rset_create_and(nmem, kc, kc->scope, 2, rsets); zebra_count_set(zh, rset, &hits, zh->approx_limit); @@ -642,7 +642,7 @@ static void term_collect_freq(ZebraHandle zh, qsort(col, no_terms_collect, sizeof(*col), term_qsort_handle); } -static struct term_collect *term_collect_create(zebra_strmap_t sm, +static struct term_collect *term_collect_create(zebra_strmap_t sm, int no_terms_collect, NMEM nmem) { @@ -650,7 +650,7 @@ static struct term_collect *term_collect_create(zebra_strmap_t sm, void *data_buf; size_t data_len; zebra_strmap_it it; - struct term_collect *col = nmem_malloc(nmem, + struct term_collect *col = nmem_malloc(nmem, sizeof *col *no_terms_collect); int i; for (i = 0; i < no_terms_collect; i++) @@ -668,11 +668,11 @@ static struct term_collect *term_collect_create(zebra_strmap_t sm, int oc = *(int*) data_buf; int j = 0; /* insertion may be slow but terms terms will be "infrequent" and - thus number of iterations should be small below + thus number of iterations should be small below */ while (j < no_terms_collect && oc > col[j].oc) j++; - if (j) + if (j) { /* oc <= col[j] and oc > col[j-1] */ --j; memmove(col, col+1, sizeof(*col) * j); @@ -698,10 +698,10 @@ static int perform_facet_sort(ZebraHandle zh, int no_ord, int *ord_array, { if (!poset[rec_i].sysno) continue; - + zebra_sort_sysno(zh->reg->sort_index, poset[rec_i].sysno); zebra_sort_type(zh->reg->sort_index, ord_array[ord_i]); - + wrbuf_rewind(w); if (zebra_sort_read(zh->reg->sort_index, 0, w)) { @@ -762,8 +762,8 @@ static int perform_facet_index(ZebraHandle zh, zebra_rec_keys_t keys = zebra_rec_keys_open(); zebra_rec_keys_set_buf(keys, rec->info[recInfo_delKeys], rec->size[recInfo_delKeys], 0); - - yaz_log(YLOG_DEBUG, "rec %d " ZINT_FORMAT " %s", + + yaz_log(YLOG_DEBUG, "rec %d " ZINT_FORMAT " %s", j, sysnos[j], zebra_rec_keys_empty(keys) ? "empty" : "non-empty"); if (zebra_rec_keys_rewind(keys)) { @@ -771,16 +771,16 @@ static int perform_facet_index(ZebraHandle zh, { int ord_i; struct index_spec *spec; - for (spec = spec_list, ord_i = 0; ord_i < no_ord; + for (spec = spec_list, ord_i = 0; ord_i < no_ord; ord_i++, spec = spec->next) { int ord = CAST_ZINT_TO_INT(key_in.mem[0]); - if (ord == ord_array[ord_i] && + if (ord == ord_array[ord_i] && str[0] != FIRST_IN_FIELD_CHAR) { int *freq; zebra_strmap_t sm = map_array[ord_i]; - + freq = zebra_strmap_lookup(sm, str, 0, 0); if (freq) (*freq)++; @@ -800,7 +800,7 @@ static int perform_facet_index(ZebraHandle zh, return 0; } -static int perform_facet(ZebraHandle zh, +static int perform_facet(ZebraHandle zh, struct special_fetch_s *fi, WRBUF result, int num_recs, ZebraMetaRecord *poset, @@ -836,16 +836,16 @@ static int perform_facet(ZebraHandle zh, NMEM nmem = nmem_create(); struct term_collect *col; int no_collect_terms = 20; - + if (spec->extra) no_collect_terms = atoi(spec->extra); if (no_collect_terms < 1) no_collect_terms = 1; col = term_collect_create(map_array[i], no_collect_terms, nmem); term_collect_freq(zh, col, no_collect_terms, ord_array[i], - resultSetRef(zh, fi->setname), + resultSetRef(zh, fi->setname), cat == zinfo_index_category_sort ? 1.0 : -1.0); - + if (use_xml) wrbuf_printf(wr, " \n", spec->index_type, spec->index_name); @@ -862,7 +862,7 @@ static int perform_facet(ZebraHandle zh, { wrbuf_printf(wr, " "); wrbuf_xmlputs(wr, dst_buf); @@ -872,7 +872,7 @@ static int perform_facet(ZebraHandle zh, { wrbuf_printf(wr, "term %d", col[j].oc); if (col[j].set_occur) - wrbuf_printf(wr, " " ZINT_FORMAT, + wrbuf_printf(wr, " " ZINT_FORMAT, col[j].set_occur); wrbuf_printf(wr, ": %s\n", dst_buf); } @@ -916,12 +916,12 @@ static int facet_fetch( use_xml = 1; spec_list = parse_index_spec(elemsetname, fi->nmem, &error); - + if (!spec_list || error) { return YAZ_BIB1_SPECIFIED_ELEMENT_SET_NAME_NOT_VALID_FOR_SPECIFIED_; - } - + } + for (spec = spec_list; spec; spec = spec->next) { if (!spec->index_type) @@ -956,7 +956,7 @@ static int facet_fetch( if (ord == -1) break; ord_array[i] = ord; - + } } if (spec) @@ -1001,11 +1001,11 @@ static int zebra_special_fetch( struct special_fetch_s *fi = (struct special_fetch_s *) handle; ZebraHandle zh = fi->zh; zint sysno = fi->sysno; - + /* processing zebra::facet */ if (elemsetname && 0 == strncmp(elemsetname, "facet", 5)) { - return facet_fetch(fi, elemsetname + 5, + return facet_fetch(fi, elemsetname + 5, input_format, output_format, result, addinfo); } @@ -1025,7 +1025,7 @@ static int zebra_special_fetch( { wrbuf_printf(result, ZINT_FORMAT, fi->sysno); *output_format = input_format; - } + } else if (!oid_oidcmp(input_format, yaz_oid_recsyn_xml)) { wrbuf_printf(result, ZEBRA_XML_HEADER_STR @@ -1059,11 +1059,11 @@ static int zebra_special_fetch( return YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS; } - /* processing special elementsetnames zebra::data */ + /* processing special elementsetnames zebra::data */ if (elemsetname && 0 == strcmp(elemsetname, "data")) { struct ZebraRecStream stream; - RecordAttr *recordAttr = rec_init_attr(zh->reg->zei, rec); + RecordAttr *recordAttr = rec_init_attr(zh->reg->zei, rec); char *b; zebra_create_record_stream(zh, &rec, &stream); @@ -1082,12 +1082,12 @@ static int zebra_special_fetch( if (elemsetname && 0 == strcmp(elemsetname, "meta")) { int ret = 0; - RecordAttr *recordAttr = rec_init_attr(zh->reg->zei, rec); + RecordAttr *recordAttr = rec_init_attr(zh->reg->zei, rec); if (!oid_oidcmp(input_format, yaz_oid_recsyn_xml)) { *output_format = input_format; - + wrbuf_printf(result, ZEBRA_XML_HEADER_STR " sysno=\"" ZINT_FORMAT "\"", sysno); retrieve_puts_attr(result, "base", rec->info[recInfo_databaseName]); @@ -1095,7 +1095,7 @@ static int zebra_special_fetch( retrieve_puts_attr(result, "type", rec->info[recInfo_fileType]); if (fi->score >= 0) retrieve_puts_attr_int(result, "score", fi->score); - + wrbuf_printf(result, " rank=\"" ZINT_FORMAT "\"" " size=\"%i\"" diff --git a/index/rpnscan.c b/index/rpnscan.c index 341acb2..8ccf7a7 100644 --- a/index/rpnscan.c +++ b/index/rpnscan.c @@ -54,7 +54,7 @@ static ZEBRA_RES trans_scan_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char *res_buf; size_t res_len; zebra_map_tokenize_start(zm, term_utf8, strlen(term_utf8)); - + if (zebra_map_tokenize_next(zm, &res_buf, &res_len, 0, 0)) { memcpy(termz, res_buf, res_len); @@ -72,7 +72,7 @@ static ZEBRA_RES trans_scan_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, int i = 0; const char *space_map = NULL; int len; - + while ((len = (cp_end - cp)) > 0) { map = zebra_maps_input(zm, &cp, len, 0); @@ -93,8 +93,8 @@ static ZEBRA_RES trans_scan_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, return ZEBRA_OK; } -static void get_first_snippet_from_rset(ZebraHandle zh, - RSET rset, zebra_snippets *snippets, +static void get_first_snippet_from_rset(ZebraHandle zh, + RSET rset, zebra_snippets *snippets, zint *sysno) { struct it_key key; @@ -162,7 +162,7 @@ static int scan_save_set(ZebraHandle zh, ODR stream, NMEM nmem, struct rset_key_control *kc, Z_AttributesPlusTerm *zapt, RSET limit_set, - const char *term, + const char *term, const char *index_type, struct scan2_info_entry *ar, int ord_no, ZebraScanEntry *glist, int pos) @@ -173,11 +173,11 @@ static int scan_save_set(ZebraHandle zh, ODR stream, NMEM nmem, AttrType global_hits_limit_attr; int l; attr_init_APT(&global_hits_limit_attr, zapt, 12); - + l = attr_find(&global_hits_limit_attr, NULL); if (l != -1) approx_limit = l; - + for (i = 0; i < ord_no; i++) { if (ar[i].isam_p && strcmp(wrbuf_cstr(ar[i].term), term) == 0) @@ -186,15 +186,15 @@ static int scan_save_set(ZebraHandle zh, ODR stream, NMEM nmem, { struct ord_list *ol = ord_list_create(nmem); RSET rset_t; - + ol = ord_list_append(nmem, ol, ar[i].ord); - + assert(ol); rset_t = rset_trunc( zh, &ar[i].isam_p, 1, wrbuf_buf(ar[i].term), wrbuf_len(ar[i].term), - NULL, 1, zapt->term->which, nmem, - kc, kc->scope, ol, index_type, + NULL, 1, zapt->term->which, nmem, + kc, kc->scope, ol, index_type, 0 /* hits_limit_value */, 0 /* term_ref_id_str */); if (!rset) @@ -202,7 +202,7 @@ static int scan_save_set(ZebraHandle zh, ODR stream, NMEM nmem, else { RSET rsets[2]; - + rsets[0] = rset; rsets[1] = rset_t; rset = rset_create_or(nmem, kc, kc->scope, 0 /* termid */, @@ -221,7 +221,7 @@ static int scan_save_set(ZebraHandle zh, ODR stream, NMEM nmem, RSET rsets[2]; rsets[0] = rset; rsets[1] = rset_dup(limit_set); - + rset = rset_create_and(nmem, kc, kc->scope, 2, rsets); } /* count it */ @@ -234,7 +234,7 @@ static int scan_save_set(ZebraHandle zh, ODR stream, NMEM nmem, glist[pos].term = 0; glist[pos].display_term = 0; - + get_first_snippet_from_rset(zh, rset, hit_snippets, &sysno); if (sysno) { @@ -242,7 +242,7 @@ static int scan_save_set(ZebraHandle zh, ODR stream, NMEM nmem, int code = zebra_get_rec_snippets(zh, sysno, rec_snippets); if (code == 0) { - const struct zebra_snippet_word *w = + const struct zebra_snippet_word *w = zebra_snippets_lookup(rec_snippets, hit_snippets); if (w) { @@ -283,7 +283,7 @@ static int scan_save_set(ZebraHandle zh, ODR stream, NMEM nmem, static ZEBRA_RES rpn_scan_norm(ZebraHandle zh, ODR stream, NMEM nmem, struct rset_key_control *kc, Z_AttributesPlusTerm *zapt, - int *position, int *num_entries, + int *position, int *num_entries, ZebraScanEntry **list, int *is_partial, RSET limit_set, const char *index_type, @@ -309,12 +309,12 @@ static ZEBRA_RES rpn_scan_norm(ZebraHandle zh, ODR stream, NMEM nmem, { char termz[IT_MAX_WORD+20]; int prefix_len = 0; - + prefix_len = key_SU_encode(ords[i], termz); termz[prefix_len] = 0; strcpy(ar[i].prefix, termz); - - if (trans_scan_term(zh, zapt, termz+prefix_len, zm) == + + if (trans_scan_term(zh, zapt, termz+prefix_len, zm) == ZEBRA_FAIL) { for (i = 0; i < ord_no; i++) @@ -352,7 +352,7 @@ static ZEBRA_RES rpn_scan_norm(ZebraHandle zh, ODR stream, NMEM nmem, /* get maximum after scan */ for (i = 0; i < ord_no; i++) { - if (ar[i].isam_p + if (ar[i].isam_p && (hi == 0 || strcmp(wrbuf_cstr(ar[i].term), hi) > 0)) hi = wrbuf_cstr(ar[i].term); } @@ -383,12 +383,12 @@ static ZEBRA_RES rpn_scan_norm(ZebraHandle zh, ODR stream, NMEM nmem, { char termz[IT_MAX_WORD+20]; int prefix_len = 0; - + prefix_len = key_SU_encode(ords[i], termz); termz[prefix_len] = 0; strcpy(ar[i].prefix, termz); - - if (trans_scan_term(zh, zapt, termz+prefix_len, zm) == + + if (trans_scan_term(zh, zapt, termz+prefix_len, zm) == ZEBRA_FAIL) return ZEBRA_FAIL; wrbuf_rewind(ar[i].term); @@ -424,7 +424,7 @@ static ZEBRA_RES rpn_scan_norm(ZebraHandle zh, ODR stream, NMEM nmem, /* get minimum after scan */ for (i = 0; i < ord_no; i++) { - if (ar[i].isam_p + if (ar[i].isam_p && (lo == 0 || strcmp(wrbuf_cstr(ar[i].term), lo) < 0)) lo = wrbuf_cstr(ar[i].term); } @@ -505,7 +505,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, { char resname[32]; sprintf(resname, "%d", termset_value_numeric); - set_name = odr_strdup(stream, resname); + set_name = odr_strdup(stream, resname); } else set_name = odr_strdup(stream, termset_value_string); @@ -515,10 +515,10 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, if (set_name) { limit_set = resultSetRef(zh, set_name); - + if (!limit_set) { - zebra_setError(zh, + zebra_setError(zh, YAZ_BIB1_SPECIFIED_RESULT_SET_DOES_NOT_EXIST, set_name); return ZEBRA_FAIL; @@ -527,7 +527,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, yaz_log(YLOG_DEBUG, "position = %d, num = %d", *position, *num_entries); - + if (zebra_maps_attr(zh->reg->zebra_maps, zapt, &index_type, &search_type, rank_type, &complete_flag, &sort_flag)) { @@ -551,7 +551,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, *num_entries = 0; return ZEBRA_FAIL; } - if (zebra_apt_get_ord(zh, zapt, index_type, 0, attributeset, &ord) + if (zebra_apt_get_ord(zh, zapt, index_type, 0, attributeset, &ord) != ZEBRA_OK) continue; ords[ord_no++] = ord; diff --git a/index/rpnsearch.c b/index/rpnsearch.c index 8b474a9..ff57c68 100644 --- a/index/rpnsearch.c +++ b/index/rpnsearch.c @@ -71,20 +71,20 @@ void rpn_char_map_prepare(struct zebra_register *reg, zebra_map_t zm, dict_grep_cmap(reg->dict, map_info, rpn_char_map_handler); } -#define TERM_COUNT - -struct grep_info { -#ifdef TERM_COUNT - int *term_no; -#endif +#define TERM_COUNT + +struct grep_info { +#ifdef TERM_COUNT + int *term_no; +#endif ISAM_P *isam_p_buf; - int isam_p_size; + int isam_p_size; int isam_p_indx; int trunc_max; ZebraHandle zh; const char *index_type; ZebraSet termset; -}; +}; static int add_isam_p(const char *name, const char *info, struct grep_info *p) @@ -102,8 +102,8 @@ static int add_isam_p(const char *name, const char *info, if (p->isam_p_indx == p->isam_p_size) { ISAM_P *new_isam_p_buf; -#ifdef TERM_COUNT - int *new_term_no; +#ifdef TERM_COUNT + int *new_term_no; #endif p->isam_p_size = 2*p->isam_p_size + 100; new_isam_p_buf = (ISAM_P *) xmalloc(sizeof(*new_isam_p_buf) * @@ -137,13 +137,13 @@ static int add_isam_p(const char *name, const char *info, int ord = 0; const char *index_name; int len = key_SU_decode(&ord, (const unsigned char *) name); - + zebra_term_untrans (p->zh, p->index_type, term_tmp, name+len); yaz_log(log_level_rpn, "grep: %d %c %s", ord, name[len], term_tmp); zebraExplain_lookup_ord(p->zh->reg->zei, ord, 0 /* index_type */, &db, &index_name); yaz_log(log_level_rpn, "grep: db=%s index=%s", db, index_name); - + resultSetAddTerm(p->zh, p->termset, name[len], db, index_name, term_tmp); } @@ -228,7 +228,7 @@ static void add_non_space(const char *start, const char *end, { char tmpbuf[80]; esc_str(tmpbuf, sizeof(tmpbuf), map[0], strlen(map[0])); - + wrbuf_puts(term_dict, map[0]); } } @@ -279,7 +279,7 @@ static int term_102_icu(zebra_map_t zm, wrbuf_putc(term_dict, '\\'); if (res_buf[i] < 32) wrbuf_putc(term_dict, '\x01'); - + wrbuf_putc(term_dict, res_buf[i]); } wrbuf_write(display_term, display_buf, display_len); @@ -289,7 +289,7 @@ static int term_102_icu(zebra_map_t zm, } if (*s1 == '\0') break; - + wrbuf_putc(term_dict, *s1); wrbuf_putc(display_term, *s1); @@ -317,10 +317,10 @@ static int term_100_icu(zebra_map_t zm, while (*s0 == ' ') s0++; - + if (*s0 == '\0') return 0; - + if (space_split) { s1 = s0; @@ -333,7 +333,7 @@ static int term_100_icu(zebra_map_t zm, *src = s1; zebra_map_tokenize_start(zm, s0, s1 - s0); - + if (!zebra_map_tokenize_next(zm, &res_buf, &res_len, &display_buf, &display_len)) { @@ -344,7 +344,7 @@ static int term_100_icu(zebra_map_t zm, { /* ICU sort keys seem to be of the form basechars \x01 accents \x01 length - For now we'll just right truncate from basechars . This + For now we'll just right truncate from basechars . This may give false hits due to accents not being used. */ i = res_len; @@ -369,7 +369,7 @@ static int term_100_icu(zebra_map_t zm, wrbuf_putc(term_dict, '\\'); if (res_buf[i] < 32) wrbuf_putc(term_dict, '\x01'); - + wrbuf_putc(term_dict, res_buf[i]); } if (mode & 1) @@ -421,7 +421,7 @@ static int term_100(zebra_map_t zm, wrbuf_putc(display_term, *space_start); wrbuf_putc(term_dict, *space_start); space_start++; - + } /* and reset */ space_start = space_end = 0; @@ -514,7 +514,7 @@ static int term_103(zebra_map_t zm, const char **src, } } *src = s0; - + return i; } @@ -527,7 +527,7 @@ static int term_102(zebra_map_t zm, const char **src, /* term_104: handle term, process ?n * # */ -static int term_104(zebra_map_t zm, const char **src, +static int term_104(zebra_map_t zm, const char **src, WRBUF term_dict, int space_split, WRBUF display_term) { const char *s0; @@ -596,7 +596,7 @@ static int term_104(zebra_map_t zm, const char **src, } /* term_105/106: handle term, process * ! and possibly right_truncate */ -static int term_105(zebra_map_t zm, const char **src, +static int term_105(zebra_map_t zm, const char **src, WRBUF term_dict, int space_split, WRBUF display_term, int right_truncate) { @@ -669,7 +669,7 @@ static void gen_regular_rel(WRBUF term_dict, int val, int islt) strcpy(dst, "(-[0-9]+|("); else strcpy(dst, "(("); - } + } else { if (!islt) @@ -696,7 +696,7 @@ static void gen_regular_rel(WRBUF term_dict, int val, int islt) if (d == '0') continue; d--; - } + } else { if (d == '9') @@ -704,7 +704,7 @@ static void gen_regular_rel(WRBUF term_dict, int val, int islt) d++; } } - + strcpy(dst + dst_p, numstr); dst_p = strlen(dst) - pos - 1; @@ -724,7 +724,7 @@ static void gen_regular_rel(WRBUF term_dict, int val, int islt) else { if (d != '9') - { + { dst[dst_p++] = '['; dst[dst_p++] = d; dst[dst_p++] = '-'; @@ -788,7 +788,7 @@ void string_rel_add_char(WRBUF term_p, WRBUF wsrc, int *indx) static int string_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char **term_sub, WRBUF term_dict, const Odr_oid *attributeSet, - zebra_map_t zm, int space_split, + zebra_map_t zm, int space_split, WRBUF display_term, int *error_code) { @@ -811,12 +811,12 @@ static int string_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt, return 0; } yaz_log(log_level_rpn, "Relation <"); - + wrbuf_putc(term_dict, '('); for (i = 0; i < wrbuf_len(term_component); ) { int j = 0; - + if (i) wrbuf_putc(term_dict, '|'); while (j < i) @@ -825,13 +825,13 @@ static int string_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt, wrbuf_putc(term_dict, '['); wrbuf_putc(term_dict, '^'); - + wrbuf_putc(term_dict, 1); wrbuf_putc(term_dict, FIRST_IN_FIELD_CHAR); - + string_rel_add_char(term_dict, term_component, &i); wrbuf_putc(term_dict, '-'); - + wrbuf_putc(term_dict, ']'); wrbuf_putc(term_dict, '.'); wrbuf_putc(term_dict, '*'); @@ -889,7 +889,7 @@ static int string_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt, while (j < i) string_rel_add_char(term_dict, term_component, &j); wrbuf_putc(term_dict, '['); - + wrbuf_putc(term_dict, '^'); wrbuf_putc(term_dict, '-'); string_rel_add_char(term_dict, term_component, &i); @@ -973,7 +973,7 @@ static int string_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt, } static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, - const char **term_sub, + const char **term_sub, WRBUF term_dict, const Odr_oid *attributeSet, NMEM stream, struct grep_info *grep_info, @@ -993,7 +993,7 @@ ZEBRA_RES zebra_term_limits_APT(ZebraHandle zh, AttrType hits_limit_attr; int term_ref_id_int; zint hits_limit_from_attr; - + attr_init_APT(&hits_limit_attr, zapt, 11); hits_limit_from_attr = attr_find(&hits_limit_attr, NULL); @@ -1018,12 +1018,12 @@ ZEBRA_RES zebra_term_limits_APT(ZebraHandle zh, */ static ZEBRA_RES search_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, - const char **term_sub, + const char **term_sub, const Odr_oid *attributeSet, zint hits_limit, NMEM stream, struct grep_info *grep_info, const char *index_type, int complete_flag, - const char *rank_type, + const char *rank_type, const char *xpath_use, NMEM rset_nmem, RSET *rset, @@ -1050,7 +1050,7 @@ static ZEBRA_RES search_term(ZebraHandle zh, yaz_log(log_level_rpn, "term: %s", wrbuf_cstr(display_term)); *rset = rset_trunc(zh, grep_info->isam_p_buf, grep_info->isam_p_indx, wrbuf_buf(display_term), - wrbuf_len(display_term), rank_type, + wrbuf_len(display_term), rank_type, 1 /* preserve pos */, zapt->term->which, rset_nmem, kc, kc->scope, ol, index_type, hits_limit_value, @@ -1063,7 +1063,7 @@ static ZEBRA_RES search_term(ZebraHandle zh, } static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, - const char **term_sub, + const char **term_sub, WRBUF term_dict, const Odr_oid *attributeSet, NMEM stream, struct grep_info *grep_info, @@ -1095,35 +1095,35 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, yaz_log(log_level_rpn, "truncation value %d", truncation_value); termp = *term_sub; /* start of term for each database */ - + if (zebra_apt_get_ord(zh, zapt, index_type, xpath_use, attributeSet, &ord) != ZEBRA_OK) { *term_sub = 0; return ZEBRA_FAIL; } - + wrbuf_rewind(term_dict); /* new dictionary regexp term */ - + *ol = ord_list_append(stream, *ol, ord); ord_len = key_SU_encode(ord, ord_buf); - + wrbuf_putc(term_dict, '('); - + for (i = 0; ireg->dict, wrbuf_cstr(term_dict), regex_range, - grep_info, &max_pos, + grep_info, &max_pos, ord_len /* number of "exact" chars */, grep_handle); if (r == 1) @@ -1374,7 +1374,7 @@ static ZEBRA_RES grep_info_prepare(ZebraHandle zh, const char *termset_name = 0; if (termset_value_numeric != -2) { - + sprintf(resname, "%d", termset_value_numeric); termset_name = resname; } @@ -1410,18 +1410,18 @@ static ZEBRA_RES search_terms_chrmap(ZebraHandle zh, struct grep_info grep_info; const char *termp = termz; int alloc_sets = 0; - + *num_result_sets = 0; if (grep_info_prepare(zh, zapt, &grep_info, index_type) == ZEBRA_FAIL) return ZEBRA_FAIL; while (1) - { + { ZEBRA_RES res; if (alloc_sets == *num_result_sets) { int add = 10; - RSET *rnew = (RSET *) nmem_malloc(stream, (alloc_sets+add) * + RSET *rnew = (RSET *) nmem_malloc(stream, (alloc_sets+add) * sizeof(*rnew)); if (alloc_sets) memcpy(rnew, *result_sets, alloc_sets * sizeof(*rnew)); @@ -1453,7 +1453,7 @@ static ZEBRA_RES search_terms_chrmap(ZebraHandle zh, grep_info_delete(&grep_info); return ZEBRA_OK; } - + /** \brief Create result set(s) for list of terms \param zh Zebra Handle @@ -1511,7 +1511,7 @@ static ZEBRA_RES search_position(ZebraHandle zh, char *val; ISAM_P isam_p; zebra_map_t zm = zebra_map_get_or_add(zh->reg->zebra_maps, index_type); - + attr_init_APT(&position, zapt, 3); position_value = attr_find(&position, NULL); switch(position_value) @@ -1550,7 +1550,7 @@ static ZEBRA_RES search_position(ZebraHandle zh, assert(*val == sizeof(ISAM_P)); memcpy(&isam_p, val+1, sizeof(isam_p)); - *rset = zebra_create_rset_isam(zh, rset_nmem, kc, kc->scope, + *rset = zebra_create_rset_isam(zh, rset_nmem, kc, kc->scope, isam_p, 0); } return ZEBRA_OK; @@ -1580,14 +1580,14 @@ static ZEBRA_RES rpn_search_APT_phrase(ZebraHandle zh, rank_type, xpath_use, rset_nmem, &result_sets, &num_result_sets, kc); - + if (res != ZEBRA_OK) return res; if (num_result_sets > 0) { RSET first_set = 0; - res = search_position(zh, zapt, attributeSet, + res = search_position(zh, zapt, attributeSet, index_type, rset_nmem, &first_set, kc); @@ -1609,7 +1609,7 @@ static ZEBRA_RES rpn_search_APT_phrase(ZebraHandle zh, } } if (num_result_sets == 0) - *rset = rset_create_null(rset_nmem, kc, 0); + *rset = rset_create_null(rset_nmem, kc, 0); else if (num_result_sets == 1) *rset = result_sets[0]; else @@ -1630,7 +1630,7 @@ static ZEBRA_RES rpn_search_APT_or_list(ZebraHandle zh, const Odr_oid *attributeSet, zint hits_limit, NMEM stream, - const char *index_type, + const char *index_type, int complete_flag, const char *rank_type, const char *xpath_use, @@ -1653,7 +1653,7 @@ static ZEBRA_RES rpn_search_APT_or_list(ZebraHandle zh, for (i = 0; iscope, 2, tmp_set, @@ -1679,7 +1679,7 @@ static ZEBRA_RES rpn_search_APT_or_list(ZebraHandle zh, } } if (num_result_sets == 0) - *rset = rset_create_null(rset_nmem, kc, 0); + *rset = rset_create_null(rset_nmem, kc, 0); else if (num_result_sets == 1) *rset = result_sets[0]; else @@ -1698,9 +1698,9 @@ static ZEBRA_RES rpn_search_APT_and_list(ZebraHandle zh, const Odr_oid *attributeSet, zint hits_limit, NMEM stream, - const char *index_type, + const char *index_type, int complete_flag, - const char *rank_type, + const char *rank_type, const char *xpath_use, NMEM rset_nmem, RSET *rset, @@ -1721,7 +1721,7 @@ static ZEBRA_RES rpn_search_APT_and_list(ZebraHandle zh, for (i = 0; iscope, 2, tmp_set, @@ -1749,7 +1749,7 @@ static ZEBRA_RES rpn_search_APT_and_list(ZebraHandle zh, if (num_result_sets == 0) - *rset = rset_create_null(rset_nmem, kc, 0); + *rset = rset_create_null(rset_nmem, kc, 0); else if (num_result_sets == 1) *rset = result_sets[0]; else @@ -1787,7 +1787,7 @@ static int numeric_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt, case 1: yaz_log(log_level_rpn, "Relation <"); if (!term_100(zm, term_sub, term_num, 1, display_term)) - { + { wrbuf_destroy(term_num); return 0; } @@ -1830,7 +1830,7 @@ static int numeric_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt, if (!term_100(zm, term_sub, term_num, 1, display_term)) { wrbuf_destroy(term_num); - return 0; + return 0; } term_value = atoi(wrbuf_cstr(term_num)); wrbuf_printf(term_dict, "(0*%d)", term_value); @@ -1842,10 +1842,10 @@ static int numeric_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt, break; default: *error_code = YAZ_BIB1_UNSUPP_RELATION_ATTRIBUTE; - wrbuf_destroy(term_num); + wrbuf_destroy(term_num); return 0; } - r = dict_lookup_grep(zh->reg->dict, wrbuf_cstr(term_dict), + r = dict_lookup_grep(zh->reg->dict, wrbuf_cstr(term_dict), 0, grep_info, max_pos, 0, grep_handle); if (r == 1) @@ -1858,7 +1858,7 @@ static int numeric_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt, } static ZEBRA_RES numeric_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, - const char **term_sub, + const char **term_sub, WRBUF term_dict, const Odr_oid *attributeSet, NMEM stream, struct grep_info *grep_info, @@ -1874,25 +1874,25 @@ static ZEBRA_RES numeric_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, int ord, ord_len, i; char ord_buf[32]; zebra_map_t zm = zebra_map_get_or_add(zh->reg->zebra_maps, index_type); - + *ol = ord_list_create(stream); rpn_char_map_prepare(zh->reg, zm, &rcmi); termp = *term_sub; - + if (zebra_apt_get_ord(zh, zapt, index_type, xpath_use, attributeSet, &ord) != ZEBRA_OK) { return ZEBRA_FAIL; } - + wrbuf_rewind(term_dict); - + *ol = ord_list_append(stream, *ol, ord); - + ord_len = key_SU_encode(ord, ord_buf); - + wrbuf_putc(term_dict, '('); for (i = 0; i < ord_len; i++) { @@ -1900,7 +1900,7 @@ static ZEBRA_RES numeric_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, wrbuf_putc(term_dict, ord_buf[i]); } wrbuf_putc(term_dict, ')'); - + if (!numeric_relation(zh, zapt, &termp, term_dict, attributeSet, grep_info, &max_pos, zm, display_term, &relation_error)) @@ -1918,16 +1918,16 @@ static ZEBRA_RES numeric_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, return ZEBRA_OK; } - + static ZEBRA_RES rpn_search_APT_numeric(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char *termz, const Odr_oid *attributeSet, zint hits_limit, NMEM stream, - const char *index_type, + const char *index_type, int complete_flag, - const char *rank_type, + const char *rank_type, const char *xpath_use, NMEM rset_nmem, RSET *rset, @@ -1949,14 +1949,14 @@ static ZEBRA_RES rpn_search_APT_numeric(ZebraHandle zh, if (grep_info_prepare(zh, zapt, &grep_info, index_type) == ZEBRA_FAIL) return ZEBRA_FAIL; while (1) - { + { struct ord_list *ol; WRBUF term_dict = wrbuf_alloc(); WRBUF display_term = wrbuf_alloc(); if (alloc_sets == num_result_sets) { int add = 10; - RSET *rnew = (RSET *) nmem_malloc(stream, (alloc_sets+add) * + RSET *rnew = (RSET *) nmem_malloc(stream, (alloc_sets+add) * sizeof(*rnew)); if (alloc_sets) memcpy(rnew, result_sets, alloc_sets * sizeof(*rnew)); @@ -1981,7 +1981,7 @@ static ZEBRA_RES rpn_search_APT_numeric(ZebraHandle zh, grep_info.isam_p_indx, wrbuf_buf(display_term), wrbuf_len(display_term), rank_type, 0 /* preserve position */, - zapt->term->which, rset_nmem, + zapt->term->which, rset_nmem, kc, kc->scope, ol, index_type, hits_limit_value, term_ref_id_str); @@ -2019,7 +2019,7 @@ static ZEBRA_RES rpn_search_APT_local(ZebraHandle zh, { Record rec; zint sysno = atozint(termz); - + if (sysno <= 0) sysno = 0; rec = rec_get(zh->reg->records, sysno); @@ -2039,7 +2039,7 @@ static ZEBRA_RES rpn_search_APT_local(ZebraHandle zh, *rset = rset_create_temp(rset_nmem, kc, kc->scope, res_get(zh->res, "setTmpDir"), 0); rsfd = rset_open(*rset, RSETF_WRITE); - + key.mem[0] = sysno; key.mem[1] = 1; key.len = 2; @@ -2063,7 +2063,7 @@ static ZEBRA_RES rpn_sort_spec(ZebraHandle zh, Z_AttributesPlusTerm *zapt, Z_SortKeySpec *sks; Z_SortKey *sk; char termz[20]; - + attr_init_APT(&sort_relation_type, zapt, 7); sort_relation_value = attr_find(&sort_relation_type, &attributeSet); @@ -2104,7 +2104,7 @@ static ZEBRA_RES rpn_sort_spec(ZebraHandle zh, Z_AttributesPlusTerm *zapt, *sks->sortRelation = Z_SortKeySpec_ascending; else if (sort_relation_value == 2) *sks->sortRelation = Z_SortKeySpec_descending; - else + else *sks->sortRelation = Z_SortKeySpec_ascending; sks->caseSensitivity = (Odr_int *) @@ -2127,7 +2127,7 @@ static int rpn_check_xpath(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const Odr_oid *curAttributeSet = attributeSet; AttrType use; const char *use_string = 0; - + attr_init_APT(&use, zapt, 1); attr_find_ex(&use, &curAttributeSet, &use_string); @@ -2136,22 +2136,22 @@ static int rpn_check_xpath(ZebraHandle zh, Z_AttributesPlusTerm *zapt, return zebra_parse_xpath_str(use_string, xpath, max, mem); } - - + + static RSET xpath_trunc(ZebraHandle zh, NMEM stream, - const char *index_type, const char *term, + const char *index_type, const char *term, const char *xpath_use, NMEM rset_nmem, struct rset_key_control *kc) { struct grep_info grep_info; - int ord = zebraExplain_lookup_attr_str(zh->reg->zei, + int ord = zebraExplain_lookup_attr_str(zh->reg->zei, zinfo_index_category_index, index_type, xpath_use); if (grep_info_prepare(zh, 0 /* zapt */, &grep_info, "0") == ZEBRA_FAIL) return rset_create_null(rset_nmem, kc, 0); - + if (ord < 0) return rset_create_null(rset_nmem, kc, 0); else @@ -2172,7 +2172,7 @@ static RSET xpath_trunc(ZebraHandle zh, NMEM stream, } wrbuf_putc(term_dict, ')'); wrbuf_puts(term_dict, term); - + grep_info.isam_p_indx = 0; dict_lookup_grep(zh->reg->dict, wrbuf_cstr(term_dict), 0, &grep_info, &max_pos, 0, grep_handle); @@ -2229,15 +2229,15 @@ ZEBRA_RES rpn_search_xpath(ZebraHandle zh, /a/b[@c = y] val range(b/a/,freetext(w,1016,val),b/a/,@c = y) /a[@c = y]/b val range(a/,range(b/a/,freetext(w,1016,val),b/a/),a/,@c = y) /a[@c = x]/b[@c = y] range(a/,range(b/a/,freetext(w,1016,val),b/a/,@c = y),a/,@c = x) - + */ dict_grep_cmap(zh->reg->dict, 0, 0); - + { int level = xpath_len; int first_path = 1; - + while (--level >= 0) { WRBUF xpath_rev = wrbuf_alloc(); @@ -2277,7 +2277,7 @@ ZEBRA_RES rpn_search_xpath(ZebraHandle zh, { const char *cp = xpath[level].predicate->u.relation.value; wrbuf_putc(wbuf, '='); - + while (*cp) { if (strchr(REGEX_CHARS, *cp)) @@ -2287,12 +2287,12 @@ ZEBRA_RES rpn_search_xpath(ZebraHandle zh, } } rset_attr = xpath_trunc( - zh, stream, "0", wrbuf_cstr(wbuf), - ZEBRA_XPATH_ATTR_NAME, + zh, stream, "0", wrbuf_cstr(wbuf), + ZEBRA_XPATH_ATTR_NAME, rset_nmem, kc); wrbuf_destroy(wbuf); - } - else + } + else { if (!first_path) { @@ -2300,23 +2300,23 @@ ZEBRA_RES rpn_search_xpath(ZebraHandle zh, continue; } } - yaz_log(log_level_rpn, "xpath_rev (%d) = %s", level, + yaz_log(log_level_rpn, "xpath_rev (%d) = %s", level, wrbuf_cstr(xpath_rev)); if (wrbuf_len(xpath_rev)) { - rset_start_tag = xpath_trunc(zh, stream, "0", + rset_start_tag = xpath_trunc(zh, stream, "0", wrbuf_cstr(xpath_rev), - ZEBRA_XPATH_ELM_BEGIN, + ZEBRA_XPATH_ELM_BEGIN, rset_nmem, kc); if (always_matches) rset = rset_start_tag; else { - rset_end_tag = xpath_trunc(zh, stream, "0", + rset_end_tag = xpath_trunc(zh, stream, "0", wrbuf_cstr(xpath_rev), - ZEBRA_XPATH_ELM_END, + ZEBRA_XPATH_ELM_END, rset_nmem, kc); - + rset = rset_create_between(rset_nmem, kc, kc->scope, rset_start_tag, rset, rset_end_tag, rset_attr); @@ -2332,7 +2332,7 @@ ZEBRA_RES rpn_search_xpath(ZebraHandle zh, #define MAX_XPATH_STEPS 10 -static ZEBRA_RES rpn_search_database(ZebraHandle zh, +static ZEBRA_RES rpn_search_database(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const Odr_oid *attributeSet, zint hits_limit, NMEM stream, @@ -2345,7 +2345,7 @@ static ZEBRA_RES rpn_search_APT(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const Odr_oid *attributeSet, zint hits_limit, NMEM stream, Z_SortKeySpecList *sort_sequence, - int num_bases, const char **basenames, + int num_bases, const char **basenames, NMEM rset_nmem, RSET *rset, struct rset_key_control *kc) @@ -2375,12 +2375,12 @@ static ZEBRA_RES rpn_search_APT(ZebraHandle zh, Z_AttributesPlusTerm *zapt, rset_delete(rsets[i]); *rset = 0; } - else + else { if (num_bases == 1) *rset = rsets[0]; else if (num_bases == 0) - *rset = rset_create_null(rset_nmem, kc, 0); + *rset = rset_create_null(rset_nmem, kc, 0); else *rset = rset_create_or(rset_nmem, kc, kc->scope, 0 /* TERMID */, num_bases, rsets); @@ -2388,7 +2388,7 @@ static ZEBRA_RES rpn_search_APT(ZebraHandle zh, Z_AttributesPlusTerm *zapt, return res; } -static ZEBRA_RES rpn_search_database(ZebraHandle zh, +static ZEBRA_RES rpn_search_database(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const Odr_oid *attributeSet, zint hits_limit, NMEM stream, @@ -2415,7 +2415,7 @@ static ZEBRA_RES rpn_search_database(ZebraHandle zh, } zebra_maps_attr(zh->reg->zebra_maps, zapt, &index_type, &search_type, rank_type, &complete_flag, &sort_flag); - + yaz_log(YLOG_DEBUG, "index_type=%s", index_type); yaz_log(YLOG_DEBUG, "complete_flag=%d", complete_flag); yaz_log(YLOG_DEBUG, "search_type=%s", search_type); @@ -2428,14 +2428,14 @@ static ZEBRA_RES rpn_search_database(ZebraHandle zh, return rpn_sort_spec(zh, zapt, attributeSet, stream, sort_sequence, rank_type, rset_nmem, rset, kc); /* consider if an X-Path query is used */ - xpath_len = rpn_check_xpath(zh, zapt, attributeSet, + xpath_len = rpn_check_xpath(zh, zapt, attributeSet, xpath, MAX_XPATH_STEPS, stream); if (xpath_len >= 0) { - if (xpath[xpath_len-1].part[0] == '@') + if (xpath[xpath_len-1].part[0] == '@') xpath_use = ZEBRA_XPATH_ATTR_CDATA; /* last step is attribute */ else - xpath_use = ZEBRA_XPATH_CDATA; /* searching for cdata */ + xpath_use = ZEBRA_XPATH_CDATA; /* searching for cdata */ if (1) { @@ -2448,7 +2448,7 @@ static ZEBRA_RES rpn_search_database(ZebraHandle zh, if (relation_value == 103) /* alwaysmatches */ { *rset = 0; /* signal no "term" set */ - return rpn_search_xpath(zh, stream, rank_type, *rset, + return rpn_search_xpath(zh, stream, rank_type, *rset, xpath_len, xpath, rset_nmem, rset, kc); } } @@ -2456,7 +2456,7 @@ static ZEBRA_RES rpn_search_database(ZebraHandle zh, /* search using one of the various search type strategies termz is our UTF-8 search term - attributeSet is top-level default attribute set + attributeSet is top-level default attribute set stream is ODR for search reg_id is the register type complete_flag is 1 for complete subfield, 0 for incomplete @@ -2512,7 +2512,7 @@ static ZEBRA_RES rpn_search_database(ZebraHandle zh, return res; if (!*rset) return ZEBRA_FAIL; - return rpn_search_xpath(zh, stream, rank_type, *rset, + return rpn_search_xpath(zh, stream, rank_type, *rset, xpath_len, xpath, rset_nmem, rset, kc); } @@ -2546,9 +2546,9 @@ ZEBRA_RES rpn_get_top_approx_limit(ZebraHandle zh, Z_RPNStructure *zs, Z_AttributesPlusTerm *zapt = zs->u.simple->u.attributesPlusTerm; AttrType global_hits_limit_attr; int l; - + attr_init_APT(&global_hits_limit_attr, zapt, 12); - + l = attr_find(&global_hits_limit_attr, NULL); if (l != -1) *approx_limit = l; @@ -2558,7 +2558,7 @@ ZEBRA_RES rpn_get_top_approx_limit(ZebraHandle zh, Z_RPNStructure *zs, } ZEBRA_RES rpn_search_top(ZebraHandle zh, Z_RPNStructure *zs, - const Odr_oid *attributeSet, + const Odr_oid *attributeSet, zint hits_limit, NMEM stream, NMEM rset_nmem, Z_SortKeySpecList *sort_sequence, @@ -2572,7 +2572,7 @@ ZEBRA_RES rpn_search_top(ZebraHandle zh, Z_RPNStructure *zs, res = rpn_search_structure(zh, zs, attributeSet, hits_limit, stream, rset_nmem, - sort_sequence, + sort_sequence, num_bases, basenames, &result_sets, &num_result_sets, 0 /* no parent op */, @@ -2645,11 +2645,11 @@ ZEBRA_RES rpn_search_structure(ZebraHandle zh, Z_RPNStructure *zs, /* make a new list of result for all children */ *num_result_sets = num_result_sets_l + num_result_sets_r; - *result_sets = nmem_malloc(stream, *num_result_sets * + *result_sets = nmem_malloc(stream, *num_result_sets * sizeof(**result_sets)); - memcpy(*result_sets, result_sets_l, + memcpy(*result_sets, result_sets_l, num_result_sets_l * sizeof(**result_sets)); - memcpy(*result_sets + num_result_sets_l, result_sets_r, + memcpy(*result_sets + num_result_sets_l, result_sets_r, num_result_sets_r * sizeof(**result_sets)); if (!parent_op || parent_op->which != zop->which @@ -2680,7 +2680,7 @@ ZEBRA_RES rpn_search_structure(ZebraHandle zh, Z_RPNStructure *zs, case Z_Operator_prox: if (zop->u.prox->which != Z_ProximityOperator_known) { - zebra_setError(zh, + zebra_setError(zh, YAZ_BIB1_UNSUPP_PROX_UNIT_CODE, 0); return ZEBRA_FAIL; @@ -2696,9 +2696,9 @@ ZEBRA_RES rpn_search_structure(ZebraHandle zh, Z_RPNStructure *zs, { rset = rset_create_prox(rset_nmem, kc, kc->scope, - *num_result_sets, *result_sets, + *num_result_sets, *result_sets, *zop->u.prox->ordered, - (!zop->u.prox->exclusion ? + (!zop->u.prox->exclusion ? 0 : *zop->u.prox->exclusion), *zop->u.prox->relationType, *zop->u.prox->distance ); @@ -2709,7 +2709,7 @@ ZEBRA_RES rpn_search_structure(ZebraHandle zh, Z_RPNStructure *zs, return ZEBRA_FAIL; } *num_result_sets = 1; - *result_sets = nmem_malloc(stream, *num_result_sets * + *result_sets = nmem_malloc(stream, *num_result_sets * sizeof(**result_sets)); (*result_sets)[0] = rset; } @@ -2736,7 +2736,7 @@ ZEBRA_RES rpn_search_structure(ZebraHandle zh, Z_RPNStructure *zs, rset = resultSetRef(zh, zs->u.simple->u.resultSetId); if (!rset) { - zebra_setError(zh, + zebra_setError(zh, YAZ_BIB1_SPECIFIED_RESULT_SET_DOES_NOT_EXIST, zs->u.simple->u.resultSetId); return ZEBRA_FAIL; @@ -2749,7 +2749,7 @@ ZEBRA_RES rpn_search_structure(ZebraHandle zh, Z_RPNStructure *zs, return ZEBRA_FAIL; } *num_result_sets = 1; - *result_sets = nmem_malloc(stream, *num_result_sets * + *result_sets = nmem_malloc(stream, *num_result_sets * sizeof(**result_sets)); (*result_sets)[0] = rset; } diff --git a/index/rset_isam.c b/index/rset_isam.c index 9142dd2..8ea67df 100644 --- a/index/rset_isam.c +++ b/index/rset_isam.c @@ -18,7 +18,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file - \brief factory function for RSET from ISAM + \brief factory function for RSET from ISAM */ #if HAVE_CONFIG_H #include diff --git a/index/sortidx.c b/index/sortidx.c index dc27758..36bf914 100644 --- a/index/sortidx.c +++ b/index/sortidx.c @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #if HAVE_CONFIG_H #include #endif -#include +#include #include #include @@ -158,7 +158,7 @@ static int sort_term_code_read(void *vp, char **dst, int *insertMode) return 0; (s->no)--; - + *insertMode = s->insert_flag; memcpy(*dst, &s->st, sizeof(s->st)); *dst += sizeof(s->st); @@ -282,7 +282,7 @@ int zebra_sort_type(zebra_sort_index_t si, int id) case ZEBRA_SORT_TYPE_ISAMB: method.codec.encode = sort_term_encode1; method.codec.decode = sort_term_decode1; - + sprintf(fname, "sortb%d", id); sf->u.isamb = isamb_open2(si->bfs, fname, si->write_flag, &method, /* cache */ 0, @@ -302,7 +302,7 @@ int zebra_sort_type(zebra_sort_index_t si, int id) isam_block_size = 32768; method.codec.encode = sort_term_encode2; method.codec.decode = sort_term_decode2; - + sprintf(fname, "sortm%d", id); sf->u.isamb = isamb_open2(si->bfs, fname, si->write_flag, &method, /* cache */ 0, @@ -376,12 +376,12 @@ void zebra_sort_delete(zebra_sort_index_t si, zint section_id) s.st.section_id = section_id; s.st.length = 0; s.st.term[0] = '\0'; - + s.no = 1; s.insert_flag = 0; isamc_i.clientData = &s; isamc_i.read_item = sort_term_code_read; - + isamb_merge(sf->u.isamb, &sf->isam_p, &isamc_i); sf->no_deleted++; } @@ -403,7 +403,7 @@ void zebra_sort_add(zebra_sort_index_t si, zint section_id, WRBUF wrbuf) len = strlen(wrbuf_buf(wrbuf)); if (len > SORT_IDX_ENTRYSIZE) len = SORT_IDX_ENTRYSIZE; - + memcpy(si->entry_buf, wrbuf_buf(wrbuf), len); if (len < SORT_IDX_ENTRYSIZE-len) memset(si->entry_buf+len, 0, SORT_IDX_ENTRYSIZE-len); @@ -432,7 +432,7 @@ void zebra_sort_add(zebra_sort_index_t si, zint section_id, WRBUF wrbuf) s.insert_flag = 1; isamc_i.clientData = &s; isamc_i.read_item = sort_term_code_read; - + isamb_merge(sf->u.isamb, &sf->isam_p, &isamc_i); sf->no_inserted++; } @@ -457,7 +457,7 @@ void zebra_sort_add(zebra_sort_index_t si, zint section_id, WRBUF wrbuf) s.insert_flag = 1; isamc_i.clientData = &s; isamc_i.read_item = sort_term_code_read; - + isamb_merge(sf->u.isamb, &sf->isam_p, &isamc_i); sf->no_inserted++; } diff --git a/index/stream.c b/index/stream.c index d1b0141..f763eb6 100644 --- a/index/stream.c +++ b/index/stream.c @@ -145,7 +145,7 @@ void zebra_create_stream_fd(struct ZebraRecStream *stream, fc->fd = fd; fc->record_offset = start_offset; fc->offset_end = 0; - + stream->fh = fc; stream->readf = zebra_ext_read; stream->seekf = zebra_ext_seek; diff --git a/index/trunc.c b/index/trunc.c index b8feeea..1127c1f 100644 --- a/index/trunc.c +++ b/index/trunc.c @@ -149,23 +149,23 @@ static RSET rset_trunc_r(ZebraHandle zi, const char *term, int length, int cmp_border = preserve_position ? 0 : 1; NMEM rset_nmem_sub = nmem_create(); /* all sub rsets not needed after this */ - + rset = (RSET *) xmalloc(sizeof(*rset) * rsmax); rsfd = (RSFD *) xmalloc(sizeof(*rsfd) * rsmax); - + for (i = from; i < to; i += i_add) { if (i_add <= to - i) rset[rscur] = rset_trunc_r(zi, term, length, flags, isam_p, i, i+i_add, merge_chunk, preserve_position, - term_type, rset_nmem_sub, + term_type, rset_nmem_sub, kctrl, scope, 0); else rset[rscur] = rset_trunc_r(zi, term, length, flags, isam_p, i, to, merge_chunk, preserve_position, - term_type, rset_nmem_sub, + term_type, rset_nmem_sub, kctrl, scope, 0); rscur++; } @@ -414,7 +414,7 @@ RSET rset_trunc(ZebraHandle zh, ISAM_P *isam_p, int no, termid = rset_term_create(term, length, flags, term_type, rset_nmem, ol, *index_type, hits_limit, term_ref_id); - + if (no < 1) return rset_create_null(rset_nmem, kctrl, termid); else if (no == 1) diff --git a/index/untrans.c b/index/untrans.c index 8143342..efdb9cc 100644 --- a/index/untrans.c +++ b/index/untrans.c @@ -61,14 +61,14 @@ int zebra_term_untrans(ZebraHandle zh, const char *index_type, return 0; } -int zebra_term_untrans_iconv(ZebraHandle zh, NMEM stream, +int zebra_term_untrans_iconv(ZebraHandle zh, NMEM stream, const char *index_type, char **dst, const char *src) { char term_src[IT_MAX_WORD]; char term_dst[IT_MAX_WORD]; int r; - + r = zebra_term_untrans (zh, index_type, term_src, src); if (r) return r; @@ -81,7 +81,7 @@ int zebra_term_untrans_iconv(ZebraHandle zh, NMEM stream, char *outbuf = term_dst; size_t outleft = sizeof(term_dst)-1; size_t ret; - + ret = yaz_iconv (zh->iconv_from_utf8, &inbuf, &inleft, &outbuf, &outleft); if (ret == (size_t)(-1)) diff --git a/index/update_file.c b/index/update_file.c index 072444a..9a2e6dd 100644 --- a/index/update_file.c +++ b/index/update_file.c @@ -49,7 +49,7 @@ static void dump_file_dict(Dict dict) int before = 10; int after = 1000; char term[1000]; - + strcpy(term, "0"); dict_scan(dict, term, &before, &after, 0, dump_file_dict_func); } @@ -77,7 +77,7 @@ static void fileDelete_r(ZebraHandle zh, sprintf(tmppath, "%s%s", base, dst->path); zebra_extract_file(zh, &dst->sysno, tmppath, action_delete); strcpy(tmppath, dst->path); - dst = dirs_read(di); + dst = dirs_read(di); dirs_del(di, tmppath); break; case dirs_dir: @@ -93,7 +93,7 @@ static void fileDelete_r(ZebraHandle zh, static void file_update_r(ZebraHandle zh, struct dirs_info *di, struct dirs_entry *dst, - const char *base, char *src, + const char *base, char *src, int level) { struct dir_entry *e_src; @@ -136,7 +136,7 @@ static void file_update_r(ZebraHandle zh, src[src_len] = '/'; src[++src_len] = '\0'; } - dst = dirs_read(di); + dst = dirs_read(di); } dir_sort(e_src); @@ -165,7 +165,7 @@ static void file_update_r(ZebraHandle zh, { strcpy(src + src_len, e_src[i_src].name); sprintf(tmppath, "%s%s", base, src); - + switch(e_src[i_src].kind) { case dirs_file: @@ -186,7 +186,7 @@ static void file_update_r(ZebraHandle zh, yaz_log(YLOG_DEBUG, "last is %s", dst ? dst->path : "null"); break; default: - dst = dirs_read(di); + dst = dirs_read(di); } i_src++; } @@ -200,7 +200,7 @@ static void file_update_r(ZebraHandle zh, { case dirs_file: if (zebra_extract_file(zh, &sysno, tmppath, action_update) == ZEBRA_OK) - dirs_add(di, src, sysno, e_src[i_src].mtime); + dirs_add(di, src, sysno, e_src[i_src].mtime); break; case dirs_dir: file_update_r(zh, di, dst, base, src, level+1); @@ -257,7 +257,7 @@ static void file_update_top(ZebraHandle zh, Dict dict, const char *path) if (ret == -1) { yaz_log(YLOG_WARN|YLOG_ERRNO, "Cannot access path %s", src); - } + } else if (S_ISREG(sbuf.st_mode)) { struct dirs_entry *e_dst; @@ -315,7 +315,7 @@ static ZEBRA_RES zebra_open_fmatch(ZebraHandle zh, Dict *dictp) ZEBRA_RES zebra_remove_file_match(ZebraHandle zh) { Dict dict; - + if (zebra_open_fmatch(zh, &dict) != ZEBRA_OK) return ZEBRA_FAIL; @@ -336,7 +336,7 @@ ZEBRA_RES zebra_update_file_match(ZebraHandle zh, const char *path) } if (zebra_open_fmatch(zh, &dict) != ZEBRA_OK) return ZEBRA_FAIL; - + if (!strcmp(path, "") || !strcmp(path, "-")) { char src[1024]; diff --git a/index/update_path.c b/index/update_path.c index 6e4585c..1c4faa6 100644 --- a/index/update_path.c +++ b/index/update_path.c @@ -52,7 +52,7 @@ static void repositoryExtractR(ZebraHandle zh, char *rep, int level, rep[rep_len] = '/'; else --rep_len; - + for (i=0; e[i].name; i++) { char *ecp; @@ -87,19 +87,19 @@ void repositoryShow(ZebraHandle zh, const char *path) yaz_log(YLOG_FATAL, "dict_open fail of %s", FMATCH_DICT); return; } - + strncpy(src, path, sizeof(src)-1); src[sizeof(src)-1]='\0'; src_len = strlen(src); - + if (src_len && src[src_len-1] != '/') { src[src_len] = '/'; src[++src_len] = '\0'; } - + di = dirs_open(dict, src, zh->m_flag_rw); - + while ((dst = dirs_read(di))) yaz_log(YLOG_LOG, "%s", dst->path); dirs_free(&di); @@ -140,13 +140,13 @@ static void repositoryExtract(ZebraHandle zh, } -ZEBRA_RES zebra_update_from_path(ZebraHandle zh, const char *path, +ZEBRA_RES zebra_update_from_path(ZebraHandle zh, const char *path, enum zebra_recctrl_action_t action) { if (!strcmp(path, "") || !strcmp(path, "-")) { char src[1024]; - + while (scanf("%1020s", src) == 1) repositoryExtract(zh, src, action); } diff --git a/index/zebraapi.c b/index/zebraapi.c index 2e64dd0..4ed0a54 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -96,7 +96,7 @@ static ZEBRA_RES zebra_flush_reg(ZebraHandle zh) return ZEBRA_OK; } -static struct zebra_register *zebra_register_open(ZebraService zs, +static struct zebra_register *zebra_register_open(ZebraService zs, const char *name, int rw, int useshadow, Res res, @@ -133,7 +133,7 @@ ZebraHandle zebra_open(ZebraService zs, Res res) zh->destroyed = 0; zh->errCode = 0; zh->errString = 0; - zh->res = 0; + zh->res = 0; zh->session_res = res_open(zs->global_res, res); zh->user_perm = 0; zh->dbaccesslist = 0; @@ -245,13 +245,13 @@ ZebraService zebra_start_res(const char *configName, Res def_res, Res over_res) zh = xmalloc(sizeof(*zh)); zh->global_res = res; zh->sessions = 0; - + if (zebra_chdir(zh)) { xfree(zh); return 0; } - + zebra_mutex_cond_init(&zh->session_lock); passwd_plain = res_get(zh->global_res, "passwd"); passwd_encrypt = res_get(zh->global_res, "passwd.c"); @@ -259,7 +259,7 @@ ZebraService zebra_start_res(const char *configName, Res def_res, Res over_res) if (!passwd_plain && !passwd_encrypt) zh->passwd_db = NULL; - else + else { zh->passwd_db = passwd_db_open(); if (!zh->passwd_db) @@ -343,7 +343,7 @@ struct zebra_register *zebra_register_open(ZebraService zs, const char *name, ZEBRA_RES ret = ZEBRA_OK; ASSERTZS; - + reg = xmalloc(sizeof(*reg)); assert(name); @@ -356,7 +356,7 @@ struct zebra_register *zebra_register_open(ZebraService zs, const char *name, yaz_log(YLOG_DEBUG, "zebra_register_open rw=%d useshadow=%d p=%p n=%s rp=%s", rw, useshadow, reg, name, reg_path ? reg_path : "(none)"); - + reg->dh = data1_create(); if (!reg->dh) { @@ -416,7 +416,7 @@ struct zebra_register *zebra_register_open(ZebraService zs, const char *name, reg->isamc = 0; reg->isamb = 0; reg->zei = 0; - + /* installing rank classes */ zebraRankInstall(reg, rank_1_class); zebraRankInstall(reg, rank_2_class); @@ -471,7 +471,7 @@ struct zebra_register *zebra_register_open(ZebraService zs, const char *name, ret = ZEBRA_FAIL; } - + if (res_get_match(res, "sortindex", "f", "f")) sort_type = ZEBRA_SORT_TYPE_FLAT; else if (res_get_match(res, "sortindex", "i", "f")) @@ -513,7 +513,7 @@ struct zebra_register *zebra_register_open(ZebraService zs, const char *name, if (res_get_match(res, "isam", "b", ISAM_DEFAULT)) { struct ISAMC_M_s isamc_m; - + if (!(reg->isamb = isamb_open(reg->bfs, "isamb", rw, key_isamc_m(res, &isamc_m), 0))) { @@ -524,7 +524,7 @@ struct zebra_register *zebra_register_open(ZebraService zs, const char *name, if (res_get_match(res, "isam", "bc", ISAM_DEFAULT)) { struct ISAMC_M_s isamc_m; - + if (!(reg->isamb = isamb_open(reg->bfs, "isamb", rw, key_isamc_m(res, &isamc_m), 1))) { @@ -535,7 +535,7 @@ struct zebra_register *zebra_register_open(ZebraService zs, const char *name, if (res_get_match(res, "isam", "null", ISAM_DEFAULT)) { struct ISAMC_M_s isamc_m; - + if (!(reg->isamb = isamb_open(reg->bfs, "isamb", rw, key_isamc_m(res, &isamc_m), -1))) { @@ -554,7 +554,7 @@ struct zebra_register *zebra_register_open(ZebraService zs, const char *name, ret = ZEBRA_FAIL; } } - + if (ret != ZEBRA_OK) { zebra_register_close(zs, reg); @@ -593,7 +593,7 @@ static void zebra_register_close(ZebraService zs, struct zebra_register *reg) yaz_log(YLOG_DEBUG, "zebra_register_close p=%p", reg); reg->stop_flag = 0; zebra_chdir(zs); - + zebraExplain_close(reg->zei); dict_close(reg->dict); if (reg->matchDict) @@ -629,7 +629,7 @@ ZEBRA_RES zebra_stop(ZebraService zs) { zebra_close(zs->sessions); } - + zebra_mutex_cond_destroy(&zs->session_lock); if (zs->passwd_db) @@ -644,7 +644,7 @@ ZEBRA_RES zebra_stop(ZebraService zs) yaz_timing_get_real(zs->timing), yaz_timing_get_user(zs->timing), yaz_timing_get_sys(zs->timing)); - + yaz_timing_destroy(&zs->timing); xfree(zs); @@ -661,7 +661,7 @@ ZEBRA_RES zebra_close(ZebraHandle zh) ZEBRA_CHECK_HANDLE(zh); zh->errCode = 0; - + zs = zh->service; yaz_log(YLOG_DEBUG, "zebra_close zh=%p", zh); resultSetDestroy(zh, -1, 0, 0); @@ -781,7 +781,7 @@ static void zebra_select_register(ZebraHandle zh, const char *new_reg) zh->path_reg = 0; if (zh->service->path_root) { - zh->path_reg = xmalloc(strlen(zh->service->path_root) + + zh->path_reg = xmalloc(strlen(zh->service->path_root) + strlen(zh->reg_name) + 3); strcpy(zh->path_reg, zh->service->path_root); if (*zh->reg_name) @@ -791,7 +791,7 @@ static void zebra_select_register(ZebraHandle zh, const char *new_reg) } } zebra_open_res(zh); - + if (zh->lock_normal) zebra_lock_destroy(zh->lock_normal); zh->lock_normal = 0; @@ -804,13 +804,13 @@ static void zebra_select_register(ZebraHandle zh, const char *new_reg) { char fname[512]; const char *lock_area = res_get(zh->res, "lockDir"); - + if (!lock_area && zh->path_reg) res_set(zh->res, "lockDir", zh->path_reg); sprintf(fname, "norm.%s.LCK", zh->reg_name); zh->lock_normal = zebra_lock_create(res_get(zh->res, "lockDir"), fname); - + sprintf(fname, "shadow.%s.LCK", zh->reg_name); zh->lock_shadow = zebra_lock_create(res_get(zh->res, "lockDir"), fname); @@ -843,7 +843,7 @@ static void zebra_select_register(ZebraHandle zh, const char *new_reg) } if (zh->res) { - if (res_get_int(zh->res, "segment", &zh->m_segment_indexing) == + if (res_get_int(zh->res, "segment", &zh->m_segment_indexing) == ZEBRA_OK) { yaz_log(YLOG_DEBUG, "segment indexing set and is %d", @@ -861,7 +861,7 @@ void map_basenames_func(void *vp, const char *name, const char *value) assert(value); assert(name); assert(vp); - + no = sscanf(value, "%127s %127s %127s %127s %127s %127s %127s %127s %127s", fromdb, todb[0], todb[1], todb[2], todb[3], todb[4], @@ -877,7 +877,7 @@ void map_basenames_func(void *vp, const char *name, const char *value) { if (p->new_num_bases == p->new_num_max) return; - p->new_basenames[(p->new_num_bases)++] = + p->new_basenames[(p->new_num_bases)++] = nmem_strdup(p->mem, todb[i]); } return; @@ -920,11 +920,11 @@ void map_basenames(ZebraHandle zh, ODR stream, info.mem = stream->mem; res_trav(zh->session_res, "mapdb", &info, map_basenames_func); - + for (i = 0; inum_bases; i++) if (p->basenames[i] && p->new_num_bases < p->new_num_max) { - p->new_basenames[(p->new_num_bases)++] = + p->new_basenames[(p->new_num_bases)++] = nmem_strdup(p->mem, p->basenames[i]); } *num_bases = info.new_num_bases; @@ -956,7 +956,7 @@ ZEBRA_RES zebra_select_databases(ZebraHandle zh, int num_bases, yaz_log(log_level, "zebra_select_databases n=%d [0]=%s", num_bases,basenames[0]); zh->errCode = 0; - + if (num_bases < 1) { zh->errCode = YAZ_BIB1_COMBI_OF_SPECIFIED_DATABASES_UNSUPP; @@ -991,7 +991,7 @@ ZEBRA_RES zebra_select_databases(ZebraHandle zh, int num_bases, for (i = 0; i < zh->num_basenames; i++) xfree(zh->basenames[i]); xfree(zh->basenames); - + zh->num_basenames = num_bases; zh->basenames = xmalloc(zh->num_basenames * sizeof(*zh->basenames)); for (i = 0; i < zh->num_basenames; i++) @@ -1079,7 +1079,7 @@ ZEBRA_RES zebra_search_RPN_x(ZebraHandle zh, ODR o, Z_RPNQuery *query, int *partial_resultset) { ZEBRA_RES r; - + ZEBRA_CHECK_HANDLE(zh); assert(o); @@ -1093,7 +1093,7 @@ ZEBRA_RES zebra_search_RPN_x(ZebraHandle zh, ODR o, Z_RPNQuery *query, if (zebra_begin_read(zh) == ZEBRA_FAIL) return ZEBRA_FAIL; - r = resultSetAddRPN(zh, odr_extract_mem(o), query, + r = resultSetAddRPN(zh, odr_extract_mem(o), query, zh->num_basenames, zh->basenames, setname, hits, estimated_hit_count); @@ -1137,7 +1137,7 @@ ZEBRA_RES zebra_records_retrieve(ZebraHandle zh, ODR stream, setname); return ZEBRA_FAIL; } - + if (zebra_begin_read(zh) == ZEBRA_FAIL) return ZEBRA_FAIL; @@ -1180,7 +1180,7 @@ ZEBRA_RES zebra_records_retrieve(ZebraHandle zh, ODR stream, /* we disable hit snippets for now. It does not work well and it slows retrieval down a lot */ #if 0 - zebra_snippets_hit_vector(zh, setname, poset[i].sysno, + zebra_snippets_hit_vector(zh, setname, poset[i].sysno, hit_snippet); #endif wrbuf_rewind(addinfo_w); @@ -1190,7 +1190,7 @@ ZEBRA_RES zebra_records_retrieve(ZebraHandle zh, ODR stream, stream, input_format, comp, &recs[i].format, &buf, &len, &recs[i].base, addinfo_w); - + if (wrbuf_len(addinfo_w)) recs[i].errString = odr_strdup(stream, wrbuf_cstr(addinfo_w)); @@ -1236,7 +1236,7 @@ ZEBRA_RES zebra_scan_PQF(ZebraHandle zh, ODR stream, const char *query, Z_AttributesPlusTerm *zapt; Odr_oid *attributeSet; ZEBRA_RES res; - + if (!(zapt = yaz_pqf_scan(pqf_parser, stream, &attributeSet, query))) { res = ZEBRA_FAIL; @@ -1345,7 +1345,7 @@ int zebra_errCode(ZebraHandle zh) return zh->errCode; } yaz_log(log_level, "zebra_errCode: o"); - return 0; + return 0; } const char *zebra_errString(ZebraHandle zh) @@ -1376,7 +1376,7 @@ ZEBRA_RES zebra_auth(ZebraHandle zh, const char *user, const char *pass) ZEBRA_CHECK_HANDLE(zh); zs = zh->service; - + sprintf(u, "perm.%.30s", user ? user : "anonymous"); p = res_get(zs->global_res, u); xfree(zh->user_perm); @@ -1392,7 +1392,7 @@ ZEBRA_RES zebra_auth(ZebraHandle zh, const char *user, const char *pass) /* users that don't require a password .. */ if (zh->user_perm && strchr(zh->user_perm, 'a')) return ZEBRA_OK; - + if (!zs->passwd_db || !passwd_db_auth(zs->passwd_db, user, pass)) return ZEBRA_OK; return ZEBRA_FAIL; @@ -1401,7 +1401,7 @@ ZEBRA_RES zebra_auth(ZebraHandle zh, const char *user, const char *pass) ZEBRA_RES zebra_admin_import_begin(ZebraHandle zh, const char *database, const char *record_type) { - yaz_log(log_level, "zebra_admin_import_begin db=%s rt=%s", + yaz_log(log_level, "zebra_admin_import_begin db=%s rt=%s", database, record_type); if (zebra_select_database(zh, database) == ZEBRA_FAIL) return ZEBRA_FAIL; @@ -1434,9 +1434,9 @@ ZEBRA_RES zebra_admin_import_segment(ZebraHandle zh, Z_Segment *segment) { Odr_oct *oct = fragment->u.notExternallyTagged; sysno = 0; - + if(zebra_update_record( - zh, + zh, action_update, 0, /* record Type */ &sysno, @@ -1506,7 +1506,7 @@ static int delete_SU_handle(void *handle, int ord, assert(zh->reg->isamb); assert(zh->reg->records); dict_delete_subtree(zh->reg->dict, ord_buf, - zh, + zh, !strcmp(string_index, "_ALLRECORDS") ? delete_w_all_handle : delete_w_handle); return 0; @@ -1568,7 +1568,7 @@ ZEBRA_RES zebra_create_database(ZebraHandle zh, const char *db) return ZEBRA_FAIL; /* announce database */ - if (zebraExplain_newDatabase(zh->reg->zei, db, 0 + if (zebraExplain_newDatabase(zh->reg->zei, db, 0 /* explainDatabase */)) { if (zebra_end_trans(zh) != ZEBRA_OK) @@ -1609,7 +1609,7 @@ int zebra_string_norm(ZebraHandle zh, const char *index_type, \param zh Zebra handle \param val state \param seqno sequence number - + val is one of: d=writing to shadow(shadow enabled); writing to register (shadow disabled) o=reading only @@ -1630,7 +1630,7 @@ static void zebra_set_state(ZebraHandle zh, int val, int seqno) if (!f) { yaz_log(YLOG_FATAL|YLOG_ERRNO, "open %s w", state_fname); - exit(1); + exit(1); } yaz_log(YLOG_DEBUG, "zebra_set_state: %c %d %ld", val, seqno, p); fprintf(f, "%c %d %ld\n", val, seqno, p); @@ -1680,7 +1680,7 @@ static void read_res_for_transaction(ZebraHandle zh) const char *group = res_get(zh->res, "group"); const char *v; /* FIXME - do we still use groups ?? */ - + zh->m_group = group; v = res_get_prefix(zh->res, "followLinks", group, "1"); zh->m_follow_links = atoi(v); @@ -1735,7 +1735,7 @@ ZEBRA_RES zebra_begin_trans(ZebraHandle zh, int rw) int seqno = 0; char val = '?'; const char *rval = 0; - + (zh->trans_no++); if (zh->trans_w_no) { @@ -1760,14 +1760,14 @@ ZEBRA_RES zebra_begin_trans(ZebraHandle zh, int rw) zh->records_deleted = 0; zh->records_processed = 0; zh->records_skipped = 0; - + #if HAVE_SYS_TIMES_H times(&zh->tms1); #endif /* lock */ if (zh->shadow_enable) rval = res_get(zh->res, "shadow"); - + if (rval) { zebra_lock_r(zh->lock_normal); @@ -1808,7 +1808,7 @@ ZEBRA_RES zebra_begin_trans(ZebraHandle zh, int rw) } zebra_set_state(zh, 'd', seqno); - + zh->reg = zebra_register_open(zh->service, zh->reg_name, 1, rval ? 1 : 0, zh->res, zh->path_reg); @@ -1833,9 +1833,9 @@ ZEBRA_RES zebra_begin_trans(ZebraHandle zh, int rw) int dirty = 0; char val; int seqno; - + (zh->trans_no)++; - + if (zh->trans_no != 1) { return zebra_flush_reg(zh); @@ -1858,7 +1858,7 @@ ZEBRA_RES zebra_begin_trans(ZebraHandle zh, int rw) zebra_get_state(zh, &val, &seqno); if (val == 'd') val = 'o'; - + if (!zh->reg) dirty = 1; else if (seqno != zh->reg->seqno) @@ -1875,12 +1875,12 @@ ZEBRA_RES zebra_begin_trans(ZebraHandle zh, int rw) } if (!dirty) return ZEBRA_OK; - + if (val == 'c') zebra_lock_r(zh->lock_shadow); else zebra_lock_r(zh->lock_normal); - + if (zh->reg) { resultSetInvalidate(zh); @@ -1952,29 +1952,29 @@ ZEBRA_RES zebra_end_transaction(ZebraHandle zh, ZebraTransactionStatus *status) { /* release write lock */ zh->trans_no--; zh->trans_w_no = 0; - + yaz_log(YLOG_DEBUG, "zebra_end_trans"); rval = res_get(zh->res, "shadow"); - + zebraExplain_runNumberIncrement(zh->reg->zei, 1); - + zebra_flush_reg(zh); - + resultSetInvalidate(zh); zebra_register_close(zh->service, zh->reg); zh->reg = 0; - + yaz_log(YLOG_LOG, "Records: "ZINT_FORMAT" i/u/d " - ZINT_FORMAT"/"ZINT_FORMAT"/"ZINT_FORMAT, + ZINT_FORMAT"/"ZINT_FORMAT"/"ZINT_FORMAT, zh->records_processed, zh->records_inserted, zh->records_updated, zh->records_deleted); - + status->processed = zh->records_processed; status->inserted = zh->records_inserted; status->updated = zh->records_updated; status->deleted = zh->records_deleted; - + zebra_get_state(zh, &val, &seqno); if (val != 'd') { @@ -1987,14 +1987,14 @@ ZEBRA_RES zebra_end_transaction(ZebraHandle zh, ZebraTransactionStatus *status) zebra_set_state(zh, 'o', seqno); zebra_unlock(zh->lock_shadow); zebra_unlock(zh->lock_normal); - + } #if HAVE_SYS_TIMES_H times(&zh->tms2); yaz_log(log_level, "user/system: %ld/%ld", (long) (zh->tms2.tms_utime - zh->tms1.tms_utime), (long) (zh->tms2.tms_stime - zh->tms1.tms_stime)); - + status->utime = (long) (zh->tms2.tms_utime - zh->tms1.tms_utime); status->stime = (long) (zh->tms2.tms_stime - zh->tms1.tms_stime); #endif @@ -2058,7 +2058,7 @@ static ZEBRA_RES zebra_commit_ex(ZebraHandle zh, int clean_only) zh->errCode = YAZ_BIB1_DATABASE_UNAVAILABLE; return ZEBRA_FAIL; } - rval = res_get(zh->res, "shadow"); + rval = res_get(zh->res, "shadow"); if (!rval) { yaz_log(YLOG_WARN, "Cannot perform commit - No shadow area defined"); @@ -2098,7 +2098,7 @@ static ZEBRA_RES zebra_commit_ex(ZebraHandle zh, int clean_only) else { zebra_set_state(zh, 'c', seqno); - + yaz_log(log_level, "commit start"); if (bf_commitExec(bfs)) res = ZEBRA_FAIL; @@ -2107,10 +2107,10 @@ static ZEBRA_RES zebra_commit_ex(ZebraHandle zh, int clean_only) { seqno++; zebra_set_state(zh, 'o', seqno); - + zebra_unlock(zh->lock_shadow); zebra_unlock(zh->lock_normal); - + zebra_lock_w(zh->lock_shadow); bf_commitClean(bfs, rval); zebra_unlock(zh->lock_shadow); @@ -2174,7 +2174,7 @@ ZEBRA_RES zebra_init(ZebraHandle zh) } if (rval && *rval) bf_cache(bfs, rval); - + bf_reset(bfs); bfs_destroy(bfs); zebra_set_state(zh, 'o', 0); @@ -2214,7 +2214,7 @@ static ZEBRA_RES zebra_record_check(ZebraHandle zh, Record rec, zebra_rec_keys_t keys = zebra_rec_keys_open(); zebra_rec_keys_set_buf(keys, rec->info[recInfo_delKeys], rec->size[recInfo_delKeys], 0); - + *no_keys = 0; if (!zebra_rec_keys_rewind(keys)) { @@ -2264,7 +2264,7 @@ static ZEBRA_RES zebra_record_check(ZebraHandle zh, Record rec, continue; } memcpy(ord_buf + ord_len, str, slen); - ord_buf[ord_len + slen] = '\0'; + ord_buf[ord_len + slen] = '\0'; if (ord_len + slen >= IT_MAX_WORD) { res = ZEBRA_FAIL; @@ -2272,7 +2272,7 @@ static ZEBRA_RES zebra_record_check(ZebraHandle zh, Record rec, if (*no_long_dict_entries <= message_limit) { do_fail = 1; - yaz_log(YLOG_WARN, "Record " ZINT_FORMAT + yaz_log(YLOG_WARN, "Record " ZINT_FORMAT ": long dictionary entry %d + %d", rec->sysno, (int) ord_len, (int) slen); } @@ -2302,7 +2302,7 @@ static ZEBRA_RES zebra_record_check(ZebraHandle zh, Record rec, if (*no_invalid_dict_infos <= message_limit) { do_fail = 1; - yaz_log(YLOG_WARN, "Record " ZINT_FORMAT + yaz_log(YLOG_WARN, "Record " ZINT_FORMAT ": long dictionary entry %d + %d", rec->sysno, (int) ord_len, (int) slen); } @@ -2322,7 +2322,7 @@ static ZEBRA_RES zebra_record_check(ZebraHandle zh, Record rec, if (*no_invalid_isam_entries <= message_limit) { do_fail = 1; - yaz_log(YLOG_WARN, "Record " ZINT_FORMAT + yaz_log(YLOG_WARN, "Record " ZINT_FORMAT ": isamb_pp_open entry " ZINT_FORMAT " not found", rec->sysno, pos); @@ -2338,11 +2338,11 @@ static ZEBRA_RES zebra_record_check(ZebraHandle zh, Record rec, struct it_key isam_key; int r; int i = 0; - + until_key.len = key_in.len - 1; for (i = 0; i < until_key.len; i++) until_key.mem[i] = key_in.mem[i+1]; - + if (until_key.mem[0] == 0) until_key.mem[0] = rec->sysno; r = isamb_pp_forward(ispt, &isam_key, &until_key); @@ -2353,7 +2353,7 @@ static ZEBRA_RES zebra_record_check(ZebraHandle zh, Record rec, if (*no_invalid_isam_entries <= message_limit) { do_fail = 1; - yaz_log(YLOG_WARN, "Record " ZINT_FORMAT + yaz_log(YLOG_WARN, "Record " ZINT_FORMAT ": isamb_pp_forward " ZINT_FORMAT " returned no entry", rec->sysno, pos); @@ -2371,7 +2371,7 @@ static ZEBRA_RES zebra_record_check(ZebraHandle zh, Record rec, { do_fail = 1; yaz_log(YLOG_WARN, "Record " - ZINT_FORMAT + ZINT_FORMAT ": isamb_pp_forward " ZINT_FORMAT " returned different entry", @@ -2412,7 +2412,7 @@ ZEBRA_RES zebra_register_check(ZebraHandle zh, const char *spec) ZEBRA_RES res = ZEBRA_FAIL; unsigned flags = 0; int message_limit = 10; - + if (!spec || *spec == '\0' || !strcmp(spec, "dict") || !strcmp(spec, "default")) flags = ZEBRA_CHECK_DICT; @@ -2434,7 +2434,7 @@ ZEBRA_RES zebra_register_check(ZebraHandle zh, const char *spec) if (zh->reg) { Record rec = rec_get_root(zh->reg->records); - + zint no_long_dict_entries = 0; zint no_failed_dict_lookups = 0; zint no_invalid_keys = 0; @@ -2524,7 +2524,7 @@ ZEBRA_RES zebra_octet_term_encoding(ZebraHandle zh, const char *encoding) yaz_iconv_close(zh->iconv_to_utf8); if (zh->iconv_from_utf8 != 0) yaz_iconv_close(zh->iconv_from_utf8); - + zh->iconv_to_utf8 = yaz_iconv_open("UTF-8", encoding); if (zh->iconv_to_utf8 == 0) @@ -2595,15 +2595,15 @@ void zebra_set_shadow_enable(ZebraHandle zh, int value) ZEBRA_RES zebra_add_record(ZebraHandle zh, const char *buf, int buf_size) { - return zebra_update_record(zh, action_update, + return zebra_update_record(zh, action_update, 0 /* record type */, 0 /* sysno */ , - 0 /* match */, + 0 /* match */, 0 /* fname */, buf, buf_size); } -ZEBRA_RES zebra_update_record(ZebraHandle zh, +ZEBRA_RES zebra_update_record(ZebraHandle zh, enum zebra_recctrl_action_t action, const char *recordType, zint *sysno, const char *match, @@ -2625,22 +2625,22 @@ ZEBRA_RES zebra_update_record(ZebraHandle zh, if (zebra_begin_trans(zh, 1) == ZEBRA_FAIL) return ZEBRA_FAIL; - res = zebra_buffer_extract_record(zh, buf, buf_size, + res = zebra_buffer_extract_record(zh, buf, buf_size, action, recordType, - sysno, - match, + sysno, + match, fname); if (zebra_end_trans(zh) != ZEBRA_OK) { yaz_log(YLOG_WARN, "zebra_end_trans failed"); res = ZEBRA_FAIL; } - return res; + return res; } /* --------------------------------------------------------------------------- - Searching + Searching */ ZEBRA_RES zebra_search_PQF(ZebraHandle zh, const char *pqf_query, @@ -2660,9 +2660,9 @@ ZEBRA_RES zebra_search_PQF(ZebraHandle zh, const char *pqf_query, assert(setname); yaz_log(log_level, "zebra_search_PQF s=%s q=%s", setname, pqf_query); - + query = p_query_rpn(odr, pqf_query); - + if (!query) { yaz_log(YLOG_WARN, "bad query %s\n", pqf_query); @@ -2671,7 +2671,7 @@ ZEBRA_RES zebra_search_PQF(ZebraHandle zh, const char *pqf_query, } else res = zebra_search_RPN(zh, odr, query, setname, &lhits); - + odr_destroy(odr); yaz_log(log_level, "Hits: " ZINT_FORMAT, lhits); @@ -2688,7 +2688,7 @@ ZEBRA_RES zebra_search_PQF(ZebraHandle zh, const char *pqf_query, int zebra_sort_by_specstr(ZebraHandle zh, ODR stream, const char *sort_spec, const char *output_setname, - const char **input_setnames) + const char **input_setnames) { int num_input_setnames = 0; int sort_status = 0; @@ -2707,17 +2707,17 @@ int zebra_sort_by_specstr(ZebraHandle zh, ODR stream, zh->errCode = YAZ_BIB1_CANNOT_SORT_ACCORDING_TO_SEQUENCE; return -1; } - - /* we can do this, since the perl typemap code for char** will + + /* we can do this, since the perl typemap code for char** will put a NULL at the end of list */ while (input_setnames[num_input_setnames]) num_input_setnames++; if (zebra_begin_read(zh)) return -1; - + resultSetSort(zh, stream->mem, num_input_setnames, input_setnames, output_setname, sort_sequence, &sort_status); - + zebra_end_read(zh); return sort_status; } @@ -2769,7 +2769,7 @@ void zebra_setError_zint(ZebraHandle zh, int code, zint i) void zebra_lock_prefix(Res res, char *path) { const char *lock_dir = res_get_def(res, "lockDir", ""); - + strcpy(path, lock_dir); if (*path && path[strlen(path)-1] != '/') strcat(path, "/"); diff --git a/index/zebraidx.c b/index/zebraidx.c index 1baaedd..0ada26b 100644 --- a/index/zebraidx.c +++ b/index/zebraidx.c @@ -62,7 +62,7 @@ int main(int argc, char **argv) char *database = 0; Res res = res_open(0, 0); Res default_res = res_open(0, 0); - + int trans_started = 0; #ifndef WIN32 char nbuf[100]; @@ -120,7 +120,7 @@ int main(int argc, char **argv) { yaz_log(YLOG_FATAL, "Cannot read config %s", config); exit(1); - } + } zh = zebra_open(zs, 0); zebra_shadow_enable(zh, enable_commit); } @@ -240,7 +240,7 @@ int main(int argc, char **argv) const char *add = zebra_errAdd(zh); yaz_log(YLOG_FATAL, "Operation failed: %s %s", zebra_errString(zh), add ? add : ""); - + if (trans_started) if (zebra_end_trans(zh) != ZEBRA_OK) yaz_log(YLOG_WARN, "zebra_end_trans failed"); diff --git a/index/zebrash.c b/index/zebrash.c index 7c176d8..d352e4b 100644 --- a/index/zebrash.c +++ b/index/zebrash.c @@ -17,7 +17,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* +/* zebrash.c - command-line interface to zebra API */ @@ -26,14 +26,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #endif #include #include -#include +#include #include #if HAVE_UNISTD_H #include #endif #if HAVE_READLINE_READLINE_H -#include +#include #endif #if HAVE_READLINE_HISTORY_H #include @@ -72,9 +72,9 @@ static int log_level=0; * Help functions */ - + static int split_args( char *line, char** args ) -{ /* splits line into individual null-terminated strings, +{ /* splits line into individual null-terminated strings, * returns pointers to them in args */ /* FIXME - do we need to handle quoted args ?? */ char *p=line; @@ -88,7 +88,7 @@ static int split_args( char *line, char** args ) while (*p==' ' || *p=='\t' || *p=='\n') p++; if (*p=='#') /* skip comments */ - break; + break; args[i++]=p; args[i]=0; while (*p && *p!=' ' && *p!='\t' && *p!='\n' && *p!='#') @@ -128,7 +128,7 @@ static char *restargs( char *args[], int n) return args[0]+skiplen; } -int onecommand( char *line, WRBUF outbuff, const char *prevout); +int onecommand( char *line, WRBUF outbuff, const char *prevout); /************************************** * Simple support commands @@ -139,7 +139,7 @@ int cmd_echo( char *args[], WRBUF outbuff) wrbuf_printf(outbuff,"%s\n",restargs(args,1)); return 0; } - + int cmd_quit( char *args[], WRBUF outbuff) { if (zs) @@ -159,9 +159,9 @@ int cmd_quit( char *args[], WRBUF outbuff) /************************************** * Tests for starting and stopping zebra, etc */ - -static int cmd_help( char *args[], WRBUF outbuff); - + +static int cmd_help( char *args[], WRBUF outbuff); + static int cmd_zebra_start( char *args[], WRBUF outbuff) { char *conf=args[1]; @@ -178,7 +178,7 @@ static int cmd_zebra_start( char *args[], WRBUF outbuff) } return 0; /* ok */ } - + static int cmd_zebra_stop( char *args[], WRBUF outbuff) { if (!zs) @@ -261,7 +261,7 @@ static int cmd_yaz_log_prefix( char *args[], WRBUF outbuff) static int cmd_logf( char *args[], WRBUF outbuff) { int lev = defargint(args[1],0); - int i=1; + int i=1; if (lev) i=2; else @@ -269,15 +269,15 @@ static int cmd_logf( char *args[], WRBUF outbuff) yaz_log( lev, "%s", restargs(args,i)); return 0; /* ok */ } - + /**************** - * Error handling + * Error handling */ static int cmd_err ( char *args[], WRBUF outbuff) { wrbuf_printf(outbuff, "errCode: %d \nerrStr: %s\nerrAdd: %s \n", zebra_errCode (zh), - zebra_errString (zh), + zebra_errString (zh), zebra_errAdd (zh) ); return 0; /* ok */ } @@ -296,7 +296,7 @@ static int cmd_errstr ( char *args[], WRBUF outbuff) static int cmd_erradd ( char *args[], WRBUF outbuff) { wrbuf_printf(outbuff, "errAdd: %s \n", - zebra_errAdd (zh) ); + zebra_errAdd (zh) ); return 0; /* ok */ } @@ -316,12 +316,12 @@ static int cmd_select_database ( char *args[], WRBUF outbuff) wrbuf_printf(outbuff,"Selecting database '%s'\n",db); return zebra_select_database(zh, db); } - + static int cmd_create_database( char *args[], WRBUF outbuff) { char *db=defarg(args[1],DEFAULTDATABASE); wrbuf_printf(outbuff,"Creating database '%s'\n",db); - + return zebra_create_database(zh, db); } @@ -355,7 +355,7 @@ static int cmd_record_insert( char *args[], WRBUF outbuff) zint sysno = 0; int rc; char *rec=restargs(args,1); - + rc = zebra_update_record(zh, action_insert, 0, /* record type */ @@ -515,7 +515,7 @@ static int cmd_sort( char *args[], WRBUF outbuff) */ /**************************************) - * Command table, parser, and help + * Command table, parser, and help */ struct cmdstruct @@ -526,71 +526,71 @@ struct cmdstruct int (*testfunc)(char *args[], WRBUF outbuff); } ; - + struct cmdstruct cmds[] = { /* special cases: * if text is 0, does not list the command * if cmd is "", adds the args (and newline) in command listing */ { "", "Starting and stopping:", "", 0 }, - { "zebra_start", - "[configfile]", + { "zebra_start", + "[configfile]", "starts the zebra service. You need to call this first\n" - "if no configfile is given, assumes " DEFAULTCONFIG, + "if no configfile is given, assumes " DEFAULTCONFIG, cmd_zebra_start }, - { "zebra_stop", "", - "stops the zebra service", + { "zebra_stop", "", + "stops the zebra service", cmd_zebra_stop }, - { "zebra_open", "", + { "zebra_open", "", "starts a zebra session. Once you have called zebra_start\n" - "you can call zebra_open to start working", + "you can call zebra_open to start working", cmd_zebra_open }, - { "zebra_close", "", - "closes a zebra session", - cmd_zebra_close }, - { "quickstart", "[configfile]", - "Does a zebra_start, zebra_open, and sets up the log", - cmd_quickstart }, - - { "", "Log file:","", 0}, - { "yaz_log_file", + { "zebra_close", "", + "closes a zebra session", + cmd_zebra_close }, + { "quickstart", "[configfile]", + "Does a zebra_start, zebra_open, and sets up the log", + cmd_quickstart }, + + { "", "Log file:","", 0}, + { "yaz_log_file", "[filename]", "Directs the log to filename (or stderr)", cmd_yaz_log_file }, - { "yaz_log_level", + { "yaz_log_level", "[level]", "Sets the logging level (or returns to default)", cmd_yaz_log_level }, - { "yaz_log_prefix", + { "yaz_log_prefix", "[prefix]", "Sets the log prefix", - cmd_yaz_log_prefix}, - { "yaz_log", + cmd_yaz_log_prefix}, + { "yaz_log", "[level] text...", "writes an entry in the log", - cmd_logf}, + cmd_logf}, { "", "Error handling:","", 0}, { "err", "", "Displays zebra's error status (code, str, add)", - cmd_err}, + cmd_err}, { "errcode", "", "Displays zebra's error code", - cmd_errcode}, + cmd_errcode}, { "errstr", "", "Displays zebra's error string", - cmd_errstr}, + cmd_errstr}, { "erradd", "", "Displays zebra's additional error message", - cmd_erradd}, - - { "", "Admin:","", 0}, + cmd_erradd}, + + { "", "Admin:","", 0}, { "init", "", "Initializes the zebra database, destroying all data in it", - cmd_init}, + cmd_init}, { "select_database", "basename", "Selects a database", - cmd_select_database}, + cmd_select_database}, { "create_database", "basename", "Create database", cmd_create_database}, @@ -632,26 +632,26 @@ struct cmdstruct cmds[] = { { "sort","sortspec", "sorts a result set. (example spec: 1=4 >)", cmd_sort}, - - { "", "Misc:","", 0}, - { "echo", "string", - "ouputs the string", + + { "", "Misc:","", 0}, + { "echo", "string", + "ouputs the string", cmd_echo }, - { "q", "", - "exits the program", + { "q", "", + "exits the program", cmd_quit }, - { "quit", "", - "exits the program", + { "quit", "", + "exits the program", cmd_quit }, - { "help", "[command]", - "Gives help on command, or lists them all", + { "help", "[command]", + "Gives help on command, or lists them all", cmd_help }, - { "", "help [command] gives more info on command", "",0 }, - + { "", "help [command] gives more info on command", "",0 }, + {0,0,0,0} /* end marker */ }; - -int onecommand( + +int onecommand( char *line, /* input line */ WRBUF outbuff, /* output goes here */ const char *prevout) /* prev output, for 'expect' */ @@ -665,7 +665,7 @@ int onecommand( argbuf[MAX_ARG_LEN-1]='\0'; /* just to be sure */ /*memset(args,'\0',MAX_NO_ARGS*sizeof(char *));*/ nargs=split_args(argbuf, args); - + #if 0 for (i = 0; i <= n; i++) { @@ -676,7 +676,7 @@ int onecommand( if (0==nargs) return -90; /* no command on line, too bad */ - if (0==strcmp(args[0],"expect")) + if (0==strcmp(args[0],"expect")) { char *rest; if (nargs>1) /* args[0] is not yet set, can't use restargs */ @@ -686,41 +686,41 @@ int onecommand( if (0==strstr(prevout,rest)) { printf( "Failed expectation, '%s' not found\n", rest); - exit(9); + exit(9); } return 0; } for (i=0;cmds[i].cmd;i++) - if (0==strcmp(cmds[i].cmd, args[0])) + if (0==strcmp(cmds[i].cmd, args[0])) { if (nargs>1) args[0]= line + (args[1]-argbuf); /* rest of the line */ else - args[0]=""; + args[0]=""; return ((cmds[i].testfunc)(args,outbuff)); } wrbuf_printf(outbuff, "Unknown command '%s'. Try help\n",args[0]); yaz_log(log_level,"Unknown command"); - return -90; + return -90; } - + static int cmd_help( char *args[], WRBUF outbuff) -{ +{ int i; int linelen; - if (args[1]) - { /* help for a single command */ + if (args[1]) + { /* help for a single command */ for (i=0;cmds[i].cmd;i++) - if (0==strcmp(cmds[i].cmd, args[1])) + if (0==strcmp(cmds[i].cmd, args[1])) { wrbuf_printf(outbuff,"%s %s\n%s\n", - cmds[i].cmd, cmds[i].args, + cmds[i].cmd, cmds[i].args, cmds[i].explanation); return 0; } wrbuf_printf(outbuff, "Unknown command '%s'", args[1]); } - else + else { /* list all commands */ linelen=9999; for (i=0;cmds[i].cmd;i++) @@ -744,7 +744,7 @@ static int cmd_help( char *args[], WRBUF outbuff) } return 0; } - + /* If Zebra reports an error after an operation, * append it to the outbuff and log it */ static void Zerrors (WRBUF outbuff) @@ -764,10 +764,10 @@ static void Zerrors (WRBUF outbuff) } } -/************************************** +/************************************** * The shell */ - + void shell(void) { int rc=0; @@ -791,8 +791,8 @@ void shell(void) } #endif /* line_in != NULL if readine is present and input is a tty */ - - printf (PROMPT); + + printf (PROMPT); fflush (stdout); if (line_in) { @@ -803,12 +803,12 @@ void shell(void) strcpy(buf,line_in); free (line_in); } - else + else { if (!fgets (buf, MAX_ARG_LEN-1, stdin)) - break; + break; } - + /* get rid of \n in line */ if ((nl_cp = strchr(buf, '\n'))) *nl_cp = '\0'; @@ -823,7 +823,7 @@ void shell(void) else if (rc>-90) { wrbuf_printf(outbuff, " command returned %d\n",rc); - } + } Zerrors(outbuff); printf("%s\n", wrbuf_cstr(outbuff)); } /* while */ @@ -838,7 +838,7 @@ static void usage(void) exit(1); } /************************************** - * Main + * Main */ int main (int argc, char ** argv) diff --git a/index/zebrasrv.c b/index/zebrasrv.c index 999e915..182f265 100644 --- a/index/zebrasrv.c +++ b/index/zebrasrv.c @@ -133,7 +133,7 @@ bend_initresult *bend_init(bend_initrequest *q) yaz_get_proposal_charneg(nmem, q->charneg_request, &charsets, &num_charsets, &langs, &num_langs, &selected); - + for (i = 0; i < num_charsets; i++) { const char *right_name = ""; @@ -143,7 +143,7 @@ bend_initresult *bend_init(bend_initrequest *q) * because a lot servers in Russia to use own in during * character set and language negotiation still. */ - + if (!yaz_matchstr(charsets[i], "win")) { right_name = "WINDOWS-1251"; } else if (!yaz_matchstr(charsets[i], "koi")) { @@ -226,13 +226,13 @@ static void search_terms(ZebraHandle zh, bend_search_rr *r) &count, &approx, outbuf, &len, &term_ref_id); se = sr->elements[i] = odr_malloc(r->stream, sizeof(**sr->elements)); - se->subqueryId = term_ref_id ? + se->subqueryId = term_ref_id ? odr_strdup(r->stream, term_ref_id) : 0; - + se->fullQuery = odr_booldup(r->stream, 0); - se->subqueryExpression = + se->subqueryExpression = odr_malloc(r->stream, sizeof(Z_QueryExpression)); - se->subqueryExpression->which = + se->subqueryExpression->which = Z_QueryExpression_term; se->subqueryExpression->u.term = odr_malloc(r->stream, sizeof(Z_QueryExpressionTerm)); @@ -266,7 +266,7 @@ static void search_terms(ZebraHandle zh, bend_search_rr *r) static int break_handler(void *client_data) { - bend_association assoc =(bend_association) client_data; + bend_association assoc =(bend_association) client_data; if (!bend_assoc_is_alive(assoc)) return 1; return 0; @@ -297,7 +297,7 @@ static Z_RPNQuery *query_add_sortkeys(ODR o, Z_RPNQuery *query, int num_arg; int ascending = 1; nmem_strsplitx(odr_getmem(o), ",", sortspec[i], &arg, &num_arg, 0); - + if (num_arg > 5 || num_arg < 1) { yaz_log(YLOG_WARN, "Invalid sort spec '%s' num_arg=%d", @@ -306,7 +306,7 @@ static Z_RPNQuery *query_add_sortkeys(ODR o, Z_RPNQuery *query, } if (num_arg > 2 && arg[2][0]) ascending = atoi(arg[2]); - + if (i < num_sortspec-1) wrbuf_puts(w, " @or"); wrbuf_puts(w, " @attr 1="); @@ -322,7 +322,7 @@ static Z_RPNQuery *query_add_sortkeys(ODR o, Z_RPNQuery *query, else { Z_RPNStructure *s = nquery->RPNStructure; - + if (s->which != Z_RPNStructure_complex) { yaz_log(YLOG_WARN, "query_add_sortkeys: not complex operand"); @@ -397,7 +397,7 @@ int bend_fetch(void *handle, bend_fetch_rr *r) ZEBRA_RES res; retrievalRecord.position = r->number; - + r->last_in_set = 0; res = zebra_records_retrieve(zh, r->stream, r->setname, r->comp, r->request_format, 1, &retrievalRecord); @@ -431,7 +431,7 @@ static int bend_scan(void *handle, bend_scan_rr *r) int is_partial, i; ZEBRA_RES res; - res = zebra_select_databases(zh, r->num_bases, + res = zebra_select_databases(zh, r->num_bases, (const char **) r->basenames); if (res != ZEBRA_OK) { @@ -446,7 +446,7 @@ static int bend_scan(void *handle, bend_scan_rr *r) res = zebra_scan(zh, r->stream, r->term, r->attributeset, &r->term_position, - &r->num_entries, &entries, &is_partial, + &r->num_entries, &entries, &is_partial, 0 /* setname */); if (res == ZEBRA_OK) { @@ -590,7 +590,7 @@ int bend_segment(void *handle, bend_segment_rr *rr) int bend_esrequest(void *handle, bend_esrequest_rr *rr) { ZebraHandle zh = (ZebraHandle) handle; - + yaz_log(YLOG_LOG, "function: " ODR_INT_PRINTF, *rr->esr->function); if (rr->esr->packageName) yaz_log(YLOG_LOG, "packagename: %s", rr->esr->packageName); @@ -613,7 +613,7 @@ int bend_esrequest(void *handle, bend_esrequest_rr *rr) Z_IUUpdateEsRequest *esRequest = up->u.esRequest; Z_IUOriginPartToKeep *toKeep = esRequest->toKeep; Z_IUSuppliedRecords *notToKeep = esRequest->notToKeep; - + yaz_log(YLOG_LOG, "action"); if (toKeep->action) { @@ -746,7 +746,7 @@ int bend_esrequest(void *handle, bend_esrequest_rr *rr) rr->errstring = "unsupported ES Update action"; break; } - + if (opaque_recid) { size_t l = opaque_recid->len; @@ -787,7 +787,7 @@ int bend_esrequest(void *handle, bend_esrequest_rr *rr) yaz_log(YLOG_WARN, "Unknown Extended Service(%d)", rr->esr->taskSpecificParameters->which); rr->errcode = YAZ_BIB1_ES_EXTENDED_SERVICE_TYPE_UNSUPP; - + } return 0; } @@ -808,9 +808,9 @@ static void bend_start(struct statserv_options_block *sob) exit(1); } #ifdef WIN32 - + #else - if (!sob->inetd && !sob->background) + if (!sob->inetd && !sob->background) { char pidfname[4096]; struct flock area; @@ -844,7 +844,7 @@ static void bend_start(struct statserv_options_block *sob) else { char pidstr[30]; - + sprintf(pidstr, "%ld", (long) getpid()); if (write(fd, pidstr, strlen(pidstr)) != strlen(pidstr)) { @@ -861,7 +861,7 @@ static void bend_stop(struct statserv_options_block *sob) #ifdef WIN32 #else - if (!sob->inetd && !sob->background && sob->handle) + if (!sob->inetd && !sob->background && sob->handle) { char pidfname[4096]; zebra_pidfname(sob->handle, pidfname); diff --git a/index/zinfo.c b/index/zinfo.c index cfede29..eb5619d 100644 --- a/index/zinfo.c +++ b/index/zinfo.c @@ -154,12 +154,12 @@ static Record createRecord(Records records, zint *sysno) if (!rec) return 0; *sysno = rec->sysno; - + rec->info[recInfo_fileType] = rec_strdup("grs.sgml", &rec->size[recInfo_fileType]); rec->info[recInfo_databaseName] = rec_strdup("IR-Explain-1", - &rec->size[recInfo_databaseName]); + &rec->size[recInfo_databaseName]); } return rec; } @@ -235,7 +235,7 @@ void zebraExplain_mergeOids(ZebraExplainInfo zei, data1_node *n, len = 63; memcpy(str, np->child->u.data.data, len); str[len] = '\0'; - + oid = odr_getoidbystr_nmem(zei->nmem, str); for (ao = *op; ao; ao = ao->next) @@ -260,7 +260,7 @@ void zebraExplain_mergeAccessInfo(ZebraExplainInfo zei, data1_node *n, zebAccessInfo *accessInfo) { data1_node *np; - + if (!n) { *accessInfo = (zebAccessInfo) @@ -355,7 +355,7 @@ ZebraExplainInfo zebraExplain_open( zei->records = records; zei->nmem = nmem; zei->dh = dh; - + data1_get_absyn(zei->dh, "explain", DATA1_XPATH_INDEXING_DISABLE); zei->attsets = 0; @@ -449,8 +449,8 @@ ZebraExplainInfo zebraExplain_open( node_aid = np2->child; } assert(node_id && node_name && node_aid); - - *zdip =(struct zebDatabaseInfoB *) + + *zdip =(struct zebDatabaseInfoB *) nmem_malloc(zei->nmem, sizeof(**zdip)); (*zdip)->readFlag = 1; (*zdip)->dirty = 0; @@ -483,7 +483,7 @@ ZebraExplainInfo zebraExplain_open( np = np->child; assert(np && np->which == DATA1N_data); zei->ordinalSU = atoi_n(np->u.data.data, np->u.data.len); - + np = data1_search_tag(zei->dh, node_zebra->child, "ordinalDatabase"); np = np->child; @@ -543,29 +543,29 @@ ZebraExplainInfo zebraExplain_open( rec_strdup("grs.sgml", &trec->size[recInfo_fileType]); trec->info[recInfo_databaseName] = rec_strdup("IR-Explain-1", &trec->size[recInfo_databaseName]); - + sgml_buf = data1_nodetoidsgml(dh, zei->data1_target, 0, &sgml_len); trec->info[recInfo_storeData] = (char *) xmalloc(sgml_len); memcpy(trec->info[recInfo_storeData], sgml_buf, sgml_len); trec->size[recInfo_storeData] = sgml_len; - + rec_put(records, &trec); rec_free(&trec); } - + zebraExplain_newDatabase(zei, "IR-Explain-1", 0); - + if (!zei->categoryList->dirty) { struct zebraCategoryListInfo *zcl = zei->categoryList; data1_node *node_cl; - + zcl->dirty = 1; zcl->data1_categoryList = data1_read_sgml(zei->dh, zei->nmem, "CategoryList\n" "\n"); - + if (zcl->data1_categoryList) { node_cl = data1_search_tag(zei->dh, zcl->data1_categoryList, @@ -637,7 +637,7 @@ static void zebraExplain_readAttributeDetails(ZebraExplainInfo zei, nmem_malloc(zei->nmem, sizeof(**zsuip)); if (node_type && node_type->u.data.len > 0) - (*zsuip)->info.index_type = + (*zsuip)->info.index_type = nmem_strdupn(zei->nmem, node_type->u.data.data, node_type->u.data.len); @@ -655,10 +655,10 @@ static void zebraExplain_readAttributeDetails(ZebraExplainInfo zei, cat = zinfo_index_category_index; else if (!strncmp(np->u.data.data, "sort", np->u.data.len)) cat = zinfo_index_category_sort; - else if (!strncmp(np->u.data.data, "alwaysmatches", + else if (!strncmp(np->u.data.data, "alwaysmatches", np->u.data.len)) cat = zinfo_index_category_alwaysmatches; - else if (!strncmp(np->u.data.data, "anchor", + else if (!strncmp(np->u.data.data, "anchor", np->u.data.len)) cat = zinfo_index_category_anchor; else @@ -714,7 +714,7 @@ static void zebraExplain_readDatabase(ZebraExplainInfo zei, rec = rec_get(zei->records, zdi->sysno); zdi->data1_database = read_sgml_rec(zei->dh, zei->nmem, rec); - + node_dbinfo = data1_search_tag(zei->dh, zdi->data1_database, "/databaseInfo"); assert(node_dbinfo); @@ -724,14 +724,14 @@ static void zebraExplain_readDatabase(ZebraExplainInfo zei, "zebraInfo"); if (node_zebra && (np = data1_search_tag(zei->dh, node_zebra->child, - "recordBytes")) + "recordBytes")) && np->child && np->child->which == DATA1N_data) zdi->recordBytes = atoi_zn(np->child->u.data.data, np->child->u.data.len); if (node_zebra && (np = data1_search_tag(zei->dh, node_zebra->child, - "ordinalDatabase")) + "ordinalDatabase")) && np->child && np->child->which == DATA1N_data) zdi->ordinalDatabase = atoi_n(np->child->u.data.data, np->child->u.data.len); @@ -767,7 +767,7 @@ int zebraExplain_removeDatabase(ZebraExplainInfo zei, void *update_handle) { /* remove attribute details keys and delete it */ zebAttributeDetails zad = zdi->attributeDetails; - + rec = rec_get(zei->records, zad->sysno); (*zei->updateFunc)(zei->updateHandle, rec, 0); rec_del(zei->records, &rec); @@ -797,7 +797,7 @@ int zebraExplain_curDatabase(ZebraExplainInfo zei, const char *database) database_n++; else database_n = database; - + assert(zei); if (zei->curDatabaseInfo && !STRCASECMP(zei->curDatabaseInfo->databaseName, database)) @@ -859,7 +859,7 @@ static void zebraExplain_updateAccessInfo(ZebraExplainInfo zei, data1_node *n, data1_node *c = data1_search_tag(zei->dh, n->child, "accessInfo"); data1_node *d; zebAccessObject p; - + if (!c) { data1_pr_tree(zei->dh, n, stdout); @@ -916,12 +916,12 @@ int zebraExplain_newDatabase(ZebraExplainInfo zei, const char *database, zdi->ordinalDatabase = zei->ordinalDatabase++; zebraExplain_mergeAccessInfo(zei, 0, &zdi->accessInfo); - + assert(zei->dh); assert(zei->nmem); zdi->data1_database = - data1_read_sgml(zei->dh, zei->nmem, + data1_read_sgml(zei->dh, zei->nmem, "DatabaseInfo\n" "\n"); if (!zdi->data1_database) @@ -936,17 +936,17 @@ int zebraExplain_newDatabase(ZebraExplainInfo zei, const char *database, data1_mk_tag_data_text(zei->dh, node_dbinfo, "name", database, zei->nmem); - + if (explain_database) data1_mk_tag_data_text(zei->dh, node_dbinfo, "explainDatabase", "", zei->nmem); - + data1_mk_tag_data_text(zei->dh, node_dbinfo, "userFee", "0", zei->nmem); - + data1_mk_tag_data_text(zei->dh, node_dbinfo, "available", "1", zei->nmem); - + #if ZINFO_DEBUG data1_pr_tree(zei->dh, zdi->data1_database, stderr); #endif @@ -1008,14 +1008,14 @@ static void zebraExplain_writeCategoryList(ZebraExplainInfo zei, drec = createRecord(zei->records, &sysno); if (!drec) return; - + node_ci = data1_search_tag(zei->dh, node_categoryList, "/categoryList"); assert (node_ci); node_ci = data1_mk_tag(zei->dh, zei->nmem, "categories", 0 /* attr */, node_ci); assert (node_ci); - + for (i = 0; category[i]; i++) { data1_node *node_cat = data1_mk_tag(zei->dh, zei->nmem, "category", @@ -1037,7 +1037,7 @@ static void zebraExplain_writeCategoryList(ZebraExplainInfo zei, drec->info[recInfo_storeData] = (char *) xmalloc(sgml_len); memcpy(drec->info[recInfo_storeData], sgml_buf, sgml_len); drec->size[recInfo_storeData] = sgml_len; - + rec_put(zei->records, &drec); } @@ -1051,13 +1051,13 @@ static void zebraExplain_writeAttributeDetails(ZebraExplainInfo zei, Record drec; data1_node *node_adinfo, *node_list, *node_zebra; struct zebSUInfoB *zsui; - + if (!zad->dirty) return; - + zad->dirty = 0; #if ZINFO_DEBUG - yaz_log(YLOG_LOG, "zebraExplain_writeAttributeDetails"); + yaz_log(YLOG_LOG, "zebraExplain_writeAttributeDetails"); data1_pr_tree(zei->dh, zad->data1_tree, stderr); #endif @@ -1122,7 +1122,7 @@ static void zebraExplain_writeAttributeDetails(ZebraExplainInfo zei, drec->info[recInfo_storeData] = (char *) xmalloc(sgml_len); memcpy(drec->info[recInfo_storeData], sgml_buf, sgml_len); drec->size[recInfo_storeData] = sgml_len; - + rec_put(zei->records, &drec); } @@ -1134,7 +1134,7 @@ static void zebraExplain_writeDatabase(ZebraExplainInfo zei, int sgml_len; Record drec; data1_node *node_dbinfo, *node_count, *node_zebra; - + if (!zdi->dirty) return; @@ -1183,7 +1183,7 @@ static void zebraExplain_writeDatabase(ZebraExplainInfo zei, drec->info[recInfo_storeData] = (char *) xmalloc(sgml_len); memcpy(drec->info[recInfo_storeData], sgml_buf, sgml_len); drec->size[recInfo_storeData] = sgml_len; - + rec_put(zei->records, &drec); } @@ -1202,7 +1202,7 @@ static void writeAttributeValues(ZebraExplainInfo zei, for (atts = attset->atts; atts; atts = atts->next) { data1_node *node_value; - + node_value = data1_mk_tag(zei->dh, zei->nmem, "attributeValue", 0 /* attr */, node_values); data1_mk_tag_data_text(zei->dh, node_value, "name", @@ -1228,10 +1228,10 @@ static void zebraExplain_writeAttributeSet(ZebraExplainInfo zei, if (o->oid) attset = data1_attset_search_id(zei->dh, o->oid); - + #if ZINFO_DEBUG yaz_log(YLOG_LOG, "zebraExplain_writeAttributeSet %s", - attset ? attset->name : ""); + attset ? attset->name : ""); #endif drec = createRecord(zei->records, &o->sysno); @@ -1254,7 +1254,7 @@ static void zebraExplain_writeAttributeSet(ZebraExplainInfo zei, if (attset && attset->name) data1_mk_tag_data_text(zei->dh, node_attinfo, "name", attset->name, zei->nmem); - + node_attributes = data1_mk_tag_uni(zei->dh, zei->nmem, "attributes", node_attinfo); node_atttype = data1_mk_tag_uni(zei->dh, zei->nmem, @@ -1282,7 +1282,7 @@ static void zebraExplain_writeAttributeSet(ZebraExplainInfo zei, drec->info[recInfo_storeData] = (char *) xmalloc(sgml_len); memcpy(drec->info[recInfo_storeData], sgml_buf, sgml_len); drec->size[recInfo_storeData] = sgml_len; - + rec_put(zei->records, &drec); } @@ -1347,11 +1347,11 @@ static void zebraExplain_writeTarget(ZebraExplainInfo zei, int key_flush) trec->info[recInfo_storeData] = (char *) xmalloc(sgml_len); memcpy(trec->info[recInfo_storeData], sgml_buf, sgml_len); trec->size[recInfo_storeData] = sgml_len; - + rec_put(zei->records, &trec); } -int zebraExplain_lookup_attr_str(ZebraExplainInfo zei, +int zebraExplain_lookup_attr_str(ZebraExplainInfo zei, zinfo_index_category_t cat, const char *index_type, const char *str) @@ -1361,7 +1361,7 @@ int zebraExplain_lookup_attr_str(ZebraExplainInfo zei, assert(zei->curDatabaseInfo); for (zsui = &zei->curDatabaseInfo->attributeDetails->SUInfo; *zsui; zsui = &(*zsui)->next) - if ( (index_type == 0 + if ( (index_type == 0 || !strcmp((*zsui)->info.index_type, index_type)) && (*zsui)->info.cat == cat && !yaz_matchstr((*zsui)->info.str, str)) @@ -1415,7 +1415,7 @@ struct zebSUInfoB *zebraExplain_get_sui_info(ZebraExplainInfo zei, int ord, if ((*zsui)->info.ordinal == ord) { struct zebSUInfoB *zsui_this = *zsui; - + /* take it out of the list and move to front */ *zsui = (*zsui)->next; zsui_this->next = zdb->attributeDetails->SUInfo; @@ -1477,7 +1477,7 @@ zint zebraExplain_ord_get_term_occurrences(ZebraExplainInfo zei, int ord) } int zebraExplain_lookup_ord(ZebraExplainInfo zei, int ord, - const char **index_type, + const char **index_type, const char **db, const char **string_index) { @@ -1507,7 +1507,7 @@ zebAccessObject zebraExplain_announceOid(ZebraExplainInfo zei, Odr_oid *oid) { zebAccessObject ao; - + for (ao = *op; ao; ao = ao->next) if (!oid_oidcmp(oid, ao->oid)) break; @@ -1543,7 +1543,7 @@ struct zebSUInfoB *zebraExplain_add_sui_info(ZebraExplainInfo zei, return zsui; } -int zebraExplain_add_attr_str(ZebraExplainInfo zei, +int zebraExplain_add_attr_str(ZebraExplainInfo zei, zinfo_index_category_t cat, const char *index_type, const char *index_name) @@ -1603,7 +1603,7 @@ RecordAttr *rec_init_attr(ZebraExplainInfo zei, Record rec) memset(recordAttr, '\0', sizeof(*recordAttr)); rec->info[recInfo_attr] = (char *) recordAttr; rec->size[recInfo_attr] = sizeof(*recordAttr); - + recordAttr->recordSize = 0; recordAttr->recordOffset = 0; recordAttr->runNumber = zei->runNumber; @@ -1635,7 +1635,7 @@ void zebraExplain_loadAttsets(data1_handle dh, Res res) adds attributeSet (in AccessInfo area) to DatabaseInfo if it doesn't exist for the database. - If the database doesn't exist globally (in TargetInfo) an + If the database doesn't exist globally (in TargetInfo) an AttributeSetInfo must be added (globally). */ /* diff --git a/index/zinfo.h b/index/zinfo.h index 709fdcf..6246761 100644 --- a/index/zinfo.h +++ b/index/zinfo.h @@ -40,9 +40,9 @@ typedef enum { zinfo_index_category_alwaysmatches, zinfo_index_category_anchor } zinfo_index_category_t; - + typedef ZEBRA_RES ZebraExplainUpdateFunc(void *handle, - Record drec, + Record drec, data1_node *n); typedef struct zebraExplainInfo *ZebraExplainInfo; @@ -60,19 +60,19 @@ int zebraExplain_newDatabase(ZebraExplainInfo zei, const char *database, int zebraExplain_add_attr_su(ZebraExplainInfo zei, int index_type, int set, int use); -/** \brief lookup ordinal from string index + index type +/** \brief lookup ordinal from string index + index type \param zei explain info \param cat category \param index_type index type \param str index string \returns -1 no such index+type exist; ordinal otherwise */ - -int zebraExplain_lookup_attr_str(ZebraExplainInfo zei, + +int zebraExplain_lookup_attr_str(ZebraExplainInfo zei, zinfo_index_category_t cat, const char *index_type, const char *str); -int zebraExplain_add_attr_str(ZebraExplainInfo zei, +int zebraExplain_add_attr_str(ZebraExplainInfo zei, zinfo_index_category_t cat, const char *index_type, const char *str); diff --git a/index/zsets.c b/index/zsets.c index a168730..e9753fb 100644 --- a/index/zsets.c +++ b/index/zsets.c @@ -112,7 +112,7 @@ static ZEBRA_RES resultSetSearch(ZebraHandle zh, NMEM nmem, NMEM rset_nmem, sizeof(*sort_sequence->specs)); for (i = 0; inum_specs; i++) sort_sequence->specs[i] = 0; - + rpn_get_top_approx_limit(zh, rpn->RPNStructure, &sset->approx_limit); res = rpn_search_top(zh, rpn->RPNStructure, rpn->attributeSetId, @@ -163,10 +163,10 @@ ZEBRA_RES resultSetAddRPN(ZebraHandle zh, NMEM m, Z_RPNQuery *rpn, zebraSet->locked = 1; zebraSet->rpn = 0; zebraSet->nmem = m; - zebraSet->rset_nmem = nmem_create(); + zebraSet->rset_nmem = nmem_create(); zebraSet->num_bases = num_bases; - zebraSet->basenames = + zebraSet->basenames = nmem_malloc(zebraSet->nmem, num_bases * sizeof(*zebraSet->basenames)); for (i = 0; ibasenames[i] = nmem_strdup(zebraSet->nmem, basenames[i]); @@ -186,7 +186,7 @@ ZEBRA_RES resultSetAddRPN(ZebraHandle zh, NMEM m, Z_RPNQuery *rpn, } void resultSetAddTerm(ZebraHandle zh, ZebraSet s, int reg_type, - const char *db, const char *index_name, + const char *db, const char *index_name, const char *term) { assert(zh); /* compiler shut up */ @@ -197,7 +197,7 @@ void resultSetAddTerm(ZebraHandle zh, ZebraSet s, int reg_type, int i; s->term_entries_max = 1000; s->term_entries = - nmem_malloc(s->nmem, s->term_entries_max * + nmem_malloc(s->nmem, s->term_entries_max * sizeof(*s->term_entries)); for (i = 0; i < s->term_entries_max; i++) s->term_entries[i].term = 0; @@ -220,7 +220,7 @@ ZebraSet resultSetAdd(ZebraHandle zh, const char *name, int ov) for (s = zh->sets; s; s = s->next) if (!strcmp(s->name, name)) break; - + if (!log_level_set) loglevels(); if (s) @@ -322,7 +322,7 @@ ZEBRA_RES resultSetGetBaseNames(ZebraHandle zh, const char *setname, void resultSetInvalidate(ZebraHandle zh) { ZebraSet s = zh->sets; - + yaz_log(log_level_resultsets, "invalidating result sets"); for (; s; s = s->next) { @@ -345,7 +345,7 @@ void resultSetDestroy(ZebraHandle zh, int num, char **names,int *statuses) { ZebraSet * ss = &zh->sets; int i; - + if (statuses) for (i = 0; inext; - + xfree(s->sort_info->all_entries); xfree(s->sort_info->entries); xfree(s->sort_info); - + if (s->nmem) nmem_destroy(s->nmem); if (s->rset) @@ -391,7 +391,7 @@ void resultSetDestroy(ZebraHandle zh, int num, char **names,int *statuses) } ZebraMetaRecord *zebra_meta_records_create_range(ZebraHandle zh, - const char *name, + const char *name, zint start, int num) { zint pos_small[10]; @@ -404,18 +404,18 @@ ZebraMetaRecord *zebra_meta_records_create_range(ZebraHandle zh, if (num > 10) pos = xmalloc(sizeof(*pos) * num); - + for (i = 0; i 10) xfree(pos); return mr; } -ZebraMetaRecord *zebra_meta_records_create(ZebraHandle zh, const char *name, +ZebraMetaRecord *zebra_meta_records_create(ZebraHandle zh, const char *name, int num, zint *positions) { ZebraSet sset; @@ -465,7 +465,7 @@ ZebraMetaRecord *zebra_meta_records_create(ZebraHandle zh, const char *name, if (sort_info) { zint position; - + for (i = 0; inum_entries; while (num_i < num && positions[num_i] <= position) num_i++; - + if (sset->cache_rfd && num_i < num && positions[num_i] > sset->cache_position) { @@ -574,7 +574,7 @@ void resultSetInsertSort(ZebraHandle zh, ZebraSet sset, { char *this_entry_buf = tmp_cmp_buf[i]; memset(this_entry_buf, '\0', SORT_IDX_ENTRYSIZE); - + if (criteria[i].ord[database_no] != -1) { yaz_log(log_level_sort, "pre zebra_sort_type ord is %d", @@ -621,7 +621,7 @@ void resultSetInsertSort(ZebraHandle zh, ZebraSet sset, for (j = 0; j 0.0) rel = 1; else if (diff < 0.0) @@ -647,11 +647,11 @@ void resultSetInsertSort(ZebraHandle zh, ZebraSet sset, rel = memcmp(this_entry_buf, other_entry_buf, SORT_IDX_ENTRYSIZE); } - /* when the compare is equal, continue to next criteria, + /* when the compare is equal, continue to next criteria, else break out */ if (rel) break; - } + } if (!rel) break; if (criteria[j].relation == 'A') @@ -739,7 +739,7 @@ void resultSetInsertRank(ZebraHandle zh, struct zset_sort_info *sort_info, --j; else j = (sort_info->num_entries)++; - + new_entry = sort_info->entries[j]; while (j != i) { @@ -811,7 +811,7 @@ ZebraSet resultSetClone(ZebraHandle zh, const char *setname, nset->nmem = nmem_create(); nset->num_bases = rset->num_bases; - nset->basenames = + nset->basenames = nmem_malloc(nset->nmem, nset->num_bases * sizeof(*rset->basenames)); for (i = 0; inum_bases; i++) nset->basenames[i] = nmem_strdup(nset->nmem, rset->basenames[i]); @@ -885,7 +885,7 @@ ZEBRA_RES resultSetSortSingle(ZebraHandle zh, NMEM nmem, TERMID *terms; int numTerms = 0; size_t sysno_mem_index = 0; - + int numbases = zh->num_basenames; yaz_log(log_level_sort, "searching %d databases",numbases); @@ -908,12 +908,12 @@ ZEBRA_RES resultSetSortSingle(ZebraHandle zh, NMEM nmem, { Z_SortKeySpec *sks = sort_sequence->specs[i]; Z_SortKey *sk; - + sort_criteria[i].ord = (int *) nmem_malloc(nmem, sizeof(int)*numbases); sort_criteria[i].numerical = (int *) nmem_malloc(nmem, sizeof(int)*numbases); - + /* initialize ord and numerical for each database */ for (ib = 0; ib < numbases; ib++) { @@ -944,7 +944,7 @@ ZEBRA_RES resultSetSortSingle(ZebraHandle zh, NMEM nmem, { zebra_setError(zh, YAZ_BIB1_SORT_ILLEGAL_SORT, 0); return ZEBRA_FAIL; - } + } sk = sks->sortElement->u.generic; switch (sk->which) { @@ -954,7 +954,7 @@ ZEBRA_RES resultSetSortSingle(ZebraHandle zh, NMEM nmem, { zebraExplain_curDatabase(zh->reg->zei, zh->basenames[ib]); sort_criteria[i].numerical[ib] = 0; - sort_criteria[i].ord[ib] = + sort_criteria[i].ord[ib] = zebraExplain_lookup_attr_str(zh->reg->zei, zinfo_index_category_sort, 0, sk->u.sortField); @@ -981,7 +981,7 @@ ZEBRA_RES resultSetSortSingle(ZebraHandle zh, NMEM nmem, zebraExplain_curDatabase(zh->reg->zei, zh->basenames[ib]); if (zebra_sort_get_ord(zh, sk->u.sortAttributes, &sort_criteria[i].ord[ib], - &sort_criteria[i].numerical[ib]) != + &sort_criteria[i].numerical[ib]) != ZEBRA_OK && sks->which != Z_SortKeySpec_null) return ZEBRA_FAIL; } @@ -1064,7 +1064,7 @@ ZEBRA_RES resultSetSortSingle(ZebraHandle zh, NMEM nmem, } yaz_log(log_level_sort, ZINT_FORMAT " keys, " ZINT_FORMAT " sysnos, sort", - kno, sset->hits); + kno, sset->hits); for (i = 0; i < numTerms; i++) yaz_log(log_level_sort, "term=\"%s\" type=%s count=" ZINT_FORMAT, terms[i]->name, terms[i]->flags, terms[i]->rset->hits_count); @@ -1135,7 +1135,7 @@ ZEBRA_RES resultSetRank(ZebraHandle zh, ZebraSet zebraSet, kno++; if (log_level_searchhits) key_logdump_txt(log_level_searchhits, &key, termid->name); - if (this_sys != psysno) + if (this_sys != psysno) { /* new record .. */ if (!(rfd->counted_items & 255) && zh->break_handler_func) { @@ -1286,7 +1286,7 @@ ZEBRA_RES zebra_result_set_term_info(ZebraHandle zh, const char *setname, TERMID *term_array = xmalloc(num_terms * sizeof(*term_array)); zint *hits_array = xmalloc(num_terms * sizeof(*hits_array)); int *approx_array = xmalloc(num_terms * sizeof(*approx_array)); - + trav_rset_for_termids(sset->rset, term_array, hits_array, approx_array); @@ -1304,14 +1304,14 @@ ZEBRA_RES zebra_result_set_term_info(ZebraHandle zh, const char *setname, { char *outbuf = termbuf; size_t ret; - + ret = yaz_iconv(zh->iconv_from_utf8, &inbuf, &inleft, &outbuf, &outleft); if (ret == (size_t)(-1)) *termlen = 0; else { - yaz_iconv(zh->iconv_from_utf8, 0, 0, + yaz_iconv(zh->iconv_from_utf8, 0, 0, &outbuf, &outleft); *termlen = outbuf - termbuf; } @@ -1351,12 +1351,12 @@ ZEBRA_RES zebra_snippets_hit_vector(ZebraHandle zh, const char *setname, NMEM nmem = nmem_create(); struct it_key key; RSET rsets[2], rset_comb; - RSET rset_temp = rset_create_temp(nmem, kc, kc->scope, + RSET rset_temp = rset_create_temp(nmem, kc, kc->scope, res_get(zh->res, "setTmpDir"),0 ); - + TERMID termid; RSFD rsfd = rset_open(rset_temp, RSETF_WRITE); - + key.mem[0] = sysno; key.mem[1] = 0; key.mem[2] = 0; @@ -1367,7 +1367,7 @@ ZEBRA_RES zebra_snippets_hit_vector(ZebraHandle zh, const char *setname, rsets[0] = rset_temp; rsets[1] = rset_dup(sset->rset); - + rset_comb = rset_create_and(nmem, kc, kc->scope, 2, rsets); rsfd = rset_open(rset_comb, RSETF_READ); @@ -1385,7 +1385,7 @@ ZEBRA_RES zebra_snippets_hit_vector(ZebraHandle zh, const char *setname, } } rset_close(rsfd); - + rset_delete(rset_comb); nmem_destroy(nmem); kc->dec(kc); @@ -1393,7 +1393,7 @@ ZEBRA_RES zebra_snippets_hit_vector(ZebraHandle zh, const char *setname, return ZEBRA_OK; } -static ZEBRA_RES zebra_recid_to_sysno(ZebraHandle zh, +static ZEBRA_RES zebra_recid_to_sysno(ZebraHandle zh, const char **basenames, int num_bases, zint recid, zint *sysnos, int *no_sysnos) @@ -1401,7 +1401,7 @@ static ZEBRA_RES zebra_recid_to_sysno(ZebraHandle zh, ZEBRA_RES res = ZEBRA_OK; int sysnos_offset = 0; int i; - + if (!zh->reg->isamb || !zh->m_segment_indexing) { if (sysnos_offset < *no_sysnos) @@ -1426,9 +1426,9 @@ static ZEBRA_RES zebra_recid_to_sysno(ZebraHandle zh, char ord_buf[32]; int ord_len = key_SU_encode(ord, ord_buf); char *info; - + ord_buf[ord_len] = '\0'; - + info = dict_lookup(zh->reg->dict, ord_buf); if (info) { @@ -1443,9 +1443,9 @@ static ZEBRA_RES zebra_recid_to_sysno(ZebraHandle zh, struct it_key key_until, key_found; int i = 0; int r; - + memcpy(&isam_p, info+1, sizeof(ISAM_P)); - + pt = isamb_pp_open(zh->reg->isamb, isam_p, 2); if (!pt) res = ZEBRA_FAIL; @@ -1457,12 +1457,12 @@ static ZEBRA_RES zebra_recid_to_sysno(ZebraHandle zh, key_until.mem[i++] = 0; /* segment */ key_until.mem[i++] = 0; key_until.len = i; - + r = isamb_pp_forward(pt, &key_found, &key_until); while (r && key_found.mem[0] == recid) { if (sysnos_offset < *no_sysnos) - sysnos[sysnos_offset++] = + sysnos[sysnos_offset++] = key_found.mem[key_found.len-1]; r = isamb_pp_read(pt, &key_found); } @@ -1478,7 +1478,7 @@ static ZEBRA_RES zebra_recid_to_sysno(ZebraHandle zh, return res; } -ZEBRA_RES zebra_result_recid_to_sysno(ZebraHandle zh, +ZEBRA_RES zebra_result_recid_to_sysno(ZebraHandle zh, const char *setname, zint recid, zint *sysnos, int *no_sysnos) @@ -1520,7 +1520,7 @@ void zebra_count_set(ZebraHandle zh, RSET rset, zint *count, rset_close(rfd); *count = rset->hits_count; } - + /* * Local variables: diff --git a/isamb/benchindex1.c b/isamb/benchindex1.c index ead7127..fd41754 100644 --- a/isamb/benchindex1.c +++ b/isamb/benchindex1.c @@ -101,10 +101,10 @@ int code_read(void *vp, char **dst, int *insertMode) if (b->current_entry >= b->no_entries) return 0; - + t = b->ar[b->current_entry]; b->current_entry++; - + key.len = 3; key.mem[0] = t->word_id; key.mem[1] = t->docid; @@ -136,7 +136,7 @@ void index_block_flush(struct index_block *b, ISAMB isb, Dict dict, zint number_of_int_splits = isamb_get_int_splits(isb); zint number_of_leaf_splits = isamb_get_leaf_splits(isb); zint number_of_dict_splits = dict_get_no_split(dict); - + b->ar = xmalloc(sizeof(*b->ar) * b->no_entries); for (i = 0; i < b->no_entries; i++, t = t->next) { @@ -144,7 +144,7 @@ void index_block_flush(struct index_block *b, ISAMB isb, Dict dict, b->ar[i] = t; } assert(!t); - + qsort(b->ar, b->no_entries, sizeof(*b->ar), cmp_ar); tim_dict = yaz_timing_create(); #if 0 @@ -190,7 +190,7 @@ void index_block_flush(struct index_block *b, ISAMB isb, Dict dict, } } dict_insert(dict, "_w", sizeof(word_id_seq), &word_id_seq); - + yaz_timing_stop(tim_dict); tim_isamb = yaz_timing_create(); @@ -199,7 +199,7 @@ void index_block_flush(struct index_block *b, ISAMB isb, Dict dict, if (b->no_entries) { ISAMC_I isamc_i; - + isamc_i.clientData = b; isamc_i.read_item = code_read; @@ -222,7 +222,7 @@ void index_block_flush(struct index_block *b, ISAMB isb, Dict dict, } b->round++; printf("%5d %9.6f %9.6f %5.2f %5.2f %9.6f %5.2f %5.2f " - "%6" ZINT_FORMAT0 " %6" ZINT_FORMAT0 + "%6" ZINT_FORMAT0 " %6" ZINT_FORMAT0 " %8d %8d %6d %6d" " %5" ZINT_FORMAT0 "\n", b->round, yaz_timing_get_real(tim_dict) + yaz_timing_get_real(tim_isamb), @@ -309,7 +309,7 @@ void index_wrbuf(struct index_block *b, WRBUF wrbuf, zint docid, { /* continuation line */ for (i = 0; i<4 && *cp; i++, cp++) ; - } + } } nl = 0; if (*cp == '\n') @@ -350,7 +350,7 @@ void index_wrbuf(struct index_block *b, WRBUF wrbuf, zint docid, sz++; } cp++; - } + } } if (sz) index_term(b, term, docid, &seqno); @@ -450,7 +450,7 @@ void index_marc_from_file(ISAMB isb, long off = ftell(inf) - 5; if (verbose || print_offset) printf("\n", + "%ld (0x%lx) -->\n", *buf & 0xff, *buf & 0xff, off, off); for (i = 0; i<4; i++) @@ -478,7 +478,7 @@ void index_marc_from_file(ISAMB isb, if (r < rlen) break; yaz_marc_read_iso2709(mt, buf, len); - + if (yaz_marc_write_line(mt, wrbuf)) break; @@ -543,7 +543,7 @@ int main(int argc, char **argv) } break; case 'c': - if (sscanf(arg, "%d:%d", &dict_cache_size, &isam_cache_size) + if (sscanf(arg, "%d:%d", &dict_cache_size, &isam_cache_size) != 2) { fprintf(stderr, "bad cache sizes for -c\n"); @@ -561,7 +561,7 @@ int main(int argc, char **argv) exit_usage(); } } - + if (fname) { inf = fopen(fname, "rb"); @@ -621,7 +621,7 @@ int main(int argc, char **argv) } if (!strcmp(type, "iso2709")) - index_marc_from_file(isb_postings, dict, &docid_seq, inf, memory, + index_marc_from_file(isb_postings, dict, &docid_seq, inf, memory, 0 /* verbose */ , 0 /* print_offset */); else if (!strcmp(type, "line")) index_marc_line_records(isb_postings, dict, &docid_seq, inf, memory); @@ -642,7 +642,7 @@ int main(int argc, char **argv) yaz_timing_get_real(tim), yaz_timing_get_user(tim), yaz_timing_get_sys(tim)); - + yaz_timing_destroy(&tim); exit(0); diff --git a/isamb/benchisamb.c b/isamb/benchisamb.c index a726e62..e0dd385 100644 --- a/isamb/benchisamb.c +++ b/isamb/benchisamb.c @@ -132,7 +132,7 @@ void bench_insert(ISAMB isb, int number_of_trees, ri.step = 1; ri.insertMode = 1; ri.sz = sizeof(int) + 1 + extra_size; - + for (round = 0; round < number_of_rounds; round++) { yaz_timing_t t = yaz_timing_create(); @@ -143,17 +143,17 @@ void bench_insert(ISAMB isb, int number_of_trees, /* insert a number of entries */ ri.no = 0; - + ri.val = (rand()); - if (RAND_MAX < 65536) + if (RAND_MAX < 65536) ri.val = ri.val + 65536*rand(); // ri.val = number_of_elements * round; ri.max = number_of_elements; - + isamc_i.clientData = &ri; isamc_i.read_item = code_read; - + isamb_merge (isb, &isamc_p[i] , &isamc_i); if (0) @@ -188,7 +188,7 @@ int main(int argc, char **argv) int number_of_isams = 1000; int extra_size = 0; yaz_timing_t t = 0; - + while ((ret = options("z:r:n:i:", argv, argc, &arg)) != -2) { switch(ret) @@ -213,7 +213,7 @@ int main(int argc, char **argv) exit_usage(); } } - + /* setup method (attributes) */ method.compare_item = compare_item; method.log_item = log_item; @@ -224,7 +224,7 @@ int main(int argc, char **argv) method.codec.stop = code_stop; t = yaz_timing_create(); - + yaz_timing_start(t); /* create block system */ @@ -246,7 +246,7 @@ int main(int argc, char **argv) } bench_insert(isb, number_of_isams, number_of_rounds, number_of_items, extra_size); - + isamb_close(isb); /* exit block system */ diff --git a/isamb/isamb.c b/isamb/isamb.c index 4c1c803..9f6b9b5 100644 --- a/isamb/isamb.c +++ b/isamb/isamb.c @@ -101,7 +101,7 @@ struct ISAMB_s { int log_io; /* log level for bf_read/bf_write calls */ int log_freelist; /* log level for freelist handling */ zint skipped_numbers; /* on a leaf node */ - zint returned_numbers; + zint returned_numbers; zint skipped_nodes[ISAMB_MAX_LEVEL]; /* [0]=skipped leaves, 1 = higher etc */ zint accessed_nodes[ISAMB_MAX_LEVEL]; /* nodes we did not skip */ zint number_of_int_splits; @@ -136,7 +136,7 @@ struct ISAMB_PP_s { zint total_size; zint no_blocks; zint skipped_numbers; /* on a leaf node */ - zint returned_numbers; + zint returned_numbers; zint skipped_nodes[ISAMB_MAX_LEVEL]; /* [0]=skipped leaves, 1 = higher etc */ zint accessed_nodes[ISAMB_MAX_LEVEL]; /* nodes we did not skip */ struct ISAMB_block **block; @@ -315,7 +315,7 @@ ISAMB isamb_open2(BFiles bfs, const char *name, int writeflag, ISAMC_M *method, pos++; if (!bf_read(isamb->file[i].bf, pos, 0, 0, hbuf + pos*sizes[i])) { - yaz_log(YLOG_WARN, "truncated isamb header for " + yaz_log(YLOG_WARN, "truncated isamb header for " "file=%s len=%d pos=%d", fname, len, pos); isamb_close(isamb); @@ -352,7 +352,7 @@ ISAMB isamb_open(BFiles bfs, const char *name, int writeflag, ISAMC_M *method, { int sizes[CAT_NO]; int i, b_size = ISAMB_MIN_SIZE; - + for (i = 0; ifile[cat].head.block_size - 1)) * b->file[cat].head.block_size); zint norm = pos / (CAT_MASK*ISAMB_CACHE_ENTRY_SIZE / b->file[cat].head.block_size); @@ -400,13 +400,13 @@ static int cache_block(ISAMB b, ISAM_P pos, unsigned char *userbuf, int wr) { ce_this = *ce; *ce = (*ce)->next; /* remove from list */ - + ce_this->next = b->file[cat].cache_entries; /* move to front */ b->file[cat].cache_entries = ce_this; - + if (wr) { - memcpy(ce_this->buf + off, userbuf, + memcpy(ce_this->buf + off, userbuf, b->file[cat].head.block_size); ce_this->dirty = 1; } @@ -513,9 +513,9 @@ void isamb_close(ISAMB isamb) 0: leader byte, != 0 leaf, == 0, non-leaf 1-2: used size of block 3-7*: number of items and all children - + * Reserve 5 bytes for large block sizes. 1 for small ones .. Number - of items. We can thus have at most 2^40 nodes. + of items. We can thus have at most 2^40 nodes. */ static struct ISAMB_block *open_block(ISAMB b, ISAM_P pos) { @@ -573,7 +573,7 @@ struct ISAMB_block *new_block(ISAMB b, int leaf, int cat) block_no = b->file[cat].head.last_block++; p->pos = block_no * CAT_MAX + cat; if (b->log_freelist) - yaz_log(b->log_freelist, "got block " + yaz_log(b->log_freelist, "got block " ZINT_FORMAT " from last %d:" ZINT_FORMAT, p->pos, cat, p->pos/CAT_MAX); } @@ -592,7 +592,7 @@ struct ISAMB_block *new_block(ISAMB b, int leaf, int cat) } } if (b->log_freelist) - yaz_log(b->log_freelist, "got block " + yaz_log(b->log_freelist, "got block " ZINT_FORMAT " from freelist %d:" ZINT_FORMAT, p->pos, cat, p->pos/CAT_MAX); memcpy(&b->file[cat].head.free_list, p->buf, sizeof(zint)); @@ -637,7 +637,7 @@ static void check_block(ISAMB b, struct ISAMB_block *p) char *endp = p->bytes + p->size; ISAM_P pos; void *c1 = (*b->method->codec.start)(); - + decode_ptr(&src, &pos); assert((pos&CAT_MASK) == p->cat); while (src != endp) @@ -686,7 +686,7 @@ void close_block(ISAMB b, struct ISAMB_block *p) int size = p->size + offset; char *dst = (char*)p->buf + 3; assert(p->size >= 0); - + /* memset becuase encode_ptr usually does not write all bytes */ memset(p->buf, 0, b->file[p->cat].head.block_offset); p->buf[0] = p->leaf; @@ -748,7 +748,7 @@ int insert_int(ISAMB b, struct ISAMB_block *p, void *lookahead_item, assert(sub_p1); diff_terms -= sub_p1->no_items; more = insert_sub(b, &sub_p1, lookahead_item, mode, - stream, &sub_p2, + stream, &sub_p2, sub_item, &sub_size, file_item_buf); diff_terms += sub_p1->no_items; src = src0; @@ -764,7 +764,7 @@ int insert_int(ISAMB b, struct ISAMB_block *p, void *lookahead_item, assert(sub_p1); diff_terms -= sub_p1->no_items; more = insert_sub(b, &sub_p1, lookahead_item, mode, - stream, &sub_p2, + stream, &sub_p2, sub_item, &sub_size, src); diff_terms += sub_p1->no_items; src = src0; @@ -780,7 +780,7 @@ int insert_int(ISAMB b, struct ISAMB_block *p, void *lookahead_item, sub_p1 = open_block(b, pos); assert(sub_p1); diff_terms -= sub_p1->no_items; - more = insert_sub(b, &sub_p1, lookahead_item, mode, stream, &sub_p2, + more = insert_sub(b, &sub_p1, lookahead_item, mode, stream, &sub_p2, sub_item, &sub_size, last_max_item); diff_terms += sub_p1->no_items; } @@ -802,7 +802,7 @@ int insert_int(ISAMB b, struct ISAMB_block *p, void *lookahead_item, assert(sub_size < DST_ITEM_MAX && sub_size > 1); memcpy(dst, startp, src - startp); - + dst += src - startp; #if INT_ENCODE @@ -846,7 +846,7 @@ int insert_int(ISAMB b, struct ISAMB_block *p, void *lookahead_item, const char *half; src = dst_buf; endp = dst; - + b->number_of_int_splits++; p->dirty = 1; @@ -948,7 +948,7 @@ int insert_leaf(ISAMB b, struct ISAMB_block **sp1, void *lookahead_item, { char file_item_buf[DST_ITEM_MAX]; char *file_item = file_item_buf; - + src = p->bytes; endp = p->bytes + p->size; (*b->method->codec.decode)(c1, &file_item, &src); @@ -958,12 +958,12 @@ int insert_leaf(ISAMB b, struct ISAMB_block **sp1, void *lookahead_item, char *lookahead_next; char *dst_0 = dst; int d = -1; - + if (lookahead_item) d = (*b->method->compare_item)(file_item_buf, lookahead_item); - + /* d now holds comparison between existing file item and - lookahead item + lookahead item d = 0: equal d > 0: lookahead before file d < 0: lookahead after file @@ -981,7 +981,7 @@ int insert_leaf(ISAMB b, struct ISAMB_block **sp1, void *lookahead_item, } else if (d == 0 && *lookahead_mode == 2) { - /* For mode == 2, we insert the new key anyway - even + /* For mode == 2, we insert the new key anyway - even though the comparison is 0. */ dst_item = lookahead_item; p->dirty = 1; @@ -1005,11 +1005,11 @@ int insert_leaf(ISAMB b, struct ISAMB_block **sp1, void *lookahead_item, /* encode the resulting item */ (*b->method->codec.encode)(c2, &dst, &dst_item); - + cut_item_size = dst_item - dst_item_0; assert(cut_item_size > 0); memcpy(cut_item_buf, dst_item_0, cut_item_size); - + half2 = dst; no_items_1 = no_items; no_items++; @@ -1022,7 +1022,7 @@ int insert_leaf(ISAMB b, struct ISAMB_block **sp1, void *lookahead_item, } /* now move "pointers" .. result has been encoded .. */ - if (d > 0) + if (d > 0) { /* we must move the lookahead pointer */ @@ -1049,7 +1049,7 @@ int insert_leaf(ISAMB b, struct ISAMB_block **sp1, void *lookahead_item, leaf. Mark it as "gone" */ lookahead_item = 0; } - + p->dirty = 1; } } @@ -1090,7 +1090,7 @@ int insert_leaf(ISAMB b, struct ISAMB_block **sp1, void *lookahead_item, char *dst_item; const char *src = lookahead_item; char *dst_0 = dst; - + /* if we have a lookahead item, we stop if we exceed the value of it */ if (max_item && (*b->method->compare_item)(max_item, lookahead_item) <= 0) @@ -1108,13 +1108,13 @@ int insert_leaf(ISAMB b, struct ISAMB_block **sp1, void *lookahead_item, { const char *src_0 = src; half1 = dst; /* candidate for splitting */ - + (*b->method->codec.encode)(c2, &dst, &src); - + cut_item_size = src - src_0; assert(cut_item_size > 0); memcpy(cut_item_buf, src_0, cut_item_size); - + no_items_1 = no_items; half2 = dst; } @@ -1138,7 +1138,7 @@ int insert_leaf(ISAMB b, struct ISAMB_block **sp1, void *lookahead_item, } } new_size = dst - dst_buf; - if (p && p->cat != b->no_cat-1 && + if (p && p->cat != b->no_cat-1 && new_size > b->file[p->cat].head.block_max) { /* non-btree block will be removed */ @@ -1166,7 +1166,7 @@ int insert_leaf(ISAMB b, struct ISAMB_block **sp1, void *lookahead_item, assert(half2); assert(cut_item_size > 0); - + /* first half */ p->size = half1 - dst_buf; assert(p->size <= b->file[p->cat].head.block_max); @@ -1214,7 +1214,7 @@ int insert_sub(ISAMB b, struct ISAMB_block **p, void *new_item, const void *max_item) { if (!*p || (*p)->leaf) - return insert_leaf(b, p, new_item, mode, stream, sp, sub_item, + return insert_leaf(b, p, new_item, mode, stream, sp, sub_item, sub_size, max_item); else return insert_int(b, *p, new_item, mode, stream, sp, sub_item, @@ -1238,7 +1238,7 @@ int isamb_unlink(ISAMB b, ISAM_P pos) #endif decode_ptr(&src, &sub_p); isamb_unlink(b, sub_p); - + while (src != p1->bytes + p1->size) { #if INT_ENCODE @@ -1289,7 +1289,7 @@ void isamb_merge(ISAMB b, ISAM_P *pos, ISAMC_I *stream) struct ISAMB_block *p = 0, *sp = 0; char sub_item[DST_ITEM_MAX]; int sub_size; - + if (*pos) p = open_block(b, *pos); more = insert_sub(b, &p, item_buf, &i_mode, stream, &sp, @@ -1314,7 +1314,7 @@ void isamb_merge(ISAMB b, ISAM_P *pos, ISAMC_I *stream) dst += sub_size; #endif encode_ptr(&dst, sp->pos); - + p2->size = dst - p2->bytes; p2->no_items = p->no_items + sp->no_items; *pos = p2->pos; /* return new super page */ @@ -1374,7 +1374,7 @@ ISAMB_PP isamb_pp_open_x(ISAMB isamb, ISAM_P pos, int *level, int scope) decode_ptr(&src, &pos); p->offset = src - p->bytes; pp->level++; - pp->accessed_nodes[pp->level]++; + pp->accessed_nodes[pp->level]++; } pp->block[pp->level+1] = 0; pp->maxlevel = pp->level; @@ -1393,7 +1393,7 @@ void isamb_pp_close_x(ISAMB_PP pp, zint *size, zint *blocks) int i; if (!pp) return; - yaz_log(YLOG_DEBUG, "isamb_pp_close lev=%d returned "ZINT_FORMAT" values, " + yaz_log(YLOG_DEBUG, "isamb_pp_close lev=%d returned "ZINT_FORMAT" values, " "skipped "ZINT_FORMAT, pp->maxlevel, pp->skipped_numbers, pp->returned_numbers); for (i = pp->maxlevel; i>=0; i--) @@ -1466,7 +1466,7 @@ static void isamb_dump_r(ISAMB b, ISAM_P pos, void (*pr)(const char *str), p->offset = src - (char*) p->bytes; isamb_dump_r(b, sub, pr, level+1); - + while (p->offset < p->size) { #if INT_ENCODE @@ -1483,11 +1483,11 @@ static void isamb_dump_r(ISAMB b, ISAM_P pos, void (*pr)(const char *str), src += item_len; #endif decode_ptr(&src, &sub); - + p->offset = src - (char*) p->bytes; - + isamb_dump_r(b, sub, pr, level+1); - } + } } close_block(b, p); } @@ -1509,7 +1509,7 @@ void isamb_pp_pos(ISAMB_PP pp, double *current, double *total) /* occureences in the isam tree, based on the current leaf */ assert(total); assert(current); - + /* if end-of-stream PP may not be leaf */ *total = (double) (pp->block[0]->no_items); @@ -1548,19 +1548,19 @@ int isamb_pp_forward(ISAMB_PP pp, void *buf, const void *untilb) pp->block[pp->level] = 0; (pp->level)--; p = pp->block[pp->level]; - assert(!p->leaf); + assert(!p->leaf); } assert(!p->leaf); src = p->bytes + p->offset; - + #if INT_ENCODE c1 = (*b->method->codec.start)(); (*b->method->codec.decode)(c1, &file_item, &src); #else decode_ptr(&src, &item_len); src += item_len; -#endif +#endif decode_ptr(&src, &pos); p->offset = src - (char*) p->bytes; @@ -1599,18 +1599,18 @@ int isamb_pp_forward(ISAMB_PP pp, void *buf, const void *untilb) pp->total_size += p->size; pp->no_blocks++; - - if (p->leaf) + + if (p->leaf) { break; } - + src = p->bytes + p->offset; while(1) { decode_ptr(&src, &pos); p->offset = src - (char*) p->bytes; - + if (!untilb || p->offset == p->size) break; assert(p->offset < p->size); @@ -1650,7 +1650,7 @@ int isamb_pp_forward(ISAMB_PP pp, void *buf, const void *untilb) dst = dst0; if (p->offset == p->size) goto again; } - pp->returned_numbers++; + pp->returned_numbers++; return 1; } diff --git a/isamb/tstisamb.c b/isamb/tstisamb.c index 72de84a..d48d837 100644 --- a/isamb/tstisamb.c +++ b/isamb/tstisamb.c @@ -130,7 +130,7 @@ void tst_insert(ISAMB isb, int n) isamc_i.clientData = &ri; isamc_i.read_item = code_read; - + isamc_p = 0; /* new list */ isamb_merge (isb, &isamc_p , &isamc_i); @@ -174,7 +174,7 @@ void tst_insert(ISAMB isb, int n) isamc_i.clientData = &ri; isamc_i.read_item = code_read; - + isamb_merge (isb, &isamc_p , &isamc_i); /* delete a number of entries (odd ones) */ @@ -187,7 +187,7 @@ void tst_insert(ISAMB isb, int n) isamc_i.clientData = &ri; isamc_i.read_item = code_read; - + isamb_merge (isb, &isamc_p, &isamc_i); if (isamc_p) @@ -216,13 +216,13 @@ void tst_forward(ISAMB isb, int n) isamc_i.clientData = &ri; isamc_i.read_item = code_read; - + isamc_p = 0; isamb_merge (isb, &isamc_p, &isamc_i); /* read the entries */ pp = isamb_pp_open (isb, isamc_p, 1); - + for (i = 0; iidx >= ri->max) return 0; - + if (ri->delta[ri->idx] > 0) { ri->level++; @@ -357,7 +357,7 @@ void tst_random(ISAMB isb, int n, int rounds, int max_dups) int i, j; for (i = 0; imethod->debug) yaz_log (YLOG_LOG, "isc:%6d %6d %6d %6d", - filecat[i].bsize, filecat[i].ifill, + filecat[i].bsize, filecat[i].ifill, filecat[i].mfill, filecat[i].mblocks); if (max_buf_size < filecat[i].mblocks * filecat[i].bsize) max_buf_size = filecat[i].mblocks * filecat[i].bsize; @@ -107,7 +107,7 @@ ISAMC isamc_open (BFiles bfs, const char *name, int writeflag, ISAMC_M *method) max_buf_size = (1+is->method->max_blocks_mem) * filecat[i].bsize; if (is->method->debug) yaz_log (YLOG_LOG, "isc: max_buf_size %d", max_buf_size); - + assert (is->no_files > 0); is->files = (ISAMC_file) xmalloc (sizeof(*is->files)*is->no_files); if (writeflag) @@ -346,7 +346,7 @@ static void release_block (ISAMC is, int cat, zint pos) { memcpy (abuf + sizeof(int), &block, sizeof(zint)); is->files[cat].head.freelist = pos; - is->files[cat].head_is_dirty = 1; + is->files[cat].head_is_dirty = 1; } else { @@ -381,9 +381,9 @@ static zint alloc_block (ISAMC is, int cat) static void release_block (ISAMC is, int cat, zint pos) { char buf[sizeof(zint)]; - + (is->files[cat].no_released)++; - is->files[cat].head_is_dirty = 1; + is->files[cat].head_is_dirty = 1; memcpy (buf, &is->files[cat].head.freelist, sizeof(zint)); is->files[cat].head.freelist = pos; bf_write (is->files[cat].bf, pos, 0, sizeof(zint), buf); @@ -433,7 +433,7 @@ void isamc_release_block (ISAMC is, int cat, zint pos) static void init_fc (ISAMC is, int cat) { int j = 100; - + is->files[cat].fc_max = j; is->files[cat].fc_list = (zint *) xmalloc (sizeof(*is->files[0].fc_list) * j); @@ -467,9 +467,9 @@ ISAMC_PP isamc_pp_open (ISAMC is, ISAM_P ipos) { ISAMC_PP pp = (ISAMC_PP) xmalloc (sizeof(*pp)); char *src; - + pp->cat = (int) isamc_type(ipos); - pp->pos = isamc_block(ipos); + pp->pos = isamc_block(ipos); src = pp->buf = (char *) xmalloc (is->method->filecat[pp->cat].bsize); @@ -497,7 +497,7 @@ ISAMC_PP isamc_pp_open (ISAMC is, ISAM_P ipos) yaz_log(YLOG_FATAL|YLOG_LOG, "pp->pos = " ZINT_FORMAT, pp->pos); assert (pp->next != pp->pos); } - pp->offset = src - pp->buf; + pp->offset = src - pp->buf; assert (pp->offset == ISAMC_BLOCK_OFFSET_1); if (is->method->debug > 2) yaz_log (YLOG_LOG, "isc: read_block size=%d %d " ZINT_FORMAT " next=" @@ -572,14 +572,14 @@ int isamc_read_item (ISAMC_PP pp, char **dst) if (pp->deleteFlag) isamc_release_block (is, pp->cat, pp->pos); (*is->method->codec.decode)(pp->decodeClientData, dst, &src); - pp->offset = src - pp->buf; + pp->offset = src - pp->buf; if (is->method->debug > 2) yaz_log (YLOG_LOG, "isc: read_block size=%d %d " ZINT_FORMAT " next=" ZINT_FORMAT, pp->size, pp->cat, pp->pos, pp->next); return 2; } (*is->method->codec.decode)(pp->decodeClientData, dst, &src); - pp->offset = src - pp->buf; + pp->offset = src - pp->buf; return 1; } diff --git a/isamc/merge.c b/isamc/merge.c index 35f19c0..a925496 100644 --- a/isamc/merge.c +++ b/isamc/merge.c @@ -72,7 +72,7 @@ static void flush_blocks (ISAMC is, struct isamc_merge_block *mb, int ptr, for (i = 0; imethod->filecat[cat].bsize : is->method->filecat[cat].ifill; int off = (ptr||firstpos) ? ISAMC_BLOCK_OFFSET_N : ISAMC_BLOCK_OFFSET_1; - + assert (ptr < 199); return mb[ptr].offset + fill - off; @@ -157,12 +157,12 @@ void isamc_merge (ISAMC is, ISAM_P *ipos, ISAMC_I *data) char i_item[128], *i_item_ptr; int i_more, i_mode, i; - ISAMC_PP pp; + ISAMC_PP pp; char f_item[128], *f_item_ptr; int f_more; int last_dirty = 0; int debug = is->method->debug; - + struct isamc_merge_block mb[200]; zint firstpos = 0; @@ -207,10 +207,10 @@ void isamc_merge (ISAMC is, ISAM_P *ipos, ISAMC_I *data) { /* block to block boundary in the original file. */ f_more = 1; - if (cat == pp->cat) + if (cat == pp->cat) { /* the resulting output is of the same category as the - the original + the original */ if (r_offset <= mb[ptr].offset +is->method->filecat[cat].mfill) { @@ -338,7 +338,7 @@ void isamc_merge (ISAMC is, ISAM_P *ipos, ISAMC_I *data) int new_offset; (*is->method->codec.encode)(r_clientData, &r_out_ptr, &src); - new_offset = r_out_ptr - r_buf; + new_offset = r_out_ptr - r_buf; numKeys++; @@ -383,7 +383,7 @@ void isamc_merge (ISAMC is, ISAM_P *ipos, ISAMC_I *data) if (cat < is->max_cat && ptr >= is->method->filecat[cat].mblocks) { /* Max number blocks in current category reached -> - must switch to next category (with larger block size) + must switch to next category (with larger block size) */ int j = 0; @@ -428,8 +428,8 @@ void isamc_merge (ISAMC is, ISAM_P *ipos, ISAMC_I *data) } if (mb[ptr].offset < r_offset) { /* make the final boundary offset */ - mb[++ptr].dirty = 1; - mb[ptr].block = 0; + mb[++ptr].dirty = 1; + mb[ptr].block = 0; mb[ptr].offset = r_offset; } else diff --git a/isams/isams.c b/isams/isams.c index 52e1be5..f38130b 100644 --- a/isams/isams.c +++ b/isams/isams.c @@ -46,7 +46,7 @@ struct ISAMS_s { int block_size; int debug; BFile bf; -}; +}; struct ISAMS_PP_s { ISAMS is; @@ -139,13 +139,13 @@ ISAM_P isams_merge (ISAMS is, ISAMS_I data) char *tmp_ptr = i_item; i_more = (*data->read_item)(data->clientData, &tmp_ptr, &i_mode); assert (i_mode); - + if (!i_more) break; else { char *r_out_ptr = is->merge_buf + is->head.last_offset; - + const char *i_item_ptr = i_item; (*is->method->codec.encode)(r_clientData, &r_out_ptr, &i_item_ptr); is->head.last_offset = r_out_ptr - is->merge_buf; @@ -246,7 +246,7 @@ int isams_read_item (ISAMS_PP pp, char **dst) } src = pp->buf + pp->block_offset; (*pp->is->method->codec.decode)(pp->decodeClientData, dst, &src); - pp->block_offset = src - pp->buf; + pp->block_offset = src - pp->buf; return 1; } diff --git a/rset/rsbetween.c b/rset/rsbetween.c index 4c51534..40ed5da 100644 --- a/rset/rsbetween.c +++ b/rset/rsbetween.c @@ -20,13 +20,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA /* rsbetween is (mostly) used for xml searches. It returns the hits of the * "middle" rset, that are in between the "left" and "right" rsets. For - * example "Shakespeare" in between "" and . The thing is + * example "Shakespeare" in between "" and . The thing is * complicated by the inclusion of attributes (from their own rset). If attrs * specified, they must match the "left" rset (start tag). "Hamlet" between * "" and "". (This assumes that the attributes are * indexed to the same seqno as the tags). * -*/ +*/ #if HAVE_CONFIG_H #include @@ -43,21 +43,21 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA static RSFD r_open(RSET ct, int flag); static void r_close(RSFD rfd); static void r_delete(RSET ct); -static int r_forward(RSFD rfd, void *buf, +static int r_forward(RSFD rfd, void *buf, TERMID *term, const void *untilbuf); static int r_read(RSFD rfd, void *buf, TERMID *term ); static int r_write(RSFD rfd, const void *buf); static void r_pos(RSFD rfd, double *current, double *total); static void r_get_terms(RSET ct, TERMID *terms, int maxterms, int *curterm); -static const struct rset_control control = +static const struct rset_control control = { "between", r_delete, r_get_terms, r_open, r_close, - r_forward, + r_forward, r_pos, r_read, r_write, @@ -84,7 +84,7 @@ struct rset_between_rfd { int depth; /* number of start-tags without end-tags */ int attrdepth; /* on what depth the attr matched */ zint hits; -}; +}; static int log_level = 0; static int log_level_initialized = 0; @@ -111,7 +111,7 @@ RSET rset_create_between(NMEM nmem, struct rset_key_control *kcontrol, (struct rset_between_info *) nmem_malloc(rnew->nmem,sizeof(*info)); RSET rsetarray[4]; int n = 4; - + if (!log_level_initialized) { log_level = yaz_log_module_level("rsbetween"); @@ -137,11 +137,11 @@ RSET rset_create_between(NMEM nmem, struct rset_key_control *kcontrol, else { info->attrterm = NULL; - n = 3; + n = 3; } rnew->no_children = 1; rnew->children = nmem_malloc(rnew->nmem, sizeof(RSET *)); - rnew->children[0] = rset_create_and(nmem, kcontrol, + rnew->children[0] = rset_create_and(nmem, kcontrol, scope, n, rsetarray); rnew->priv = info; yaz_log(log_level, "create rset at %p", rnew); @@ -164,14 +164,14 @@ static RSFD r_open(RSET ct, int flag) return NULL; } rfd = rfd_create_base(ct); - if (rfd->priv) + if (rfd->priv) p=(struct rset_between_rfd *)rfd->priv; else { p = (struct rset_between_rfd *) nmem_malloc(ct->nmem, (sizeof(*p))); rfd->priv = p; - p->recbuf = nmem_malloc(ct->nmem, ct->keycontrol->key_size); - p->startbuf = nmem_malloc(ct->nmem, ct->keycontrol->key_size); - p->attrbuf = nmem_malloc(ct->nmem, ct->keycontrol->key_size); + p->recbuf = nmem_malloc(ct->nmem, ct->keycontrol->key_size); + p->startbuf = nmem_malloc(ct->nmem, ct->keycontrol->key_size); + p->attrbuf = nmem_malloc(ct->nmem, ct->keycontrol->key_size); } p->andrfd = rset_open(ct->children[0], RSETF_READ); p->hits = -1; @@ -190,7 +190,7 @@ static void r_close(RSFD rfd) rset_close(p->andrfd); } -static int r_forward(RSFD rfd, void *buf, +static int r_forward(RSFD rfd, void *buf, TERMID *term, const void *untilbuf) { struct rset_between_rfd *p=(struct rset_between_rfd *)rfd->priv; @@ -209,7 +209,7 @@ static void checkattr(RSFD rfd) int cmp; if (p->attrdepth) return; /* already found one */ - if (!info->attrterm) + if (!info->attrterm) { p->attrdepth=-1; /* matches always */ return; @@ -240,7 +240,7 @@ static int r_read(RSFD rfd, void *buf, TERMID *term) { yaz_log(log_level,"read loop term=%p d=%d ad=%d", *term, p->depth, p->attrdepth); - if (p->hits<0) + if (p->hits<0) {/* first time? */ memcpy(p->recbuf, buf, kctrl->key_size); p->hits = 0; @@ -252,7 +252,7 @@ static int r_read(RSFD rfd, void *buf, TERMID *term) } if (cmp>=rfd->rset->scope) - { + { yaz_log(log_level, "new record"); p->depth = 0; p->attrdepth = 0; @@ -284,12 +284,12 @@ static int r_read(RSFD rfd, void *buf, TERMID *term) p->attrbufok = 1; checkattr(rfd); /* in case the start tag came first */ } - else + else { /* mut be a real hit */ if (p->depth && p->attrdepth) { p->hits++; - yaz_log(log_level,"got a hit h="ZINT_FORMAT" d=%d ad=%d", + yaz_log(log_level,"got a hit h="ZINT_FORMAT" d=%d ad=%d", p->hits, p->depth, p->attrdepth); return 1; /* we have everything in place already! */ } else @@ -322,7 +322,7 @@ static void r_get_terms(RSET ct, TERMID *terms, int maxterms, int *curterm) rset_getterms(ct->children[0], terms, maxterms, curterm); } - + /* * Local variables: * c-basic-offset: 4 diff --git a/rset/rsbool.c b/rset/rsbool.c index 2335771..f7fb85a 100644 --- a/rset/rsbool.c +++ b/rset/rsbool.c @@ -36,19 +36,19 @@ static RSFD r_open(RSET ct, int flag); static void r_close(RSFD rfd); static void r_delete(RSET ct); static int r_forward(RSFD rfd, void *buf, TERMID *term, const void *untilbuf); -static void r_pos(RSFD rfd, double *current, double *total); +static void r_pos(RSFD rfd, double *current, double *total); static int r_read_not(RSFD rfd, void *buf, TERMID *term); static int r_write(RSFD rfd, const void *buf); static void r_get_terms(RSET ct, TERMID *terms, int maxterms, int *curterm); -static const struct rset_control control_not = +static const struct rset_control control_not = { "not", r_delete, r_get_terms, r_open, r_close, - r_forward, + r_forward, r_pos, r_read_not, r_write, @@ -70,7 +70,7 @@ struct rfd_private { TERMID term_l; TERMID term_r; int tail; -}; +}; static RSET rsbool_create_base(const struct rset_control *ctrl, NMEM nmem, @@ -151,8 +151,8 @@ static int r_forward(RSFD rfd, void *buf, TERMID *term, p->more_l = rset_forward(p->rfd_l, p->buf_l, &p->term_l, untilbuf); if ( p->more_r && ((kctrl->cmp)(untilbuf,p->buf_r)>=rfd->rset->scope)) p->more_r = rset_forward(p->rfd_r, p->buf_r, &p->term_r, untilbuf); - p->tail = 0; - return rset_read(rfd,buf,term); + p->tail = 0; + return rset_read(rfd,buf,term); } @@ -196,7 +196,7 @@ static int r_read_not(RSFD rfd, void *buf, TERMID *term) } else if (cmp >= rfd->rset->scope) /* cmp >1 */ { - p->more_r = rset_forward( p->rfd_r, p->buf_r, + p->more_r = rset_forward( p->rfd_r, p->buf_r, &p->term_r, p->buf_l); } else @@ -205,7 +205,7 @@ static int r_read_not(RSFD rfd, void *buf, TERMID *term) if (term) *term = p->term_l; do - { + { p->more_l = rset_read(p->rfd_l, p->buf_l, &p->term_l); if (!p->more_l) break; @@ -246,18 +246,18 @@ static void r_pos(RSFD rfd, double *current, double *total) *current = rcur; /* return same as you got */ *total = rtot; /* probably -1 for not available */ } - if (rtot < 0) - rtot = rcur = 0; /* if only one useful, use it */ - if (ltot < 0) + if (rtot < 0) + rtot = rcur = 0; /* if only one useful, use it */ + if (ltot < 0) ltot = lcur = 0; - if (rtot+ltot < 1) + if (rtot+ltot < 1) { /* empty rset */ *current = *total = 0; return; } r = 1.0*(lcur+rcur)/(ltot+rtot); /* weighed average of l and r */ *current = (double) (p->hits); - *total = *current/r ; + *total = *current/r ; #if RSET_DEBUG yaz_log(YLOG_DEBUG,"bool_pos: (%s/%s) %0.1f/%0.1f= %0.4f ", info->rset_l->control->desc, info->rset_r->control->desc, diff --git a/rset/rset.c b/rset/rset.c index 3da4bd6..bec6da4 100644 --- a/rset/rset.c +++ b/rset/rset.c @@ -34,31 +34,31 @@ static int log_level_initialized = 0; /** \brief Common constuctor for RFDs \param rs Result set handle. - - Creates an rfd. Either allocates a new one, in which case the priv - pointer is null, and will have to be filled in, or picks up one + + Creates an rfd. Either allocates a new one, in which case the priv + pointer is null, and will have to be filled in, or picks up one from the freelist, in which case the priv is already allocated, - and presumably everything that hangs from it as well + and presumably everything that hangs from it as well */ RSFD rfd_create_base(RSET rs) { RSFD rnew = rs->free_list; - if (rnew) + if (rnew) { rs->free_list = rnew->next; assert(rnew->rset==rs); - yaz_log(log_level, "rfd_create_base (fl): rfd=%p rs=%p fl=%p priv=%p", - rnew, rs, rs->free_list, rnew->priv); - } + yaz_log(log_level, "rfd_create_base (fl): rfd=%p rs=%p fl=%p priv=%p", + rnew, rs, rs->free_list, rnew->priv); + } else { rnew = nmem_malloc(rs->nmem, sizeof(*rnew)); rnew->counted_buf = nmem_malloc(rs->nmem, rs->keycontrol->key_size); rnew->priv = 0; rnew->rset = rs; - yaz_log(log_level, "rfd_create_base (new): rfd=%p rs=%p fl=%p priv=%p", - rnew, rs, rs->free_list, rnew->priv); + yaz_log(log_level, "rfd_create_base (new): rfd=%p rs=%p fl=%p priv=%p", + rnew, rs, rs->free_list, rnew->priv); } rnew->next = rs->use_list; rs->use_list = rnew; @@ -70,9 +70,9 @@ static void rset_close_int(RSET rs, RSFD rfd) { RSFD *pfd; (*rs->control->f_close)(rfd); - + yaz_log(log_level, "rfd_delete_base: rfd=%p rs=%p priv=%p fl=%p", - rfd, rs, rfd->priv, rs->free_list); + rfd, rs, rfd->priv, rs->free_list); for (pfd = &rs->use_list; *pfd; pfd = &(*pfd)->next) if (*pfd == rfd) { @@ -107,7 +107,7 @@ void rset_close(RSFD rfd) while (rfd->counted_items <= rs->hits_limit && rset_default_read(rfd, buf, &termid)) ; - + rs->hits_count = rfd->counted_items; yaz_log(log_level, "rset_close rset=%p hits_count=" ZINT_FORMAT " hits_limit=" ZINT_FORMAT, @@ -117,7 +117,7 @@ void rset_close(RSFD rfd) { double cur, tot; zint est; - rset_pos(rfd, &cur, &tot); + rset_pos(rfd, &cur, &tot); if (tot > 0) { int i; double ratio = cur/tot; @@ -139,7 +139,7 @@ void rset_close(RSFD rfd) rs->hits_approx = 1; } } - yaz_log(log_level, "rset_close(%s) p=%p count=" ZINT_FORMAT, + yaz_log(log_level, "rset_close(%s) p=%p count=" ZINT_FORMAT, rs->control->desc, rs, rs->hits_count); } @@ -155,28 +155,28 @@ void rset_close(RSFD rfd) \param term Information about term for it (NULL for none). \param no_children number of child rsets (0 for none) \param children child rsets (NULL for none). - - Creates an rfd. Either allocates a new one, in which case the priv - pointer is null, and will have to be filled in, or picks up one + + Creates an rfd. Either allocates a new one, in which case the priv + pointer is null, and will have to be filled in, or picks up one from the freelist, in which case the priv is already allocated, - and presumably everything that hangs from it as well + and presumably everything that hangs from it as well */ -RSET rset_create_base(const struct rset_control *sel, +RSET rset_create_base(const struct rset_control *sel, NMEM nmem, struct rset_key_control *kcontrol, int scope, TERMID term, int no_children, RSET *children) { RSET rset; assert(nmem); - if (!log_level_initialized) + if (!log_level_initialized) { log_level = yaz_log_module_level("rset"); log_level_initialized = 1; } rset = (RSET) nmem_malloc(nmem, sizeof(*rset)); - yaz_log(log_level, "rs_create(%s) rs=%p (nm=%p)", sel->desc, rset, nmem); - yaz_log(log_level, " ref_id=%s", + yaz_log(log_level, "rs_create(%s) rs=%p (nm=%p)", sel->desc, rset, nmem); + yaz_log(log_level, " ref_id=%s", (term && term->ref_id ? term->ref_id : "null")); rset->nmem = nmem; rset->control = sel; @@ -211,7 +211,7 @@ RSET rset_create_base(const struct rset_control *sel, /** \brief Destructor RSETs \param rs Handle for result set. - + Destroys a result set and all its children. The f_delete method of control is called for the result set. */ @@ -219,7 +219,7 @@ void rset_delete(RSET rs) { (rs->refcount)--; yaz_log(log_level, "rs_delete(%s), rs=%p, refcount=%d", - rs->control->desc, rs, rs->refcount); + rs->control->desc, rs, rs->refcount); if (!rs->refcount) { int i; @@ -236,7 +236,7 @@ void rset_delete(RSET rs) /** \brief Test for last use of RFD \param rfd RFD handle. - + Returns 1 if this RFD is the last reference to it; 0 otherwise. */ int rfd_is_last(RSFD rfd) @@ -249,18 +249,18 @@ int rfd_is_last(RSFD rfd) /** \brief Duplicate an RSET \param rs Handle for result set. - + Duplicates a result set by incrementing the reference count to it. */ RSET rset_dup (RSET rs) { (rs->refcount)++; yaz_log(log_level, "rs_dup(%s), rs=%p, refcount=%d", - rs->control->desc, rs, rs->refcount); + rs->control->desc, rs, rs->refcount); return rs; } -/** +/** \brief Estimates hit count for result set. \param rs Result Set. @@ -381,7 +381,7 @@ int rset_default_read(RSFD rfd, void *buf, TERMID *term) got_scope = rset->scope+1; else got_scope = rset->keycontrol->cmp(buf, rfd->counted_buf); - + #if 0 key_logdump_txt(YLOG_LOG, buf, "rset_default_read"); yaz_log(YLOG_LOG, "rset_scope=%d got_scope=%d", rset->scope, got_scope); @@ -407,7 +407,7 @@ int rset_default_forward(RSFD rfd, void *buf, TERMID *term, assert (rset->control->f_forward != rset_default_forward); return rset->control->f_forward(rfd, buf, term, untilbuf); } - + while ((more = rset_read(rfd, buf, term)) > 0) { if ((rfd->rset->keycontrol->cmp)(untilbuf, buf) < rset->scope) @@ -416,7 +416,7 @@ int rset_default_forward(RSFD rfd, void *buf, TERMID *term, if (log_level) yaz_log(log_level, "rset_default_forward exiting rfd=%p scope=%d m=%d c=%d", rfd, rset->scope, more, rset->scope); - + return more; } diff --git a/rset/rsisamb.c b/rset/rsisamb.c index b860a68..024c9c2 100644 --- a/rset/rsisamb.c +++ b/rset/rsisamb.c @@ -35,27 +35,27 @@ static int r_read(RSFD rfd, void *buf, TERMID *term); static int r_read_filter(RSFD rfd, void *buf, TERMID *term); static int r_write(RSFD rfd, const void *buf); -static const struct rset_control control = +static const struct rset_control control = { "isamb", r_delete, rset_get_one_term, r_open, r_close, - r_forward, + r_forward, r_pos, r_read, r_write, }; -static const struct rset_control control_filter = +static const struct rset_control control_filter = { "isamb", r_delete, rset_get_one_term, r_open, r_close, - r_forward, + r_forward, r_pos, r_read_filter, r_write, @@ -141,7 +141,7 @@ static int r_forward(RSFD rfd, void *buf, TERMID *term, const void *untilbuf) if (rc && term) *term = rfd->rset->term; yaz_log(log_level, "rsisamb_forward"); - return rc; + return rc; } static void r_pos(RSFD rfd, double *current, double *total) diff --git a/rset/rsisamc.c b/rset/rsisamc.c index 39af63a..9e5d426 100644 --- a/rset/rsisamc.c +++ b/rset/rsisamc.c @@ -33,7 +33,7 @@ static int r_read (RSFD rfd, void *buf, TERMID *term); static int r_write (RSFD rfd, const void *buf); static void r_pos (RSFD rfd, double *current, double *total); -static const struct rset_control control = +static const struct rset_control control = { "isamc", r_delete, diff --git a/rset/rsisams.c b/rset/rsisams.c index 7236fc2..1aaefca 100644 --- a/rset/rsisams.c +++ b/rset/rsisams.c @@ -32,7 +32,7 @@ static int r_read (RSFD rfd, void *buf, TERMID *term); static int r_write (RSFD rfd, const void *buf); static void r_pos (RSFD rfd, double *current, double *total); -static const struct rset_control control = +static const struct rset_control control = { "isams", r_delete, diff --git a/rset/rsmultiandor.c b/rset/rsmultiandor.c index fd7ed2b..2ff6e23 100644 --- a/rset/rsmultiandor.c +++ b/rset/rsmultiandor.c @@ -59,7 +59,7 @@ static void r_pos_and(RSFD rfd, double *current, double *total); static void r_pos_or(RSFD rfd, double *current, double *total); static void r_get_terms(RSET ct, TERMID *terms, int maxterms, int *curterm); -static const struct rset_control control_or = +static const struct rset_control control_or = { "multi-or", r_delete, @@ -72,7 +72,7 @@ static const struct rset_control control_or = r_write, }; -static const struct rset_control control_and = +static const struct rset_control control_and = { "multi-and", r_delete, @@ -85,12 +85,12 @@ static const struct rset_control control_and = r_write, }; -/* The heap structure: - * The rset contains a list or rsets we are ORing together +/* The heap structure: + * The rset contains a list or rsets we are ORing together * The rfd contains a heap of heap-items, which contain * a rfd opened to those rsets, and a buffer for one key. - * They also contain a ptr to the rset list in the rset - * itself, for practical reasons. + * They also contain a ptr to the rset list in the rset + * itself, for practical reasons. */ struct heap_item { @@ -139,7 +139,7 @@ static void heap_dump_item( HEAP h, int i, int level) if (i>h->heapnum) return; (void)rset_pos(h->heap[i]->rset,h->heap[i]->fd, &cur, &tot); - yaz_log(log_level," %d %*s i=%p buf=%p %0.1f/%0.1f",i, level, "", + yaz_log(log_level," %d %*s i=%p buf=%p %0.1f/%0.1f",i, level, "", &(h->heap[i]), h->heap[i]->buf, cur,tot ); heap_dump_item(h, 2*i, level+1); heap_dump_item(h, 2*i+1, level+1); @@ -168,7 +168,7 @@ static int heap_empty(HEAP h) return ( 0==h->heapnum ); } -/** \brief deletes the first item in the heap, and balances the rest +/** \brief deletes the first item in the heap, and balances the rest */ static void heap_delete (HEAP h) { @@ -190,8 +190,8 @@ static void heap_delete (HEAP h) } /** \brief puts item into heap. - The heap root element has changed value (to bigger) - Swap downwards until the heap is ordered again + The heap root element has changed value (to bigger) + Swap downwards until the heap is ordered again */ static void heap_balance (HEAP h) { @@ -272,9 +272,9 @@ int compare_ands(const void *x, const void *y) } static RSET rsmulti_andor_create(NMEM nmem, - struct rset_key_control *kcontrol, + struct rset_key_control *kcontrol, int scope, TERMID termid, - int no_rsets, RSET* rsets, + int no_rsets, RSET* rsets, const struct rset_control *ctrl) { RSET rnew = rset_create_base(ctrl, nmem, kcontrol, scope, termid, @@ -329,7 +329,7 @@ static RSFD r_open_andor (RSET ct, int flag, int is_and) assert(p->items); /* all other pointers shouls already be allocated, in right sizes! */ } - else + else { p = (struct rfd_private *) nmem_malloc (ct->nmem,sizeof(*p)); rfd->priv = p; @@ -337,9 +337,9 @@ static RSFD r_open_andor (RSET ct, int flag, int is_and) p->tailbits = 0; if (is_and) p->tailbits = nmem_malloc(ct->nmem, ct->no_children*sizeof(char) ); - else + else p->h = heap_create( ct->nmem, ct->no_children, kctrl); - p->items = (struct heap_item *) + p->items = (struct heap_item *) nmem_malloc(ct->nmem, ct->no_children*sizeof(*p->items)); for (i = 0; ino_children; i++) { @@ -360,7 +360,7 @@ static RSFD r_open_andor (RSET ct, int flag, int is_and) p->tailbits[i] = 0; } qsort(p->items, ct->no_children, sizeof(p->items[0]), compare_ands); - } + } else { /* fill the heap for ORing */ for (i = 0; ino_children; i++){ @@ -390,12 +390,12 @@ static void r_close (RSFD rfd) if (p->h) heap_destroy (p->h); - for (i = 0; irset->no_children; i++) + for (i = 0; irset->no_children; i++) if (p->items[i].fd) rset_close(p->items[i].fd); } -static int r_forward_or(RSFD rfd, void *buf, +static int r_forward_or(RSFD rfd, void *buf, TERMID *term, const void *untilbuf) { /* while heap head behind untilbuf, forward it and rebalance heap */ struct rfd_private *p = rfd->priv; @@ -407,7 +407,7 @@ static int r_forward_or(RSFD rfd, void *buf, if (rset_forward(p->h->heap[1]->fd,p->h->heap[1]->buf, &p->h->heap[1]->term, untilbuf)) heap_balance(p->h); - else + else { heap_delete(p->h); if (heap_empty(p->h)) @@ -460,7 +460,7 @@ static int r_read_or (RSFD rfd, void *buf, TERMID *term) \param term resulting term \retval 0 EOF \retval 1 item could be read - + Has to return all hits where each item points to the same sysno (scope), in order. Keep an extra key (hitkey) as long as all records do not point to hitkey, forward @@ -477,11 +477,11 @@ static int r_read_and (RSFD rfd, void *buf, TERMID *term) int i; while (1) { - if (p->tailcount) + if (p->tailcount) { /* we are tailing, find lowest tail and return it */ int mintail = -1; int cmp; - + for (i = 0; ino_children; i++) { if (p->tailbits[i]) @@ -500,7 +500,7 @@ static int r_read_and (RSFD rfd, void *buf, TERMID *term) /* store segment if not stored already */ if (!p->segment && segment) p->segment = segment; - + /* skip rest entirely if segments don't match */ if (p->segment && segment && p->segment != segment) p->skip = 1; @@ -508,14 +508,14 @@ static int r_read_and (RSFD rfd, void *buf, TERMID *term) } } /* return the lowest tail */ - memcpy(buf, p->items[mintail].buf, kctrl->key_size); + memcpy(buf, p->items[mintail].buf, kctrl->key_size); if (term) *term = p->items[mintail].term; if (!rset_read(p->items[mintail].fd, p->items[mintail].buf, &p->items[mintail].term)) { p->eof = 1; /* game over, once tails have been returned */ - p->tailbits[mintail] = 0; + p->tailbits[mintail] = 0; (p->tailcount)--; } else @@ -533,33 +533,33 @@ static int r_read_and (RSFD rfd, void *buf, TERMID *term) if (p->tailcount == 0) (p->hits)++; return 1; - } + } /* not tailing, forward until all records match, and set up */ /* as tails. the earlier 'if' will then return the hits */ if (p->eof) return 0; /* nothing more to see */ i = 1; /* assume items[0] is highest up */ - while (i < ct->no_children) + while (i < ct->no_children) { int cmp = (*kctrl->cmp)(p->items[0].buf, p->items[i].buf); if (cmp <= -rfd->rset->scope) { /* [0] was behind, forward it */ - if (!rset_forward(p->items[0].fd, p->items[0].buf, + if (!rset_forward(p->items[0].fd, p->items[0].buf, &p->items[0].term, p->items[i].buf)) { p->eof = 1; /* game over */ return 0; } i = 0; /* start forwarding from scratch */ - } + } else if (cmp>=rfd->rset->scope) { /* [0] was ahead, forward i */ - if (!rset_forward(p->items[i].fd, p->items[i].buf, + if (!rset_forward(p->items[i].fd, p->items[i].buf, &p->items[i].term, p->items[0].buf)) { p->eof = 1; /* game over */ return 0; } - } + } else i++; } /* while i */ @@ -575,9 +575,9 @@ static int r_read_and (RSFD rfd, void *buf, TERMID *term) } -static int r_forward_and(RSFD rfd, void *buf, TERMID *term, +static int r_forward_and(RSFD rfd, void *buf, TERMID *term, const void *untilbuf) -{ +{ struct rfd_private *p = rfd->priv; RSET ct = rfd->rset; const struct rset_key_control *kctrl = ct->keycontrol; @@ -591,7 +591,7 @@ static int r_forward_and(RSFD rfd, void *buf, TERMID *term, if (cmp <= -rfd->rset->scope) { killtail = 1; /* we are moving to a different hit */ - if (!rset_forward(p->items[i].fd, p->items[i].buf, + if (!rset_forward(p->items[i].fd, p->items[i].buf, &p->items[i].term, untilbuf)) { p->eof = 1; /* game over */ @@ -600,7 +600,7 @@ static int r_forward_and(RSFD rfd, void *buf, TERMID *term, } } } - if (killtail) + if (killtail) { for (i = 0; ino_children; i++) p->tailbits[i] = 0; @@ -612,7 +612,7 @@ static int r_forward_and(RSFD rfd, void *buf, TERMID *term, static void r_pos_x(RSFD rfd, double *current, double *total, int and_op) { RSET ct = rfd->rset; - struct rfd_private *mrfd = + struct rfd_private *mrfd = (struct rfd_private *)(rfd->priv); double ratio = and_op ? 0.0 : 1.0; int i; @@ -671,9 +671,9 @@ static void r_get_terms(RSET ct, TERMID *terms, int maxterms, int *curterm) rset_get_one_term(ct, terms, maxterms, curterm); else { - /* Special case: Some multi-ors have all terms pointing to the same + /* Special case: Some multi-ors have all terms pointing to the same term. We do not want to duplicate those. Other multiors (and ands) - have different terms under them. Those we want. + have different terms under them. Those we want. */ int firstterm= *curterm; int i; @@ -683,7 +683,7 @@ static void r_get_terms(RSET ct, TERMID *terms, int maxterms, int *curterm) rset_getterms(ct->children[i], terms, maxterms, curterm); if ( ( *curterm > firstterm+1 ) && ( *curterm <= maxterms ) && - ( terms[(*curterm)-1] == terms[firstterm] ) + ( terms[(*curterm)-1] == terms[firstterm] ) ) (*curterm)--; /* forget the term, seen that before */ } diff --git a/rset/rsnull.c b/rset/rsnull.c index 3731eaa..5d0c5ee 100644 --- a/rset/rsnull.c +++ b/rset/rsnull.c @@ -32,7 +32,7 @@ static void r_pos(RSFD rfd, double *current, double *total); static int r_read(RSFD rfd, void *buf, TERMID *term); static int r_write(RSFD rfd, const void *buf); -static const struct rset_control control = +static const struct rset_control control = { "null", r_delete, diff --git a/rset/rsprox.c b/rset/rsprox.c index 9a9951a..964ef71 100644 --- a/rset/rsprox.c +++ b/rset/rsprox.c @@ -41,7 +41,7 @@ static int r_write(RSFD rfd, const void *buf); static void r_pos(RSFD rfd, double *current, double *total); static void r_get_terms(RSET ct, TERMID *terms, int maxterms, int *curterm); -static const struct rset_control control = +static const struct rset_control control = { "prox", r_delete, @@ -67,7 +67,7 @@ struct rset_prox_rfd { char *more; /* more in each lookahead? */ TERMID *terms; /* lookahead terms */ zint hits; -}; +}; RSET rset_create_prox(NMEM nmem, struct rset_key_control *kcontrol, @@ -113,16 +113,16 @@ static RSFD r_open(RSET ct, int flag) p->more = nmem_malloc(ct->nmem,sizeof(*p->more) * ct->no_children); p->buf = nmem_malloc(ct->nmem,sizeof(*p->buf) * ct->no_children); p->terms = nmem_malloc(ct->nmem,sizeof(*p->terms) * ct->no_children); - for (i = 0; i < ct->no_children; i++) + for (i = 0; i < ct->no_children; i++) { p->buf[i] = nmem_malloc(ct->nmem,ct->keycontrol->key_size); p->terms[i] = 0; } p->rfd = nmem_malloc(ct->nmem,sizeof(*p->rfd) * ct->no_children); } - yaz_log(YLOG_DEBUG,"rsprox (%s) open [%p] n=%d", + yaz_log(YLOG_DEBUG,"rsprox (%s) open [%p] n=%d", ct->control->desc, rfd, ct->no_children); - + for (i = 0; i < ct->no_children; i++) { p->rfd[i] = rset_open(ct->children[i], RSETF_READ); @@ -136,7 +136,7 @@ static void r_close(RSFD rfd) { RSET ct = rfd->rset; struct rset_prox_rfd *p = (struct rset_prox_rfd *)(rfd->priv); - + int i; for (i = 0; i < ct->no_children; i++) rset_close(p->rfd[i]); @@ -155,17 +155,17 @@ static int r_forward(RSFD rfd, void *buf, TERMID *term, const void *untilbuf) { /* it is enough to forward first one. Other will follow. */ if (p->more[0] && /* was: cmp >=2 */ - ((kctrl->cmp)(untilbuf, p->buf[0]) >= rfd->rset->scope) ) - p->more[0] = rset_forward(p->rfd[0], p->buf[0], + ((kctrl->cmp)(untilbuf, p->buf[0]) >= rfd->rset->scope) ) + p->more[0] = rset_forward(p->rfd[0], p->buf[0], &p->terms[0], untilbuf); } if (info->ordered && info->relation <= 3 && info->exclusion == 0) { - while (p->more[0]) + while (p->more[0]) { for (i = 1; i < ct->no_children; i++) { - if (!p->more[i]) + if (!p->more[i]) { p->more[0] = 0; /* saves us a goto out of while loop. */ break; @@ -189,7 +189,7 @@ static int r_forward(RSFD rfd, void *buf, TERMID *term, const void *untilbuf) continue; else if (info->relation == 1 && diff < info->distance) continue; - + p->more[i-1] = rset_read(p->rfd[i-1], p->buf[i-1], &p->terms[i-1]); break; @@ -215,20 +215,20 @@ static int r_forward(RSFD rfd, void *buf, TERMID *term, const void *untilbuf) } else if (ct->no_children == 2) { - while (p->more[0] && p->more[1]) + while (p->more[0] && p->more[1]) { int cmp = (*kctrl->cmp)(p->buf[0], p->buf[1]); if ( cmp <= - rfd->rset->scope) /* cmp<-1*/ - p->more[0] = rset_forward(p->rfd[0], p->buf[0], + p->more[0] = rset_forward(p->rfd[0], p->buf[0], &p->terms[0],p->buf[1]); else if ( cmp >= rfd->rset->scope ) /* cmp>1 */ - p->more[1] = rset_forward(p->rfd[1], p->buf[1], + p->more[1] = rset_forward(p->rfd[1], p->buf[1], &p->terms[1],p->buf[0]); else { zint seqno[500]; /* FIXME - why 500 ?? */ int n = 0; - + seqno[n++] = (*kctrl->getseq)(p->buf[0]); while ((p->more[0] = rset_read(p->rfd[0], p->buf[0], &p->terms[0]))) @@ -317,7 +317,7 @@ static void r_pos(RSFD rfd, double *current, double *total) struct rset_prox_rfd *p = (struct rset_prox_rfd *)(rfd->priv); int i; double ratio = 0.0; - + for (i = 0; i < ct->no_children; i++) { double cur, tot; @@ -334,7 +334,7 @@ static void r_pos(RSFD rfd, double *current, double *total) *total = *current/ratio; else *total = 0.0; - + yaz_log(YLOG_DEBUG, "prox_pos: [%d] %0.1f/%0.1f= %0.4f ", i, *current, *total, ratio); } diff --git a/rset/rstemp.c b/rset/rstemp.c index f92eaa4..c02121b 100644 --- a/rset/rstemp.c +++ b/rset/rstemp.c @@ -45,7 +45,7 @@ static void r_pos(RSFD rfd, double *current, double *total); static void r_flush(RSFD rfd, int mk); static void r_reread(RSFD rfd); -static const struct rset_control control = +static const struct rset_control control = { "temp", r_delete, @@ -53,7 +53,7 @@ static const struct rset_control control = r_open, r_close, 0, /* no forward */ - r_pos, + r_pos, r_read, r_write, }; @@ -106,7 +106,7 @@ RSET rset_create_temp(NMEM nmem, struct rset_key_control *kcontrol, info->temp_path = NULL; else info->temp_path = nmem_strdup(rnew->nmem, temp_path); - rnew->priv = info; + rnew->priv = info; return rnew; } /* rstemp_create */ @@ -146,7 +146,7 @@ static RSFD r_open(RSET ct, int flag) prfd = (struct rfd_private *) nmem_malloc(ct->nmem, sizeof(*prfd)); rfd->priv = (void *)prfd; prfd->buf = nmem_malloc(ct->nmem,ct->keycontrol->key_size); - } + } else prfd= rfd->priv; r_flush(rfd, 0); @@ -203,7 +203,7 @@ static void r_flush(RSFD rfd, int mk) { size_t count; int r; - + if (lseek(info->fd, info->pos_buf, SEEK_SET) == -1) { yaz_log(YLOG_FATAL|YLOG_ERRNO, "rstemp: lseek (1) %s", info->fname); @@ -246,7 +246,7 @@ static void r_close(RSFD rfd) */ static void r_reread(RSFD rfd) { - struct rfd_private *mrfd = (struct rfd_private*) rfd->priv; + struct rfd_private *mrfd = (struct rfd_private*) rfd->priv; struct rset_private *info = (struct rset_private *)rfd->rset->priv; if (info->fname) @@ -283,7 +283,7 @@ static void r_reread(RSFD rfd) static int r_read(RSFD rfd, void *buf, TERMID *term) { - struct rfd_private *mrfd = (struct rfd_private*) rfd->priv; + struct rfd_private *mrfd = (struct rfd_private*) rfd->priv; struct rset_private *info = (struct rset_private *)rfd->rset->priv; size_t nc = mrfd->pos_cur + rfd->rset->keycontrol->key_size; @@ -299,7 +299,7 @@ static int r_read(RSFD rfd, void *buf, TERMID *term) memcpy(buf, info->buf_mem + (mrfd->pos_cur - info->pos_buf), rfd->rset->keycontrol->key_size); if (term) - *term = rfd->rset->term; + *term = rfd->rset->term; /* FIXME - should we store and return terms ?? */ mrfd->pos_cur = nc; mrfd->cur++; @@ -308,7 +308,7 @@ static int r_read(RSFD rfd, void *buf, TERMID *term) static int r_write(RSFD rfd, const void *buf) { - struct rfd_private *mrfd = (struct rfd_private*) rfd->priv; + struct rfd_private *mrfd = (struct rfd_private*) rfd->priv; struct rset_private *info = (struct rset_private *)rfd->rset->priv; size_t nc = mrfd->pos_cur + rfd->rset->keycontrol->key_size; @@ -332,9 +332,9 @@ static int r_write(RSFD rfd, const void *buf) static void r_pos(RSFD rfd, double *current, double *total) { - struct rfd_private *mrfd = (struct rfd_private*) rfd->priv; + struct rfd_private *mrfd = (struct rfd_private*) rfd->priv; struct rset_private *info = (struct rset_private *)rfd->rset->priv; - + *current = (double) mrfd->cur; *total = (double) info->hits; } diff --git a/test/api/test_create_databases.c b/test/api/test_create_databases.c index 77f76a9..9e7e187 100644 --- a/test/api/test_create_databases.c +++ b/test/api/test_create_databases.c @@ -37,7 +37,7 @@ static void tst(int argc, char **argv) zh = zebra_open(zs, 0); YAZ_CHECK(zh); - + YAZ_CHECK(zebra_begin_trans (zh, 1) == ZEBRA_OK); for (i = 0; ititle %d\n", i); zebra_add_record (zh, rec_buf, strlen(rec_buf)); diff --git a/test/api/test_icu_indexing.c b/test/api/test_icu_indexing.c index 71f8127..975246f 100644 --- a/test/api/test_icu_indexing.c +++ b/test/api/test_icu_indexing.c @@ -49,7 +49,7 @@ const char *myrec[] = { "\nB" char_aring "d\n" "זיהוי סדר הארועים בסיפור המרד הגדול מאת צביה בן-שלום 提示:直接点击数据库名称,将进入单库检索 Ngày xửa ngày xưa D.W. all wet\n\n" , 0} ; - + static void tst(int argc, char **argv) { #if YAZ_HAVE_ICU @@ -62,7 +62,7 @@ static void tst(int argc, char **argv) /* simple term */ YAZ_CHECK(tl_query(zh, "@attr 1=title notfound", 0)); - + YAZ_CHECK(tl_query(zh, "@attr 1=title computer", 3)); YAZ_CHECK(tl_query(zh, "@attr 5=1 @attr 1=title computer", 3)); @@ -154,7 +154,7 @@ static void tst(int argc, char **argv) YAZ_CHECK(tl_query(zh, "@attr 1=abstract @attr 5=1 ב", 1)); YAZ_CHECK(tl_query(zh, "@attr 1=abstract @attr 5=102 בן", 1)); - + /* phrase search */ YAZ_CHECK(tl_query(zh, "@attr 1=title {my computer}", 2)); YAZ_CHECK(tl_query(zh, "@attr 1=title @attr 6=1 {my computer}", 2)); @@ -169,10 +169,10 @@ static void tst(int argc, char **argv) YAZ_CHECK(tl_query(zh, "@attr 1=title @attr 2=103 {}", 5)); YAZ_CHECK(tl_query(zh, "@attr 1=abstract @attr 2=103 {}", 1)); YAZ_CHECK(tl_query(zh, "@attr 1=abstract @attr 2=103 {does not match}", 1)); - + /* scan */ { /* word search */ - const char *ent[] = { char_ae "rme", "B" char_aring "d", "computer", + const char *ent[] = { char_ae "rme", "B" char_aring "d", "computer", "My", "x", 0 }; YAZ_CHECK(tl_scan(zh, "@attr 1=title 0", 1, 10, 1, 5, 1, ent)); } @@ -186,7 +186,7 @@ static void tst(int argc, char **argv) const char *ent[] = { char_ae "rme", "B" char_aring "d", "My computer" }; YAZ_CHECK(tl_scan(zh, "@attr 1=title @attr 6=2 0", 1, 3, 1, 3, 0, ent)); } - + YAZ_CHECK(tl_close_down(zh, zs)); #endif } diff --git a/test/api/test_insert_fetch.c b/test/api/test_insert_fetch.c index 32c34ee..8d17903 100644 --- a/test/api/test_insert_fetch.c +++ b/test/api/test_insert_fetch.c @@ -29,7 +29,7 @@ const char *myrec[] = { " My title\n" "\n", 0}; - + #define NUMBER_TO_FETCH_MAX 1000 static void tst(int argc, char **argv) @@ -65,12 +65,12 @@ static void tst(int argc, char **argv) ZebraRetrievalRecord retrievalRecord[NUMBER_TO_FETCH_MAX]; char setname[20]; int j; - ODR odr_input = odr_createmem(ODR_DECODE); - ODR odr_output = odr_createmem(ODR_DECODE); + ODR odr_input = odr_createmem(ODR_DECODE); + ODR odr_output = odr_createmem(ODR_DECODE); YAZ_PQF_Parser parser = yaz_pqf_create(); Z_RPNQuery *query = yaz_pqf_parse(parser, odr_input, "@attr 1=4 my"); zint hits; - + sprintf(setname, "s%d", i+1); ret = zebra_search_RPN(zh, odr_input, query, setname, &hits); if (ret != ZEBRA_OK) @@ -81,7 +81,7 @@ static void tst(int argc, char **argv) } if (hits != number_to_be_inserted) { - yaz_log(YLOG_WARN, "Unexpected hit count " ZINT_FORMAT + yaz_log(YLOG_WARN, "Unexpected hit count " ZINT_FORMAT "(should be %d)", hits, number_to_be_inserted); exit(1); } @@ -105,7 +105,7 @@ static void tst(int argc, char **argv) code); exit(1); } - + for (j = 0; j < number_to_fetch; j++) { if (!retrievalRecord[j].buf) diff --git a/test/api/test_private_attset.c b/test/api/test_private_attset.c index 35b7e0a..ecd2d84 100644 --- a/test/api/test_private_attset.c +++ b/test/api/test_private_attset.c @@ -44,18 +44,18 @@ static void tst(int argc, char **argv) YAZ_CHECK(tl_query(zh, "@attr 1=extra_title my", 1)); // numeric attributes with Bib-1 should produce an error - YAZ_CHECK(tl_query_x(zh, + YAZ_CHECK(tl_query_x(zh, "@attr 1=4 my", 0, 121)); - YAZ_CHECK(tl_query_x(zh, + YAZ_CHECK(tl_query_x(zh, "@attr 1=7 my", 0, 121)); // private OID with incorrect use attribute - YAZ_CHECK(tl_query_x(zh, + YAZ_CHECK(tl_query_x(zh, "@attr 1.2.840.10003.3.1000.1000.1 1=4 my", 0, 114)); // private OID with OK use attribute - YAZ_CHECK(tl_query(zh, + YAZ_CHECK(tl_query(zh, "@attr 1.2.840.10003.3.1000.1000.1 1=7 my", 1)); - YAZ_CHECK(tl_query(zh, + YAZ_CHECK(tl_query(zh, "@attr 1.2.840.10003.3.1000.1000.1 1=8 my", 1)); YAZ_CHECK(tl_close_down(zh, zs)); diff --git a/test/api/test_rank.c b/test/api/test_rank.c index 8bf17f4..331937a 100644 --- a/test/api/test_rank.c +++ b/test/api/test_rank.c @@ -49,7 +49,7 @@ const char *recs[] = { " but all have the foo bar \n" " \n" "\n", - + 0 }; static void tst(int argc, char **argv) @@ -58,13 +58,13 @@ static void tst(int argc, char **argv) ZebraHandle zh = zebra_open(zs, 0); YAZ_CHECK(tl_init_data(zh, recs)); - + YAZ_CHECK(tl_ranking_query(zh, "@attr 1=4 @attr 2=102 the", 3, "first title", 936 )); - + YAZ_CHECK(tl_ranking_query(zh, "@attr 1=62 @attr 2=102 foo", 3, "second title", 850 )); - + YAZ_CHECK(tl_close_down(zh, zs)); } diff --git a/test/api/test_resources.c b/test/api/test_resources.c index bf0eb88..9c69658 100644 --- a/test/api/test_resources.c +++ b/test/api/test_resources.c @@ -42,10 +42,10 @@ static void tst_res(void) temp_res = res_open(0, 0); /* completely empty */ YAZ_CHECK(temp_res); - + zs = zebra_start_res(0, default_res, temp_res); YAZ_CHECK(zs); - + zh = zebra_open(zs, 0); YAZ_CHECK(zh); @@ -65,10 +65,10 @@ static void tst_res(void) /* we should find the name1 from temp_res */ val = zebra_get_resource(zh, "name1", 0); YAZ_CHECK(val && !strcmp(val, "value2")); - + val = zebra_get_resource(zh, "name4", 0); YAZ_CHECK(val && !strcmp(val, "value4")); - + res_clear(temp_res); } zebra_close(zh); @@ -94,9 +94,9 @@ static void tst_no_config(void) YAZ_CHECK_EQ(zebra_select_database(zh, "Default"), ZEBRA_OK); YAZ_CHECK_EQ(zebra_init(zh), ZEBRA_OK); - + zebra_set_resource(zh, "profilePath", "${srcdir:-.}/../../tab"); - + YAZ_CHECK_EQ(zebra_update_record(zh /* handle */, action_insert, "grs.sgml" /* record type */, diff --git a/test/api/test_result_sets.c b/test/api/test_result_sets.c index 7f35f47..a08718c 100644 --- a/test/api/test_result_sets.c +++ b/test/api/test_result_sets.c @@ -43,10 +43,10 @@ static void tst(int argc, char **argv) char setname[20]; char *setnamep = setname; int status; - ODR odr_input = odr_createmem (ODR_DECODE); - ODR odr_output = odr_createmem (ODR_ENCODE); + ODR odr_input = odr_createmem (ODR_DECODE); + ODR odr_output = odr_createmem (ODR_ENCODE); YAZ_PQF_Parser parser = yaz_pqf_create(); - Z_RPNQuery *query = yaz_pqf_parse(parser, odr_input, + Z_RPNQuery *query = yaz_pqf_parse(parser, odr_input, "@attr 1=4 my"); zint hits; if (zebra_begin_trans (zh, 1) != ZEBRA_OK) @@ -59,7 +59,7 @@ static void tst(int argc, char **argv) fprintf(stderr, "zebra_begin_trans failed\n"); exit(1); } - + sprintf(setname, "s%d", i+1); zebra_search_RPN (zh, odr_input, query, setname, &hits); diff --git a/test/api/test_safari.c b/test/api/test_safari.c index 2834b2f..d18cee2 100644 --- a/test/api/test_safari.c +++ b/test/api/test_safari.c @@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #endif #include "testlib.h" -const char *myrec[] = +const char *myrec[] = { "1234\n" /* ID first record */ /* chunk owner seq idx term */ @@ -83,7 +83,7 @@ static void tst(int argc, char **argv) zint ids[3]; zint limits[3]; ZebraService zs = tl_start_up("test_safari.cfg", argc, argv); - + ZebraHandle zh = zebra_open(zs, 0); YAZ_CHECK(tl_init_data(zh, myrec)); @@ -115,7 +115,7 @@ static void tst(int argc, char **argv) myrec[2]), ZEBRA_OK); YAZ_CHECK_EQ(tl_fetch_compare(zh, 3, "R", yaz_oid_recsyn_sutrs, myrec[4]), ZEBRA_OK); - YAZ_CHECK_EQ(tl_fetch_compare(zh, 1, "zebra::facet::any:0", + YAZ_CHECK_EQ(tl_fetch_compare(zh, 1, "zebra::facet::any:0", yaz_oid_recsyn_xml, "\n" " \n" @@ -126,7 +126,7 @@ static void tst(int argc, char **argv) " old\n" " \n" "\n"), ZEBRA_OK); - YAZ_CHECK_EQ(tl_fetch_compare(zh, 1, "zebra::facet::any:0:2", + YAZ_CHECK_EQ(tl_fetch_compare(zh, 1, "zebra::facet::any:0:2", yaz_oid_recsyn_xml, "\n" " \n" @@ -136,7 +136,7 @@ static void tst(int argc, char **argv) "\n"), ZEBRA_OK); - YAZ_CHECK_EQ(tl_fetch_compare(zh, 1, "zebra::facet::ti:s", + YAZ_CHECK_EQ(tl_fetch_compare(zh, 1, "zebra::facet::ti:s", yaz_oid_recsyn_xml, "\n" " \n" @@ -182,7 +182,7 @@ static void tst(int argc, char **argv) YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title @and a b", 1)); YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title @and a c", 1)); - + YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title @and c d", 1)); YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title @and b f", 1)); YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title @and f g", 0)); diff --git a/test/api/test_scan.c b/test/api/test_scan.c index d1e3f8c..dccc487 100644 --- a/test/api/test_scan.c +++ b/test/api/test_scan.c @@ -28,7 +28,7 @@ const char *myrec[] = { "\nc d\n\n", "\ne f\n\n" , 0} ; - + static void tst(int argc, char **argv) { ZebraService zs = tl_start_up(0, argc, argv); diff --git a/test/api/test_search.c b/test/api/test_search.c index 2b1119f..409713e 100644 --- a/test/api/test_search.c +++ b/test/api/test_search.c @@ -77,7 +77,7 @@ const char *myrec[] = { "" , 0} ; - + static void tst(int argc, char **argv) { ZebraService zs = tl_start_up(0, argc, argv); @@ -94,7 +94,7 @@ static void tst(int argc, char **argv) "term 3 3: my\n" "term 3 3: title\n" "term 2 2: x\n"), ZEBRA_OK); - + YAZ_CHECK_EQ(tl_fetch_compare(zh, 1, "zebra::facet::title:s", yaz_oid_recsyn_sutrs, "facet s title\n" @@ -112,7 +112,7 @@ static void tst(int argc, char **argv) "term 2 2: my\n" "term 2 2: title\n" "term 2 2: x\n"), ZEBRA_OK); - + /* trunc left */ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=2 titl", 0)); YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=2 x", 2)); @@ -183,7 +183,7 @@ static void tst(int argc, char **argv) /* = */ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=3 my", 3)); YAZ_CHECK( - tl_query(zh, + tl_query(zh, "@attr 1=4 @attr 2=3 " "1234567890" "1234567890""1234567890""1234567890""1234567890" "1234567890" "1234567890""1234567890""1234567890""1234567890" @@ -199,16 +199,16 @@ static void tst(int argc, char **argv) "1234567890" "1234567890""1234567890""1234567890""1234567890" "1234567890" "1" , 1)); - + YAZ_CHECK( - tl_query_x(zh, + tl_query_x(zh, "@attr 1=4 @attr 2=3 " "1234567890" "1234567890""1234567890""1234567890""1234567890" "1234567890" "1234567890""1234567890""1234567890""1234567890" "1234567890" "1234567890""1234567890""1234567890""1234567890" "1234567890" "1234567890""1234567890""1234567890""1234567890" "1234567890" "1234567890""1234567890""1234567890""1234567890" - + "1234567890" "1234567890""1234567890""1234567890""1234567890" "1234567890" "1234567890""1234567890""1234567890""1234567890" "1234567890" "1234567890""1234567890""1234567890""1234567890" @@ -216,7 +216,7 @@ static void tst(int argc, char **argv) "1234567890" "1234567890""1234567890""1234567890""1234567890" "1234567890" "12" , 0, 11)); - + /* string relations, >= */ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=4 x", 2)); @@ -234,31 +234,31 @@ static void tst(int argc, char **argv) YAZ_CHECK(tl_query_x(zh, "@attr 1=1 @attr 2=103 {x my}", 0, 114)); /* and searches */ - YAZ_CHECK(tl_query(zh, "@and @attr 1=4 notfound @attr 1=4 x", 0)); - YAZ_CHECK(tl_query(zh, "@and @attr 1=4 x @attr 1=4 notfound", 0)); - YAZ_CHECK(tl_query(zh, "@and @attr 1=4 notfound @attr 1=4 notfound", 0)); - YAZ_CHECK(tl_query(zh, "@and @attr 1=4 x @attr 1=4 x", 2)); - YAZ_CHECK(tl_query(zh, "@and @attr 1=4 x @attr 1=4 my", 2)); - YAZ_CHECK(tl_query(zh, "@and @attr 1=4 my @attr 1=4 x", 2)); - YAZ_CHECK(tl_query(zh, "@and @attr 1=4 my @attr 1=4 my", 3)); + YAZ_CHECK(tl_query(zh, "@and @attr 1=4 notfound @attr 1=4 x", 0)); + YAZ_CHECK(tl_query(zh, "@and @attr 1=4 x @attr 1=4 notfound", 0)); + YAZ_CHECK(tl_query(zh, "@and @attr 1=4 notfound @attr 1=4 notfound", 0)); + YAZ_CHECK(tl_query(zh, "@and @attr 1=4 x @attr 1=4 x", 2)); + YAZ_CHECK(tl_query(zh, "@and @attr 1=4 x @attr 1=4 my", 2)); + YAZ_CHECK(tl_query(zh, "@and @attr 1=4 my @attr 1=4 x", 2)); + YAZ_CHECK(tl_query(zh, "@and @attr 1=4 my @attr 1=4 my", 3)); /* or searches */ - YAZ_CHECK(tl_query(zh, "@or @attr 1=4 notfound @attr 1=4 x", 2)); - YAZ_CHECK(tl_query(zh, "@or @attr 1=4 x @attr 1=4 notfound", 2)); - YAZ_CHECK(tl_query(zh, "@or @attr 1=4 notfound @attr 1=4 notfound", 0)); - YAZ_CHECK(tl_query(zh, "@or @attr 1=4 x @attr 1=4 x", 2)); - YAZ_CHECK(tl_query(zh, "@or @attr 1=4 x @attr 1=4 my", 3)); - YAZ_CHECK(tl_query(zh, "@or @attr 1=4 my @attr 1=4 x", 3)); - YAZ_CHECK(tl_query(zh, "@or @attr 1=4 my @attr 1=4 my", 3)); + YAZ_CHECK(tl_query(zh, "@or @attr 1=4 notfound @attr 1=4 x", 2)); + YAZ_CHECK(tl_query(zh, "@or @attr 1=4 x @attr 1=4 notfound", 2)); + YAZ_CHECK(tl_query(zh, "@or @attr 1=4 notfound @attr 1=4 notfound", 0)); + YAZ_CHECK(tl_query(zh, "@or @attr 1=4 x @attr 1=4 x", 2)); + YAZ_CHECK(tl_query(zh, "@or @attr 1=4 x @attr 1=4 my", 3)); + YAZ_CHECK(tl_query(zh, "@or @attr 1=4 my @attr 1=4 x", 3)); + YAZ_CHECK(tl_query(zh, "@or @attr 1=4 my @attr 1=4 my", 3)); /* not searches */ /* bug 619 */ - YAZ_CHECK(tl_query(zh, "@not @attr 1=4 notfound @attr 1=4 x", 0)); + YAZ_CHECK(tl_query(zh, "@not @attr 1=4 notfound @attr 1=4 x", 0)); YAZ_CHECK(tl_query(zh, "@not @attr 1=4 x @attr 1=4 x", 0)); YAZ_CHECK(tl_query(zh, "@not @attr 1=4 my @attr 1=4 x", 1)); YAZ_CHECK(tl_query(zh, "@not @attr 1=4 my @attr 1=4 notfound", 3)); YAZ_CHECK(tl_query(zh, "@not @attr 1=4 notfound @attr 1=4 notfound", 0)); - + /* phrase searches */ YAZ_CHECK(tl_query(zh, "@attr 1=4 my", 3)); YAZ_CHECK(tl_query(zh, "@attr 1=4 {my x}", 1)); @@ -295,7 +295,7 @@ static void tst(int argc, char **argv) /* exl=1 distance=2 order=0 relation=3 (=), known, unit=word */ YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 1 2 1 3 k 2 my x", 1)); - + /* exl=0 distance=2 order=1 relation=2 (<=), known, unit=word */ YAZ_CHECK(tl_query(zh, "@attr 1=1016 @prox 0 2 1 2 k 2 a y", 1)); @@ -374,7 +374,7 @@ static void tst(int argc, char **argv) /* position , or-list */ YAZ_CHECK(tl_query(zh, "@attr 4=105 @attr 3=1 {title my}", 3)); YAZ_CHECK(tl_query(zh, "@attr 4=105 @attr 3=1 {title x}", 0)); - + /* position, and-list */ YAZ_CHECK(tl_query(zh, "@attr 4=6 @attr 3=1 {title my}", 0)); YAZ_CHECK(tl_query(zh, "@attr 4=6 @attr 3=1 {title x}", 0)); @@ -429,7 +429,7 @@ static void tst(int argc, char **argv) YAZ_CHECK(tl_query(zh, "@attr 1=30 @attr 4=5 @attr 2=4 {2107-09-19 00:00:00}", 1)); /* > */ YAZ_CHECK(tl_query(zh, "@attr 1=30 @attr 4=5 @attr 2=5 {2107-09-19 00:00:00}", 0)); - + YAZ_CHECK(tl_close_down(zh, zs)); } diff --git a/test/api/test_sort3.c b/test/api/test_sort3.c index 88e8062..0ced9c2 100644 --- a/test/api/test_sort3.c +++ b/test/api/test_sort3.c @@ -17,7 +17,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/** \file +/** \file \brief sort using various sortindex types */ @@ -35,7 +35,7 @@ const char *myrec[] = { "\n", /* 3 */ - "\n" + "\n" " My x title\n" " B\n" "\n", @@ -46,7 +46,7 @@ const char *myrec[] = { " A\n" "\n" , 0} ; - + static void tst_sortindex(int argc, char **argv, const char *type) { zint ids[5]; @@ -58,7 +58,7 @@ static void tst_sortindex(int argc, char **argv, const char *type) res_set(res, "sortindex", type); zh = zebra_open(zs, res); - + YAZ_CHECK(tl_init_data(zh, myrec)); if (strcmp(type, "m")) diff --git a/test/api/test_sort_set.c b/test/api/test_sort_set.c index 525a794..60fa3b9 100644 --- a/test/api/test_sort_set.c +++ b/test/api/test_sort_set.c @@ -37,8 +37,8 @@ static void tst(int argc, char **argv) int status; ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open (zs, 0); - ODR odr_input = odr_createmem (ODR_DECODE); - ODR odr_output = odr_createmem (ODR_ENCODE); + ODR odr_input = odr_createmem (ODR_DECODE); + ODR odr_output = odr_createmem (ODR_ENCODE); YAZ_PQF_Parser parser = yaz_pqf_create(); Z_RPNQuery *query = yaz_pqf_parse(parser, odr_input, "@attr 1=4 my"); Z_SortKeySpecList *spec = yaz_sort_spec (odr_output, "1=4 My title\n" "\n", 0}; - + static void tst(int argc, char **argv) { zint hits; ZEBRA_RES res; - const char * zebra_xml_sysno + const char * zebra_xml_sysno = "\n"; - const char * zebra_xml_meta + const char * zebra_xml_meta = "\n"; const char * zebra_xml_index_title_p @@ -58,41 +58,41 @@ static void tst(int argc, char **argv) res = zebra_search_PQF(zh, "@attr 1=4 my", "rsetname", &hits); YAZ_CHECK_EQ(res, ZEBRA_OK); YAZ_CHECK_EQ(hits, 1); - + YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::data", yaz_oid_recsyn_xml, "mismatch"), ZEBRA_FAIL); - + YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::data", yaz_oid_recsyn_sutrs, myrec[0]), ZEBRA_OK); - + YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::data", yaz_oid_recsyn_xml, myrec[0]), ZEBRA_OK); - - YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::meta::sysno", + + YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::meta::sysno", yaz_oid_recsyn_sutrs, "2"), ZEBRA_OK); - - YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::meta::sysno", + + YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::meta::sysno", yaz_oid_recsyn_xml, zebra_xml_sysno), ZEBRA_OK); - + YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::meta", yaz_oid_recsyn_xml, zebra_xml_meta), ZEBRA_OK); - - YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::index::title:p", + + YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::index::title:p", yaz_oid_recsyn_xml, zebra_xml_index_title_p), ZEBRA_OK); - - YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::index::title:s", + + YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::index::title:s", yaz_oid_recsyn_xml, zebra_xml_index_title_s), ZEBRA_OK); - - YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::nonexistent", + + YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::nonexistent", yaz_oid_recsyn_xml, ""), ZEBRA_OK); - - YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::index::nonexistent", + + YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::index::nonexistent", yaz_oid_recsyn_xml, ""), ZEBRA_OK); - + YAZ_CHECK(tl_close_down(zh, zs)); } diff --git a/test/api/test_start_stop.c b/test/api/test_start_stop.c index 2e46030..0f0488d 100644 --- a/test/api/test_start_stop.c +++ b/test/api/test_start_stop.c @@ -29,7 +29,7 @@ static void tst(int argc, char **argv) { ZebraService zs = tl_start_up(0, argc, argv); - ZebraHandle zh = 0; + ZebraHandle zh = 0; YAZ_CHECK(zs); if (zs) @@ -37,7 +37,7 @@ static void tst(int argc, char **argv) zh = zebra_open(zs, 0); YAZ_CHECK(zh); } - + YAZ_CHECK(tl_close_down(zh, zs)); } } diff --git a/test/api/test_trunc.c b/test/api/test_trunc.c index 002d5a3..ec1283c 100644 --- a/test/api/test_trunc.c +++ b/test/api/test_trunc.c @@ -31,7 +31,7 @@ static void tst(int argc, char **argv) ZebraHandle zh = zebra_open(zs, 0); srand(17); - + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); zebra_init(zh); zebra_close(zh); @@ -44,7 +44,7 @@ static void tst(int argc, char **argv) YAZ_CHECK(zh); YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); - + YAZ_CHECK(zebra_begin_trans (zh, 1) == ZEBRA_OK); for (l = 0; l<100; l++) diff --git a/test/api/test_update_record.c b/test/api/test_update_record.c index 7aefb78..90cce8e 100644 --- a/test/api/test_update_record.c +++ b/test/api/test_update_record.c @@ -38,7 +38,7 @@ static void create_search_drop(ZebraHandle zh) 0 /* fname */, rec, strlen(rec)) == ZEBRA_OK); /* insert really */ - + YAZ_CHECK(zebra_update_record( zh, action_update, 0 /* record type */, @@ -47,7 +47,7 @@ static void create_search_drop(ZebraHandle zh) 0 /* fname */, rec, strlen(rec)) == ZEBRA_OK); /* replace really */ - + YAZ_CHECK(tl_query(zh, "@attr 1=4 some", 1)); zebra_drop_database(zh, "Default"); diff --git a/test/api/test_zebra_fork.c b/test/api/test_zebra_fork.c index 281ff1d..516afb4 100644 --- a/test/api/test_zebra_fork.c +++ b/test/api/test_zebra_fork.c @@ -61,11 +61,11 @@ static void search_process(ZebraService zs, int iter) for (i = 0; i= hits_max); if (hits < hits_max) printf("i=%d hits=%lld hits_max=%lld\n", i, hits, hits_max); @@ -82,7 +82,7 @@ static pid_t fork_service(ZebraService zs, int iter, YAZ_CHECK(pid != -1); if (pid) return pid; - + (*f)(zs, iter); YAZ_CHECK_TERM; } @@ -91,7 +91,7 @@ static void tst(int argc, char **argv) { ZebraService zs; ZebraHandle zh; - + mkdir("register", 0775); mkdir("shadow", 0775); diff --git a/test/api/testclient.c b/test/api/testclient.c index 377f838..4175d82 100644 --- a/test/api/testclient.c +++ b/test/api/testclient.c @@ -98,7 +98,7 @@ int main(int argc, char **argv) exit (3); } z = ZOOM_connection_new (target, 0); - + if ((error = ZOOM_connection_error(z, &errmsg, &addinfo))) { printf ("Error: %s (%d) %s\n", errmsg, error, addinfo); @@ -131,7 +131,7 @@ int main(int argc, char **argv) ZOOM_record_get( ZOOM_resultset_record(r, pos + retrieve_offset), "render", &len); - + if (rec) fwrite (rec, 1, len, stdout); } diff --git a/test/api/testlib.c b/test/api/testlib.c index 82aa14d..55a1c06 100644 --- a/test/api/testlib.c +++ b/test/api/testlib.c @@ -41,11 +41,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA int log_level = YLOG_LOG; -/* +/* * tl_start_up : do common start things, and a zebra_start * - build the name of logfile from argv[0], and open it * if no argv passed, do not open a log - * - read zebra.cfg from env var srcdir if it exists; otherwise current dir + * - read zebra.cfg from env var srcdir if it exists; otherwise current dir * default to zebra.cfg, if no name is given */ ZebraService tl_start_up(char *cfgname, int argc, char **argv) @@ -110,7 +110,7 @@ int tl_init_data(ZebraHandle zh, const char **recs) yaz_log(log_level, "going to call init"); res = zebra_init(zh); - if (res == ZEBRA_FAIL) + if (res == ZEBRA_FAIL) { yaz_log(log_level, "init_data: zebra_init failed with %d", res); printf("init_data failed with %d\n", res); @@ -192,16 +192,16 @@ int tl_query_x(ZebraHandle zh, const char *query, zint exphits, int experror) if (rc == ZEBRA_FAIL) { int code = zebra_errCode(zh); yaz_log(log_level, "search returned %d. Code %d", rc, code); - - printf("Error: search returned %d. Code %d\n%s\n", rc, + + printf("Error: search returned %d. Code %d\n%s\n", rc, code, query); return 0; } if (exphits != -1 && hits != exphits) { - yaz_log(log_level, "search returned " ZINT_FORMAT + yaz_log(log_level, "search returned " ZINT_FORMAT " hits instead of " ZINT_FORMAT, hits, exphits); - printf("Error: search returned " ZINT_FORMAT + printf("Error: search returned " ZINT_FORMAT " hits instead of " ZINT_FORMAT "\n%s\n", hits, exphits, query); return 0; @@ -230,7 +230,7 @@ int tl_scan(ZebraHandle zh, const char *query, yaz_log(log_level, "======================================"); yaz_log(log_level, "scan: pos=%d num=%d %s", pos, num, query); - res = zebra_scan_PQF(zh, odr, query, &pos, &num, &entries, &partial, + res = zebra_scan_PQF(zh, odr, query, &pos, &num, &entries, &partial, 0 /* setname */); if (partial == -123) @@ -299,11 +299,11 @@ int tl_scan(ZebraHandle zh, const char *query, return ret; } -/** - * makes a query, checks number of hits, and for the first hit, that +/** + * makes a query, checks number of hits, and for the first hit, that * it contains the given string, and that it gets the right score */ -int tl_ranking_query(ZebraHandle zh, char *query, +int tl_ranking_query(ZebraHandle zh, char *query, int exphits, char *firstrec, int firstscore) { ZebraRetrievalRecord retrievalRecord[10]; @@ -312,14 +312,14 @@ int tl_ranking_query(ZebraHandle zh, char *query, int rc; int i; int ret = 1; - + if (!tl_query(zh, query, exphits)) return 0; for (i = 0; i<10; i++) retrievalRecord[i].position = i+1; - odr_output = odr_createmem(ODR_ENCODE); + odr_output = odr_createmem(ODR_ENCODE); rc = zebra_records_retrieve(zh, odr_output, setname, 0, yaz_oid_recsyn_xml, exphits, retrievalRecord); if (rc != ZEBRA_OK) @@ -348,16 +348,16 @@ int tl_meta_query(ZebraHandle zh, char *query, int exphits, const char *setname= "rsetname"; zint *positions = 0; int i, ret = 1; - + if (!tl_query(zh, query, exphits)) return 0; - + positions = (zint *) xmalloc(1 + (exphits * sizeof(zint))); for (i = 0; imem); - res = zebra_records_retrieve(zh, odr, "rsetname", comp, format, 1, + res = zebra_records_retrieve(zh, odr, "rsetname", comp, format, 1, retrievalRecord); if (res != ZEBRA_OK) { diff --git a/test/api/testlib.h b/test/api/testlib.h index dcc952b..5bd8dc4 100644 --- a/test/api/testlib.h +++ b/test/api/testlib.h @@ -27,50 +27,50 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -/** +/** * tl_start_up : Does all the usual start functions * - nmem_init * - build the name of logfile from argv[0], and open it * if no argv passed, do not open a log - * - read zebra.cfg from env var srcdir if it exists; otherwise current dir + * - read zebra.cfg from env var srcdir if it exists; otherwise current dir * default to zebra.cfg, if no name is given */ ZebraService tl_start_up(char *cfgname, int argc, char **argv); /** * get_srcdir : returns the source dir. Most often ".", but when - * making distcheck, some other dir + * making distcheck, some other dir */ const char *tl_get_srcdir(void); -/** - * start_log: open a log file +/** + * start_log: open a log file */ /* FIXME - parse command line arguments to set log levels etc */ void tl_start_log(int argc, char **argv); -/** - * tl_zebra_start - do a zebra_start with a decent config name +/** + * tl_zebra_start - do a zebra_start with a decent config name * Takes care of checking the environment for srcdir (as needed by distcheck) - * and uses that if need be. + * and uses that if need be. * The name defaults to zebra.cfg, if null or emtpy */ ZebraService tl_zebra_start(const char *cfgname); -/** +/** * close_down closes it all down * Does a zebra_close on zh, if not null. - * Does a zebra_stop on zs, if not null + * Does a zebra_stop on zs, if not null * Writes a log message, OK if retcode is zero, error if not * closes down nmem and xmalloc * returns the retcode, for use in return or exit in main() */ int tl_close_down(ZebraHandle zh, ZebraService zs - ) ZEBRA_GCC_ATTR((warn_unused_result)); + ) ZEBRA_GCC_ATTR((warn_unused_result)); /** inits the database and inserts test data */ int tl_init_data(ZebraHandle zh, const char **recs - ) ZEBRA_GCC_ATTR((warn_unused_result)); + ) ZEBRA_GCC_ATTR((warn_unused_result)); /** * tl_query does a simple query, and checks that the number of hits matches @@ -85,9 +85,9 @@ int tl_query(ZebraHandle zh, const char *query, zint exphits int tl_query_x(ZebraHandle zh, const char *query, zint exphits, int experror ) ZEBRA_GCC_ATTR((warn_unused_result)); - + /** - * tl_scan is a utility for scan testing + * tl_scan is a utility for scan testing */ int tl_scan(ZebraHandle zh, const char *query, int pos, int num, /* input params */ @@ -98,17 +98,17 @@ int tl_scan(ZebraHandle zh, const char *query, int tl_sort(ZebraHandle zh, const char *query, zint hits, zint *exp ) ZEBRA_GCC_ATTR((warn_unused_result)); -/** - * ranking_query makes a query, checks number of hits, and for - * the first hit, that it contains the given string, and that it +/** + * ranking_query makes a query, checks number of hits, and for + * the first hit, that it contains the given string, and that it * gets the right score */ -int tl_ranking_query(ZebraHandle zh, char *query, +int tl_ranking_query(ZebraHandle zh, char *query, int exphits, char *firstrec, int firstscore ) ZEBRA_GCC_ATTR((warn_unused_result)); -/** - * meta_query makes a query, checks number of hits, and for +/** + * meta_query makes a query, checks number of hits, and for * checks that the all records in result set has the proper identifiers (ids) */ int tl_meta_query(ZebraHandle zh, char *query, int exphits, @@ -116,7 +116,7 @@ int tl_meta_query(ZebraHandle zh, char *query, int exphits, ) ZEBRA_GCC_ATTR((warn_unused_result)); /** - * if filter given by name does not exist, exit nicely but warn in log + * if filter given by name does not exist, exit nicely but warn in log */ void tl_check_filter(ZebraService zs, const char *name); diff --git a/test/charmap/charmap1.c b/test/charmap/charmap1.c index 92d2bb5..f9a6ba8 100644 --- a/test/charmap/charmap1.c +++ b/test/charmap/charmap1.c @@ -66,22 +66,22 @@ static void tst(int argc, char **argv) /* search for aaa */ YAZ_CHECK(tl_query(zh, "@attr 1=4 @term string laaas", 0)); - + /* search ABC in title:0 . */ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=3 @attr 1=4 ABC", 1)); - + /* search DEF in title:0 . */ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=3 @attr 1=4 DEF", 0)); - + /* search [ in title:0 . */ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=3 @attr 1=4 [", 1)); - + /* search \ in title:0 . */ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=3 @attr 1=4 \\\\\\\\", 1)); /* search { in title:0 . */ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=3 @attr 1=4 \\{", 1)); - + YAZ_CHECK(tl_close_down(zh, zs)); } diff --git a/test/codec/tstcodec.c b/test/codec/tstcodec.c index cd9bee6..e397359 100644 --- a/test/codec/tstcodec.c +++ b/test/codec/tstcodec.c @@ -64,7 +64,7 @@ int tst_encode(int num) char *dst = (char *) &key; const char *src0 = src; iscz1_decode(codec_handle, &dst, &src); - + if (key.len != 2) { printf ("%s: i=%d key.len=%d expected 2\n", prog, @@ -137,7 +137,7 @@ void tstcodec1(void) dst = (char*) &key2; src = buf; - + iscz1_decode(codec_handle, &dst, &src); iscz1_stop(codec_handle); @@ -179,7 +179,7 @@ int tstcodec2(int num) const char *src = (const char *) &ar1; char *dst = dstbuf; iscz1_encode(encode_handle, &dst, &src); - + src = dstbuf; dst = (char *) &ar2; iscz1_decode(decode_handle, &dst, &src); @@ -223,7 +223,7 @@ int main(int argc, char **argv) ret = tst_encode(num); exit(ret); } - + /* * Local variables: * c-basic-offset: 4 diff --git a/test/filters/grs.xml.idzebra.c b/test/filters/grs.xml.idzebra.c index 0816551..ac3e0fb 100644 --- a/test/filters/grs.xml.idzebra.c +++ b/test/filters/grs.xml.idzebra.c @@ -58,7 +58,7 @@ void tst(int argc, char **argv) TL_MAIN /* - * Local variables: + * Local variables: * c-basic-offset: 4 * c-file-style: "Stroustrup" * indent-tabs-mode: nil diff --git a/test/marcxml/t1.c b/test/marcxml/t1.c index 458ea73..53dc247 100644 --- a/test/marcxml/t1.c +++ b/test/marcxml/t1.c @@ -42,7 +42,7 @@ static void tst(int argc, char **argv) zebra_repository_update(zh, path); YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK); zebra_commit(zh); - + YAZ_CHECK(tl_query(zh, "@and " "@attr 1=54 eng " "@and @attr 1=1003 jack @attr 1=4 computer", 2)); diff --git a/test/marcxml/t2.c b/test/marcxml/t2.c index 7bb40dd..7e95680 100644 --- a/test/marcxml/t2.c +++ b/test/marcxml/t2.c @@ -33,7 +33,7 @@ static void tst(int argc, char **argv) zebra_init(zh); zebra_set_resource(zh, "recordType", "grs.marcxml.record"); - + YAZ_CHECK(zebra_begin_trans(zh, 1) == ZEBRA_OK); sprintf(path, "%.200s/sample-marc", tl_get_srcdir()); diff --git a/test/mbox/mbox1.c b/test/mbox/mbox1.c index 578896f..5484b8c 100644 --- a/test/mbox/mbox1.c +++ b/test/mbox/mbox1.c @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #endif #include "testlib.h" - + static void tst(int argc, char **argv) { char path[256]; @@ -49,7 +49,7 @@ static void tst(int argc, char **argv) YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK); zebra_commit(zh); - + YAZ_CHECK(tl_close_down(zh, zs)); } diff --git a/test/rusmarc/t1.c b/test/rusmarc/t1.c index cd15f6a..ae33ed6 100644 --- a/test/rusmarc/t1.c +++ b/test/rusmarc/t1.c @@ -37,7 +37,7 @@ void check_koi8r(void) static void tst(int argc, char **argv) { - + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); char path[256]; diff --git a/test/xpath/xpath3.c b/test/xpath/xpath3.c index c37343a..087276a 100644 --- a/test/xpath/xpath3.c +++ b/test/xpath/xpath3.c @@ -45,7 +45,7 @@ static void tst(int argc, char **argv) YAZ_CHECK(tl_query(zh, "@attr 1=/root/first content",1)); YAZ_CHECK(tl_query(zh, "@attr {1=/root/first[@attr='danish']} content",1)); YAZ_CHECK(tl_query(zh, "@attr {1=/root/second[@attr='danish lake']} content",1)); - YAZ_CHECK(tl_query(zh, "@attr {1=/root/third[@attr='dansk s\xc3\xb8']} content",1)); + YAZ_CHECK(tl_query(zh, "@attr {1=/root/third[@attr='dansk s\xc3\xb8']} content",1)); /* FIXME - This triggers bug200 */ YAZ_CHECK(tl_close_down(zh, zs)); diff --git a/test/xpath/xpath4.c b/test/xpath/xpath4.c index 1e6f3d4..0d641f4 100644 --- a/test/xpath/xpath4.c +++ b/test/xpath/xpath4.c @@ -30,22 +30,22 @@ const char *myrec[] = { " bar \n" " gryf \n" " \n", - + " \n" " foo bar \n" " gryf \n" " \n", - + " \n" " foo gryf \n" " grunt \n" " \n", - + " \n" " foo grunt \n" " bar \n" " \n", - + " \n" " double english \n" " double danish \n" @@ -99,10 +99,10 @@ static void tst(int argc, char **argv) YAZ_CHECK(tl_query(zh, "@attr 1=/record/title[@lang='da'] foo",1)); YAZ_CHECK(tl_query(zh, "@attr 1=/record/title[@lang='en'] foo",1)); - YAZ_CHECK(tl_query(zh, "@attr 1=/record/title[@lang='en'] english",1)); - YAZ_CHECK(tl_query(zh, "@attr 1=/record/title[@lang='da'] english",0)); - YAZ_CHECK(tl_query(zh, "@attr 1=/record/title[@lang='da'] danish",1)); - YAZ_CHECK(tl_query(zh, "@attr 1=/record/title[@lang='en'] danish",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/title[@lang='en'] english",1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/title[@lang='da'] english",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/title[@lang='da'] danish",1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/title[@lang='en'] danish",0)); YAZ_CHECK(tl_query(zh, "@attr 1=/record/title @and foo bar",2)); /* The previous one returns two hits, as the and applies to the whole diff --git a/test/xpath/xpath5.c b/test/xpath/xpath5.c index f2c63ed..a525e3f 100644 --- a/test/xpath/xpath5.c +++ b/test/xpath/xpath5.c @@ -51,7 +51,7 @@ const char *recs[] = { " but all have the foo bar \n" " \n" "\n", - + 0 }; diff --git a/test/xpath/xpath6.c b/test/xpath/xpath6.c index f22e714..d6e9e2f 100644 --- a/test/xpath/xpath6.c +++ b/test/xpath/xpath6.c @@ -51,8 +51,8 @@ static void tst(int argc, char **argv) YAZ_CHECK(tl_query(zh, "@attr 5=1 @attr 6=3 @attr 4=1 @attr 1=18 \"367-93-1\"", 2)); YAZ_CHECK(tl_query(zh, "@attr 1=/assembled/orgs/org 0", 1)); - - YAZ_CHECK(tl_query(zh, + + YAZ_CHECK(tl_query(zh, "@and @attr 1=/assembled/orgs/org 0 @attr 5=1 @attr 6=3 @attr 4=1 " "@attr 1=/assembled/basic/names/CASno \"367-93-1\"", 1)); diff --git a/test/xslt/dom1.c b/test/xslt/dom1.c index 3a5d015..3c916e6 100644 --- a/test/xslt/dom1.c +++ b/test/xslt/dom1.c @@ -29,7 +29,7 @@ void index_more(ZebraHandle zh, const char *filter, const char *file) char path[256]; char profile_path[256]; - sprintf(profile_path, "%.80s:%.80s/../../tab", + sprintf(profile_path, "%.80s:%.80s/../../tab", tl_get_srcdir(), tl_get_srcdir()); zebra_set_resource(zh, "profilePath", profile_path); @@ -61,14 +61,14 @@ ZebraHandle index_some(ZebraService zs, void tst(int argc, char **argv) { ZebraHandle zh; - + ZebraService zs = tl_start_up(0, argc, argv); zh = index_some(zs, "dom.bad.xml", "marc-col.xml"); zebra_close(zh); - - /* testing XMLREADER input with PI stylesheet */ + + /* testing XMLREADER input with PI stylesheet */ zh = index_some(zs, "dom.dom-config-col.xml", "marc-col.xml"); YAZ_CHECK(tl_query(zh, "@attr 1=title computer", 3)); @@ -91,13 +91,13 @@ void tst(int argc, char **argv) ZEBRA_OK); YAZ_CHECK(tl_query(zh, "@attr 1=control 11224466", 1)); - + YAZ_CHECK(tl_query_x(zh, "@attr 1=titl computer", 0, 114)); YAZ_CHECK(tl_query_x(zh, "@attr 1=4 computer", 0, 121)); zebra_close(zh); - /* testing XMLREADER input with ELEMENT stylesheet */ + /* testing XMLREADER input with ELEMENT stylesheet */ zh = index_some(zs, "dom.dom-config-one.xml", "marc-one.xml"); YAZ_CHECK(tl_query(zh, "@attr 1=title computer", 1)); YAZ_CHECK(tl_query(zh, "@attr 1=control 11224466", 1)); @@ -105,7 +105,7 @@ void tst(int argc, char **argv) YAZ_CHECK(tl_query_x(zh, "@attr 1=4 computer", 0, 121)); zebra_close(zh); - /* testing MARC input with ELEMENT stylesheet */ + /* testing MARC input with ELEMENT stylesheet */ zh = index_some(zs, "dom.dom-config-marc.xml", "marc-col.mrc"); YAZ_CHECK(tl_query(zh, "@attr 1=title computer", 3)); YAZ_CHECK(tl_query(zh, "@attr 1=control 11224466", 1)); @@ -113,14 +113,14 @@ void tst(int argc, char **argv) YAZ_CHECK(tl_query_x(zh, "@attr 1=4 computer", 0, 121)); zebra_close(zh); - /* testing XMLREADER input with ELEMENT stylesheet and skipped records */ + /* testing XMLREADER input with ELEMENT stylesheet and skipped records */ zh = index_some(zs, "dom.dom-config-skipped.xml", "marc-col.xml"); YAZ_CHECK(tl_query(zh, "@attr 1=title computer", 1)); YAZ_CHECK(tl_query(zh, "@attr 1=control 11224466", 0)); YAZ_CHECK(tl_query(zh, "@attr 1=control 11224467", 1)); YAZ_CHECK(tl_query(zh, "@attr 1=control 73090924", 0)); - /* testing XMLREADER input with type attributes (insert,delete,..) */ + /* testing XMLREADER input with type attributes (insert,delete,..) */ zh = index_some(zs, "dom.dom-config-del.xml", "del-col.xml"); YAZ_CHECK(tl_query(zh, "@attr 1=title a", 1)); YAZ_CHECK(tl_query(zh, "@attr 1=title 1", 0)); diff --git a/test/xslt/xslt1.c b/test/xslt/xslt1.c index 52ce29d..4a9ae77 100644 --- a/test/xslt/xslt1.c +++ b/test/xslt/xslt1.c @@ -37,7 +37,7 @@ void tst(int argc, char **argv) zebra_init(zh); - sprintf(profile_path, "%s:%s/../../tab", + sprintf(profile_path, "%s:%s/../../tab", tl_get_srcdir(), tl_get_srcdir()); zebra_set_resource(zh, "profilePath", profile_path); @@ -54,7 +54,7 @@ void tst(int argc, char **argv) YAZ_CHECK(tl_query(zh, "@attr 1=control 11224466", 1)); YAZ_CHECK(tl_query_x(zh, "@attr 1=titl computer", 0, 114)); YAZ_CHECK(tl_query_x(zh, "@attr 1=4 computer", 0, 121)); - + YAZ_CHECK(tl_close_down(zh, zs)); } diff --git a/test/xslt/xslt2.c b/test/xslt/xslt2.c index 2d32aff..290fa8a 100644 --- a/test/xslt/xslt2.c +++ b/test/xslt/xslt2.c @@ -40,10 +40,10 @@ static void tst(int argc, char **argv) tl_check_filter(zs, "alvis"); YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); - + zebra_init(zh); - sprintf(profile_path, "%s:%s/../../tab", + sprintf(profile_path, "%s:%s/../../tab", tl_get_srcdir(), tl_get_srcdir()); zebra_set_resource(zh, "profilePath", profile_path); @@ -74,7 +74,7 @@ static void tst(int argc, char **argv) YAZ_CHECK(tl_query(zh, "@attr 1=title computer", 3)); YAZ_CHECK(tl_query(zh, "@attr 1=control 11224466", 1)); YAZ_CHECK(tl_query_x(zh, "@attr 1=titl computer", 0, 114)); - + YAZ_CHECK(tl_close_down(zh, zs)); } diff --git a/test/xslt/xslt3.c b/test/xslt/xslt3.c index 4a0fada..596132f 100644 --- a/test/xslt/xslt3.c +++ b/test/xslt/xslt3.c @@ -40,10 +40,10 @@ static void tst(int argc, char **argv) tl_check_filter(zs, "alvis"); YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); - + zebra_init(zh); - sprintf(profile_path, "%s:%s/../../tab", + sprintf(profile_path, "%s:%s/../../tab", tl_get_srcdir(), tl_get_srcdir()); zebra_set_resource(zh, "profilePath", profile_path); @@ -74,7 +74,7 @@ static void tst(int argc, char **argv) YAZ_CHECK(tl_query(zh, "@attr 1=control 11224466", 1)); YAZ_CHECK(tl_query_x(zh, "@attr 1=titl computer", 0, 114)); - + /* index one more time to see that we don't get dups, since index.xsl has a record ID associated with them */ zebra_add_record(zh, record_buf, strlen(record_buf)); @@ -83,7 +83,7 @@ static void tst(int argc, char **argv) YAZ_CHECK(tl_query(zh, "@attr 1=title computer", 1)); YAZ_CHECK(tl_query(zh, "@attr 1=control 11224466", 1)); YAZ_CHECK(tl_query_x(zh, "@attr 1=titl computer", 0, 114)); - + YAZ_CHECK(tl_close_down(zh, zs)); } diff --git a/test/xslt/xslt4.c b/test/xslt/xslt4.c index 99337e6..ac12cff 100644 --- a/test/xslt/xslt4.c +++ b/test/xslt/xslt4.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #endif #include #include "testlib.h" - + static void tst(int argc, char **argv) { char path[256]; @@ -37,7 +37,7 @@ static void tst(int argc, char **argv) zebra_init(zh); - sprintf(profile_path, "%s:%s/../../tab", + sprintf(profile_path, "%s:%s/../../tab", tl_get_srcdir(), tl_get_srcdir()); zebra_set_resource(zh, "profilePath", profile_path); diff --git a/test/xslt/xslt5.c b/test/xslt/xslt5.c index 83d51e3..216b3f9 100644 --- a/test/xslt/xslt5.c +++ b/test/xslt/xslt5.c @@ -41,10 +41,10 @@ static void tst(int argc, char **argv) tl_check_filter(zs, "alvis"); YAZ_CHECK_EQ(zebra_select_database(zh, "Default"), ZEBRA_OK); - + zebra_init(zh); - sprintf(profile_path, "%s:%s/../../tab", + sprintf(profile_path, "%s:%s/../../tab", tl_get_srcdir(), tl_get_srcdir()); zebra_set_resource(zh, "profilePath", profile_path); @@ -62,7 +62,7 @@ static void tst(int argc, char **argv) record_buf[r] = '\0'; #if 0 -/* disable this test for now: bug #730 */ +/* disable this test for now: bug #730 */ /* http://xmlsoft.org/html/libxml-parser.html#xmlReadIO */ #if YAZ_HAVE_XML2 /* On Mac OSX using Libxml 2.6.16, we xmlTextReaderExpand does diff --git a/util/attrfind.c b/util/attrfind.c index 79ed7a6..7821948 100644 --- a/util/attrfind.c +++ b/util/attrfind.c @@ -55,7 +55,7 @@ int attr_find_ex(AttrType *src, const Odr_oid **attribute_set_oid, element = src->attributeList[src->major]; if (src->type == *element->attributeType) { - switch (element->which) + switch (element->which) { case Z_AttributeValue_numeric: ++(src->major); @@ -68,20 +68,20 @@ int attr_find_ex(AttrType *src, const Odr_oid **attribute_set_oid, break; if (element->attributeSet && attribute_set_oid) *attribute_set_oid = element->attributeSet; - if (element->value.complex->list[src->minor]->which == + if (element->value.complex->list[src->minor]->which == Z_StringOrNumeric_numeric) { ++(src->minor); return *element->value.complex->list[src->minor-1]->u.numeric; } - else if (element->value.complex->list[src->minor]->which == + else if (element->value.complex->list[src->minor]->which == Z_StringOrNumeric_string) { if (!string_value) break; ++(src->minor); - *string_value = + *string_value = element->value.complex->list[src->minor-1]->u.string; return -2; } diff --git a/util/charmap.c b/util/charmap.c index c67cae9..db5a809 100644 --- a/util/charmap.c +++ b/util/charmap.c @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA /** * \file charmap.c * \brief character conversions (.chr) - * + * * Support module to handle character-conversions into and out of the * Zebra dictionary. */ @@ -71,7 +71,7 @@ struct chr_t_entry /* * General argument structure for callback functions (internal use only) */ -typedef struct chrwork +typedef struct chrwork { chrmaptab map; char string[CHR_MAXSTR+1]; @@ -103,10 +103,10 @@ static chr_t_entry *set_map_string(chr_t_entry *root, NMEM nmem, } if (!len) { - if (!root->target || !root->target[0] || + if (!root->target || !root->target[0] || strcmp((const char *) root->target[0], to)) { - if (from_0 && + if (from_0 && root->target && root->target[0] && root->target[0][0] && strcmp((const char *) root->target[0], CHR_UNKNOWN)) { @@ -163,8 +163,8 @@ static chr_t_entry *find_entry_x(chr_t_entry *t, const char **from, int *len, in else res = 0; /* otherwhise there was no match on beginning of field, move on */ - } - + } + if (!res && t->children[(unsigned char) **from]) { (*len)--; @@ -210,7 +210,7 @@ const char **chr_map_q_input(chrmaptab maptab, chr_t_entry *t = maptab->q_input; chr_t_entry *res; int len_tmp[2]; - + len_tmp[0] = len; len_tmp[1] = -1; if (!(res = find_entry_x(t, from, len_tmp, first))) @@ -253,7 +253,7 @@ ucs4_t zebra_prim_w(ucs4_t **s) case 'n': c = '\n'; (*s)++; break; case 't': c = '\t'; (*s)++; break; case 's': c = ' '; (*s)++; break; - case 'x': + case 'x': if (zebra_ucs4_strlen(*s) >= 3) { fmtstr[0] = (*s)[1]; @@ -319,14 +319,14 @@ static void fun_addentry(const char *s, void *data, int num) { chrmaptab tab = (chrmaptab) data; char tmp[2]; - + tmp[0] = num; tmp[1] = '\0'; tab->input = set_map_string(tab->input, tab->nmem, s, strlen(s), tmp, 0); tab->output[num + tab->base_uppercase] = (unsigned char *) nmem_strdup(tab->nmem, s); } -/* +/* * Callback function. * Add a space-entry to the value space. */ @@ -337,7 +337,7 @@ static void fun_addspace(const char *s, void *data, int num) (char*) CHR_SPACE, 0); } -/* +/* * Callback function. * Add a space-entry to the value space. */ @@ -369,7 +369,7 @@ static void fun_mkstring(const char *s, void *data, int num) static void fun_add_equivalent_string(const char *s, void *data, int num) { chr_equiv_work *arg = (chr_equiv_work *) data; - + if (arg->no_eq == CHR_MAXEQUIV) return; arg->eq[arg->no_eq++] = nmem_strdup(arg->nmem, s); @@ -396,7 +396,7 @@ static int scan_to_utf8(yaz_iconv_t t, ucs4_t *from, size_t inlen, size_t inbytesleft = inlen * sizeof(ucs4_t); char *inbuf = (char*) from; size_t ret; - + if (t == 0) *outbuf++ = *from; /* ISO-8859-1 is OK here */ else @@ -404,8 +404,8 @@ static int scan_to_utf8(yaz_iconv_t t, ucs4_t *from, size_t inlen, ret = yaz_iconv(t, &inbuf, &inbytesleft, &outbuf, &outbytesleft); if (ret != (size_t) (-1)) ret = yaz_iconv(t, 0, 0, &outbuf, &outbytesleft); - - + + if (ret == (size_t) (-1)) { yaz_log(YLOG_LOG, "from: %2X %2X %2X %2X", @@ -437,18 +437,18 @@ static int scan_string(char *s_native, char *inbuf = s_native; size_t outbytesleft = sizeof(arg)-4; size_t inbytesleft = strlen(s_native); - size_t ret; + size_t ret; ret = yaz_iconv(t_unicode, &inbuf, &inbytesleft, &outbuf, &outbytesleft); if (ret != (size_t)(-1)) ret = yaz_iconv(t_unicode, 0, 0, &outbuf, &outbytesleft); - + if (ret == (size_t)(-1)) return -1; i = (outbuf - (char*) arg)/sizeof(ucs4_t); } else - { + { for (i = 0; s_native[i]; i++) arg[i] = s_native[i] & 255; /* ISO-8859-1 conversion */ } @@ -672,7 +672,7 @@ chrmaptab chrmaptab_create(const char *tabpath, const char *name, } w.nmem = res->nmem; w.no_eq = 0; - if (scan_string(argv[1], t_unicode, t_utf8, + if (scan_string(argv[1], t_unicode, t_utf8, fun_add_equivalent_string, &w, 0) < 0) { yaz_log(YLOG_FATAL, "equivalent: invalid string"); @@ -725,7 +725,7 @@ chrmaptab chrmaptab_create(const char *tabpath, const char *name, yaz_log(YLOG_WARN, "Syntax error at '%s' in %s", line, name); errors++; } - } + } yaz_fclose(f); if (no_directives == 0) { diff --git a/util/dirent.c b/util/dirent.c index add845b..55a9f3d 100644 --- a/util/dirent.c +++ b/util/dirent.c @@ -52,7 +52,7 @@ DIR *opendir (const char *name) dd->handle = FindFirstFile(fullName, &dd->find_data); return dd; } - + struct dirent *readdir (DIR *dd) { if (dd->handle == INVALID_HANDLE_VALUE) diff --git a/util/flock.c b/util/flock.c index 3157f36..2472c60 100644 --- a/util/flock.c +++ b/util/flock.c @@ -85,12 +85,12 @@ char *zebra_mk_fname(const char *dir, const char *name) { int dlen = dir ? strlen(dir) : 0; char *fname = xmalloc(dlen + strlen(name) + 3); - + #ifdef WIN32 if (dlen) { int last_one = dir[dlen-1]; - + if (!strchr("/\\:", last_one)) sprintf(fname, "%s\\%s", dir, name); else @@ -135,7 +135,7 @@ ZebraLockHandle zebra_lock_create(const char *dir, const char *name) if (!p) { /* didn't match (or we didn't want it to match! */ p = (struct zebra_lock_info *) xmalloc(sizeof(*p)); - + p->ref_count = 0; #ifdef WIN32 p->fd = open(name, O_BINARY|O_RDONLY); @@ -147,7 +147,7 @@ ZebraLockHandle zebra_lock_create(const char *dir, const char *name) if (p->fd == -1) { xfree(p); - yaz_log(YLOG_WARN | YLOG_ERRNO, + yaz_log(YLOG_WARN | YLOG_ERRNO, "zebra_lock_create fail fname=%s", fname); p = 0; } @@ -243,7 +243,7 @@ static int unixLock(int fd, int type, int cmd) yaz_log(YLOG_WARN|YLOG_ERRNO, "fcntl FAIL type=%d fd=%d", type, fd); else yaz_log(log_level, "fcntl type=%d OK fd=%d", type, fd); - + return r; } #endif @@ -252,7 +252,7 @@ int zebra_lock_w(ZebraLockHandle h) { int r = 0; int do_lock = 0; - yaz_log(log_level, "zebra_lock_w fd=%d p=%p fname=%s begin", + yaz_log(log_level, "zebra_lock_w fd=%d p=%p fname=%s begin", h->p->fd, h, h->p->fname); #ifdef WIN32 @@ -279,7 +279,7 @@ int zebra_lock_w(ZebraLockHandle h) h->write_flag = 1; #endif - yaz_log(log_level, "zebra_lock_w fd=%d p=%p fname=%s end", + yaz_log(log_level, "zebra_lock_w fd=%d p=%p fname=%s end", h->p->fd, h, h->p->fname); return r; @@ -290,7 +290,7 @@ int zebra_lock_r(ZebraLockHandle h) int r = 0; int do_lock = 0; - yaz_log(log_level, "zebra_lock_r fd=%d p=%p fname=%s begin", + yaz_log(log_level, "zebra_lock_r fd=%d p=%p fname=%s begin", h->p->fd, h, h->p->fname); #ifdef WIN32 while ((r = _locking(h->p->fd, _LK_LOCK, 1))) @@ -313,10 +313,10 @@ int zebra_lock_r(ZebraLockHandle h) assert(posix_locks); } zebra_mutex_unlock(&h->p->file_mutex); - + h->write_flag = 0; #endif - yaz_log(log_level, "zebra_lock_r fd=%d p=%p fname=%s end", + yaz_log(log_level, "zebra_lock_r fd=%d p=%p fname=%s end", h->p->fd, h, h->p->fname); return r; } @@ -363,7 +363,7 @@ int zebra_unlock(ZebraLockHandle h) return r; } -/** \brief see if the fcntl locking is not POSIX +/** \brief see if the fcntl locking is not POSIX * * The default posix_locks=1 is assumed.. This function sets posix_locks * to zero if linuxthreads is in use. diff --git a/util/it_key.c b/util/it_key.c index 2be5886..5ec244b 100644 --- a/util/it_key.c +++ b/util/it_key.c @@ -132,7 +132,7 @@ int key_qsort_compare (const void *p1, const void *p2) size_t l; char *cp1 = *(char **) p1; char *cp2 = *(char **) p2; - + if ((r = strcmp (cp1, cp2))) return r; l = strlen(cp1)+1; @@ -216,7 +216,7 @@ void iscz1_encode (void *vp, char **dst, const char **src) 3, 2, 9, 12 3, 2, 10, 2 4, 1 - + if diff is 0, then there is more ... if diff is non-zero, then _may_ be more */ diff --git a/util/passwddb.c b/util/passwddb.c index f3113be..b8ac8d8 100644 --- a/util/passwddb.c +++ b/util/passwddb.c @@ -57,7 +57,7 @@ Passwd_db passwd_db_open (void) } static int get_entry (const char **p, char *dst, int max) -{ +{ int i = 0; while ((*p)[i] != ':' && (*p)[i]) i++; @@ -109,7 +109,7 @@ void passwd_db_close(Passwd_db db) while (pe) { struct passwd_entry *pe_next = pe->next; - + xfree (pe->name); xfree (pe->des); xfree (pe); @@ -166,7 +166,7 @@ int passwd_db_auth(Passwd_db db, const char *user, const char *pass) if (strcmp (pe->des, pass)) return -2; } - return 0; + return 0; } int passwd_db_file_crypt(Passwd_db db, const char *fname) diff --git a/util/res.c b/util/res.c index efb6473..a38a419 100644 --- a/util/res.c +++ b/util/res.c @@ -125,7 +125,7 @@ static char *xstrdup_env(const char *src) strcpy(dst+j, env_val); j += strlen(env_val); } - else if (src[i] == ':' && src[i+1] == '-') + else if (src[i] == ':' && src[i+1] == '-') { i = i + 2; while (src[i] && !strchr("}\n\r\f", src[i])) @@ -163,12 +163,12 @@ ZEBRA_RES res_read_file(Res r, const char *fname) int lineno = 1; WRBUF wrbuf_val = wrbuf_alloc(); yaz_tok_cfg_t yt = yaz_tok_cfg_create(); - + while ((line = fgets(fr_buf, sizeof(fr_buf)-1, fr))) { yaz_tok_parse_t tp = yaz_tok_parse_buf(yt, line); int t = yaz_tok_move(tp); - + if (t == YAZ_TOK_STRING) { size_t sz; @@ -200,7 +200,7 @@ ZEBRA_RES res_read_file(Res r, const char *fname) { /* name: value */ t = yaz_tok_move(tp); - + if (t != YAZ_TOK_STRING) { resp->value = xstrdup(""); @@ -221,7 +221,7 @@ ZEBRA_RES res_read_file(Res r, const char *fname) } lineno++; yaz_tok_parse_destroy(tp); - } + } fclose(fr); yaz_tok_cfg_destroy(yt); wrbuf_destroy(wrbuf_val); @@ -276,7 +276,7 @@ const char *res_get_prefix(Res r, const char *name, const char *prefix, if (prefix) { char rname[128]; - + if (strlen(name) + strlen(prefix) >= (sizeof(rname)-2)) return 0; strcpy(rname, prefix); @@ -298,7 +298,7 @@ const char *res_get(Res r, const char *name) if (!r) return 0; - + v = res_get(r->over_res, name); if (v) return v; @@ -360,7 +360,7 @@ int res_trav(Res r, const char *prefix, void *p, struct res_entry *re; int l = 0; int no = 0; - + if (!r) return 0; no = res_trav(r->over_res, prefix, p, f); @@ -454,22 +454,22 @@ void res_add(Res r, const char *name, const char *value) re->value = xstrdup_env(value); } -void res_dump(Res r, int level) +void res_dump(Res r, int level) { struct res_entry *re; - + if (!r) return; - + for (re = r->first; re; re=re->next) { printf("%*s - %s:='%s'\n",level * 4,"",re->name,re->value); } - + if (r->def_res) { printf("%*s DEF ",level * 4,""); res_dump(r->def_res, level + 1); } - + if (r->over_res) { printf("%*s OVER ",level * 4,""); res_dump(r->over_res, level + 1); @@ -480,7 +480,7 @@ int res_check(Res r_i, Res r_v) { struct res_entry *e_i; int errors = 0; - + for (e_i = r_i->first; e_i; e_i = e_i->next) { struct res_entry *e_v; @@ -498,7 +498,7 @@ int res_check(Res r_i, Res r_v) prefix_allowed = 1; if (strchr(e_v->value, 's')) suffix_allowed = 1; - + first_dot = strchr(name, '.'); if (prefix_allowed && first_dot) { diff --git a/util/snippet.c b/util/snippet.c index 98f1206..1cb7a4f 100644 --- a/util/snippet.c +++ b/util/snippet.c @@ -111,7 +111,7 @@ void zebra_snippets_log(const zebra_snippets *l, int log_level, int all) if (all || w->mark) yaz_log(log_level, "term='%s'%s mark=%d seqno=" ZINT_FORMAT " ord=%d", - wrbuf_cstr(wr_term), + wrbuf_cstr(wr_term), (w->match && !w->ws ? "*" : ""), w->mark, w->seqno, w->ord); wrbuf_destroy(wr_term); @@ -189,7 +189,7 @@ zebra_snippets *zebra_snippets_window(const zebra_snippets *doc, hit_w = hit_w->next) { if (hit_w->ord == ord && hit_w->seqno == doc_w->seqno) - + { match = 1; break; @@ -197,7 +197,7 @@ zebra_snippets *zebra_snippets_window(const zebra_snippets *doc, } zebra_snippets_append_match(result, doc_w->seqno, doc_w->ws, - ord, doc_w->term, + ord, doc_w->term, strlen(doc_w->term), match); } } @@ -269,7 +269,7 @@ void zebra_snippets_ring(zebra_snippets *doc, const zebra_snippets *hit, doc_w->mark = 1; break; } - + } /* mark following terms */ if (doc_w) @@ -277,7 +277,7 @@ void zebra_snippets_ring(zebra_snippets *doc, const zebra_snippets *hit, zebra_snippet_word *w = doc_w->next; while (w) if (w->ord == ord - && hit_w->seqno - before < w->seqno + && hit_w->seqno - before < w->seqno && hit_w->seqno + after > w->seqno) { w->mark = 1; @@ -292,7 +292,7 @@ void zebra_snippets_ring(zebra_snippets *doc, const zebra_snippets *hit, zebra_snippet_word *w = doc_w->prev; while (w) if (w->ord == ord - && hit_w->seqno - before < w->seqno + && hit_w->seqno - before < w->seqno && hit_w->seqno + after > w->seqno) { w->mark = 1; @@ -306,7 +306,7 @@ void zebra_snippets_ring(zebra_snippets *doc, const zebra_snippets *hit, } } - + /* * Local variables: * c-basic-offset: 4 diff --git a/util/strmap.c b/util/strmap.c index cb51d81..6fe4014 100644 --- a/util/strmap.c +++ b/util/strmap.c @@ -32,7 +32,7 @@ struct strmap_entry { void *data_buf; struct strmap_entry *next; }; - + struct zebra_strmap { NMEM nmem_str; NMEM nmem_ent; @@ -142,7 +142,7 @@ struct zebra_strmap_it_s { int hno; struct strmap_entry *ent; zebra_strmap_t st; - + }; zebra_strmap_it zebra_strmap_it_create(zebra_strmap_t st) @@ -183,7 +183,7 @@ const char *zebra_strmap_it_next(zebra_strmap_it it, void **data_buf, } return 0; } - + /* * Local variables: * c-basic-offset: 4 diff --git a/util/test_strmap.c b/util/test_strmap.c index 5826b92..076213b 100644 --- a/util/test_strmap.c +++ b/util/test_strmap.c @@ -38,10 +38,10 @@ static void test1(void) size_t data_len; zebra_strmap_t sm = zebra_strmap_create(); YAZ_CHECK(!zebra_strmap_lookup(sm, "a", 0, 0)); - + zebra_strmap_add(sm, "a", &v, sizeof v); data_buf = zebra_strmap_lookup(sm, "a", 0, &data_len); - YAZ_CHECK(data_buf && data_len == sizeof v + YAZ_CHECK(data_buf && data_len == sizeof v && v == *((int*) data_buf)); zebra_strmap_remove(sm, "a"); diff --git a/util/tstflock.c b/util/tstflock.c index 2bea667..1ac1417 100644 --- a/util/tstflock.c +++ b/util/tstflock.c @@ -107,7 +107,7 @@ void *run_func(void *arg) if (use_write_lock == 2) /* random lock */ write_lock = (rand() & 3) == 3 ? 1 : 0; - + if (write_lock) { zebra_lock_w(lh); @@ -115,21 +115,21 @@ void *run_func(void *arg) write(test_fd, "L", 1); *seqp++ = 'L'; small_sleep(); - *seqp++ = 'U'; + *seqp++ = 'U'; write(test_fd, "U", 1); - + zebra_unlock(lh); } else { zebra_lock_r(lh); - + write(test_fd, "l", 1); *seqp++ = 'l'; small_sleep(); *seqp++ = 'u'; write(test_fd, "u", 1); - + zebra_unlock(lh); } } @@ -190,7 +190,7 @@ static void tst_thread(int num, int write_flag) for (i = 0; i < num; i++) YAZ_CHECK(id[i] == 123); *seqp++ = '\0'; - yaz_log(YLOG_LOG, "tst_thread(%d,%d) returns seq=%s", + yaz_log(YLOG_LOG, "tst_thread(%d,%d) returns seq=%s", num, write_flag, seq); } diff --git a/util/tstlockscope.c b/util/tstlockscope.c index a541cfa..b317763 100644 --- a/util/tstlockscope.c +++ b/util/tstlockscope.c @@ -45,7 +45,7 @@ static int file_lock(int fd, int type, int cmd) area.l_type = type; area.l_whence = SEEK_SET; area.l_len = area.l_start = 0L; - + return fcntl(fd, cmd, &area); } diff --git a/util/tstpass.c b/util/tstpass.c index e15146d..2584894 100644 --- a/util/tstpass.c +++ b/util/tstpass.c @@ -39,7 +39,7 @@ static void tst(void) { char path[1024]; Passwd_db db; - + db = passwd_db_open(); YAZ_CHECK(db); if (!db) diff --git a/util/tstres.c b/util/tstres.c index 61f5dab..c617afb 100644 --- a/util/tstres.c +++ b/util/tstres.c @@ -64,7 +64,7 @@ static void tst_res_read_file(void) const char *v; char path[1024]; int r; - + yaz_snprintf(path, sizeof(path), "%s/tstres.cfg", get_srcdir()); r = res_read_file(res, path); YAZ_CHECK_EQ(r, ZEBRA_OK); diff --git a/util/xpath.c b/util/xpath.c index 1a9f0d4..ffb6eb0 100644 --- a/util/xpath.c +++ b/util/xpath.c @@ -122,13 +122,13 @@ static struct xpath_predicate *get_xpath_boolean(char **pr, NMEM mem, char **look, int *literal) { struct xpath_predicate *left = 0; - + left = get_xpath_relation(pr, mem, look, literal); if (!left) return 0; - + while (*look && !*literal && - (!strcmp(*look, "and") || !strcmp(*look, "or") || + (!strcmp(*look, "and") || !strcmp(*look, "or") || !strcmp(*look, "not"))) { struct xpath_predicate *res, *right; @@ -164,13 +164,13 @@ int zebra_parse_xpath_str(const char *xpath_string, { const char *cp; char *a; - + int no = 0; - + if (!xpath_string || *xpath_string != '/') return -1; cp = xpath_string; - + while (*cp && no < max) { int i = 0; @@ -218,7 +218,7 @@ void dump_xp_predicate (struct xpath_predicate *p) if (p) { if (p->which == XPATH_PREDICATE_RELATION && p->u.relation.name[0]) { - fprintf (stderr, "%s,%s,%s", + fprintf (stderr, "%s,%s,%s", p->u.relation.name, p->u.relation.op, p->u.relation.value); diff --git a/util/zebra-lock.c b/util/zebra-lock.c index 3332eda..8d44094 100644 --- a/util/zebra-lock.c +++ b/util/zebra-lock.c @@ -46,7 +46,7 @@ int zebra_mutex_destroy (Zebra_mutex *p) if (p->state != 0) { fprintf (stderr, "zebra_mutex_destroy. state = %d\n", p->state); - } + } #if YAZ_POSIX_THREADS pthread_mutex_destroy (&p->mutex); #endif @@ -140,7 +140,7 @@ int zebra_lock_rdwr_runlock (Zebra_lock_rdwr *p) { pthread_mutex_unlock (&p->mutex); return -1; - } + } else { p->readers_reading--; diff --git a/util/zebramap.c b/util/zebramap.c index 8165026..abf7e52 100644 --- a/util/zebramap.c +++ b/util/zebramap.c @@ -170,7 +170,7 @@ static int parse_command(zebra_maps_t zms, int argc, char **argv, } else if (!zm) { - yaz_log(YLOG_WARN, "%s:%d: Missing sort/index before '%s'", + yaz_log(YLOG_WARN, "%s:%d: Missing sort/index before '%s'", fname, lineno, argv[0]); return -1; } @@ -215,8 +215,8 @@ static int parse_command(zebra_maps_t zms, int argc, char **argv, zm->u.sort.entry_size = atoi(argv[1]); else { - yaz_log(YLOG_WARN, - "%s:%d: entrysize only valid in sort section", + yaz_log(YLOG_WARN, + "%s:%d: entrysize only valid in sort section", fname, lineno); return -1; } @@ -251,14 +251,14 @@ static int parse_command(zebra_maps_t zms, int argc, char **argv, #if YAZ_HAVE_ICU UErrorCode status; xmlNode *xml_node = xmlDocGetRootElement(zm->doc); - zm->icu_chain = + zm->icu_chain = icu_chain_xml_config(xml_node, /* not sure about sort for this function yet.. */ #if 1 1, #else zm->type == ZEBRA_MAP_TYPE_SORT, -#endif +#endif &status); if (!zm->icu_chain) { @@ -284,7 +284,7 @@ static int parse_command(zebra_maps_t zms, int argc, char **argv, } else { - yaz_log(YLOG_WARN, "%s:%d: Unrecognized directive '%s'", + yaz_log(YLOG_WARN, "%s:%d: Unrecognized directive '%s'", fname, lineno, argv[0]); return -1; } @@ -366,7 +366,7 @@ zebra_map_t zebra_map_get_or_add(zebra_maps_t zms, const char *id) if (!zm) { zm = zebra_add_map(zms, id, ZEBRA_MAP_TYPE_INDEX); - + /* no reason to warn if no maps are read from file */ if (zms->no_files_read) yaz_log(YLOG_WARN, "Unknown register type: %s", id); @@ -401,7 +401,7 @@ const char **zebra_maps_input(zebra_map_t zm, chrmaptab maptab = zebra_charmap_get(zm); if (maptab) return chr_map_input(maptab, from, len, first); - + zm->zebra_maps->temp_map_str[0] = **from; (*from)++; @@ -412,7 +412,7 @@ const char **zebra_maps_search(zebra_map_t zm, const char **from, int len, int *q_map_match) { chrmaptab maptab; - + *q_map_match = 0; maptab = zebra_charmap_get(zm); if (maptab) @@ -447,7 +447,7 @@ const char *zebra_maps_output(zebra_map_t zm, /* ------------------------------------ */ int zebra_maps_is_complete(zebra_map_t zm) -{ +{ if (zm) return zm->completeness; return 0; @@ -473,7 +473,7 @@ int zebra_maps_is_staticrank(zebra_map_t zm) return zm->type == ZEBRA_MAP_TYPE_STATICRANK; return 0; } - + int zebra_maps_is_sort(zebra_map_t zm) { if (zm) @@ -572,11 +572,11 @@ int zebra_maps_attr(zebra_maps_t zms, Z_AttributesPlusTerm *zapt, break; case 106: /* document-text */ *search_type = "or-list"; - break; + break; case -1: case 1: /* phrase */ case 2: /* word */ - case 108: /* string */ + case 108: /* string */ *search_type = "phrase"; break; case 107: /* local-number */ @@ -718,9 +718,9 @@ int zebra_map_tokenize_start(zebra_map_t zm, wrbuf_rewind(zm->print_str); wrbuf_write_escaped(zm->print_str, wrbuf_buf(zm->input_str), wrbuf_len(zm->input_str)); - - yaz_log(YLOG_LOG, "input %s", - wrbuf_cstr(zm->print_str)); + + yaz_log(YLOG_LOG, "input %s", + wrbuf_cstr(zm->print_str)); } ret = icu_chain_assign_cstr(zm->icu_chain, wrbuf_cstr(zm->input_str), &status); -- 1.7.10.4