Exemplo n.º 1
0
/* char * findSynonym(char * word, char * dictionary, unsigned int dictSize, unsigned int * synonymdSize_p) summary
* Get a word from a string of content and return it as a string
* param: char * word | word to find synonym of
* param: char * dictionary | string of dictionary to find synonym from
* param: unsigned int dictSize | dictionary size
* param: unsigned int * synonymSize_p | pointer of unsigned int to save synonym size in
*/
char * findSynonym(char * word, char * dictionary, unsigned int dictSize, unsigned int * synonymSize_p)
{
	char * synonym = NULL;
	unsigned int dictFile_index = 0;
	while (dictFile_index < dictSize && dictionary[dictFile_index] != '\0') // T: check parameters for null pointers
	{
		unsigned int Number_Of_Bytes = 0;
		char * curr_word = getWord(dictionary, dictFile_index, dictSize, &Number_Of_Bytes);
		if (strcmp(word, curr_word) == 0) // T: use strncmp, now you count on word to be null terminated
		{
			dictFile_index = getLineStart(dictionary, dictFile_index);
			synonym = getWord(dictionary, dictFile_index, dictSize, synonymSize_p);
			while (strcmp(curr_word, synonym) == 0) // T: if the dict file has bad format you will get to EOF
			{
				dictFile_index += *synonymSize_p+1;
				synonym = getWord(dictionary, dictFile_index, dictSize, synonymSize_p); // T: free synonym memory!
			}
			break;
		}
		free(curr_word);
		dictFile_index += Number_Of_Bytes + 1;
	}

	return synonym;
}
Exemplo n.º 2
0
void LLExpandableTextBox::LLTextBoxEx::showExpandText()
{
	if (!mExpanderVisible)
	{
		// make sure we're scrolled to top when collapsing
		if (mScroller)
		{
			mScroller->goToTop();
		}
		// get fully visible lines
		std::pair<S32, S32> visible_lines = getVisibleLines(true);
		S32 last_line = visible_lines.second - 1;

		LLStyle::Params expander_style(getDefaultStyleParams());
		expander_style.font.style = "UNDERLINE";
		expander_style.color = LLUIColorTable::instance().getColor("HTMLLinkColor");
		LLExpanderSegment* expanderp = new LLExpanderSegment(new LLStyle(expander_style), getLineStart(last_line), getLength() + 1, mExpanderLabel, *this);
		insertSegment(expanderp);
		mExpanderVisible = true;
	}

}