1/* 2 * Copyright (c) 1988, 1989, 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * Copyright (c) 1988, 1989 by Adam de Boor 5 * Copyright (c) 1989 by Berkeley Softworks 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by --- 26 unchanged lines hidden (view full) --- 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 * 39 * @(#)dir.c 8.2 (Berkeley) 1/2/94 40 */ 41 42#include <sys/cdefs.h> |
43__FBSDID("$FreeBSD: head/usr.bin/make/dir.c 138455 2004-12-06 15:20:12Z harti $"); |
44 45/*- 46 * dir.c -- 47 * Directory searching using wildcards and/or normal names... 48 * Used both for source wildcarding in the Makefile and for finding 49 * implicit sources. 50 * 51 * The interface for this module is: --- 133 unchanged lines hidden (view full) --- 185 * XXX: If this is done way early, there's a chance other rules will 186 * have already updated the file, in which case we'll update it again. 187 * Generally, there won't be two rules to update a single file, so this 188 * should be ok, but... 189 */ 190static Hash_Table mtimes; 191 192static int DirFindName(void *, void *); |
193static int DirPrintWord(void *, void *); 194static int DirPrintDir(void *, void *); 195 196/*- 197 *----------------------------------------------------------------------- 198 * Dir_Init -- 199 * initialize things for this module 200 * --- 96 unchanged lines hidden (view full) --- 297 * Results: 298 * returns TRUE if the word should be expanded, FALSE otherwise 299 * 300 * Side Effects: 301 * none 302 *----------------------------------------------------------------------- 303 */ 304Boolean |
305Dir_HasWildcards(const char *name) |
306{ |
307 const char *cp; |
308 int wild = 0, brace = 0, bracket = 0; 309 310 for (cp = name; *cp; cp++) { 311 switch (*cp) { 312 case '{': 313 brace++; 314 wild = 1; 315 break; --- 31 unchanged lines hidden (view full) --- 347 * Always returns 0 348 * 349 * Side Effects: 350 * File names are added to the expansions lst. The directory will be 351 * fully hashed when this is done. 352 *----------------------------------------------------------------------- 353 */ 354static int |
355DirMatchFiles(const char *pattern, const Path *p, Lst expansions) |
356{ 357 Hash_Search search; /* Index into the directory's table */ 358 Hash_Entry *entry; /* Current entry in the table */ 359 Boolean isDot; /* TRUE if the directory being searched is . */ 360 361 isDot = (*p->name == '.' && p->name[1] == '\0'); 362 363 for (entry = Hash_EnumFirst(&p->files, &search); --- 31 unchanged lines hidden (view full) --- 395 * None. 396 * 397 * Side Effects: 398 * The given list is filled with the expansions... 399 * 400 *----------------------------------------------------------------------- 401 */ 402static void |
403DirExpandCurly(const char *word, const char *brace, Lst path, Lst expansions) |
404{ |
405 const char *end; /* Character after the closing brace */ 406 const char *cp; /* Current position in brace clause */ 407 const char *start; /* Start of current piece of brace clause */ |
408 int bracelevel; /* Number of braces we've seen. If we see a right brace 409 * when this is 0, we've hit the end of the clause. */ 410 char *file; /* Current expansion */ 411 int otherLen; /* The length of the other pieces of the expansion 412 * (chars before and after the clause in 'word') */ 413 char *cp2; /* Pointer for checking for wildcards in 414 * expansion before calling Dir_Expand */ 415 --- 66 unchanged lines hidden (view full) --- 482 } else { 483 next: 484 free(file); 485 } 486 start = cp + 1; 487 } 488} 489 |
490/*- 491 *----------------------------------------------------------------------- 492 * DirExpandInt -- 493 * Internal expand routine. Passes through the directories in the 494 * path one by one, calling DirMatchFiles for each. NOTE: This still 495 * doesn't handle patterns in directories... Works given a word to 496 * expand, a path to look in, and a list to store expansions in. 497 * 498 * Results: 499 * None. 500 * 501 * Side Effects: 502 * Things are added to the expansions list. 503 * 504 *----------------------------------------------------------------------- 505 */ 506static void |
507DirExpandInt(const char *word, Lst path, Lst expansions) |
508{ 509 LstNode ln; /* Current node */ 510 Path *p; /* Directory in the node */ 511 512 if (Lst_Open(path) == SUCCESS) { 513 while ((ln = Lst_Next(path)) != NULL) { 514 p = Lst_Datum(ln); 515 DirMatchFiles(word, p, expansions); --- 746 unchanged lines hidden --- |