Resolve "." and ".." in a '/'-separated path, in place. false when it * leaves the repository. */
| 2091 | /* Resolve "." and ".." in a '/'-separated path, in place. false when it |
| 2092 | * leaves the repository. */ |
| 2093 | static bool msb_normalize(char *path) { |
| 2094 | /* The text is read by index up to its original length: what is written |
| 2095 | * (every kept segment and a '/' after it) never passes the read position, |
| 2096 | * but it does overwrite the terminator. */ |
| 2097 | size_t len = strlen(path); |
| 2098 | size_t w = 0; |
| 2099 | size_t i = 0; |
| 2100 | while (i < len) { |
| 2101 | size_t s = i; |
| 2102 | while (i < len && path[i] != '/') { |
| 2103 | i++; |
| 2104 | } |
| 2105 | size_t n = i - s; |
| 2106 | i += i < len; /* past the '/' */ |
| 2107 | if (n == PAIR_LEN && path[s] == '.' && path[s + SKIP_ONE] == '.') { |
| 2108 | if (w == 0) { |
| 2109 | return false; |
| 2110 | } |
| 2111 | w--; /* the '/' that ends the previous segment */ |
| 2112 | while (w > 0 && path[w - SKIP_ONE] != '/') { |
| 2113 | w--; |
| 2114 | } |
| 2115 | } else if (n > 0 && !(n == SKIP_ONE && path[s] == '.')) { |
| 2116 | memmove(path + w, path + s, n); |
| 2117 | msb_work(n + SKIP_ONE); /* copied segment and slash */ |
| 2118 | w += n; |
| 2119 | path[w++] = '/'; |
| 2120 | } |
| 2121 | } |
| 2122 | path[w > 0 ? w - SKIP_ONE : 0] = '\0'; |
| 2123 | return true; |
| 2124 | } |
| 2125 | |
| 2126 | /* The file an <Import Project="..."> written in `file` names: its index, or |
| 2127 | * CBM_NOT_FOUND. What cannot be followed is counted: a path that is not |
no test coverage detected