Beispiel #1
0
static
void    swd_accept(ucl_swd_t * s, ucl_uint n)
{
	assert(n <= s->look);

	if (n > 0)
		do {
			ucl_uint key;

			swd_remove_node(s, s->rp);

			/* add bp into HEAD3 */
			key = HEAD3(s->b, s->bp);
			s->succ3[s->bp] = s_head3(s, key);
			s->head3[key] = SWD_UINT(s->bp);
			s->best3[s->bp] = SWD_UINT(s->f + 1);
			s->llen3[key]++;
			assert(s->llen3[key] <= s->n);

#ifdef HEAD2
			/* add bp into HEAD2 */
			key = HEAD2(s->b, s->bp);
			s->head2[key] = SWD_UINT(s->bp);
#endif

			swd_getbyte(s);
		} while (--n > 0);
}
Beispiel #2
0
static
void    swd_findbest(ucl_swd_t * s)
{
	ucl_uint key;
	ucl_uint cnt, node;
	ucl_uint len;

	assert(s->m_len > 0);

	/* get current head, add bp into HEAD3 */
	key = HEAD3(s->b, s->bp);
	node = s->succ3[s->bp] = s_head3(s, key);
	cnt = s->llen3[key]++;
	assert(s->llen3[key] <= s->n + s->f);
	if (cnt > s->max_chain && s->max_chain > 0)
		cnt = s->max_chain;
	s->head3[key] = SWD_UINT(s->bp);

	s->b_char = s->b[s->bp];
	len = s->m_len;
	if (s->m_len >= s->look) {
		if (s->look == 0)
			s->b_char = -1;
		s->m_off = 0;
		s->best3[s->bp] = SWD_UINT(s->f + 1);
	} else {
#ifdef HEAD2
		if (swd_search2(s))
#endif
			if (s->look >= 3)
				swd_search(s, node, cnt);
		if (s->m_len > len)
			s->m_off = swd_pos2off(s, s->m_pos);
		s->best3[s->bp] = SWD_UINT(s->m_len);

#if defined(SWD_BEST_OFF)
		if (s->use_best_off) {
			int     i;
			for (i = 2; i < SWD_BEST_OFF; i++)
				if (s->best_pos[i] > 0)
					s->best_off[i] =
					    swd_pos2off(s,
							s->best_pos[i] -
							1);
				else
					s->best_off[i] = 0;
		}
#endif
	}

	swd_remove_node(s, s->rp);

#ifdef HEAD2
	/* add bp into HEAD2 */
	key = HEAD2(s->b, s->bp);
	s->head2[key] = SWD_UINT(s->bp);
#endif
}
Beispiel #3
0
static void
swd_findbest (lzo1x_999_swd_t * s)
{
	lzo_uint key;
	lzo_uint cnt, node;
	lzo_uint len;

	key = HEAD3 (s->b, s->bp);
	node = s->succ3[s->bp] = s_head3 (s, key);
	cnt = s->llen3[key]++;

	if (cnt > s->max_chain && s->max_chain > 0)
		cnt = s->max_chain;
	s->head3[key] = SWD_UINT (s->bp);

	s->b_char = s->b[s->bp];
	len = s->m_len;
	if (s->m_len >= s->look)
	{
		if (s->look == 0)
			s->b_char = -1;
		s->m_off = 0;
		s->best3[s->bp] = SWD_UINT (s->f + 1);
	}
	else
	{

		if (swd_search2 (s))

			if (s->look >= 3)
				swd_search (s, node, cnt);
		if (s->m_len > len)
			s->m_off = swd_pos2off (s, s->m_pos);
		s->best3[s->bp] = SWD_UINT (s->m_len);

		if (s->use_best_off)
		{
			int i;
			for (i = 2; i < SWD_BEST_OFF; i++)
				if (s->best_pos[i] > 0)
					s->best_off[i] =
						swd_pos2off (s,
							     s->best_pos[i] -
							     1);
				else
					s->best_off[i] = 0;
		}

	}

	swd_remove_node (s, s->rp);

	key = HEAD2 (s->b, s->bp);
	s->head2[key] = SWD_UINT (s->bp);

}
Beispiel #4
0
static void
swd_accept (lzo1x_999_swd_t * s, lzo_uint n)
{

	while (n--)
	{
		lzo_uint key;

		swd_remove_node (s, s->rp);

		key = HEAD3 (s->b, s->bp);
		s->succ3[s->bp] = s_head3 (s, key);
		s->head3[key] = SWD_UINT (s->bp);
		s->best3[s->bp] = SWD_UINT (s->f + 1);
		s->llen3[key]++;

		key = HEAD2 (s->b, s->bp);
		s->head2[key] = SWD_UINT (s->bp);;

		swd_getbyte (s);
	}
}
Beispiel #5
0
static void
swd_insertdict (lzo1x_999_swd_t * s, lzo_uint node, lzo_uint len)
{
	lzo_uint key;

	s->node_count = s->n - len;
	s->first_rp = node;

	while (len-- > 0)
	{
		key = HEAD3 (s->b, node);
		s->succ3[node] = s_head3 (s, key);
		s->head3[key] = SWD_UINT (node);
		s->best3[node] = SWD_UINT (s->f + 1);
		s->llen3[key]++;

		key = HEAD2 (s->b, node);
		s->head2[key] = SWD_UINT (node);

		node++;
	}
}
Beispiel #6
0
static
void    swd_insertdict(ucl_swd_t * s, ucl_uint node, ucl_uint len)
{
	ucl_uint key;

	s->node_count = s->n - len;
	s->first_rp = node;

	while (len-- > 0) {
		key = HEAD3(s->b, node);
		s->succ3[node] = s_head3(s, key);
		s->head3[key] = SWD_UINT(node);
		s->best3[node] = SWD_UINT(s->f + 1);
		s->llen3[key]++;
		assert(s->llen3[key] <= s->n);

#ifdef HEAD2
		key = HEAD2(s->b, node);
		s->head2[key] = SWD_UINT(node);
#endif

		node++;
	}
}