diff options
author | Joseph Hunkeler <jhunkeler@users.noreply.github.com> | 2021-05-06 17:45:01 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-06 17:45:01 -0400 |
commit | c967ce981c2bedc23f0cd614ea7a3b108d009365 (patch) | |
tree | 29640d70b2259152ee6abe080f1049b767ead2e8 /lib/cleanpath.c | |
parent | be932c2f558b535ba2c2d10bf6d0df68040a1821 (diff) | |
download | cleanpath-c967ce981c2bedc23f0cd614ea7a3b108d009365.tar.gz |
Add windows (#3)
* Add windows support
Diffstat (limited to 'lib/cleanpath.c')
-rw-r--r-- | lib/cleanpath.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/cleanpath.c b/lib/cleanpath.c index 9c46c38..2337869 100644 --- a/lib/cleanpath.c +++ b/lib/cleanpath.c @@ -1,9 +1,13 @@ +#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <regex.h> #include "config.h" #include "cleanpath.h" +#if !OS_WINDOWS +#include <regex.h> +#endif + /** * Split path into parts by sep * @param path a string (e.g. "/path1:/path2:/pathN") @@ -58,8 +62,10 @@ struct CleanPath *cleanpath_init(const char *path, const char *sep) { * @note CLEANPATH_FILTER_EXACT is the default mode */ void cleanpath_filter(struct CleanPath *path, unsigned mode, const char *pattern) { - int match; +#if !OS_WINDOWS regex_t regex; +#endif + int match; for (size_t i = 0; path->part[i]; i++) { match = 0; @@ -68,11 +74,15 @@ void cleanpath_filter(struct CleanPath *path, unsigned mode, const char *pattern match = strstr(path->part[i], pattern) != NULL ? 1 : 0; break; case CLEANPATH_FILTER_REGEX: +#if !OS_WINDOWS if (regcomp(®ex, pattern, REG_EXTENDED | REG_NOSUB) != 0) { return; } match = regexec(®ex, path->part[i], 0, NULL, 0) == 0 ? 1 : 0; regfree(®ex); +#else + fprintf(stderr, "WARNING: --regex|-r is not implemented on Windows. Using default filter mode.\n"); +#endif break; case CLEANPATH_FILTER_EXACT: default: |