X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fkcompare.c;h=82f9343f24390b675d612acd23bfba89ef80e180;hb=9fe3bf8d659adc5c0623185779272d933fc51d15;hp=d326493b521ff2fa1136b7bf9b234bdff4b36b11;hpb=ca19a15163ee74ee0c6765bfef4fd9794627e26a;p=idzebra-moved-to-github.git diff --git a/index/kcompare.c b/index/kcompare.c index d326493..82f9343 100644 --- a/index/kcompare.c +++ b/index/kcompare.c @@ -4,7 +4,19 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: kcompare.c,v $ - * Revision 1.8 1995-09-28 09:19:42 adam + * Revision 1.12 1995-10-17 18:02:08 adam + * New feature: databases. Implemented as prefix to words in dictionary. + * + * Revision 1.11 1995/10/06 16:33:37 adam + * Use attribute mappings. + * + * Revision 1.10 1995/09/29 14:01:41 adam + * Bug fixes. + * + * Revision 1.9 1995/09/28 12:10:32 adam + * Bug fixes. Field prefix used in queries. + * + * Revision 1.8 1995/09/28 09:19:42 adam * xfree/xmalloc used everywhere. * Extract/retrieve method seems to work for text records. * @@ -83,7 +95,48 @@ int key_compare (const void *p1, const void *p2) return 0; } +int key_qsort_compare (const void *p1, const void *p2) +{ + int r; + size_t l; + char *cp1 = *(char **) p1; + char *cp2 = *(char **) p2; + + if ((r = strcmp (cp1, cp2))) + return r; + l = strlen(cp1)+1; + if ((r = key_compare (cp1+l+1, cp2+l+1))) + return r; + return cp1[l] - cp2[l]; +} + int index_char_cvt (int c) { return tolower (c); } + +int index_word_prefix (char *string, int attset_ordinal, + int local_attribute, + int num_bases, + char **databaseNames) +{ + int i; + if (num_bases > 1) + { + sprintf (string, "%c%04d(", attset_ordinal + '0', local_attribute); + strcat (string, databaseNames[i]); + for (i = 1; i < num_bases; i++) + { + strcat (string, "|"); + strcat (string, databaseNames[i]); + } + strcat (string, ")@"); + } + else + sprintf (string, "%c%04d%s@", attset_ordinal + '0', local_attribute, + *databaseNames); + for (i = 0; string[i]; i++) + string[i] = index_char_cvt (string[i]); + return i; +} +