find extended command entries matching findstr. if findstr is NULL, returns all available entries. returns: number of matching extended commands, and the entry indexes in matchlist. for windowport use. */
| 2520 | and the entry indexes in matchlist. |
| 2521 | for windowport use. */ |
| 2522 | int |
| 2523 | extcmds_match(const char *findstr, int ecmflags, int **matchlist) |
| 2524 | { |
| 2525 | static int retmatchlist[SIZE(extcmdlist)] = DUMMY; |
| 2526 | int i, mi = 0; |
| 2527 | int fslen = findstr ? Strlen(findstr) : 0; |
| 2528 | boolean ignoreac = (ecmflags & ECM_IGNOREAC) != 0; |
| 2529 | boolean exactmatch = (ecmflags & ECM_EXACTMATCH) != 0; |
| 2530 | boolean no1charcmd = (ecmflags & ECM_NO1CHARCMD) != 0; |
| 2531 | |
| 2532 | for (i = 0; extcmdlist[i].ef_txt; i++) { |
| 2533 | if (extcmdlist[i].flags & (CMD_NOT_AVAILABLE|INTERNALCMD)) |
| 2534 | continue; |
| 2535 | if (!wizard && (extcmdlist[i].flags & WIZMODECMD)) |
| 2536 | continue; |
| 2537 | if (!ignoreac && !(extcmdlist[i].flags & AUTOCOMPLETE)) |
| 2538 | continue; |
| 2539 | if (no1charcmd && (strlen(extcmdlist[i].ef_txt) == 1)) |
| 2540 | continue; |
| 2541 | if (!findstr) { |
| 2542 | retmatchlist[mi++] = i; |
| 2543 | } else if (exactmatch) { |
| 2544 | if (!strcmpi(findstr, extcmdlist[i].ef_txt)) { |
| 2545 | retmatchlist[mi++] = i; |
| 2546 | } |
| 2547 | } else { |
| 2548 | if (!strncmpi(findstr, extcmdlist[i].ef_txt, fslen)) { |
| 2549 | retmatchlist[mi++] = i; |
| 2550 | } |
| 2551 | } |
| 2552 | } |
| 2553 | |
| 2554 | if (matchlist) |
| 2555 | *matchlist = retmatchlist; |
| 2556 | |
| 2557 | return mi; |
| 2558 | } |
| 2559 | |
| 2560 | const char * |
| 2561 | key2extcmddesc(uchar key) |
no test coverage detected