From owner-svn-src-head@freebsd.org Sat Jul 23 03:49:03 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D571ABA28BE; Sat, 23 Jul 2016 03:49:03 +0000 (UTC) (envelope-from ache@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8D29C1E30; Sat, 23 Jul 2016 03:49:03 +0000 (UTC) (envelope-from ache@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6N3n2WR032501; Sat, 23 Jul 2016 03:49:02 GMT (envelope-from ache@FreeBSD.org) Received: (from ache@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6N3n2VN032500; Sat, 23 Jul 2016 03:49:02 GMT (envelope-from ache@FreeBSD.org) Message-Id: <201607230349.u6N3n2VN032500@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ache set sender to ache@FreeBSD.org using -f From: "Andrey A. Chernov" Date: Sat, 23 Jul 2016 03:49:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r303210 - head/lib/libc/gen X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jul 2016 03:49:03 -0000 Author: ache Date: Sat Jul 23 03:49:02 2016 New Revision: 303210 URL: https://svnweb.freebsd.org/changeset/base/303210 Log: 1) POSIX defines well when GLOB_NOMATCH or original pattern (instead) should be returned, so we can't return GLOB_NOMATCH blindly just because we dislike something in the pattern. 2) Remove extra condition. Modified: head/lib/libc/gen/glob.c Modified: head/lib/libc/gen/glob.c ============================================================================== --- head/lib/libc/gen/glob.c Sat Jul 23 02:27:42 2016 (r303209) +++ head/lib/libc/gen/glob.c Sat Jul 23 03:49:02 2016 (r303210) @@ -217,7 +217,8 @@ glob(const char * __restrict pattern, in while (bufnext <= bufend) { clen = mbrtowc(&wc, patnext, MB_LEN_MAX, &mbs); if (clen == (size_t)-1 || clen == (size_t)-2) - return (GLOB_NOMATCH); + return (globfinal(pglob, &limit, + pglob->gl_pathc, pattern)); else if (clen == 0) { too_long = 0; break; @@ -239,7 +240,8 @@ glob(const char * __restrict pattern, in prot = 0; clen = mbrtowc(&wc, patnext, MB_LEN_MAX, &mbs); if (clen == (size_t)-1 || clen == (size_t)-2) - return (GLOB_NOMATCH); + return (globfinal(pglob, &limit, + pglob->gl_pathc, pattern)); else if (clen == 0) { too_long = 0; break; @@ -249,7 +251,7 @@ glob(const char * __restrict pattern, in } } if (too_long) - return (GLOB_NOMATCH); + return (globfinal(pglob, &limit, pglob->gl_pathc, pattern)); *bufnext = EOS; if (flags & GLOB_BRACE) @@ -613,9 +615,9 @@ globfinal(glob_t *pglob, struct glob_lim * GLOB_NOMAGIC is there just for compatibility with csh. */ if (pglob->gl_pathc == oldpathc) { - if (origpat != NULL && ((pglob->gl_flags & GLOB_NOCHECK) || + if ((pglob->gl_flags & GLOB_NOCHECK) || ((pglob->gl_flags & GLOB_NOMAGIC) && - !(pglob->gl_flags & GLOB_MAGCHAR)))) + !(pglob->gl_flags & GLOB_MAGCHAR))) return (globextend(NULL, pglob, limit, origpat)); else return (GLOB_NOMATCH);