Found a rather glaring bug in my source code, which unfortunately didn't show up since I had an incompatibility problem with one of the internal functions, get_number (which chops at a "period" no matter what). I added in a check to see if start of the string isdigit, before it does any chopping. The bug is that given just one argument which does NOT match the start of any elements in namelist, would always match. Therefore the read [0-9] on a board would just show the board. 1. so if you add in a isdigit check in get_number:handler.c allows look city.cityguard look death.reaper look small.sword get small.sword wie small.sword 2. changed str_cmp in generic_find for equipped objects to isname allows rem small.sword what follows is a condensed no comments, except for what pertains to where I screwed up. d. -- #include <stdio.h> #include <stdlib.h> #define LOWER(c) (((c)>='A' && (c) <= 'Z') ? ((c)+('a'-'A')) : (c)) /* 12.15/95 dhall: attempt to incorporate "dot notation" */ /* 12.16/95 dhall: fixed one char always matching bug */ int isname(textlist, namelist) char *textlist; char *namelist; { register char *cptr, *sptr; char *curname; short active, search, string; active = 0; for (curname = textlist; *curname; curname++) { if (active) { if (*curname == '.') active = 0; continue; } if (*curname == '.') continue; search = 0; string = 1; cptr = curname; for (sptr = namelist; string; sptr++) { if (search) { if (*sptr == ' ') search = 0; if (*sptr != '\0') continue; } switch (*sptr) { case '\0': string = 0; case ' ': active = 1; break; default: if (LOWER(*sptr) != LOWER(*cptr)) search = 1; break; } if (*cptr == '.' || *cptr == '\0') { if (active) break; active = 1; } /* if active is TRUE, then only one of the two conditions was */ /* TRUE, therefore the substring did not match, but continue */ /* with inner loop until string is FALSE, also don't increment */ /* cptr if search is TRUE */ if (active || search) { cptr = curname; active = 0; } else cptr++; } if (!active) return (0); } return (1); } void main () { char *nlist = "red orange yellow green blue indigo violet"; char *tlist[] = { "r", "re", "red", "redd", "red.orange", "RED", "ReD", "red.orangee", "red.orang", NULL, }; int i; for (i = 0; tlist[i]; i++) printf ("%s = %d\n", tlist[i], isname (tlist[i], nlist)); }
This archive was generated by hypermail 2b30 : 12/07/00 PST