MCPcopy Create free account
hub / github.com/NetHack/NetHack / determine_ambiguities

Function determine_ambiguities

src/options.c:6702–6736  ·  view source on GitHub ↗

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. */

Source from the content-addressed store, hash-verified

6700 based on what is needed for uniqueness of each individual
6701 option. Set a minimum of 3 characters. */
6702staticfn void
6703determine_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
6738staticfn int
6739length_without_val(const char *user_string, int len)

Callers 1

allopt_array_initFunction · 0.85

Calls 1

lowcFunction · 0.70

Tested by

no test coverage detected