Exemple #1
0
void 
lex_AddStrings(struct sLexInitString * lex)
{
	while (lex->tzName) {
		struct sLexString **ppHash;
		ULONG hash;

		ppHash = &tLexHash[hash = lexcalchash(lex->tzName)];
		while (*ppHash)
			ppHash = &((*ppHash)->pNext);

		if (((*ppHash) = malloc(sizeof(struct sLexString))) != NULL) {
			if (((*ppHash)->tzName =
				(char *) strdup(lex->tzName)) != NULL) {
				(*ppHash)->nNameLength = strlen(lex->tzName);
				(*ppHash)->nToken = lex->nToken;
				(*ppHash)->pNext = NULL;

				upperstring((*ppHash)->tzName);

				if ((*ppHash)->nNameLength > nLexMaxLength)
					nLexMaxLength = (*ppHash)->nNameLength;

			} else
				fatalerror("Out of memory!");
		} else
			fatalerror("Out of memory!");

		lex += 1;
	}
}
Exemple #2
0
/* foldcmp: fold upper and lower case together */
int foldcmp(const char *s1, const char *s2)
{
	char *x, *y;
	int i;

	x = alloc(strLen(s1) + 1);
	y = alloc(strLen(s2) + 1);
	strCpy(x, s1);
	strCpy(y, s2);

	upperstring(x);
	upperstring(y);
	i = strCmp(x, y);

	afree(x);
	afree(y);
	return i;
}