diff options
Diffstat (limited to 'openbsd-compat/glob.c')
-rw-r--r-- | openbsd-compat/glob.c | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/openbsd-compat/glob.c b/openbsd-compat/glob.c index 365d4334f..e928a2272 100644 --- a/openbsd-compat/glob.c +++ b/openbsd-compat/glob.c | |||
@@ -56,7 +56,7 @@ get_arg_max(void) | |||
56 | #if 0 | 56 | #if 0 |
57 | static char sccsid[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93"; | 57 | static char sccsid[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93"; |
58 | #else | 58 | #else |
59 | static char rcsid[] = "$OpenBSD: glob.c,v 1.16 2001/04/05 18:36:12 deraadt Exp $"; | 59 | static char rcsid[] = "$OpenBSD: glob.c,v 1.20 2002/06/14 21:34:58 todd Exp $"; |
60 | #endif | 60 | #endif |
61 | #endif /* LIBC_SCCS and not lint */ | 61 | #endif /* LIBC_SCCS and not lint */ |
62 | 62 | ||
@@ -97,6 +97,7 @@ static char rcsid[] = "$OpenBSD: glob.c,v 1.16 2001/04/05 18:36:12 deraadt Exp $ | |||
97 | #define RBRACKET ']' | 97 | #define RBRACKET ']' |
98 | #define SEP '/' | 98 | #define SEP '/' |
99 | #define STAR '*' | 99 | #define STAR '*' |
100 | #undef TILDE /* Some platforms may already define it */ | ||
100 | #define TILDE '~' | 101 | #define TILDE '~' |
101 | #define UNDERSCORE '_' | 102 | #define UNDERSCORE '_' |
102 | #define LBRACE '{' | 103 | #define LBRACE '{' |
@@ -136,32 +137,32 @@ typedef char Char; | |||
136 | #define ismeta(c) (((c)&M_QUOTE) != 0) | 137 | #define ismeta(c) (((c)&M_QUOTE) != 0) |
137 | 138 | ||
138 | 139 | ||
139 | static int compare __P((const void *, const void *)); | 140 | static int compare(const void *, const void *); |
140 | static int g_Ctoc __P((const Char *, char *, u_int)); | 141 | static int g_Ctoc(const Char *, char *, u_int); |
141 | static int g_lstat __P((Char *, struct stat *, glob_t *)); | 142 | static int g_lstat(Char *, struct stat *, glob_t *); |
142 | static DIR *g_opendir __P((Char *, glob_t *)); | 143 | static DIR *g_opendir(Char *, glob_t *); |
143 | static Char *g_strchr __P((Char *, int)); | 144 | static Char *g_strchr(Char *, int); |
144 | static int g_stat __P((Char *, struct stat *, glob_t *)); | 145 | static int g_stat(Char *, struct stat *, glob_t *); |
145 | static int glob0 __P((const Char *, glob_t *)); | 146 | static int glob0(const Char *, glob_t *); |
146 | static int glob1 __P((Char *, Char *, glob_t *, size_t *)); | 147 | static int glob1(Char *, Char *, glob_t *, size_t *); |
147 | static int glob2 __P((Char *, Char *, Char *, Char *, Char *, Char *, | 148 | static int glob2(Char *, Char *, Char *, Char *, Char *, Char *, |
148 | glob_t *, size_t *)); | 149 | glob_t *, size_t *); |
149 | static int glob3 __P((Char *, Char *, Char *, Char *, Char *, Char *, | 150 | static int glob3(Char *, Char *, Char *, Char *, Char *, Char *, |
150 | Char *, Char *, glob_t *, size_t *)); | 151 | Char *, Char *, glob_t *, size_t *); |
151 | static int globextend __P((const Char *, glob_t *, size_t *)); | 152 | static int globextend(const Char *, glob_t *, size_t *); |
152 | static const Char * | 153 | static const Char * |
153 | globtilde __P((const Char *, Char *, size_t, glob_t *)); | 154 | globtilde(const Char *, Char *, size_t, glob_t *); |
154 | static int globexp1 __P((const Char *, glob_t *)); | 155 | static int globexp1(const Char *, glob_t *); |
155 | static int globexp2 __P((const Char *, const Char *, glob_t *, int *)); | 156 | static int globexp2(const Char *, const Char *, glob_t *, int *); |
156 | static int match __P((Char *, Char *, Char *)); | 157 | static int match(Char *, Char *, Char *); |
157 | #ifdef DEBUG | 158 | #ifdef DEBUG |
158 | static void qprintf __P((const char *, Char *)); | 159 | static void qprintf(const char *, Char *); |
159 | #endif | 160 | #endif |
160 | 161 | ||
161 | int | 162 | int |
162 | glob(pattern, flags, errfunc, pglob) | 163 | glob(pattern, flags, errfunc, pglob) |
163 | const char *pattern; | 164 | const char *pattern; |
164 | int flags, (*errfunc) __P((const char *, int)); | 165 | int flags, (*errfunc)(const char *, int); |
165 | glob_t *pglob; | 166 | glob_t *pglob; |
166 | { | 167 | { |
167 | const u_char *patnext; | 168 | const u_char *patnext; |
@@ -676,7 +677,7 @@ glob3(pathbuf, pathbuf_last, pathend, pathend_last, pattern, pattern_last, | |||
676 | 677 | ||
677 | 678 | ||
678 | /* | 679 | /* |
679 | * Extend the gl_pathv member of a glob_t structure to accomodate a new item, | 680 | * Extend the gl_pathv member of a glob_t structure to accommodate a new item, |
680 | * add the new item, and update gl_pathc. | 681 | * add the new item, and update gl_pathc. |
681 | * | 682 | * |
682 | * This assumes the BSD realloc, which only copies the block when its size | 683 | * This assumes the BSD realloc, which only copies the block when its size |
@@ -821,7 +822,7 @@ g_opendir(str, pglob) | |||
821 | char buf[MAXPATHLEN]; | 822 | char buf[MAXPATHLEN]; |
822 | 823 | ||
823 | if (!*str) | 824 | if (!*str) |
824 | strcpy(buf, "."); | 825 | strlcpy(buf, ".", sizeof buf); |
825 | else { | 826 | else { |
826 | if (g_Ctoc(str, buf, sizeof(buf))) | 827 | if (g_Ctoc(str, buf, sizeof(buf))) |
827 | return(NULL); | 828 | return(NULL); |