History

Fix section-from-path > 1

When having found the first path separator occurrence at position i, we invoked strchr() on the same position i in subsequent iterations resulting in the same path separator being returned by strchr() over and over again. Increase the position by one to skip the occurrence that has just been found and advance to the next separator.

Lukas Fleischer committed 13 years ago

Commit 86e309f1 parent 1a194aa1 file · +4 −4Browse files

Unified · Split

scan-tree.c+4−4
@@ -148,14 +148,14 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn) · 147 unmodified lines
148148 }
149149
150150 if (ctx.cfg.section_from_path) {
151− n = ctx.cfg.section_from_path;
151+ n = ctx.cfg.section_from_path;
152152 if (n > 0) {
153− slash = rel.buf;
154− while (slash && n && (slash = strchr(slash, '/')))
153+ slash = rel.buf - 1;
154+ while (slash && n && (slash = strchr(slash + 1, '/')))
155155 n--;
156156 } else {
157157 slash = rel.buf + rel.len;
158− while (slash && n && (slash = xstrrchr(rel.buf, slash, '/')))
158+ while (slash && n && (slash = xstrrchr(rel.buf, slash - 1, '/')))
159159 n++;
160160 }
161161 if (slash && !n) {