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); _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"