Esempio n. 1
0
wchar_t * build_idiom_word_name(Dictionary dict, wchar_t * s) {
    /* Allocates string space and returns a pointer to it.
       In this string is placed the idiomized name of the given string s.
       This is the same as s, but with a postfix of ".Ix", where x is an
       appropriate number.  x is the minimum number that distinguishes
       this word from others in the dictionary.
       */
    wchar_t * new_s, * x, *id;
    int count, sz;

    count = max_postfix_found(dictionary_lookup(dict, s))+1;

    sz = wcslen(s)+10;
    new_s = x = (wchar_t *) xalloc(sizeof(wchar_t)*sz); /* fails if > 10**10 idioms */
    while((*s != L'\0') && (*s != L'.')) {
	*x = *s;
	x++;
	s++;
    }
    swprintf_s(x, sz - (x - new_s), L".I%d", count);

    id = string_set_add(new_s, dict->string_set);
    xfree(new_s, sizeof(wchar_t)*sz);
    return id;
}
Esempio n. 2
0
/**
 * build_idiom_word_name() -- return idiomized name of given string.
 *
 * Allocates string space and returns a pointer to it.
 * In this string is placed the idiomized name of the given string s.
 * This is the same as s, but with a postfix of ".Ix", where x is an
 * appropriate number.  x is the minimum number that distinguishes
 * this word from others in the dictionary.
 */
static const char * build_idiom_word_name(Dictionary dict, const char * s)
{
	char buff[2*MAX_WORD];
	char *x;
	int count;

	Dict_node *dn = dictionary_lookup_list(dict, s);
	count = max_postfix_found(dn)+1;
	free_lookup_list(dn);

	x = buff;
	while((*s != '\0') && (*s != '.'))
	{
		*x = *s;
		x++;
		s++;
	}
	sprintf(x, ".I%d",count);

	return string_set_add(buff, dict->string_set);
}