Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/gen Instead of changing the code to match the docum...



details:   https://anonhg.NetBSD.org/src/rev/1cc1cd1b147e
branches:  trunk
changeset: 783536:1cc1cd1b147e
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Dec 27 21:17:47 2012 +0000

description:
Instead of changing the code to match the documentation, change the documentation
to match the code. NOCHECK is used only by csh(1) and csh(1) is too broken for
words (histchars quoting is "special").

diffstat:

 lib/libc/gen/glob.3 |   7 ++++---
 lib/libc/gen/glob.c |  42 ++++++++++++++++--------------------------
 2 files changed, 20 insertions(+), 29 deletions(-)

diffs (159 lines):

diff -r 81aa6a2d36e4 -r 1cc1cd1b147e lib/libc/gen/glob.3
--- a/lib/libc/gen/glob.3       Thu Dec 27 20:32:41 2012 +0000
+++ b/lib/libc/gen/glob.3       Thu Dec 27 21:17:47 2012 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: glob.3,v 1.41 2012/08/12 13:31:41 christos Exp $
+.\"    $NetBSD: glob.3,v 1.42 2012/12/27 21:17:47 christos Exp $
 .\"
 .\" Copyright (c) 1989, 1991, 1993, 1994
 .\"    The Regents of the University of California.  All rights reserved.
@@ -31,7 +31,7 @@
 .\"
 .\"     @(#)glob.3     8.3 (Berkeley) 4/16/94
 .\"
-.Dd August 12, 2012
+.Dd December 27, 2012
 .Dt GLOB 3
 .Os
 .Sh NAME
@@ -185,7 +185,8 @@
 returns a list
 consisting of only
 .Fa pattern ,
-with the number of total pathnames set to 1, and the number of matched
+with one level of backslash escapes removed,
+the number of total pathnames set to 1, and the number of matched
 pathnames set to 0.
 .It Dv GLOB_NOSORT
 By default, the pathnames are sorted in ascending
diff -r 81aa6a2d36e4 -r 1cc1cd1b147e lib/libc/gen/glob.c
--- a/lib/libc/gen/glob.c       Thu Dec 27 20:32:41 2012 +0000
+++ b/lib/libc/gen/glob.c       Thu Dec 27 21:17:47 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: glob.c,v 1.32 2012/12/18 01:39:56 christos Exp $       */
+/*     $NetBSD: glob.c,v 1.33 2012/12/27 21:17:47 christos Exp $       */
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)glob.c     8.3 (Berkeley) 10/13/93";
 #else
-__RCSID("$NetBSD: glob.c,v 1.32 2012/12/18 01:39:56 christos Exp $");
+__RCSID("$NetBSD: glob.c,v 1.33 2012/12/27 21:17:47 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -163,7 +163,7 @@
 static DIR     *g_opendir(Char *, glob_t *);
 static Char    *g_strchr(const Char *, int);
 static int      g_stat(Char *, __gl_stat_t *, glob_t *);
-static int      glob0(const char *, const Char *, glob_t *, struct glob_limit *);
+static int      glob0(const Char *, glob_t *, struct glob_limit *);
 static int      glob1(Char *, glob_t *, struct glob_limit *);
 static int      glob2(Char *, Char *, Char *, const Char *, glob_t *,
     struct glob_limit *);
@@ -171,8 +171,8 @@
     const Char *, glob_t *, struct glob_limit *);
 static int      globextend(const Char *, glob_t *, struct glob_limit *);
 static const Char *globtilde(const Char *, Char *, size_t, glob_t *);
-static int      globexp1(const char *, const Char *, glob_t *, struct glob_limit *);
-static int      globexp2(const char *, const Char *, const Char *, glob_t *, int *,
+static int      globexp1(const Char *, glob_t *, struct glob_limit *);
+static int      globexp2(const Char *, const Char *, glob_t *, int *,
     struct glob_limit *);
 static int      match(const Char *, const Char *, const Char *);
 #ifdef DEBUG
@@ -222,9 +222,9 @@
        *bufnext = EOS;
 
        if (flags & GLOB_BRACE)
-           return globexp1(pattern, patbuf, pglob, &limit);
+           return globexp1(patbuf, pglob, &limit);
        else
-           return glob0(pattern, patbuf, pglob, &limit);
+           return glob0(patbuf, pglob, &limit);
 }
 
 /*
@@ -233,7 +233,7 @@
  * characters
  */
 static int
-globexp1(const char *orig, const Char *pattern, glob_t *pglob, struct glob_limit *limit)
+globexp1(const Char *pattern, glob_t *pglob, struct glob_limit *limit)
 {
        const Char* ptr = pattern;
        int rv;
@@ -249,13 +249,13 @@
 
        /* Protect a single {}, for find(1), like csh */
        if (pattern[0] == LBRACE && pattern[1] == RBRACE && pattern[2] == EOS)
-               return glob0(orig, pattern, pglob, limit);
+               return glob0(pattern, pglob, limit);
 
        while ((ptr = (const Char *) g_strchr(ptr, LBRACE)) != NULL)
-               if (!globexp2(orig, ptr, pattern, pglob, &rv, limit))
+               if (!globexp2(ptr, pattern, pglob, &rv, limit))
                        return rv;
 
-       return glob0(orig, pattern, pglob, limit);
+       return glob0(pattern, pglob, limit);
 }
 
 
@@ -265,7 +265,7 @@
  * If it fails then it tries to glob the rest of the pattern and returns.
  */
 static int
-globexp2(const char *orig, const Char *ptr, const Char *pattern, glob_t *pglob, int *rv,
+globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, int *rv,
     struct glob_limit *limit)
 {
        int     i;
@@ -311,7 +311,7 @@
                 * we use `pattern', not `patbuf' here so that that
                 * unbalanced braces are passed to the match
                 */
-               *rv = glob0(orig, pattern, pglob, limit);
+               *rv = glob0(pattern, pglob, limit);
                return 0;
        }
 
@@ -358,7 +358,7 @@
 #ifdef DEBUG
                                qprintf("globexp2", patbuf);
 #endif
-                               *rv = globexp1(orig, patbuf, pglob, limit);
+                               *rv = globexp1(patbuf, pglob, limit);
 
                                /* move after the comma, to the next string */
                                pl = pm + 1;
@@ -471,7 +471,7 @@
  * to find no matches.
  */
 static int
-glob0(const char *orig, const Char *pattern, glob_t *pglob, struct glob_limit *limit)
+glob0(const Char *pattern, glob_t *pglob, struct glob_limit *limit)
 {
        const Char *qpatnext;
        int c, error;
@@ -556,17 +556,7 @@
                if ((pglob->gl_flags & GLOB_NOCHECK) ||
                    ((pglob->gl_flags & (GLOB_NOMAGIC|GLOB_MAGCHAR))
                     == GLOB_NOMAGIC)) {
-                       const u_char *patnext;
-                       Char *bufend;
-                       bufend = patbuf + MAXPATHLEN;
-                       patnext = (const unsigned char *)orig;
-                       bufnext = patbuf;
-                       while (bufnext < bufend && (c = *patnext++) != EOS) 
-                               *bufnext++ = c;
-
-                       *bufnext = EOS;
-
-                       return globextend(patbuf, pglob, limit);
+                       return globextend(pattern, pglob, limit);
                } else {
                        return GLOB_NOMATCH;
                }



Home | Main Index | Thread Index | Old Index