search for a word in a space-separated list; returns non-Null if found */
| 598 | |
| 599 | /* search for a word in a space-separated list; returns non-Null if found */ |
| 600 | const char * |
| 601 | findword( |
| 602 | const char *list, /* string of space-separated words */ |
| 603 | const char *word, /* word to try to find */ |
| 604 | int wordlen, /* so that it isn't required to be \0 terminated */ |
| 605 | boolean ignorecase) /* T: case-blind, F: case-sensitive */ |
| 606 | { |
| 607 | const char *p = list; |
| 608 | |
| 609 | while (p) { |
| 610 | while (*p == ' ') |
| 611 | ++p; |
| 612 | if (!*p) |
| 613 | break; |
| 614 | if ((ignorecase ? !strncmpi(p, word, wordlen) |
| 615 | : !strncmp(p, word, wordlen)) |
| 616 | && (p[wordlen] == '\0' || p[wordlen] == ' ')) |
| 617 | return p; |
| 618 | p = strchr(p + 1, ' '); |
| 619 | } |
| 620 | return (const char *) 0; |
| 621 | } |
| 622 | |
| 623 | /* return the ordinal suffix of a number */ |
| 624 | const char * |
no test coverage detected