The public functions simply use char instead of Dict_char to represent
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 2 Feb 1996 13:43:50 +0000 (13:43 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 2 Feb 1996 13:43:50 +0000 (13:43 +0000)
search strings. Dict_char is used internally only.

dict/delete.c
dict/dicttest.c
dict/insert.c
dict/lookgrep.c
dict/lookup.c
dict/lookupec.c
dict/open.c
dict/scan.c
include/dict.h

index e5be225..cb9d64d 100644 (file)
@@ -4,7 +4,11 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: delete.c,v $
- * Revision 1.3  1995-12-07 11:48:55  adam
+ * Revision 1.4  1996-02-02 13:43:50  adam
+ * The public functions simply use char instead of Dict_char to represent
+ * search strings. Dict_char is used internally only.
+ *
+ * Revision 1.3  1995/12/07  11:48:55  adam
  * Insert operation obeys DICT_type = 1 (slack in page).
  * Function dict_open exists if page size or magic aren't right.
  *
@@ -108,9 +112,9 @@ static int dict_del (Dict dict, const Dict_char *str)
     return 0;
 }
 
-int dict_delete (Dict dict, const Dict_char *p)
+int dict_delete (Dict dict, const char *p)
 {
     if (dict->head.last == 1)
         return 0;
-    return dict_del (dict, p);
+    return dict_del (dict, (const Dict_char*) p);
 }
index 5d97bb2..181f14a 100644 (file)
@@ -4,7 +4,11 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: dicttest.c,v $
- * Revision 1.18  1996-02-01 20:39:52  adam
+ * Revision 1.19  1996-02-02 13:43:50  adam
+ * The public functions simply use char instead of Dict_char to represent
+ * search strings. Dict_char is used internally only.
+ *
+ * Revision 1.18  1996/02/01  20:39:52  adam
  * Bug fix: insert didn't work on 8-bit characters due to unsigned char
  * compares in dict_strcmp (strcmp) and signed Dict_char. Dict_char is
  * unsigned now.
@@ -79,7 +83,7 @@ static Dict dict;
 
 static int look_hits;
 
-static int grep_handle (Dict_char *name, const char *info, void *client)
+static int grep_handle (char *name, const char *info, void *client)
 {
     look_hits++;
     printf ("%s\n", name);
index 5ec6d4c..b3b6a47 100644 (file)
@@ -4,7 +4,11 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: insert.c,v $
- * Revision 1.15  1996-02-01 20:39:59  adam
+ * Revision 1.16  1996-02-02 13:43:50  adam
+ * The public functions simply use char instead of Dict_char to represent
+ * search strings. Dict_char is used internally only.
+ *
+ * Revision 1.15  1996/02/01  20:39:59  adam
  * Bug fix: insert didn't work on 8-bit characters due to unsigned char
  * compares in dict_strcmp (strcmp) and signed Dict_char. Dict_char is
  * unsigned now.
@@ -159,7 +163,7 @@ static int split_page (Dict dict, Dict_ptr ptr, void *p)
         /* entry start */
         memcpy (&dc, info, sizeof(dc));
         assert (dc == best_char);
-        slen = dict_strlen(info);
+        slen = dict_strlen((Dict_char*) info);
 
         assert (slen > 0);
         if (slen == 1)
@@ -170,7 +174,8 @@ static int split_page (Dict dict, Dict_ptr ptr, void *p)
         else
         {
             info1 = info+(1+slen)*sizeof(Dict_char);  /* info start */
-            dict_ins (dict, info+sizeof(Dict_char), subptr, *info1, info1+1);
+            dict_ins (dict, (Dict_char*) (info+sizeof(Dict_char)),
+                      subptr, *info1, info1+1);
             dict_bf_readp (dict->dbf, ptr, &p);
         }
     }
@@ -220,7 +225,7 @@ static void clean_page (Dict dict, Dict_ptr ptr, void *p, Dict_char *out,
                 continue;
            }
             *--indxp2 = info2 - np;
-            slen = (dict_strlen(info1)+1)*sizeof(Dict_char);
+            slen = (dict_strlen((Dict_char*) info1)+1)*sizeof(Dict_char);
             memcpy (info2, info1, slen);
            info1 += slen;
             info2 += slen;
@@ -300,7 +305,7 @@ static int dict_ins (Dict dict, const Dict_char *str,
             cmp = dict_strcmp((Dict_char*) info, str);
             if (!cmp)
             {
-                info += (dict_strlen(info)+1)*sizeof(Dict_char);
+                info += (dict_strlen((Dict_char*) info)+1)*sizeof(Dict_char);
                 /* consider change of userinfo length... */
                 if (*info == userlen)
                 {
@@ -468,12 +473,12 @@ static int dict_ins (Dict dict, const Dict_char *str,
     return 1;
 }
 
-int dict_insert (Dict dict, const Dict_char *str, int userlen, void *userinfo)
+int dict_insert (Dict dict, const char *str, int userlen, void *userinfo)
 {
     assert (dict->head.last > 0);
     if (dict->head.last == 1)
-        return dict_ins (dict, str, 0, userlen, userinfo);
+        return dict_ins (dict, (const Dict_char *) str, 0, userlen, userinfo);
     else
-        return dict_ins (dict, str, 1, userlen, userinfo);
+        return dict_ins (dict, (const Dict_char *) str, 1, userlen, userinfo);
 }
 
index 2336970..2fd3533 100644 (file)
@@ -4,7 +4,11 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: lookgrep.c,v $
- * Revision 1.13  1996-01-08 09:09:30  adam
+ * Revision 1.14  1996-02-02 13:43:51  adam
+ * The public functions simply use char instead of Dict_char to represent
+ * search strings. Dict_char is used internally only.
+ *
+ * Revision 1.13  1996/01/08  09:09:30  adam
  * Function dfa_parse got 'const' string argument.
  *
  * Revision 1.12  1995/12/11  09:04:48  adam
@@ -257,7 +261,7 @@ static INLINE int move (MatchContext *mc, MatchWord *Rj1, MatchWord *Rj,
 
 static int dict_grep (Dict dict, Dict_ptr ptr, MatchContext *mc,
                       MatchWord *Rj, int pos, void *client,
-                      int (*userfunc)(Dict_char *, const char *, void *),
+                      int (*userfunc)(char *, const char *, void *),
                       Dict_char *prefix, struct DFA *dfa,
                       int *max_pos)
 {
@@ -295,8 +299,8 @@ static int dict_grep (Dict dict, Dict_ptr ptr, MatchContext *mc,
                 if (ch == DICT_EOS)
                 {
                     if (was_match)
-                        if ((*userfunc)(prefix, info+(j+1)*sizeof(Dict_char),
-                                        client))
+                        if ((*userfunc)((char*) prefix,
+                                        info+(j+1)*sizeof(Dict_char), client))
                             return 1;
                     break;
                 }
@@ -344,7 +348,8 @@ static int dict_grep (Dict dict, Dict_ptr ptr, MatchContext *mc,
                         if (Rj1[mc->range*mc->n + d] & mc->match_mask[d])
                         {
                             prefix[pos+1] = DICT_EOS;
-                            if ((*userfunc)(prefix, info+sizeof(Dict_ptr)+
+                            if ((*userfunc)((char*) prefix,
+                                            info+sizeof(Dict_ptr)+
                                             sizeof(Dict_char), client))
                                 return 1;
                             break;
@@ -367,9 +372,9 @@ static int dict_grep (Dict dict, Dict_ptr ptr, MatchContext *mc,
     return 0;
 }
 
-int dict_lookup_grep (Dict dict, Dict_char *pattern, int range, void *client,
+int dict_lookup_grep (Dict dict, const char *pattern, int range, void *client,
                       int *max_pos,
-                      int (*userfunc)(Dict_char *name, const char *info,
+                      int (*userfunc)(char *name, const char *info,
                                       void *client))
 {
     MatchWord *Rj;
index 46a13c4..01f5ac4 100644 (file)
@@ -4,7 +4,11 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: lookup.c,v $
- * Revision 1.6  1995-12-11 09:04:50  adam
+ * Revision 1.7  1996-02-02 13:43:51  adam
+ * The public functions simply use char instead of Dict_char to represent
+ * search strings. Dict_char is used internally only.
+ *
+ * Revision 1.6  1995/12/11  09:04:50  adam
  * Bug fix: the lookup/scan/lookgrep didn't handle empty dictionary.
  *
  * Revision 1.5  1995/09/04  09:09:15  adam
@@ -55,7 +59,8 @@ static char *dict_look (Dict dict, const Dict_char *str)
             info = (char*)p + indxp[-mid];
             cmp = dict_strcmp((Dict_char*) info, str);
             if (!cmp)
-                return info+(dict_strlen (info)+1)*sizeof(Dict_char);
+                return info+(dict_strlen ((Dict_char*) info)+1)
+                    *sizeof(Dict_char);
         }
         else
         {
@@ -100,11 +105,11 @@ static char *dict_look (Dict dict, const Dict_char *str)
     return NULL;
 }
 
-char *dict_lookup (Dict dict, const Dict_char *p)
+char *dict_lookup (Dict dict, const char *p)
 {
     if (dict->head.last <= 1)
         return NULL;
-    return dict_look (dict, p);
+    return dict_look (dict, (const Dict_char *) p);
 }
 
 
index 95ead81..686aa04 100644 (file)
@@ -4,7 +4,11 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: lookupec.c,v $
- * Revision 1.5  1995-01-24 16:01:03  adam
+ * Revision 1.6  1996-02-02 13:43:51  adam
+ * The public functions simply use char instead of Dict_char to represent
+ * search strings. Dict_char is used internally only.
+ *
+ * Revision 1.5  1995/01/24  16:01:03  adam
  * Added -ansi to CFLAGS.
  * Use new API of dfa module.
  *
@@ -41,8 +45,8 @@ typedef struct {
 #define SH(x) (((x)<<1)+1)
 
 int dict_look_ec (Dict dict, Dict_ptr ptr, MatchInfo *mi, MatchWord *ri_base,
-                  int pos, int (*userfunc)(Dict_char *),
-                  int range, Dict_char *prefix)
+                  int pos, int (*userfunc)(char *), int range,
+                  Dict_char *prefix)
 {
     int lo, hi;
     void *p;
@@ -73,7 +77,7 @@ int dict_look_ec (Dict dict, Dict_ptr ptr, MatchInfo *mi, MatchWord *ri_base,
                 if (ch == DICT_EOS)
                 {
                     if (ri[range] & match_mask)
-                        (*userfunc)(prefix);
+                        (*userfunc)((char*) prefix);
                     break;
                 }
                 if (j+pos >= mi->m+range)
@@ -115,7 +119,7 @@ int dict_look_ec (Dict dict, Dict_ptr ptr, MatchInfo *mi, MatchWord *ri_base,
                     (ri[range] & match_mask))
                 {
                     prefix[pos+1] = DICT_EOS;
-                    (*userfunc)(prefix);
+                    (*userfunc)((char*) prefix);
                 }
                 memcpy (&subptr, info, sizeof(Dict_ptr));
                 if (subptr)
@@ -149,8 +153,8 @@ static MatchInfo *prepare_match (Dict_char *pattern)
     return mi;
 }
 
-int dict_lookup_ec (Dict dict, Dict_char *pattern, int range,
-                    int (*userfunc)(Dict_char *name))
+int dict_lookup_ec (Dict dict, char *pattern, int range,
+                    int (*userfunc)(char *name))
 {
     MatchInfo *mi;
     MatchWord *ri;
@@ -160,9 +164,10 @@ int dict_lookup_ec (Dict dict, Dict_char *pattern, int range,
     if (dict->head.last == 1)
         return 0;
     
-    mi = prepare_match (pattern);
+    mi = prepare_match ((Dict_char*) pattern);
 
-    ri = xmalloc ((dict_strlen(pattern)+range+2)*(range+1)*sizeof(*ri));
+    ri = xmalloc ((dict_strlen((Dict_char*) pattern)+range+2)
+                  * (range+1)*sizeof(*ri));
     for (i=0; i<=range; i++)
         ri[i] = (2<<i)-1;
     
index 95c86ca..aed9054 100644 (file)
@@ -4,7 +4,11 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: open.c,v $
- * Revision 1.8  1995-12-07 11:48:56  adam
+ * Revision 1.9  1996-02-02 13:43:51  adam
+ * The public functions simply use char instead of Dict_char to represent
+ * search strings. Dict_char is used internally only.
+ *
+ * Revision 1.8  1995/12/07  11:48:56  adam
  * Insert operation obeys DICT_type = 1 (slack in page).
  * Function dict_open exists if page size or magic aren't right.
  *
@@ -104,10 +108,10 @@ Dict dict_open (const char *name, int cache, int rw)
 
 int dict_strcmp (const Dict_char *s1, const Dict_char *s2)
 {
-    return strcmp (s1, s2);
+    return strcmp ((const char *) s1, (const char *) s2);
 }
 
 int dict_strlen (const Dict_char *s)
 {
-    return strlen(s);
+    return strlen((const char *) s);
 }
index 01be13e..44ff661 100644 (file)
@@ -4,7 +4,11 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: scan.c,v $
- * Revision 1.7  1995-12-11 09:04:50  adam
+ * Revision 1.8  1996-02-02 13:43:52  adam
+ * The public functions simply use char instead of Dict_char to represent
+ * search strings. Dict_char is used internally only.
+ *
+ * Revision 1.7  1995/12/11  09:04:50  adam
  * Bug fix: the lookup/scan/lookgrep didn't handle empty dictionary.
  *
  * Revision 1.6  1995/11/20  11:58:04  adam
@@ -35,7 +39,7 @@
 
 int dict_scan_trav (Dict dict, Dict_ptr ptr, int pos, Dict_char *str, 
                    int start, int *count, void *client,
-                    int (*userfunc)(Dict_char *, const char *, int, void *),
+                    int (*userfunc)(char *, const char *, int, void *),
                    int dir)
 {
     int lo, hi, j;
@@ -63,8 +67,8 @@ int dict_scan_trav (Dict dict, Dict_ptr ptr, int pos, Dict_char *str,
             for (j = 0; info[j] != DICT_EOS; j++)
                str[pos+j] = info[j];
             str[pos+j] = DICT_EOS;
-            if ((*userfunc)(str, info+(j+1)*sizeof(Dict_char), *count * dir,
-                            client))
+            if ((*userfunc)((char*) str, info+(j+1)*sizeof(Dict_char),
+                            *count * dir, client))
                 return 1;
             --(*count);
         }
@@ -85,7 +89,8 @@ int dict_scan_trav (Dict dict, Dict_ptr ptr, int pos, Dict_char *str,
            if (info[sizeof(Dict_ptr)+sizeof(Dict_char)])
             {
                  str[pos+1] = DICT_EOS;
-                 if ((*userfunc)(str, info+sizeof(Dict_ptr)+sizeof(Dict_char),
+                 if ((*userfunc)((char*) str,
+                                 info+sizeof(Dict_ptr)+sizeof(Dict_char),
                                  *count * dir, client))
                      return 1;
                  --(*count);
@@ -101,7 +106,7 @@ int dict_scan_trav (Dict dict, Dict_ptr ptr, int pos, Dict_char *str,
     
 int dict_scan_r (Dict dict, Dict_ptr ptr, int pos, Dict_char *str, 
                 int *before, int *after, void *client,
-                 int (*userfunc)(Dict_char *, const char *, int, void *))
+                 int (*userfunc)(char *, const char *, int, void *))
 {
     int cmp = 0, mid, lo, hi;
     void *p;
@@ -128,8 +133,9 @@ int dict_scan_r (Dict dict, Dict_ptr ptr, int pos, Dict_char *str,
             {
                 if (*after)
                 {
-                    (*userfunc)(str, info+
-                                (dict_strlen(info)+1)*sizeof(Dict_char), 
+                    (*userfunc)((char *) str, info+
+                                (dict_strlen((Dict_char*) info)+1)
+                                *sizeof(Dict_char), 
                                 *after, client);
                     --(*after);
                 }
@@ -157,7 +163,7 @@ int dict_scan_r (Dict dict, Dict_ptr ptr, int pos, Dict_char *str,
                     {
                         if (*after)
                         {
-                            (*userfunc)(str, 
+                            (*userfunc)((char*) str,
                                         info+sizeof(Dict_ptr)+
                                         sizeof(Dict_char),
                                         *after, client);
@@ -194,13 +200,12 @@ int dict_scan_r (Dict dict, Dict_ptr ptr, int pos, Dict_char *str,
     return 0;
 }
 
-int dict_scan (Dict dict, Dict_char *str, int *before, int *after,
-               void *client,
-               int (*f)(Dict_char *name, const char *info, int pos,
-                        void *client))
+int dict_scan (Dict dict, char *str, int *before, int *after, void *client,
+               int (*f)(char *name, const char *info, int pos, void *client))
 {
     if (dict->head.last <= 1)
         return 0;
-    return dict_scan_r (dict, 1, 0, str, before, after, client, f);
+    return dict_scan_r (dict, 1, 0, (Dict_char *) str, before, after, client,
+                        f);
 }
 
index 2b78d2d..2323ac7 100644 (file)
@@ -4,7 +4,11 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: dict.h,v $
- * Revision 1.18  1996-02-01 20:41:06  adam
+ * Revision 1.19  1996-02-02 13:43:54  adam
+ * The public functions simply use char instead of Dict_char to represent
+ * search strings. Dict_char is used internally only.
+ *
+ * Revision 1.18  1996/02/01  20:41:06  adam
  * Bug fix: insert didn't work on 8-bit characters due to unsigned char
  * compares in dict_strcmp (strcmp) and signed Dict_char. Dict_char is
  * unsigned now.
@@ -127,21 +131,20 @@ int        dict_bf_close (Dict_BFile dbf);
      
 Dict       dict_open (const char *name, int cache, int rw);
 int        dict_close (Dict dict);
-int        dict_insert (Dict dict, const Dict_char *p, int userlen,
-                        void *userinfo);
-int        dict_delete (Dict dict, const Dict_char *p);
-char      *dict_lookup (Dict dict, const Dict_char *p);
-int        dict_lookup_ec (Dict dict, Dict_char *p, int range,
-                           int (*f)(Dict_char *name));
-int        dict_lookup_grep (Dict dict, Dict_char *p, int range, void *client,
+int        dict_insert (Dict dict, const char *p, int userlen, void *userinfo);
+int        dict_delete (Dict dict, const char *p);
+char      *dict_lookup (Dict dict, const char *p);
+int        dict_lookup_ec (Dict dict, char *p, int range,
+                           int (*f)(char *name));
+int        dict_lookup_grep (Dict dict, const char *p, int range, void *client,
                              int *max_pos,
-                             int (*f)(Dict_char *name, const char *info,
+                             int (*f)(char *name, const char *info,
                                       void *client));
 int        dict_strcmp (const Dict_char *s1, const Dict_char *s2);
 int        dict_strlen (const Dict_char *s);
-int       dict_scan (Dict dict, Dict_char *str, 
+int       dict_scan (Dict dict, char *str, 
                      int *before, int *after, void *client,
-                     int (*f)(Dict_char *name, const char *info, int pos,
+                     int (*f)(char *name, const char *info, int pos,
                                void *client));
 
 #define DICT_EOS        0