From 1bb217ab477284fd7fee47f19a6e8a780fa2bb50 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 6 Aug 2004 12:28:22 +0000 Subject: [PATCH] Added several type casts and changed many types - mostly from int to zint. --- bfile/cfile.c | 72 ++++++++++++++++++++++++++------------------------ bfile/cfile.h | 12 ++++----- bfile/commit.c | 9 ++++--- bfile/mfile.c | 23 +++++++++++----- include/isam-codec.h | 4 +-- include/recctrl.h | 4 +-- include/rset.h | 4 +-- include/zebraver.h | 9 +++---- index/invstat.c | 16 +++++------ index/kcompare.c | 10 +++---- index/recindex.c | 14 +++++----- index/recindxp.h | 4 +-- index/trunc.c | 17 +++++++++--- index/zvrank.c | 21 ++++++++------- isamb/isamb.c | 28 ++++++++++---------- isamc/isamc-p.h | 8 +++--- isamc/isamc.c | 9 ++++--- isamc/merge.c | 8 +++--- rset/rsbool.c | 4 +-- rset/rstemp.c | 6 ++--- 20 files changed, 153 insertions(+), 129 deletions(-) diff --git a/bfile/cfile.c b/bfile/cfile.c index 550da60..3023ec5 100644 --- a/bfile/cfile.c +++ b/bfile/cfile.c @@ -1,4 +1,4 @@ -/* $Id: cfile.c,v 1.28 2004-08-04 08:35:22 adam Exp $ +/* $Id: cfile.c,v 1.29 2004-08-06 12:28:22 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -32,7 +32,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA static int write_head (CFile cf) { - int left = cf->head.hash_size * sizeof(int); + int left = cf->head.hash_size * sizeof(zint); int bno = 1; const char *tab = (char*) cf->array; @@ -51,7 +51,7 @@ static int write_head (CFile cf) static int read_head (CFile cf) { - int left = cf->head.hash_size * sizeof(int); + int left = cf->head.hash_size * sizeof(zint); int bno = 1; char *tab = (char*) cf->array; @@ -99,13 +99,13 @@ CFile cf_open (MFile mf, MFile_area area, const char *fname, cf->head.state = 1; cf->head.block_size = block_size; cf->head.hash_size = 199; - hash_bytes = cf->head.hash_size * sizeof(int); + hash_bytes = cf->head.hash_size * sizeof(zint); 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; if (wflag) mf_write (cf->hash_mf, 0, 0, sizeof(cf->head), &cf->head); - cf->array = (int *) xmalloc (hash_bytes); + cf->array = (zint *) xmalloc (hash_bytes); for (i = 0; ihead.hash_size; i++) cf->array[i] = 0; if (wflag) @@ -116,11 +116,11 @@ CFile cf_open (MFile mf, MFile_area area, const char *fname, *firstp = 0; assert (cf->head.block_size == block_size); assert (cf->head.hash_size > 2); - hash_bytes = cf->head.hash_size * sizeof(int); + hash_bytes = cf->head.hash_size * sizeof(zint); assert (cf->head.next_bucket > 0); assert (cf->head.next_block > 0); if (cf->head.state == 1) - cf->array = (int *) xmalloc (hash_bytes); + cf->array = (zint *) xmalloc (hash_bytes); else cf->array = NULL; read_head (cf); @@ -146,9 +146,9 @@ CFile cf_open (MFile mf, MFile_area area, const char *fname, return cf; } -static int cf_hash (CFile cf, int no) +static int cf_hash (CFile cf, zint no) { - return (no>>3) % cf->head.hash_size; + return (int) (((no >> 3) % cf->head.hash_size)); } static void release_bucket (CFile cf, struct CFile_hash_bucket *p) @@ -189,7 +189,7 @@ static void flush_bucket (CFile cf, int no_to_flush) } } -static struct CFile_hash_bucket *alloc_bucket (CFile cf, int block_no, int hno) +static struct CFile_hash_bucket *alloc_bucket (CFile cf, zint block_no, int hno) { struct CFile_hash_bucket *p, **pp; @@ -216,7 +216,7 @@ static struct CFile_hash_bucket *alloc_bucket (CFile cf, int block_no, int hno) return p; } -static struct CFile_hash_bucket *get_bucket (CFile cf, int block_no, int hno) +static struct CFile_hash_bucket *get_bucket (CFile cf, zint block_no, int hno) { struct CFile_hash_bucket *p; @@ -231,10 +231,11 @@ static struct CFile_hash_bucket *get_bucket (CFile cf, int block_no, int hno) return p; } -static struct CFile_hash_bucket *new_bucket (CFile cf, int *block_nop, int hno) +static struct CFile_hash_bucket *new_bucket (CFile cf, zint *block_nop, int hno) { struct CFile_hash_bucket *p; - int i, block_no; + int i; + zint block_no; block_no = *block_nop = cf->head.next_bucket++; p = alloc_bucket (cf, block_no, hno); @@ -250,21 +251,22 @@ static struct CFile_hash_bucket *new_bucket (CFile cf, int *block_nop, int hno) return p; } -static int cf_lookup_flat (CFile cf, int no) +static zint cf_lookup_flat (CFile cf, zint no) { - int hno = (no*sizeof(int))/HASH_BSIZE; - int off = (no*sizeof(int)) - hno*HASH_BSIZE; - int vno = 0; + zint hno = (no*sizeof(zint))/HASH_BSIZE; + int off = (int) ((no*sizeof(zint)) - hno*HASH_BSIZE); + zint vno = 0; - mf_read (cf->hash_mf, hno+cf->head.next_bucket, off, sizeof(int), &vno); + mf_read (cf->hash_mf, hno+cf->head.next_bucket, off, sizeof(zint), &vno); return vno; } -static int cf_lookup_hash (CFile cf, int no) +static zint cf_lookup_hash (CFile cf, zint no) { int hno = cf_hash (cf, no); struct CFile_hash_bucket *hb; - int block_no, i; + zint block_no; + int i; for (hb = cf->parray[hno]; hb; hb = hb->h_next) { @@ -310,22 +312,23 @@ static int cf_lookup_hash (CFile cf, int no) return 0; } -static void cf_write_flat (CFile cf, int no, int vno) +static void cf_write_flat (CFile cf, zint no, zint vno) { - int hno = (no*sizeof(int))/HASH_BSIZE; - int off = (no*sizeof(int)) - hno*HASH_BSIZE; + zint hno = (no*sizeof(zint))/HASH_BSIZE; + int off = (int) ((no*sizeof(zint)) - hno*HASH_BSIZE); hno += cf->head.next_bucket; if (hno >= cf->head.flat_bucket) cf->head.flat_bucket = hno+1; cf->dirty = 1; - mf_write (cf->hash_mf, hno, off, sizeof(int), &vno); + mf_write (cf->hash_mf, hno, off, sizeof(zint), &vno); } static void cf_moveto_flat (CFile cf) { struct CFile_hash_bucket *p; - int i, j; + int j; + zint i; logf (LOG_DEBUG, "cf: Moving to flat shadow: %s", cf->rmf->name); logf (LOG_DEBUG, "cf: hits=%d miss=%d bucket_in_memory=" ZINT_FORMAT " total=" @@ -355,27 +358,28 @@ static void cf_moveto_flat (CFile cf) cf->dirty = 1; } -static int cf_lookup (CFile cf, int no) +static zint cf_lookup (CFile cf, zint no) { if (cf->head.state > 1) return cf_lookup_flat (cf, no); return cf_lookup_hash (cf, no); } -static int cf_new_flat (CFile cf, int no) +static zint cf_new_flat (CFile cf, zint no) { - int vno = (cf->head.next_block)++; + zint vno = (cf->head.next_block)++; cf_write_flat (cf, no, vno); return vno; } -static int cf_new_hash (CFile cf, int no) +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]; - int *bucketpp = &cf->array[hno]; - int i, vno = (cf->head.next_block)++; + 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]) @@ -434,7 +438,7 @@ static int cf_new_hash (CFile cf, int no) return vno; } -int cf_new (CFile cf, int no) +zint cf_new (CFile cf, zint no) { if (cf->head.state > 1) return cf_new_flat (cf, no); @@ -450,7 +454,7 @@ int cf_new (CFile cf, int no) int cf_read (CFile cf, zint no, int offset, int nbytes, void *buf) { - int block; + zint block; assert (cf); zebra_mutex_lock (&cf->mutex); @@ -470,7 +474,7 @@ int cf_read (CFile cf, zint no, int offset, int nbytes, void *buf) int cf_write (CFile cf, zint no, int offset, int nbytes, const void *buf) { - int block; + zint block; assert (cf); zebra_mutex_lock (&cf->mutex); diff --git a/bfile/cfile.h b/bfile/cfile.h index 5b88209..f50ba1b 100644 --- a/bfile/cfile.h +++ b/bfile/cfile.h @@ -1,4 +1,4 @@ -/* $Id: cfile.h,v 1.15 2004-08-04 08:35:22 adam Exp $ +/* $Id: cfile.h,v 1.16 2004-08-06 12:28:22 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -32,10 +32,10 @@ YAZ_BEGIN_CDECL #define HASH_BUCKET 15 struct CFile_ph_bucket { /* structure on disc */ - int no[HASH_BUCKET]; /* block number in original file */ - int vno[HASH_BUCKET]; /* block number in shadow file */ - int this_bucket; /* this bucket number */ - int next_bucket; /* next bucket number */ + zint no[HASH_BUCKET]; /* block number in original file */ + zint vno[HASH_BUCKET]; /* block number in shadow file */ + zint this_bucket; /* this bucket number */ + zint next_bucket; /* next bucket number */ }; struct CFile_hash_bucket { @@ -62,7 +62,7 @@ typedef struct CFile_struct } head; MFile block_mf; MFile hash_mf; - int *array; + zint *array; struct CFile_hash_bucket **parray; struct CFile_hash_bucket *bucket_lru_front, *bucket_lru_back; int dirty; diff --git a/bfile/commit.c b/bfile/commit.c index 875a27d..29a7312 100644 --- a/bfile/commit.c +++ b/bfile/commit.c @@ -1,4 +1,4 @@ -/* $Id: commit.c,v 1.17 2004-08-04 08:35:22 adam Exp $ +/* $Id: commit.c,v 1.18 2004-08-06 12:28:22 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -137,7 +137,8 @@ static void map_cache_add (struct map_cache *m_p, int from, int to) static void cf_commit_hash (CFile cf) { - int i, bucket_no; + int i; + zint bucket_no; int hash_bytes; struct CFile_ph_bucket *p; #if CF_OPTIMIZE_COMMIT @@ -149,7 +150,7 @@ static void cf_commit_hash (CFile cf) #endif p = (struct CFile_ph_bucket *) xmalloc (sizeof(*p)); - hash_bytes = cf->head.hash_size * sizeof(int); + hash_bytes = cf->head.hash_size * sizeof(zint); bucket_no = cf->head.first_bucket; for (; bucket_no < cf->head.next_bucket; bucket_no++) { @@ -181,7 +182,7 @@ static void cf_commit_hash (CFile cf) static void cf_commit_flat (CFile cf) { zint *fp; - int hno; + zint hno; int i; zint vno = 0; diff --git a/bfile/mfile.c b/bfile/mfile.c index a96820a..9ea9201 100644 --- a/bfile/mfile.c +++ b/bfile/mfile.c @@ -1,4 +1,4 @@ -/* $Id: mfile.c,v 1.53 2004-08-04 08:35:22 adam Exp $ +/* $Id: mfile.c,v 1.54 2004-08-06 12:28:22 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 Index Data Aps @@ -132,9 +132,10 @@ static int scan_areadef(MFile_area ma, const char *ad, const char *base) return 0; } -static int file_position(MFile mf, int pos, int offset) +static zint file_position(MFile mf, zint pos, int offset) { - int off = 0, c = mf->cur_file, ps; + zint off = 0, ps; + int c = mf->cur_file; if ((c > 0 && pos <= mf->files[c-1].top) || (c < mf->no_files -1 && pos > mf->files[c].top)) @@ -167,7 +168,7 @@ static int file_position(MFile mf, int pos, int offset) SEEK_SET) < 0) { logf (LOG_WARN|LOG_ERRNO, "Failed to seek in %s", mf->files[c].path); - logf(LOG_WARN, "pos=%d off=%d blocksize=%d offset=%d", + logf(LOG_WARN, "pos=" ZINT_FORMAT " off=" ZINT_FORMAT " blocksize=%d offset=%d", pos, off, mf->blocksize, offset); return -1; } @@ -177,7 +178,12 @@ static int file_position(MFile mf, int pos, int offset) static int cmp_part_file(const void *p1, const void *p2) { - return ((part_file *)p1)->number - ((part_file *)p2)->number; + zint d = ((part_file *)p1)->number - ((part_file *)p2)->number; + if (d > 0) + return 1; + if (d < 0) + return -1; + return 0; } /* @@ -453,7 +459,8 @@ int mf_close(MFile mf) */ int mf_read(MFile mf, zint no, int offset, int nbytes, void *buf) { - int rd, toread; + zint rd; + int toread; zebra_mutex_lock (&mf->mutex); if ((rd = file_position(mf, no, offset)) < 0) @@ -488,7 +495,9 @@ int mf_read(MFile mf, zint no, int offset, int nbytes, void *buf) */ int mf_write(MFile mf, zint no, int offset, int nbytes, const void *buf) { - int ps, nblocks, towrite; + zint ps; + zint nblocks; + int towrite; mf_dir *dp; char tmp[FILENAME_MAX+1]; unsigned char dummych = '\xff'; diff --git a/include/isam-codec.h b/include/isam-codec.h index c7c6dc9..117c403 100644 --- a/include/isam-codec.h +++ b/include/isam-codec.h @@ -1,4 +1,4 @@ -/* $Id: isam-codec.h,v 1.1 2004-08-04 08:35:23 adam Exp $ +/* $Id: isam-codec.h,v 1.2 2004-08-06 12:28:22 adam Exp $ Copyright (C) 2004 Index Data Aps @@ -24,7 +24,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #define ISAM_CODEC_H typedef struct { - void *(*start)(void); + void *(*start)(); void (*stop)(void *p); void (*decode)(void *p, char **dst, const char **src); void (*encode)(void *p, char **dst, const char **src); diff --git a/include/recctrl.h b/include/recctrl.h index 3f345a9..3a32935 100644 --- a/include/recctrl.h +++ b/include/recctrl.h @@ -1,4 +1,4 @@ -/* $Id: recctrl.h,v 1.40 2002-10-22 12:51:08 adam Exp $ +/* $Id: recctrl.h,v 1.41 2004-08-06 12:28:22 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -79,7 +79,7 @@ struct recRetrieveCtrl { oid_value input_format; /* Preferred record syntax */ Z_RecordComposition *comp; /* formatting instructions */ char *encoding; /* preferred character encoding */ - int localno; /* local id of record */ + zint localno; /* local id of record */ int score; /* score 0-1000 or -1 if none */ int recordSize; /* size of record in bytes */ char *fname; /* name of file (or NULL if internal) */ diff --git a/include/rset.h b/include/rset.h index 079acb2..b6da795 100644 --- a/include/rset.h +++ b/include/rset.h @@ -1,4 +1,4 @@ -/* $Id: rset.h,v 1.26 2004-08-06 10:09:27 heikki Exp $ +/* $Id: rset.h,v 1.27 2004-08-06 12:28:22 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -59,7 +59,7 @@ void rset_default_pos(RSFD rfd, double *current, double *total); struct rset_term { char *name; - int nn; + zint nn; char *flags; int count; int type; diff --git a/include/zebraver.h b/include/zebraver.h index 9f49208..e6a749a 100644 --- a/include/zebraver.h +++ b/include/zebraver.h @@ -1,4 +1,4 @@ -/* $Id: zebraver.h,v 1.39 2004-08-04 08:35:23 adam Exp $ +/* $Id: zebraver.h,v 1.40 2004-08-06 12:28:22 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -24,7 +24,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #define ZEBRAVER "1.4.0" -#define ZEBRADATE "$Date: 2004-08-04 08:35:23 $" +#define ZEBRADATE "$Date: 2004-08-06 12:28:22 $" #ifdef __GNUC__ typedef long long int zint; @@ -33,9 +33,8 @@ typedef long long int zint; #else #ifdef WIN32 typedef __int64 zint; -#define ZINT_FORMAT "%lld" -#define ZINT_FORMAT0 "lld" -#error must define ZINT_FORMAT on Windows +#define ZINT_FORMAT "%I64d" +#define ZINT_FORMAT0 "I64d" #else typedef long zint; #define ZINT_FORMAT "%ld" diff --git a/index/invstat.c b/index/invstat.c index 7443538..a29be66 100644 --- a/index/invstat.c +++ b/index/invstat.c @@ -1,4 +1,4 @@ -/* $Id: invstat.c,v 1.36 2004-08-04 08:35:23 adam Exp $ +/* $Id: invstat.c,v 1.37 2004-08-06 12:28:22 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -29,7 +29,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA struct inv_stat_info { ZebraHandle zh; - int no_isam_entries[9]; + zint no_isam_entries[9]; int no_dict_entries; int no_dict_bytes; int isam_bounds[20]; @@ -45,7 +45,7 @@ struct inv_stat_info { #define SINGLETON_TYPE 8 /* the type to use for singletons that */ /* have no block and no block type */ -static void print_dict_item (ZebraMaps zm, const char *s, int count, +static void print_dict_item (ZebraMaps zm, const char *s, zint count, int firstsys, int firstseq, int lastsys, int lastseq ) { int reg_type = s[1]; @@ -71,7 +71,7 @@ static void print_dict_item (ZebraMaps zm, const char *s, int count, static int inv_stat_handle (char *name, const char *info, int pos, void *client) { - int occur = 0; + zint occur = 0; int i = 0; struct inv_stat_info *stat_info = (struct inv_stat_info*) client; ISAMS_P isam_p; @@ -118,7 +118,7 @@ static int inv_stat_handle (char *name, const char *info, int pos, { ISPT ispt; - ispt = is_position (stat_info->zh->reg->isam, isam_p); + ispt = is_position (stat_info->zh->reg->isam, (int) isam_p); occur = is_numkeys (ispt); stat_info->no_isam_entries[is_type(isam_p)] += occur; is_pt_free (ispt); @@ -126,7 +126,7 @@ static int inv_stat_handle (char *name, const char *info, int pos, if (stat_info->zh->reg->isamc) { ISAMC_PP pp; - int occurx = 0; + zint occurx = 0; struct it_key key; pp = isc_pp_open (stat_info->zh->reg->isamc, isam_p); @@ -155,7 +155,7 @@ static int inv_stat_handle (char *name, const char *info, int pos, { ISAMB_PP pp; struct it_key key; - int cat = isam_p & 3; + int cat = (int) (isam_p & 3); int level; int size; int blocks; @@ -200,7 +200,7 @@ int zebra_register_statistics (ZebraHandle zh, int dumpdict) { int i, prev; int before = 0; - int occur; + zint occur; int after = 1000000000; struct inv_stat_info stat_info; char term_dict[2*IT_MAX_WORD+2]; diff --git a/index/kcompare.c b/index/kcompare.c index bb4fd08..b1d8e93 100644 --- a/index/kcompare.c +++ b/index/kcompare.c @@ -1,4 +1,4 @@ -/* $Id: kcompare.c,v 1.49 2004-08-06 09:37:37 adam Exp $ +/* $Id: kcompare.c,v 1.50 2004-08-06 12:28:22 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -167,7 +167,7 @@ int key_get_seq(const void *p) struct it_key k; memcpy (&k, p, sizeof(k)); #if IT_KEY_NEW - return k.mem[k.len-1]; + return (int) k.mem[k.len-1]; #else return k.seqno; #endif @@ -237,10 +237,10 @@ static CODEC_INLINE void iscz1_encode_int (zint d, char **dst) while (d > 127) { - *bp++ = 128 | (d & 127); + *bp++ = (unsigned) (128 | (d & 127)); d = d >> 7; } - *bp++ = d; + *bp++ = (unsigned) d; *dst = (char *) bp; } @@ -394,7 +394,7 @@ void iscz1_decode (void *vp, char **dst, const char **src) #endif #if IT_KEY_NEW - int leader = iscz1_decode_int ((unsigned char **) src); + int leader = (int) iscz1_decode_int ((unsigned char **) src); i = leader & 7; if (leader & 64) p->key.mem[i] += iscz1_decode_int ((unsigned char **) src); diff --git a/index/recindex.c b/index/recindex.c index 0f19b21..64eea73 100644 --- a/index/recindex.c +++ b/index/recindex.c @@ -1,4 +1,4 @@ -/* $Id: recindex.c,v 1.35 2004-08-04 08:35:23 adam Exp $ +/* $Id: recindex.c,v 1.36 2004-08-06 12:28:22 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -77,7 +77,7 @@ static int read_indx (Records p, SYSNO sysno, void *buf, int itemsize, int r; zint pos = (sysno-1)*itemsize; - r = bf_read (p->index_BFile, 1+pos/128, pos%128, itemsize, buf); + r = bf_read (p->index_BFile, 1+pos/128, (int) (pos%128), itemsize, buf); if (r != 1 && !ignoreError) { logf (LOG_FATAL|LOG_ERRNO, "read in %s at pos %ld", @@ -91,7 +91,7 @@ static void write_indx (Records p, SYSNO sysno, void *buf, int itemsize) { zint pos = (sysno-1)*itemsize; - bf_write (p->index_BFile, 1+pos/128, pos%128, itemsize, buf); + bf_write (p->index_BFile, 1+pos/128, (int) (pos%128), itemsize, buf); } static void rec_release_blocks (Records p, SYSNO sysno) @@ -107,7 +107,7 @@ static void rec_release_blocks (Records p, SYSNO sysno) freeblock = entry.next; assert (freeblock > 0); - dst_type = freeblock & 7; + dst_type = (int) (freeblock & 7); assert (dst_type < REC_BLOCK_TYPES); freeblock = freeblock / 8; while (freeblock) @@ -340,11 +340,11 @@ static void rec_encode_zint (zint n, unsigned char *buf, int *len) (*len) = 0; while (n > 127) { - buf[*len] = 128 + (n & 127); + buf[*len] = (unsigned) (128 + (n & 127)); n = n >> 7; (*len)++; } - buf[*len] = n; + buf[*len] = (unsigned) n; (*len)++; } @@ -624,7 +624,7 @@ static Record rec_get_int (Records p, SYSNO sysno) if (!entry.size) return NULL; /* record is deleted */ - dst_type = entry.next & 7; + dst_type = (int) (entry.next & 7); assert (dst_type < REC_BLOCK_TYPES); freeblock = entry.next / 8; diff --git a/index/recindxp.h b/index/recindxp.h index 1e4da12..3fc695d 100644 --- a/index/recindxp.h +++ b/index/recindxp.h @@ -1,4 +1,4 @@ -/* $Id: recindxp.h,v 1.13 2004-08-04 08:35:23 adam Exp $ +/* $Id: recindxp.h,v 1.14 2004-08-06 12:28:22 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -53,7 +53,7 @@ struct records_info { struct records_head { char magic[8]; char version[4]; - zint block_size[REC_BLOCK_TYPES]; + int block_size[REC_BLOCK_TYPES]; zint block_free[REC_BLOCK_TYPES]; zint block_last[REC_BLOCK_TYPES]; zint block_used[REC_BLOCK_TYPES]; diff --git a/index/trunc.c b/index/trunc.c index c166c94..47bcdf1 100644 --- a/index/trunc.c +++ b/index/trunc.c @@ -1,4 +1,4 @@ -/* $Id: trunc.c,v 1.29 2004-08-04 08:35:23 adam Exp $ +/* $Id: trunc.c,v 1.30 2004-08-06 12:28:22 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -439,7 +439,11 @@ static int isams_trunc_cmp (const void *p1, const void *p2) ISAMS_P i1 = *(ISAMS_P*) p1; ISAMS_P i2 = *(ISAMS_P*) p2; - return i1 - i2; + if (i1 > i2) + return 1; + if (i1 < i2) + return -1; + return 0; } static int isam_trunc_cmp (const void *p1, const void *p2) @@ -460,10 +464,15 @@ static int isamc_trunc_cmp (const void *p1, const void *p2) ISAMC_P i2 = *(ISAMC_P*) p2; int d; - d = isc_type (i1) - isc_type (i2); + d = (int) (isc_type (i1) - isc_type (i2)); if (d) return d; - return isc_block (i1) - isc_block (i2); + d = isc_block (i1) - isc_block (i2); + if (d > 0) + return 1; + else if (d < 0) + return -1; + return 0; } RSET rset_trunc (ZebraHandle zi, ISAMS_P *isam_p, int no, diff --git a/index/zvrank.c b/index/zvrank.c index 4322dda..061f3ad 100644 --- a/index/zvrank.c +++ b/index/zvrank.c @@ -1,4 +1,4 @@ -/* $Id: zvrank.c,v 1.8 2004-08-04 08:35:24 adam Exp $ +/* $Id: zvrank.c,v 1.9 2004-08-06 12:28:22 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 Index Data Aps @@ -131,7 +131,7 @@ struct ts_info { /* term info */ char *name; int *id; /**/ - int gocc; + zint gocc; int locc; double tf; double idf; @@ -267,7 +267,7 @@ static void idf_none(void *rsi, void *dsi) { static void idf_tfidf(void *rsi, void *dsi) { RS rs=(RS)rsi; DS ds=(DS)dsi; - int num_docs, gocc; + zint num_docs, gocc; int i, veclen; double idf; /* normal tfidf weight */ @@ -278,7 +278,7 @@ static void idf_tfidf(void *rsi, void *dsi) { if (gocc==0) idf=0.0; else - idf=blog(num_docs/gocc); + idf=blog((double) (num_docs/gocc)); ds->terms[i].idf=idf; } return; @@ -287,7 +287,7 @@ static void idf_tfidf(void *rsi, void *dsi) { static void idf_prob(void *rsi, void *dsi) { RS rs=(RS)rsi; DS ds=(DS)dsi; - int num_docs, gocc; + zint num_docs, gocc; int i, veclen; double idf; /* probabilistic formulation */ @@ -298,7 +298,7 @@ static void idf_prob(void *rsi, void *dsi) { if (gocc==0) idf=0.0; else - idf=blog((num_docs-gocc)/gocc); + idf=blog((double) ((num_docs-gocc)/gocc)); ds->terms[i].idf=idf; } return; @@ -326,7 +326,7 @@ static void idf_freq(void *rsi, void *dsi) { static void idf_squared(void *rsi, void *dsi) { RS rs=(RS)rsi; DS ds=(DS)dsi; - int num_docs, gocc; + zint num_docs, gocc; int i, veclen; double idf; /* idf ^ 2 */ @@ -689,7 +689,8 @@ static void *zv_begin(struct zebra_register *reg, void *class_handle, RSET rset) struct rs_info *rs=(struct rs_info *)xmalloc(sizeof(*rs)); struct rank_class_info *ci=(struct rank_class_info *)class_handle; int i; - int veclen, gocc; + int veclen; + zint gocc; /**/ yaz_log(LOG_DEBUG, "zv_begin"); veclen=rset->no_rset_terms; /* smaller vector here */ @@ -775,11 +776,11 @@ static int zv_calc (void *rsi, zint sysno) (*rs->d_norm_fct)(rs, rs->rdoc); dscore=rs->sim_fct(rs->qdoc, rs->rdoc); } - score = dscore * 1000; + score = (int) dscore * 1000; yaz_log (LOG_LOG, "sysno=" ZINT_FORMAT " score=%d", sysno, score); if (score > 1000) /* should not happen */ score = 1000; - return score; + return (int) score; } /* diff --git a/isamb/isamb.c b/isamb/isamb.c index 8ddb9c7..bf29085 100644 --- a/isamb/isamb.c +++ b/isamb/isamb.c @@ -1,4 +1,4 @@ -/* $Id: isamb.c,v 1.51 2004-08-06 10:09:27 heikki Exp $ +/* $Id: isamb.c,v 1.52 2004-08-06 12:28:23 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -235,11 +235,11 @@ static void flush_blocks (ISAMB b, int cat) static int get_block (ISAMB b, ISAMC_P pos, char *userbuf, int wr) { - int cat = pos&CAT_MASK; - int off = ((pos/CAT_MAX) & + int cat = (int) (pos&CAT_MASK); + int off = (int) (((pos/CAT_MAX) & (ISAMB_CACHE_ENTRY_SIZE / b->file[cat].head.block_size - 1)) - * b->file[cat].head.block_size; - int norm = pos / (CAT_MASK*ISAMB_CACHE_ENTRY_SIZE / b->file[cat].head.block_size); + * b->file[cat].head.block_size); + zint norm = pos / (CAT_MASK*ISAMB_CACHE_ENTRY_SIZE / b->file[cat].head.block_size); int no = 0; struct ISAMB_cache_entry **ce, *ce_this = 0, **ce_last = 0; @@ -330,13 +330,13 @@ void isamb_close (ISAMB isamb) static struct ISAMB_block *open_block (ISAMB b, ISAMC_P pos) { - int cat = pos&CAT_MASK; + int cat = (int) (pos&CAT_MASK); struct ISAMB_block *p; if (!pos) return 0; p = xmalloc (sizeof(*p)); p->pos = pos; - p->cat = pos & CAT_MASK; + p->cat = (int) (pos & CAT_MASK); p->buf = xmalloc (b->file[cat].head.block_size); p->cbuf = 0; @@ -376,7 +376,7 @@ struct ISAMB_block *new_block (ISAMB b, int leaf, int cat) if (!b->file[cat].head.free_list) { - int block_no; + zint block_no; block_no = b->file[cat].head.last_block++; p->pos = block_no * CAT_MAX + cat; } @@ -579,7 +579,7 @@ int insert_int (ISAMB b, struct ISAMB_block *p, void *lookahead_item, while (src <= half) { decode_ptr (&src, &split_size_tmp); - *split_size = split_size_tmp; + *split_size = (int) split_size_tmp; src += *split_size; decode_ptr (&src, &pos); @@ -588,7 +588,7 @@ int insert_int (ISAMB b, struct ISAMB_block *p, void *lookahead_item, memcpy (p->bytes, dst_buf, p_new_size); decode_ptr (&src, &split_size_tmp); - *split_size = split_size_tmp; + *split_size = (int) split_size_tmp; memcpy (split_item, src, *split_size); src += *split_size; @@ -1074,7 +1074,7 @@ static void isamb_dump_r (ISAMB b, ISAMB_P pos, void (*pr)(const char *str), void isamb_dump (ISAMB b, ISAMB_P pos, void (*pr)(const char *str)) { - return isamb_dump_r(b, pos, pr, 0); + isamb_dump_r(b, pos, pr, 0); } #if 0 @@ -1310,7 +1310,7 @@ static int isamb_pp_climb_level(ISAMB_PP pp, ISAMB_P *pos) } /* climb_level */ -static int isamb_pp_forward_unode(ISAMB_PP pp, int pos, const void *untilbuf) +static zint isamb_pp_forward_unode(ISAMB_PP pp, zint pos, const void *untilbuf) { /* scans a upper node until it finds a child <= untilbuf */ /* pp points to the key value, as always. pos is the child read from */ /* the buffer */ @@ -1867,7 +1867,7 @@ static void isamb_pp_upper_pos( ISAMB_PP pp, double *current, double *total, decode_ptr (&src, &child ); } if (level>0) - isamb_pp_upper_pos(pp, current, total, *total, level-1); + isamb_pp_upper_pos(pp, current, total, (zint) *total, level-1); } /* upper_pos */ void isamb_pp_pos( ISAMB_PP pp, double *current, double *total ) @@ -1880,5 +1880,5 @@ void isamb_pp_pos( ISAMB_PP pp, double *current, double *total ) assert(p->leaf); isamb_pp_leaf_pos(pp,current, total, dummy); if (pp->level>0) - isamb_pp_upper_pos(pp, current, total, *total, pp->level-1); + isamb_pp_upper_pos(pp, current, total, (zint) *total, pp->level-1); } diff --git a/isamc/isamc-p.h b/isamc/isamc-p.h index 02d212a..65f559c 100644 --- a/isamc/isamc-p.h +++ b/isamc/isamc-p.h @@ -1,4 +1,4 @@ -/* $Id: isamc-p.h,v 1.10 2004-08-04 08:35:24 adam Exp $ +/* $Id: isamc-p.h,v 1.11 2004-08-06 12:28:23 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -48,8 +48,8 @@ typedef struct ISAMC_file_s { int no_forward; int no_backward; - int sum_forward; - int sum_backward; + zint sum_forward; + zint sum_backward; int no_next; int no_prev; @@ -58,7 +58,7 @@ typedef struct ISAMC_file_s { int alloc_entries_max; int fc_max; - int *fc_list; + zint *fc_list; } *ISAMC_file; struct ISAMC_s { diff --git a/isamc/isamc.c b/isamc/isamc.c index 0a0d53c..d15ba1e 100644 --- a/isamc/isamc.c +++ b/isamc/isamc.c @@ -1,4 +1,4 @@ -/* $Id: isamc.c,v 1.25 2004-08-04 08:35:24 adam Exp $ +/* $Id: isamc.c,v 1.26 2004-08-06 12:28:23 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -420,7 +420,7 @@ static void init_fc (ISAMC is, int cat) int j = 100; is->files[cat].fc_max = j; - is->files[cat].fc_list = (int *) + is->files[cat].fc_list = (zint *) xmalloc (sizeof(*is->files[0].fc_list) * j); while (--j >= 0) is->files[cat].fc_list[j] = 0; @@ -428,7 +428,8 @@ static void init_fc (ISAMC is, int cat) static void release_fc (ISAMC is, int cat) { - int b, j = is->files[cat].fc_max; + int j = is->files[cat].fc_max; + zint b; while (--j >= 0) if ((b = is->files[cat].fc_list[j])) @@ -452,7 +453,7 @@ ISAMC_PP isc_pp_open (ISAMC is, ISAMC_P ipos) ISAMC_PP pp = (ISAMC_PP) xmalloc (sizeof(*pp)); char *src; - pp->cat = isc_type(ipos); + pp->cat = (int) isc_type(ipos); pp->pos = isc_block(ipos); src = pp->buf = (char *) xmalloc (is->method->filecat[pp->cat].bsize); diff --git a/isamc/merge.c b/isamc/merge.c index 5b5669f..9f010c5 100644 --- a/isamc/merge.c +++ b/isamc/merge.c @@ -1,4 +1,4 @@ -/* $Id: merge.c,v 1.24 2004-08-04 08:35:24 adam Exp $ +/* $Id: merge.c,v 1.25 2004-08-06 12:28:23 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -135,8 +135,8 @@ static void flush_blocks (ISAMC is, struct isc_merge_block *mb, int ptr, } } -static int get_border (ISAMC is, struct isc_merge_block *mb, int ptr, - int cat, int firstpos) +static int get_border (ISAMC is, struct isc_merge_block *mb, zint ptr, + int cat, zint firstpos) { /* Border set to initial fill or block size depending on whether we are creating a new one or updating and old one. @@ -172,7 +172,7 @@ ISAMC_P isc_merge (ISAMC is, ISAMC_P ipos, ISAMC_I *data) int r_offset = 0; /* current offset in r_buf */ int ptr = 0; /* pointer */ void *r_clientData; /* encode client data */ - int border; + zint border; zint numKeys = 0; r_clientData = (*is->method->codec.start)(); diff --git a/rset/rsbool.c b/rset/rsbool.c index 0289566..ec3831d 100644 --- a/rset/rsbool.c +++ b/rset/rsbool.c @@ -1,4 +1,4 @@ -/* $Id: rsbool.c,v 1.35 2004-08-06 10:09:28 heikki Exp $ +/* $Id: rsbool.c,v 1.36 2004-08-06 12:28:23 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -595,7 +595,7 @@ static void r_pos (RSFD rfd, double *current, double *total) return; } r=1.0*(lcur+rcur)/(ltot+rtot); /* weighed average of l and r */ - *current=p->hits; + *current=(double) (p->hits); *total=*current/r ; #if RSET_DEBUG yaz_log(LOG_DEBUG,"bool_pos: (%s/%s) %0.1f/%0.1f= %0.4f ", diff --git a/rset/rstemp.c b/rset/rstemp.c index 8971b49..0df8f16 100644 --- a/rset/rstemp.c +++ b/rset/rstemp.c @@ -1,4 +1,4 @@ -/* $Id: rstemp.c,v 1.40 2004-08-06 10:09:28 heikki Exp $ +/* $Id: rstemp.c,v 1.41 2004-08-06 12:28:23 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 Index Data Aps @@ -374,6 +374,6 @@ static int r_write (RSFD rfd, const void *buf) static void r_pos (RSFD rfd, double *current, double *total) { struct rset_temp_rfd *mrfd = (struct rset_temp_rfd*) rfd; - *current=mrfd->cur; - *total=mrfd->info->hits; + *current=(double) mrfd->cur; + *total=(double) mrfd->info->hits; } -- 1.7.10.4