X-Git-Url: http://lists.indexdata.com/cgi-bin?a=blobdiff_plain;f=index%2Fkcompare.c;h=f39b750989882ad548f88d95821e87ee74add261;hb=81a75ae20b5b250309a70de51bfdf8de0019f882;hp=39ee8536a4b754ea05a0687ca3f3499eea517537;hpb=e8f4cf34c75ffdc7bbfaf3fa232f29cc1384b60c;p=idzebra-moved-to-github.git diff --git a/index/kcompare.c b/index/kcompare.c index 39ee853..f39b750 100644 --- a/index/kcompare.c +++ b/index/kcompare.c @@ -201,22 +201,6 @@ static void iscz1_code_item (int mode, void *vp, char **dst, char **src) } } -ISAMC_M key_isamc_m (Res res, ISAMC_M me) -{ - isc_getmethod (me); - - me->compare_item = key_compare; - - me->code_start = iscz1_code_start; - me->code_item = iscz1_code_item; - me->code_stop = iscz1_code_stop; - me->code_reset = iscz1_code_reset; - - me->debug = atoi(res_get_def (res, "isamcDebug", "0")); - - return me; -} - ISAMS_M key_isams_m (Res res, ISAMS_M me) { isams_getmethod (me); @@ -232,14 +216,9 @@ ISAMS_M key_isams_m (Res res, ISAMS_M me) return me; } -ISAMH_M key_isamh_m (Res res) +ISAMC_M key_isamc_m (Res res, ISAMC_M me) { - static ISAMH_M me = NULL; - - if (me) - return me; - - me = isamh_getmethod (); + isc_getmethod (me); me->compare_item = key_compare; @@ -248,7 +227,7 @@ ISAMH_M key_isamh_m (Res res) me->code_stop = iscz1_code_stop; me->code_reset = iscz1_code_reset; - me->debug = atoi(res_get_def (res, "isamhDebug", "9")); + me->debug = atoi(res_get_def (res, "isamcDebug", "0")); return me; } @@ -270,25 +249,60 @@ ISAMD_M key_isamd_m (Res res,ISAMD_M me) return me; } - -int key_SU_code (int ch, char *out) +int key_SU_encode (int ch, char *out) { int i; for (i = 0; ch; i++) { - if (ch > 63) - out[i] = 128 + (ch & 63); + if (ch >= 64) + out[i] = 65 + (ch & 63); else out[i] = 1 + ch; ch = ch >> 6; } return i; + /* in out + 0 1 + 1 2 + 63 64 + 64 65, 2 + 65 66, 2 + 127 128, 2 + 128 65, 3 + 191 128, 3 + 192 65, 4 + */ } +int key_SU_decode (int *ch, const unsigned char *out) +{ + int len = 1; + int fact = 1; + *ch = 0; + for (len = 1; *out >= 65; len++, out++) + { + *ch += (*out - 65) * fact; + fact <<= 6; + } + *ch += (*out - 1) * fact; + return len; +} /* * $Log: kcompare.c,v $ - * Revision 1.34 1999-07-14 13:21:34 heikki + * Revision 1.38 2002-04-05 08:46:26 adam + * Zebra with full functionality + * + * Revision 1.37 2001/11/19 23:08:30 adam + * Added const qualifier for name parameter of key_SU_decode. + * + * Revision 1.36 2001/10/15 19:53:43 adam + * POSIX thread updates. First work on term sets. + * + * Revision 1.35 1999/11/30 13:48:03 adam + * Improved installation. Updated for inclusion of YAZ header files. + * + * Revision 1.34 1999/07/14 13:21:34 heikki * Added isam-d files. Compiles (almost) clean. Doesn't work at all * * Revision 1.33 1999/07/14 10:59:26 adam