Exit early, so that we can get rid of the large if block.
}
static const char* skip_root(const LookupPaths *p, const char *path) {
- if (p->root_dir) {
- char *e;
+ char *e;
- e = path_startswith(path, p->root_dir);
- if (!e)
- return NULL;
+ assert(p);
+ assert(path);
- /* Make sure the returned path starts with a slash */
- if (e[0] != '/') {
- if (e == path || e[-1] != '/')
- return NULL;
+ if (!p->root_dir)
+ return path;
- e--;
- }
+ e = path_startswith(path, p->root_dir);
+ if (!e)
+ return NULL;
+
+ /* Make sure the returned path starts with a slash */
+ if (e[0] != '/') {
+ if (e == path || e[-1] != '/')
+ return NULL;
- return e;
+ e--;
}
- return path;
+ return e;
}
static int path_is_generator(const LookupPaths *p, const char *path) {