Re: [ Code ] search_block

From: Sean Butler (sbutler@DEVEAST.COM)
Date: 11/10/97


int search_block(char *arg, char **list, int exact)
{
  register int i, l;

  /* Make into lower case, and get length of string */
  for (l = 0; *(arg + l); l++)
    *(arg + l) = LOWER(*(arg + l));

You'll never match uppercase because it uses 'strcmp' and 'strncmp' for
case sensitivity.  I'm thinking they should be str_cmp and strn_cmp, almost
everything else in the mud is case insensitive.

--------------------

Yes, I do remember this as being a problem.  I did change search_block
to use the case insensitive comparison functions, and all problems
went away :-)

int search_block(char *arg, char **list, bool exact)
{
  register int i, l;

  l = strlen(arg);

  if (exact) {
    for (i = 0; **(list + i) != '\n'; i++)
      if (!str_cmp(arg, *(list + i)))
        return (i);
  } else {
    if (!l)
      l = 1;                    /* Avoid "" to match the first available
                                 * string */
    for (i = 0; **(list + i) != '\n'; i++)
      if (!strn_cmp(arg, *(list + i), l))
        return (i);
  }

  return -1;
}


--Sean


     +------------------------------------------------------------+
     | 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/08/00 PST