| 70 | } |
| 71 | |
| 72 | static void extend_prefix_length(struct string_list_item *p, |
| 73 | const char *other_string, size_t max_length) |
| 74 | { |
| 75 | size_t *len = p->util; |
| 76 | |
| 77 | if (!*len || memcmp(p->string, other_string, *len)) |
| 78 | return; |
| 79 | |
| 80 | for (;;) { |
| 81 | char c = p->string[*len]; |
| 82 | |
| 83 | /* |
| 84 | * Is `p` a strict prefix of `other`? Or have we exhausted the |
| 85 | * maximal length of the prefix? Or is the current character a |
| 86 | * multi-byte UTF-8 one? If so, there is no valid, unique |
| 87 | * prefix. |
| 88 | */ |
| 89 | if (!c || ++*len > max_length || !isascii(c)) { |
| 90 | *len = 0; |
| 91 | break; |
| 92 | } |
| 93 | |
| 94 | if (c != other_string[*len - 1]) |
| 95 | break; |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | static void find_unique_prefixes(struct prefix_item_list *list) |
| 100 | { |
no outgoing calls
no test coverage detected