go through all of the options and set the minmatch value based on what is needed for uniqueness of each individual option. Set a minimum of 3 characters. */
| 6700 | based on what is needed for uniqueness of each individual |
| 6701 | option. Set a minimum of 3 characters. */ |
| 6702 | staticfn void |
| 6703 | determine_ambiguities(void) |
| 6704 | { |
| 6705 | int i, j, len, tmpneeded, needed[SIZE(allopt)]; |
| 6706 | const char *p1, *p2; |
| 6707 | |
| 6708 | for (i = 0; i < SIZE(allopt) - 1; ++i) { |
| 6709 | needed[i] = 0; |
| 6710 | } |
| 6711 | |
| 6712 | for (i = 0; i < SIZE(allopt) - 1; ++i) { |
| 6713 | for (j = 0; j < SIZE(allopt) - 1; ++j) { |
| 6714 | if (j == i) |
| 6715 | continue; |
| 6716 | |
| 6717 | p1 = allopt[i].name; /* back to the start */ |
| 6718 | p2 = allopt[j].name; |
| 6719 | tmpneeded = 1; |
| 6720 | while (*p1 && *p2 && lowc(*p1) == lowc(*p2)) { |
| 6721 | ++tmpneeded; |
| 6722 | ++p1; |
| 6723 | ++p2; |
| 6724 | } |
| 6725 | if (tmpneeded > needed[i]) |
| 6726 | needed[i] = tmpneeded; |
| 6727 | if (tmpneeded > needed[j]) |
| 6728 | needed[j] = tmpneeded; |
| 6729 | } |
| 6730 | } |
| 6731 | for (i = 0; i < SIZE(allopt) - 1; ++i) { |
| 6732 | len = Strlen(allopt[i].name); |
| 6733 | allopt[i].minmatch = (needed[i] < 3) ? 3 |
| 6734 | : (needed[i] <= len) ? needed[i] : len; |
| 6735 | } |
| 6736 | } |
| 6737 | |
| 6738 | staticfn int |
| 6739 | length_without_val(const char *user_string, int len) |
no test coverage detected