The code used isalnum to skip leading white space. This could lead to
skip of whole string if that contained anything but 7-bit characters -
and as a result it would skip the whole string buffer (strstr
would find " ").
char *pout = firstword;
char articles[] = "the den der die des an a "; // must end in space
- while (*p && !isalnum(*(unsigned char *)p))
- p++;
for (; *p && *p != ' ' && pout - firstword < (sizeof(firstword)-2); p++)
*pout++ = tolower(*(unsigned char *)p);
*pout++ = ' ';