aboutsummaryrefslogtreecommitdiff
path: root/lib/cleanpath.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2022-02-14 20:04:35 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2022-02-14 20:04:35 -0500
commit10a13c64cc5ee3ff16caa77a7b809702cff38595 (patch)
tree2816b6e83dba605d73dbe4602e88744759e2e21a /lib/cleanpath.c
parent68bb18b1dde2b42913c68501a9d875804b181318 (diff)
downloadcleanpath-10a13c64cc5ee3ff16caa77a7b809702cff38595.tar.gz
Implement --all/-A
* Apply filters to all environment variables
Diffstat (limited to 'lib/cleanpath.c')
-rw-r--r--lib/cleanpath.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/cleanpath.c b/lib/cleanpath.c
index 91b399d..138251f 100644
--- a/lib/cleanpath.c
+++ b/lib/cleanpath.c
@@ -102,18 +102,24 @@ void cleanpath_filter(struct CleanPath *path, unsigned mode, const char *pattern
char *cleanpath_read(struct CleanPath *path) {
char *result;
size_t result_len;
+ size_t part_count;
result = calloc(path->data_len, sizeof(char));
if (result == NULL) {
goto cleanpath_read__failure;
}
+ for (part_count = 0; part_count < CLEANPATH_PART_MAX && path->part[part_count] != NULL; part_count++);
+
for (size_t i = 0; i < CLEANPATH_PART_MAX && path->part[i] != NULL; i++) {
// Ignore filtered paths
if (*path->part[i] == '\0') {
continue;
}
strcat(result, path->part[i]);
+ if (part_count > 1 && i == 0) {
+ continue;
+ }
strcat(result, path->sep);
}