Project

General

Profile

Bug #1097 » glob.c-w9.diff

Gary Mills, 2013-02-19 08:17 PM

View differences:

glob.c-w9 Mon Feb 18 14:57:50 2013
59 59
 *	Number of matches in the current invocation of glob.
60 60
 */
61 61

  
62
#pragma	weak _glob = glob
63
#pragma	weak __glob_ext = _glob_ext
64
#pragma	weak _globfree = globfree
65
#pragma	weak __globfree_ext = _globfree_ext
66

  
67
#include "lint.h"
68

  
62 69
#include <sys/param.h>
63 70
#include <sys/stat.h>
64 71

  
65 72
#include <ctype.h>
66 73
#include <dirent.h>
67 74
#include <errno.h>
75
#define	_GLOB_LIBC
68 76
#include <glob.h>
77
#undef _GLOB_LIBC
69 78
#include <limits.h>
70 79
#include <pwd.h>
71 80
#include <stdio.h>
......
136 145
static DIR	*g_opendir(wcat_t *, glob_t *);
137 146
static wcat_t	*g_strchr(const wcat_t *, wchar_t);
138 147
static int	 g_stat(wcat_t *, struct stat *, glob_t *);
148
static int	 glob_com(const char *, int, int (*)(const char *, int),
149
			glob_t *);
139 150
static int	 glob0(const wcat_t *, glob_t *, struct glob_lim *,
140 151
			int (*)(const char *, int));
141 152
static int	 glob1(wcat_t *, wcat_t *, glob_t *, struct glob_lim *,
......
155 166
static int	 globexp2(const wcat_t *, const wcat_t *, glob_t *,
156 167
		    struct glob_lim *, int (*)(const char *, int));
157 168
static int	 match(wcat_t *, wcat_t *, wcat_t *, int);
169
static void	 globfree_com(glob_t *);
158 170
#ifdef DEBUG
159 171
static void	 qprintf(const char *, wcat_t *);
160 172
#endif
161 173

  
174
/* glob() function with legacy glob structure */
162 175
int
163 176
glob(const char *pattern, int flags, int (*errfunc)(const char *, int),
164 177
    glob_t *pglob)
165 178
{
179
	/* Only POSIX flags allowed */
180
	if ((flags & ~GLOB_POSIX) != 0)
181
		return (GLOB_NOMATCH);
182

  
183
	return (glob_com(pattern, flags, errfunc, pglob));
184
}
185

  
186
/* Extended glob() function, selected by #pragma redefine_extname in glob.h */
187
int
188
_glob_ext(const char *pattern, int flags, int (*errfunc)(const char *, int),
189
    glob_t *pglob)
190
{
191
	return (glob_com(pattern, flags, errfunc, pglob));
192
}
193

  
194
static int
195
glob_com(const char *pattern, int flags, int (*errfunc)(const char *, int),
196
    glob_t *pglob)
197
{
166 198
	const char *patnext;
167 199
	int n;
168 200
	size_t patlen;
......
1118 1150
	return (name->w_wc == EOS);
1119 1151
}
1120 1152

  
1121
/* Free allocated data belonging to a glob_t structure. */
1153
/* globfree() function with legacy glob structure */
1122 1154
void
1123 1155
globfree(glob_t *pglob)
1124 1156
{
1157
	/* Only POSIX flags allowed */
1158
	pglob->gl_flags &= GLOB_POSIX;
1159

  
1160
	globfree_com(pglob);
1161
}
1162

  
1163
/*
1164
 * Extended globfree() function, selected by #pragma redefine_extname
1165
 * in glob.h
1166
 */
1167
void
1168
_globfree_ext(glob_t *pglob)
1169
{
1170
	globfree_com(pglob);
1171
}
1172

  
1173
/* Free allocated data belonging to a glob_t structure. */
1174
void
1175
globfree_com(glob_t *pglob)
1176
{
1125 1177
	int i;
1126 1178
	char **pp;
1127 1179

  
(11-11/11)