[CODE] handler.c:isname() and abbrev checking

From: Angus Mezick (angus@EDGIL.CCMAIL.COMPUSERVE.COM)
Date: 07/04/98


I was happily patching in bpl14 when i ran into isname().  At some point it had
been coded to use strtok instead of this nice simple counting scheme.   I saw
this form and noticed I couldn't do a 'tell cymy thing' and tell cymynedd thing.
Here is a drop-in replacement that will do two things for you.
1) allow abbreviations to be used with all isname() calls.
2) ignore abbreviations if the last char of str is '.'.  This is to allow you to
'vnum o pot.' and not get every single darn potion in the game.

int isname(const char *str, const char *namelist)
{
   const char *curname, *curstr;

   curname = namelist;
   for (;;)
      {
      for (curstr = str;; curstr++, curname++)
    {
    if (!*curstr)
       return (1);
    if (*curstr=='.' && !isalpha(*curname))
       return (1);

    if (!*curname)
       return (0);

    if (*curname == ' ')
       break;

    if (LOWER(*curstr) != LOWER(*curname))
       break;
    }

     /* skip to next name */

      for (; isalpha(*curname); curname++)
    ;
      if (!*curname)
    return (0);
      curname++;                  /* first char of new name */
      }
}


--Angus


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST