From 008ebd1262268cf1c9a4bbdc0bf78d5c11cd5b1d Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Thu, 6 May 2021 17:21:47 -0400 Subject: Disable regex on windows --- include/cleanpath.h | 3 +++ lib/cleanpath.c | 5 +++++ src/main.c | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/cleanpath.h b/include/cleanpath.h index 6d50db4..b2d21f4 100644 --- a/include/cleanpath.h +++ b/include/cleanpath.h @@ -35,10 +35,13 @@ #define CLEANPATH_PART_MAX 1024 #define CLEANPATH_VAR "PATH" #define CLEANPATH_SEP ":" +#define CLEANPATH_MSG_NOAVAIL "" #if OS_WINDOWS #undef CLEANPATH_SEP #define CLEANPATH_SEP ";" +#undef CLEANPATH_MSG_NOAVAIL +#define CLEANPATH_MSG_NOAVAIL " [not implemented] " #endif struct CleanPath { diff --git a/lib/cleanpath.c b/lib/cleanpath.c index c64da40..d1c9637 100644 --- a/lib/cleanpath.c +++ b/lib/cleanpath.c @@ -1,3 +1,4 @@ +#include #include #include #include "config.h" @@ -71,11 +72,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: diff --git a/src/main.c b/src/main.c index ba23fcc..7bb92c3 100644 --- a/src/main.c +++ b/src/main.c @@ -52,7 +52,7 @@ static void show_usage() { printf(" --version -V Displays the program's version\n"); printf(" --exact -e Filter when pattern is an exact match (default)\n"); printf(" --loose -l Filter when any part of the pattern matches\n"); - printf(" --regex -r Filter matches with (Extended) Regular Expressions\n"); + printf(" --regex -r Filter matches with (Extended) Regular Expressions " CLEANPATH_MSG_NOAVAIL "\n"); printf(" --sep [str] -s Use custom path separator (default: ':')\n"); printf(" --env [str] -E Use custom environment variable (default: PATH)\n"); } -- cgit