First you need to add Jvrgen's snippet
(see credits at bottom of the page):
IN hander.c add:
#define WHITESPACE " \t"
AND replace isname with:
int isname(char *str, char *namelist)
{
char *newlist;
char *curtok;
newlist = strdup(namelist); /* make a copy since strtok 'modifies' strings */
for(curtok = strtok(newlist, WHITESPACE); curtok; curtok = strtok(NULL, WHITESPACE))
if(curtok && is_apart(str, curtok))
/* was if(curtok && is_abbrev(str, curtok)) in Jvrgen's code */
free(newlist);
return 1;
}
free(newlist);
return 0;
}
Now my code:
What you need to add and where:
IN interpreter.h add:
int is_apart(const char *arg1, const char *arg2);
below:
int is_abbrev(const char *arg1, const char *arg2);
IN interpreter.c add:
/* Is ARG1 anywhere in ARG2 */
int is_apart(const char *arg1, const char *arg2)
{
int matchnum = 0; /* how many letters have we matched */
if (!*arg1 || !*arg2)
return (0);
while (*arg1 && *arg2) {
if (LOWER(*arg1) != LOWER(*arg2)) {
if (matchnum == 0)
arg2++;
else {
while (matchnum > 0) { /* need to backup and try again */
if (matchnum != 1)
arg2--;
arg1--;
matchnum--;
}
}
} else {
matchnum++;
arg1++;
arg2++;
}
}
if (!*arg1 && !*arg2)
return (1);
else {
if (!*arg2)
return (0);
else
return (1);
}
}