|
From: Ben H. <bh...@al...> - 2002-04-11 10:21:14
|
Was trying to use ifOurChar_BEGIN to add support for:
Par Troon says in Thoom, "Bones, you already know the language I teach."
.. and is it just me, or is the ifOurChar_BEGIN function totally
bogus. It actually doesn't check if yytext BEGINs with the
charactername, it checks if yytext *IS* the charactername.
(strncasecmp == 0 if they are equal, not prefixed). And if it's not
prefixed, it adds the entire yytext to the exile hash which is bad if
you try to use this as a yytext "prefix" function.
Either I am missing something, or Lark was when writing this function. :)
// Test if yytext begins with our character name, if so, put scanner
in state inState.
void CScribiaDoc::ifOurChar_BEGIN(const int inState) {
if((strncasecmp(mCharacterName.c_str(), yytext, yyleng) == 0) &&
// make sure name isn't simply a prefix of yytext!
((mCharacterName.length() < yyleng &&
// XXX use class ci_string instead of strchr
strchr(" \t\r\n",
yytext[mCharacterName.length()]) != 0) ||
mCharacterName.length() >= yyleng)) {
sHaveSeenMyName = true;
BEGIN(inState);
} else
// it's not us; add this name to the exile hash to improve
the karma heuristic
mExile[yytext];
}
Anyway, a new release will be soon, for those just tuning in.
-Ben
--
http://homepage.mac.com/bhines/
|