search strings. Dict_char is used internally only.
* 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.
*
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);
}
* 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.
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);
* 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.
/* 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)
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);
}
}
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;
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)
{
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);
}
* 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
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)
{
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;
}
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;
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;
* 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
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
{
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);
}
* 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.
*
#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;
if (ch == DICT_EOS)
{
if (ri[range] & match_mask)
- (*userfunc)(prefix);
+ (*userfunc)((char*) prefix);
break;
}
if (j+pos >= mi->m+range)
(ri[range] & match_mask))
{
prefix[pos+1] = DICT_EOS;
- (*userfunc)(prefix);
+ (*userfunc)((char*) prefix);
}
memcpy (&subptr, info, sizeof(Dict_ptr));
if (subptr)
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;
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;
* 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.
*
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);
}
* 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
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;
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);
}
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);
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;
{
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);
}
{
if (*after)
{
- (*userfunc)(str,
+ (*userfunc)((char*) str,
info+sizeof(Dict_ptr)+
sizeof(Dict_char),
*after, client);
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);
}
* 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.
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