MCPcopy Index your code
hub / github.com/git/git / stripped_path_suffix_offset

Function stripped_path_suffix_offset

path.c:1287–1308  ·  view source on GitHub ↗

* If path ends with suffix (complete path components), returns the offset of * the last character in the path before the suffix (sans trailing directory * separators), and -1 otherwise. */

Source from the content-addressed store, hash-verified

1285 * separators), and -1 otherwise.
1286 */
1287static ssize_t stripped_path_suffix_offset(const char *path, const char *suffix)
1288{
1289 int path_len = strlen(path), suffix_len = strlen(suffix);
1290
1291 while (suffix_len) {
1292 if (!path_len)
1293 return -1;
1294
1295 if (is_dir_sep(path[path_len - 1])) {
1296 if (!is_dir_sep(suffix[suffix_len - 1]))
1297 return -1;
1298 path_len = chomp_trailing_dir_sep(path, path_len);
1299 suffix_len = chomp_trailing_dir_sep(suffix, suffix_len);
1300 }
1301 else if (path[--path_len] != suffix[--suffix_len])
1302 return -1;
1303 }
1304
1305 if (path_len && !is_dir_sep(path[path_len - 1]))
1306 return -1;
1307 return chomp_trailing_dir_sep(path, path_len);
1308}
1309
1310/*
1311 * Returns true if the path ends with components, considering only complete path

Callers 2

strip_path_suffixFunction · 0.85

Calls 1

chomp_trailing_dir_sepFunction · 0.85

Tested by

no test coverage detected