Esempio n. 1
0
/* copied from stree library internals */
static LST_Edge *
node_find_edge_with_startitem(LST_Node *node, LST_String *string, u_int index)
{
  LST_Edge *edge = NULL;

  if (!node || !string || index >= string->num_items)
    {
      return NULL;
    }

  for (edge = node->kids.lh_first; edge; edge = edge->siblings.le_next)
    {
      /* Skip this edge if the first characters don't match
       * what we're looking for.
       */
      if (lst_string_eq(edge->range.string, edge->range.start_index,
                        string, index))
        return edge;
    }

  return NULL;
}
Esempio n. 2
0
u_int
lst_string_items_common(LST_String *s1, u_int off1,
			LST_String *s2, u_int off2,
			u_int max_len)
{
  u_int i = 0;
  u_int len;

  if (!s1 || !s2 || off1 >= s1->num_items || off2 >= s2->num_items)
    return 0;

  len = MIN(MIN(s1->num_items - off1, s2->num_items - off2), max_len);

  for (i = 0; i < len; i++)
    {
      if (! lst_string_eq(s1, off1 + i,
			  s2, off2 + i))
	return i;
    }

  return len;
}