~mdw
/
sgt
/
agedu
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
6a4287f
)
Chris Walker reports that if you give a trailing slash on the pathname
author
simon
<simon@cda61777-01e9-0310-a592-d414129be87e>
Mon, 20 Feb 2012 07:35:04 +0000
(07:35 +0000)
committer
simon
<simon@cda61777-01e9-0310-a592-d414129be87e>
Mon, 20 Feb 2012 07:35:04 +0000
(07:35 +0000)
you tell agedu to scan, it will store that slash in the index and
confuse parts of the rest of the code. Strip such slashes off before
beginning the scan.
git-svn-id: svn://svn.tartarus.org/sgt/agedu@9416
cda61777
-01e9-0310-a592-
d414129be87e
du.c
patch
|
blob
|
blame
|
history
diff --git
a/du.c
b/du.c
index
6d26c34
..
03276c4
100644
(file)
--- a/
du.c
+++ b/
du.c
@@
-255,9
+255,18
@@
void du(const char *inpath, gotdata_fn_t gotdata, err_fn_t err,
size_t pathlen, pathsize;
pathlen = strlen(inpath);
+
+ /*
+ * Trim any trailing slashes from the input path, otherwise we'll
+ * store them in the index with confusing effects.
+ */
+ while (pathlen > 1 && inpath[pathlen-1] == '/')
+ pathlen--;
+
pathsize = pathlen + 256;
path = snewn(pathsize, char);
- strcpy(path, inpath);
+ memcpy(path, inpath, pathlen);
+ path[pathlen] = '\0';
du_recurse(&path, pathlen, &pathsize, gotdata, err, gotdata_ctx, 1);
}