[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 52/150: fnmatch: optimize processing of consecutive
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 52/150: fnmatch: optimize processing of consecutive *s and ?s pattern characters |
Date: |
Fri, 30 Mar 2018 16:48:26 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnurl.
commit a0984eae14b2840a470800bb1bfb18bd99dc302b
Author: Patrick Monnerat <address@hidden>
AuthorDate: Wed Feb 7 15:01:51 2018 +0100
fnmatch: optimize processing of consecutive *s and ?s pattern characters
Reported-By: Daniel Stenberg
Fixes #2291
Closes #2293
---
lib/curl_fnmatch.c | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/lib/curl_fnmatch.c b/lib/curl_fnmatch.c
index f303881d3..0179a4f71 100644
--- a/lib/curl_fnmatch.c
+++ b/lib/curl_fnmatch.c
@@ -256,7 +256,6 @@ static int loop(const unsigned char *pattern, const
unsigned char *string,
unsigned char *p = (unsigned char *)pattern;
unsigned char *s = (unsigned char *)string;
unsigned char charset[CURLFNM_CHSET_SIZE] = { 0 };
- int rc = 0;
for(;;) {
unsigned char *pp;
@@ -265,18 +264,24 @@ static int loop(const unsigned char *pattern, const
unsigned char *string,
case '*':
if(!maxstars)
return CURL_FNMATCH_NOMATCH;
- while(p[1] == '*') /* eliminate multiple stars */
- p++;
- if(*s == '\0' && p[1] == '\0')
- return CURL_FNMATCH_MATCH;
- rc = loop(p + 1, s, maxstars - 1); /* *.txt matches .txt <=>
- .txt matches .txt */
- if(rc == CURL_FNMATCH_MATCH)
- return CURL_FNMATCH_MATCH;
- if(!*s)
- return CURL_FNMATCH_NOMATCH;
- s++; /* let the star eat up one character */
- break;
+ /* Regroup consecutive stars and question marks. This can be done because
+ '*?*?*' can be expressed as '??*'. */
+ for(;;) {
+ if(*++p == '\0')
+ return CURL_FNMATCH_MATCH;
+ if(*p == '?') {
+ if(!*s++)
+ return CURL_FNMATCH_NOMATCH;
+ }
+ else if(*p != '*')
+ break;
+ }
+ /* Skip string characters until we find a match with pattern suffix. */
+ for(maxstars--; *s; s++) {
+ if(loop(p, s, maxstars) == CURL_FNMATCH_MATCH)
+ return CURL_FNMATCH_MATCH;
+ }
+ return CURL_FNMATCH_NOMATCH;
case '?':
if(!*s)
return CURL_FNMATCH_NOMATCH;
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnurl] 30/150: curlver: next release will be 7.59.0, (continued)
- [GNUnet-SVN] [gnurl] 30/150: curlver: next release will be 7.59.0, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 40/150: fnmatch: pattern syntax can no longer fail, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 51/150: build-openssl.bat/build-wolfssl.bat: Build platform is optional, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 25/150: curl: add --proxy-pinnedpubkey, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 31/150: RELEASE-NOTES: synced with 811beab9f, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 55/150: build-openssl.bat: Fixed incorrect move if destination build folder exists, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 78/150: travis: add build with iconv enabled, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 23/150: curl_ctype: private is*() type macros and functions, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 59/150: get_posix_time: only check for overflows if they can happen!, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 64/150: smtp: fix processing of initial dot in data, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 52/150: fnmatch: optimize processing of consecutive *s and ?s pattern characters,
gnunet <=
- [GNUnet-SVN] [gnurl] 47/150: time-cond: fix reading the file modification time on Windows, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 67/150: RELEASE-NOTES: synced with e551910f8, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 43/150: time_t-fixes: remove typecasts to 'long' for info.filetime, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 82/150: TODO: 1.7 Support HTTP/2 for HTTP(S) proxies, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 50/150: openssl: Don't add verify locations when verifypeer==0, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 42/150: curl_setup: move the precautionary define of SIZEOF_TIME_T, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 28/150: time: support > year 2038 time stamps for system with 32bit long, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 49/150: build-wolfssl.bat: Extend VC15 support to include Enterprise and Professional, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 83/150: TODO: 1.1 Option to refuse usernames in URLs, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 57/150: content_encoding: Add "none" alias to "identity", gnunet, 2018/03/30