Deleted Added
sdiff udiff text old ( 138441 ) new ( 138455 )
full compact
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 138441 2004-12-06 11:30:36Z 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 DirMatchFiles(char *, Path *, Lst);
194static void DirExpandCurly(char *, char *, Lst, Lst);
195static void DirExpandInt(char *, Lst, Lst);
196static int DirPrintWord(void *, void *);
197static int DirPrintDir(void *, void *);
198
199/*-
200 *-----------------------------------------------------------------------
201 * Dir_Init --
202 * initialize things for this module
203 *

--- 96 unchanged lines hidden (view full) ---

300 * Results:
301 * returns TRUE if the word should be expanded, FALSE otherwise
302 *
303 * Side Effects:
304 * none
305 *-----------------------------------------------------------------------
306 */
307Boolean
308Dir_HasWildcards(char *name)
309{
310 char *cp;
311 int wild = 0, brace = 0, bracket = 0;
312
313 for (cp = name; *cp; cp++) {
314 switch (*cp) {
315 case '{':
316 brace++;
317 wild = 1;
318 break;

--- 31 unchanged lines hidden (view full) ---

350 * Always returns 0
351 *
352 * Side Effects:
353 * File names are added to the expansions lst. The directory will be
354 * fully hashed when this is done.
355 *-----------------------------------------------------------------------
356 */
357static int
358DirMatchFiles(char *pattern, Path *p, Lst expansions)
359{
360 Hash_Search search; /* Index into the directory's table */
361 Hash_Entry *entry; /* Current entry in the table */
362 Boolean isDot; /* TRUE if the directory being searched is . */
363
364 isDot = (*p->name == '.' && p->name[1] == '\0');
365
366 for (entry = Hash_EnumFirst(&p->files, &search);

--- 31 unchanged lines hidden (view full) ---

398 * None.
399 *
400 * Side Effects:
401 * The given list is filled with the expansions...
402 *
403 *-----------------------------------------------------------------------
404 */
405static void
406DirExpandCurly(char *word, char *brace, Lst path, Lst expansions)
407{
408 char *end; /* Character after the closing brace */
409 char *cp; /* Current position in brace clause */
410 char *start; /* Start of current piece of brace clause */
411 int bracelevel; /* Number of braces we've seen. If we see a right brace
412 * when this is 0, we've hit the end of the clause. */
413 char *file; /* Current expansion */
414 int otherLen; /* The length of the other pieces of the expansion
415 * (chars before and after the clause in 'word') */
416 char *cp2; /* Pointer for checking for wildcards in
417 * expansion before calling Dir_Expand */
418

--- 66 unchanged lines hidden (view full) ---

485 } else {
486 next:
487 free(file);
488 }
489 start = cp + 1;
490 }
491}
492
493
494/*-
495 *-----------------------------------------------------------------------
496 * DirExpandInt --
497 * Internal expand routine. Passes through the directories in the
498 * path one by one, calling DirMatchFiles for each. NOTE: This still
499 * doesn't handle patterns in directories... Works given a word to
500 * expand, a path to look in, and a list to store expansions in.
501 *
502 * Results:
503 * None.
504 *
505 * Side Effects:
506 * Things are added to the expansions list.
507 *
508 *-----------------------------------------------------------------------
509 */
510static void
511DirExpandInt(char *word, Lst path, Lst expansions)
512{
513 LstNode ln; /* Current node */
514 Path *p; /* Directory in the node */
515
516 if (Lst_Open(path) == SUCCESS) {
517 while ((ln = Lst_Next(path)) != NULL) {
518 p = Lst_Datum(ln);
519 DirMatchFiles(word, p, expansions);

--- 746 unchanged lines hidden ---