Test whether canonical prefix is parent or match of path. */
| 128 | |
| 129 | /* Test whether canonical prefix is parent or match of path. */ |
| 130 | ATTRIBUTE_PURE |
| 131 | static bool |
| 132 | path_prefix (char const *prefix, char const *path) |
| 133 | { |
| 134 | /* We already know prefix[0] and path[0] are '/'. */ |
| 135 | prefix++; |
| 136 | path++; |
| 137 | |
| 138 | /* '/' is the prefix of everything except '//' (since we know '//' |
| 139 | is only present after canonicalization if it is distinct). */ |
| 140 | if (!*prefix) |
| 141 | return *path != '/'; |
| 142 | |
| 143 | /* Likewise, '//' is a prefix of any double-slash path. */ |
| 144 | if (*prefix == '/' && !prefix[1]) |
| 145 | return *path == '/'; |
| 146 | |
| 147 | /* Any other prefix has a non-slash portion. */ |
| 148 | while (*prefix && *path) |
| 149 | { |
| 150 | if (*prefix != *path) |
| 151 | break; |
| 152 | prefix++; |
| 153 | path++; |
| 154 | } |
| 155 | return (!*prefix && (*path == '/' || !*path)); |
| 156 | } |
| 157 | |
| 158 | static bool |
| 159 | isdir (char const *path) |
no outgoing calls
no test coverage detected