예제 #1
0
int word_replace_g(char **pline, char *find, const char *replace)
{
	char *pos = *pline;
	int r = 0;

	DEBUG(DEBUG_VERB, "word_find(\"%s\", \"%s\")\n", pos, find);

	while((pos = word_find(pos, find))){
		int posidx = pos - *pline;

		DEBUG(DEBUG_VERB, "word_replace(line=\"%s\", pos=\"%s\", nam=\"%s\", val=\"%s\")\n",
				*pline, pos, find, replace);

		*pline = word_replace(*pline, pos, find, replace);
		pos = *pline + posidx + strlen(replace);

		r = 1;
	}

	return r;
}
예제 #2
0
파일: parse.c 프로젝트: saucjedi/nagi
void parse(u8 *string)
{
	u16 wordNumber;
	u8 *wordString;	// the string data of the word

	memset(word_string, 0, sizeof(word_string));
	memset(word_num, 0, sizeof(word_num));

	parse_read(string);
	word_total = 0;
	strPtr = parse_string;
	
	while ((*strPtr != 0) && (word_total < WORD_BUF_SIZE))
	{
		wordString = strPtr;
		wordNumber = word_find();
	
		if (wordNumber == 0xFFFF)	// bad
		{
			word_string[word_total] = strPtr;
			state.var[V09_BADWORD] = word_total + 1;	// bad word
			word_total++;
			assert(word_total > 0); // we need flag 2 set
			break;
		}

		if (wordNumber != WORD_IGNORE)	// good
		{
			word_num[word_total] = wordNumber;
			word_string[word_total] = wordString;
			word_total++;
		}
		// if WORD_IGNORE then skip it
	}
	
	if (word_total > 0)
		flag_set(F02_PLAYERCMD);
}