From 6b7d23ca74b41b83cdab86c4b6de5ce8a814003b Mon Sep 17 00:00:00 2001 From: Spiro Trikaliotis Date: Wed, 22 Jun 2022 21:23:44 +0200 Subject: [PATCH] isequal with --wildcard: Allow DOS/Win paths Allow a colon (':') at the second position of a DOS or Windows path, so a path with drive specifier (i.e., "c:") is recognized as a path of the wildcard should end with a colon. --- test/isequal.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/test/isequal.c b/test/isequal.c index 6d98701bd..1add62412 100644 --- a/test/isequal.c +++ b/test/isequal.c @@ -349,18 +349,37 @@ static int processwildcardchar(FILE *f1) static int wildcard_path(FILE * f2) { int isstillwildcard = 1; + static int allowedcolonin = 2; int ch = getnext(f2); + if (allowedcolonin >= 0) { + --allowedcolonin; + } + if ((ch == wildcardendchar) || ch < ' ' || ch > 126) { /* this is not a path char anymore, abort the wildcard processing */ - isstillwildcard = 0; - if (ch != wildcardendchar) { - exit(EXIT_FAILURE); + /* first of all, ignore a colon at position 2 if it is the wildcardendchar. + * This is needed for windows path specifications, which can begin with + * a drive specifier and a colon. + */ + + if ( (allowedcolonin >= 0) && (ch == ':') ) { + fprintf(stderr, "Ignoring ':' at drive specifier, do not end the path here!\n"); + } + else { + isstillwildcard = 0; + + allowedcolonin = 2; + + if (ch != wildcardendchar) { + exit(EXIT_FAILURE); + } } } + return isstillwildcard; }