Return-Path: X-Original-To: apmail-apr-commits-archive@www.apache.org Delivered-To: apmail-apr-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CD4013B16 for ; Sat, 30 Apr 2011 23:27:38 +0000 (UTC) Received: (qmail 868 invoked by uid 500); 30 Apr 2011 23:27:38 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 808 invoked by uid 500); 30 Apr 2011 23:27:38 -0000 Mailing-List: contact commits-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: Reply-To: dev@apr.apache.org List-Id: Delivered-To: mailing list commits@apr.apache.org Received: (qmail 801 invoked by uid 99); 30 Apr 2011 23:27:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 30 Apr 2011 23:27:37 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 30 Apr 2011 23:27:36 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A982F23888FD; Sat, 30 Apr 2011 23:27:16 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1098185 - /apr/apr/branches/1.4.x/strings/apr_fnmatch.c Date: Sat, 30 Apr 2011 23:27:16 -0000 To: commits@apr.apache.org From: wrowe@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110430232716.A982F23888FD@eris.apache.org> Author: wrowe Date: Sat Apr 30 23:27:16 2011 New Revision: 1098185 URL: http://svn.apache.org/viewvc?rev=1098185&view=rev Log: Document a mess of apr_fnmatch_test bugs mostly due to the missing flags arg. Modified: apr/apr/branches/1.4.x/strings/apr_fnmatch.c Modified: apr/apr/branches/1.4.x/strings/apr_fnmatch.c URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/strings/apr_fnmatch.c?rev=1098185&r1=1098184&r2=1098185&view=diff ============================================================================== --- apr/apr/branches/1.4.x/strings/apr_fnmatch.c (original) +++ apr/apr/branches/1.4.x/strings/apr_fnmatch.c Sat Apr 30 23:27:16 2011 @@ -211,40 +211,48 @@ static const char *rangematch(const char } -/* This function is an Apache addition */ -/* return non-zero if pattern has any glob chars in it */ +/* This function is an Apache addition + * return non-zero if pattern has any glob chars in it + * @bug Function does not distinguish for FNM_PATHNAME mode, which renders + * a false positive for test[/]this (which is not a range, but + * seperate test[ and ]this segments and no glob.) + * @bug Function does not distinguish for non-FNM_ESCAPE mode. + * @bug Function does not parse []] correctly + * Solution may be to use fnmatch_ch() to walk the patterns? + */ APR_DECLARE(int) apr_fnmatch_test(const char *pattern) { int nesting; nesting = 0; while (*pattern) { - switch (*pattern) { - case '?': - case '*': - return 1; - - case '\\': - if (*++pattern == '\0') { - return 0; - } - break; - - case '[': /* '[' is only a glob if it has a matching ']' */ - ++nesting; - break; - - case ']': - if (nesting) { - return 1; - } - break; - } - ++pattern; + switch (*pattern) { + case '?': + case '*': + return 1; + + case '\\': + if (*++pattern == '\0') { + return 0; + } + break; + + case '[': /* '[' is only a glob if it has a matching ']' */ + ++nesting; + break; + + case ']': + if (nesting) { + return 1; + } + break; + } + ++pattern; } return 0; } + /* Find all files matching the specified pattern */ APR_DECLARE(apr_status_t) apr_match_glob(const char *pattern, apr_array_header_t **result,