1 /* Target file hash table management for GNU Make.
2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
3 2002 Free Software Foundation, Inc.
4 This file is part of GNU Make.
6 GNU Make is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Make is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Make; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
34 /* Remember whether snap_deps has been invoked: we need this to be sure we
35 don't add new rules (via $(eval ...)) afterwards. In the future it would
36 be nice to support this, but it means we'd need to re-run snap_deps() or
37 at least its functionality... it might mean changing snap_deps() to be run
38 per-file, so we can invoke it after the eval... or remembering which files
39 in the hash have been snapped (a new boolean flag?) and having snap_deps()
40 only work on files which have not yet been snapped. */
43 /* Hash table of files the makefile knows how to make. */
46 file_hash_1 (const void *key
)
48 return_ISTRING_HASH_1 (((struct file
const *) key
)->hname
);
52 file_hash_2 (const void *key
)
54 return_ISTRING_HASH_2 (((struct file
const *) key
)->hname
);
58 file_hash_cmp (const void *x
, const void *y
)
60 return_ISTRING_COMPARE (((struct file
const *) x
)->hname
,
61 ((struct file
const *) y
)->hname
);
65 #define FILE_BUCKETS 1007
67 static struct hash_table files
;
69 /* Whether or not .SECONDARY with no prerequisites was given. */
70 static int all_secondary
= 0;
72 /* Access the hash table of all file records.
73 lookup_file given a name, return the struct file * for that name,
74 or nil if there is none.
75 enter_file similar, but create one if there is none. */
78 lookup_file (char *name
)
80 register struct file
*f
;
82 #if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS)
83 register char *lname
, *ln
;
86 assert (*name
!= '\0');
88 /* This is also done in parse_file_seq, so this is redundant
89 for names read from makefiles. It is here for names passed
90 on the command line. */
92 # ifndef WANT_CASE_SENSITIVE_TARGETS
95 lname
= (char *) malloc (strlen (name
) + 1);
96 for (n
= name
, ln
= lname
; *n
!= '\0'; ++n
, ++ln
)
97 *ln
= isupper ((unsigned char)*n
) ? tolower ((unsigned char)*n
) : *n
;
103 while (name
[0] == '[' && name
[1] == ']' && name
[2] != '\0')
106 while (name
[0] == '.' && name
[1] == '/' && name
[2] != '\0')
110 /* Skip following slashes: ".//foo" is "foo", not "/foo". */
115 /* It was all slashes after a dot. */
126 file_key
.hname
= name
;
127 f
= (struct file
*) hash_find_item (&files
, &file_key
);
128 #if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS)
135 enter_file (char *name
)
137 register struct file
*f
;
138 register struct file
*new;
139 register struct file
**file_slot
;
140 struct file file_key
;
141 #if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS)
145 assert (*name
!= '\0');
147 #if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS)
150 lname
= (char *) malloc (strlen (name
) + 1);
151 for (n
= name
, ln
= lname
; *n
!= '\0'; ++n
, ++ln
)
153 if (isupper ((unsigned char)*n
))
154 *ln
= tolower ((unsigned char)*n
);
160 /* Creates a possible leak, old value of name is unreachable, but I
161 currently don't know how to fix it. */
166 file_key
.hname
= name
;
167 file_slot
= (struct file
**) hash_find_slot (&files
, &file_key
);
169 if (! HASH_VACANT (f
) && !f
->double_colon
)
171 #if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS)
177 new = (struct file
*) xmalloc (sizeof (struct file
));
178 bzero ((char *) new, sizeof (struct file
));
179 new->name
= new->hname
= name
;
180 new->update_status
= -1;
185 hash_insert_at (&files
, new, file_slot
);
189 /* There is already a double-colon entry for this file. */
190 new->double_colon
= f
;
198 /* Rename FILE to NAME. This is not as simple as resetting
199 the `name' member, since it must be put in a new hash bucket,
200 and possibly merged with an existing file called NAME. */
203 rename_file (struct file
*from_file
, char *to_hname
)
205 rehash_file (from_file
, to_hname
);
208 from_file
->name
= from_file
->hname
;
209 from_file
= from_file
->prev
;
213 /* Rehash FILE to NAME. This is not as simple as resetting
214 the `hname' member, since it must be put in a new hash bucket,
215 and possibly merged with an existing file called NAME. */
218 rehash_file (struct file
*from_file
, char *to_hname
)
220 struct file file_key
;
221 struct file
**file_slot
;
222 struct file
*to_file
;
223 struct file
*deleted_file
;
226 file_key
.hname
= to_hname
;
227 if (0 == file_hash_cmp (from_file
, &file_key
))
230 file_key
.hname
= from_file
->hname
;
231 while (from_file
->renamed
!= 0)
232 from_file
= from_file
->renamed
;
233 if (file_hash_cmp (from_file
, &file_key
))
234 /* hname changed unexpectedly */
237 deleted_file
= hash_delete (&files
, from_file
);
238 if (deleted_file
!= from_file
)
239 /* from_file isn't the one stored in files */
242 file_key
.hname
= to_hname
;
243 file_slot
= (struct file
**) hash_find_slot (&files
, &file_key
);
244 to_file
= *file_slot
;
246 from_file
->hname
= to_hname
;
247 for (f
= from_file
->double_colon
; f
!= 0; f
= f
->prev
)
250 if (HASH_VACANT (to_file
))
251 hash_insert_at (&files
, from_file
, file_slot
);
254 /* TO_FILE already exists under TO_HNAME.
255 We must retain TO_FILE and merge FROM_FILE into it. */
257 if (from_file
->cmds
!= 0)
259 if (to_file
->cmds
== 0)
260 to_file
->cmds
= from_file
->cmds
;
261 else if (from_file
->cmds
!= to_file
->cmds
)
263 /* We have two sets of commands. We will go with the
264 one given in the rule explicitly mentioning this name,
265 but give a message to let the user know what's going on. */
266 if (to_file
->cmds
->fileinfo
.filenm
!= 0)
267 error (&from_file
->cmds
->fileinfo
,
268 _("Commands were specified for file `%s' at %s:%lu,"),
269 from_file
->name
, to_file
->cmds
->fileinfo
.filenm
,
270 to_file
->cmds
->fileinfo
.lineno
);
272 error (&from_file
->cmds
->fileinfo
,
273 _("Commands for file `%s' were found by implicit rule search,"),
275 error (&from_file
->cmds
->fileinfo
,
276 _("but `%s' is now considered the same file as `%s'."),
277 from_file
->name
, to_hname
);
278 error (&from_file
->cmds
->fileinfo
,
279 _("Commands for `%s' will be ignored in favor of those for `%s'."),
280 to_hname
, from_file
->name
);
284 /* Merge the dependencies of the two files. */
286 if (to_file
->deps
== 0)
287 to_file
->deps
= from_file
->deps
;
290 register struct dep
*deps
= to_file
->deps
;
291 while (deps
->next
!= 0)
293 deps
->next
= from_file
->deps
;
296 merge_variable_set_lists (&to_file
->variables
, from_file
->variables
);
298 if (to_file
->double_colon
&& from_file
->is_target
&& !from_file
->double_colon
)
299 fatal (NILF
, _("can't rename single-colon `%s' to double-colon `%s'"),
300 from_file
->name
, to_hname
);
301 if (!to_file
->double_colon
&& from_file
->double_colon
)
303 if (to_file
->is_target
)
304 fatal (NILF
, _("can't rename double-colon `%s' to single-colon `%s'"),
305 from_file
->name
, to_hname
);
307 to_file
->double_colon
= from_file
->double_colon
;
310 if (from_file
->last_mtime
> to_file
->last_mtime
)
311 /* %%% Kludge so -W wins on a file that gets vpathized. */
312 to_file
->last_mtime
= from_file
->last_mtime
;
314 to_file
->mtime_before_update
= from_file
->mtime_before_update
;
316 #define MERGE(field) to_file->field |= from_file->field
318 MERGE (tried_implicit
);
324 MERGE (ignore_vpath
);
327 from_file
->renamed
= to_file
;
331 /* Remove all nonprecious intermediate files.
332 If SIG is nonzero, this was caused by a fatal signal,
333 meaning that a different message will be printed, and
334 the message will go to stderr rather than stdout. */
337 remove_intermediates (int sig
)
339 register struct file
**file_slot
;
340 register struct file
**file_end
;
343 /* If there's no way we will ever remove anything anyway, punt early. */
344 if (question_flag
|| touch_flag
|| all_secondary
)
347 if (sig
&& just_print_flag
)
350 file_slot
= (struct file
**) files
.ht_vec
;
351 file_end
= file_slot
+ files
.ht_size
;
352 for ( ; file_slot
< file_end
; file_slot
++)
353 if (! HASH_VACANT (*file_slot
))
355 register struct file
*f
= *file_slot
;
356 /* Is this file eligible for automatic deletion?
357 Yes, IFF: it's marked intermediate, it's not secondary, it wasn't
358 given on the command-line, and it's either a -include makefile or
359 it's not precious. */
360 if (f
->intermediate
&& (f
->dontcare
|| !f
->precious
)
361 && !f
->secondary
&& !f
->cmd_target
)
364 if (f
->update_status
== -1)
365 /* If nothing would have created this file yet,
366 don't print an "rm" command for it. */
372 status
= unlink (f
->name
);
373 if (status
< 0 && errno
== ENOENT
)
379 error (NILF
, _("*** Deleting intermediate file `%s'"), f
->name
);
383 DB (DB_BASIC
, (_("Removing intermediate files...\n")));
388 fputs ("rm ", stdout
);
393 fputs (f
->name
, stdout
);
398 perror_with_name ("unlink: ", f
->name
);
411 parse_prereqs (char *p
)
413 struct dep
*new = (struct dep
*)
414 multi_glob (parse_file_seq (&p
, '|', sizeof (struct dep
), 1),
415 sizeof (struct dep
));
419 /* Files that follow '|' are "order-only" prerequisites that satisfy the
420 dependency by existing: their modification times are irrelevant. */
425 multi_glob (parse_file_seq (&p
, '\0', sizeof (struct dep
), 1),
426 sizeof (struct dep
));
433 for (dp
= new; dp
->next
!= NULL
; dp
= dp
->next
)
438 for (; ood
!= NULL
; ood
= ood
->next
)
439 ood
->ignore_mtime
= 1;
446 /* Set the intermediate flag. */
449 set_intermediate (const void *item
)
451 struct file
*f
= (struct file
*) item
;
455 /* Expand and parse each dependency line. */
457 expand_deps (struct file
*f
)
460 struct dep
*old
= f
->deps
;
461 unsigned int last_dep_has_cmds
= f
->updating
;
467 for (d
= old
; d
!= 0; d
= d
->next
)
469 struct dep
*new, *d1
;
475 /* Create the dependency list.
476 If we're not doing 2nd expansion, then it's just the name. */
477 if (! d
->need_2nd_expansion
)
481 /* If it's from a static pattern rule, convert the patterns into
482 "$*" so they'll expand properly. */
483 if (d
->staticpattern
)
486 char *buffer
= variable_expand ("");
488 o
= subst_expand (buffer
, d
->name
, "%", "$*", 1, 2, 0);
491 d
->name
= savestring (buffer
, o
- buffer
);
492 d
->staticpattern
= 0;
495 /* We are going to do second expansion so initialize file variables
499 initialize_file_variables (f
, 0);
503 set_file_variables (f
);
505 p
= variable_expand_for_file (d
->name
, f
);
508 /* Parse the prerequisites. */
509 new = parse_prereqs (p
);
511 /* If this dep list was from a static pattern rule, expand the %s. We
512 use patsubst_expand to translate the prerequisites' patterns into
513 plain prerequisite names. */
514 if (new && d
->staticpattern
)
517 char *buffer
= variable_expand ("");
518 struct dep
*dp
= new, *dl
= 0;
522 char *percent
= find_percent (dp
->name
);
525 /* We have to handle empty stems specially, because that
526 would be equivalent to $(patsubst %,dp->name,) which
527 will always be empty. */
528 if (f
->stem
[0] == '\0')
529 /* This needs memmove() in ISO C. */
530 bcopy (percent
+1, percent
, strlen (percent
));
533 char *o
= patsubst_expand (buffer
, f
->stem
, pattern
,
541 dp
->name
= savestring (buffer
, o
- buffer
);
545 /* If the name expanded to the empty string, ignore it. */
546 if (dp
->name
[0] == '\0')
550 dp
= new = new->next
;
552 dp
= dl
->next
= dp
->next
;
562 /* Enter them as files. */
563 for (d1
= new; d1
!= 0; d1
= d1
->next
)
565 d1
->file
= lookup_file (d1
->name
);
567 d1
->file
= enter_file (d1
->name
);
571 d1
->staticpattern
= 0;
572 d1
->need_2nd_expansion
= 0;
575 /* Add newly parsed deps to f->deps. If this is the last dependency
576 line and this target has commands then put it in front so the
577 last dependency line (the one with commands) ends up being the
578 first. This is important because people expect $< to hold first
579 prerequisite from the rule with commands. If it is not the last
580 dependency line or the rule does not have commands then link it
581 at the end so it appears in makefile order. */
585 if (d
->next
== 0 && last_dep_has_cmds
)
588 for (d_ptr
= &new; *d_ptr
; d_ptr
= &(*d_ptr
)->next
)
597 for (d_ptr
= &f
->deps
; *d_ptr
; d_ptr
= &(*d_ptr
)->next
)
605 free_ns_chain ((struct nameseq
*) old
);
608 /* For each dependency of each file, make the `struct dep' point
609 at the appropriate `struct file' (which may have to be created).
611 Also mark the files depended on by .PRECIOUS, .PHONY, .SILENT,
612 and various other special targets. */
620 struct file
**file_slot_0
;
621 struct file
**file_slot
;
622 struct file
**file_end
;
624 /* Perform second expansion and enter each dependency
627 /* Expand .SUFFIXES first; it's dependencies are used for
629 for (f
= lookup_file (".SUFFIXES"); f
!= 0; f
= f
->prev
)
632 /* We must use hash_dump (), because within this loop
633 we might add new files to the table, possibly causing
634 an in-situ table expansion. */
635 file_slot_0
= (struct file
**) hash_dump (&files
, 0, 0);
636 file_end
= file_slot_0
+ files
.ht_fill
;
637 for (file_slot
= file_slot_0
; file_slot
< file_end
; file_slot
++)
638 for (f
= *file_slot
; f
!= 0; f
= f
->prev
)
640 if (strcmp (f
->name
, ".SUFFIXES") != 0)
645 for (f
= lookup_file (".PRECIOUS"); f
!= 0; f
= f
->prev
)
646 for (d
= f
->deps
; d
!= 0; d
= d
->next
)
647 for (f2
= d
->file
; f2
!= 0; f2
= f2
->prev
)
650 for (f
= lookup_file (".LOW_RESOLUTION_TIME"); f
!= 0; f
= f
->prev
)
651 for (d
= f
->deps
; d
!= 0; d
= d
->next
)
652 for (f2
= d
->file
; f2
!= 0; f2
= f2
->prev
)
653 f2
->low_resolution_time
= 1;
655 for (f
= lookup_file (".PHONY"); f
!= 0; f
= f
->prev
)
656 for (d
= f
->deps
; d
!= 0; d
= d
->next
)
657 for (f2
= d
->file
; f2
!= 0; f2
= f2
->prev
)
659 /* Mark this file as phony nonexistent target. */
662 f2
->last_mtime
= NONEXISTENT_MTIME
;
663 f2
->mtime_before_update
= NONEXISTENT_MTIME
;
666 for (f
= lookup_file (".INTERMEDIATE"); f
!= 0; f
= f
->prev
)
668 /* .INTERMEDIATE with deps listed
669 marks those deps as intermediate files. */
670 for (d
= f
->deps
; d
!= 0; d
= d
->next
)
671 for (f2
= d
->file
; f2
!= 0; f2
= f2
->prev
)
672 f2
->intermediate
= 1;
673 /* .INTERMEDIATE with no deps does nothing.
674 Marking all files as intermediates is useless
675 since the goal targets would be deleted after they are built. */
678 for (f
= lookup_file (".SECONDARY"); f
!= 0; f
= f
->prev
)
680 /* .SECONDARY with deps listed
681 marks those deps as intermediate files
682 in that they don't get rebuilt if not actually needed;
683 but unlike real intermediate files,
684 these are not deleted after make finishes. */
686 for (d
= f
->deps
; d
!= 0; d
= d
->next
)
687 for (f2
= d
->file
; f2
!= 0; f2
= f2
->prev
)
688 f2
->intermediate
= f2
->secondary
= 1;
689 /* .SECONDARY with no deps listed marks *all* files that way. */
693 hash_map (&files
, set_intermediate
);
697 f
= lookup_file (".EXPORT_ALL_VARIABLES");
698 if (f
!= 0 && f
->is_target
)
699 export_all_variables
= 1;
701 f
= lookup_file (".IGNORE");
702 if (f
!= 0 && f
->is_target
)
705 ignore_errors_flag
= 1;
707 for (d
= f
->deps
; d
!= 0; d
= d
->next
)
708 for (f2
= d
->file
; f2
!= 0; f2
= f2
->prev
)
709 f2
->command_flags
|= COMMANDS_NOERROR
;
712 f
= lookup_file (".SILENT");
713 if (f
!= 0 && f
->is_target
)
718 for (d
= f
->deps
; d
!= 0; d
= d
->next
)
719 for (f2
= d
->file
; f2
!= 0; f2
= f2
->prev
)
720 f2
->command_flags
|= COMMANDS_SILENT
;
723 f
= lookup_file (".NOTPARALLEL");
724 if (f
!= 0 && f
->is_target
)
727 #ifndef NO_MINUS_C_MINUS_O
728 /* If .POSIX was defined, remove OUTPUT_OPTION to comply. */
729 /* This needs more work: what if the user sets this in the makefile?
731 define_variable (STRING_SIZE_TUPLE("OUTPUT_OPTION"), "", o_default, 1);
735 /* Remember that we've done this. */
739 /* Set the `command_state' member of FILE and all its `also_make's. */
742 set_command_state (struct file
*file
, enum cmd_state state
)
746 file
->command_state
= state
;
748 for (d
= file
->also_make
; d
!= 0; d
= d
->next
)
749 d
->file
->command_state
= state
;
752 /* Convert an external file timestamp to internal form. */
755 file_timestamp_cons (const char *fname
, time_t s
, int ns
)
757 int offset
= ORDINARY_MTIME_MIN
+ (FILE_TIMESTAMP_HI_RES
? ns
: 0);
758 FILE_TIMESTAMP product
= (FILE_TIMESTAMP
) s
<< FILE_TIMESTAMP_LO_BITS
;
759 FILE_TIMESTAMP ts
= product
+ offset
;
761 if (! (s
<= FILE_TIMESTAMP_S (ORDINARY_MTIME_MAX
)
762 && product
<= ts
&& ts
<= ORDINARY_MTIME_MAX
))
764 char buf
[FILE_TIMESTAMP_PRINT_LEN_BOUND
+ 1];
765 ts
= s
<= OLD_MTIME
? ORDINARY_MTIME_MIN
: ORDINARY_MTIME_MAX
;
766 file_timestamp_sprintf (buf
, ts
);
767 error (NILF
, _("%s: Timestamp out of range; substituting %s"),
768 fname
? fname
: _("Current time"), buf
);
774 /* Return the current time as a file timestamp, setting *RESOLUTION to
777 file_timestamp_now (int *resolution
)
783 /* Don't bother with high-resolution clocks if file timestamps have
784 only one-second resolution. The code below should work, but it's
785 not worth the hassle of debugging it on hosts where it fails. */
786 #if FILE_TIMESTAMP_HI_RES
787 # if HAVE_CLOCK_GETTIME && defined CLOCK_REALTIME
789 struct timespec timespec
;
790 if (clock_gettime (CLOCK_REALTIME
, ×pec
) == 0)
794 ns
= timespec
.tv_nsec
;
799 # if HAVE_GETTIMEOFDAY
801 struct timeval timeval
;
802 if (gettimeofday (&timeval
, 0) == 0)
806 ns
= timeval
.tv_usec
* 1000;
814 s
= time ((time_t *) 0);
817 #if FILE_TIMESTAMP_HI_RES
821 return file_timestamp_cons (0, s
, ns
);
824 /* Place into the buffer P a printable representation of the file
827 file_timestamp_sprintf (char *p
, FILE_TIMESTAMP ts
)
829 time_t t
= FILE_TIMESTAMP_S (ts
);
830 struct tm
*tm
= localtime (&t
);
833 sprintf (p
, "%04d-%02d-%02d %02d:%02d:%02d",
834 tm
->tm_year
+ 1900, tm
->tm_mon
+ 1, tm
->tm_mday
,
835 tm
->tm_hour
, tm
->tm_min
, tm
->tm_sec
);
837 sprintf (p
, "%ld", (long) t
);
839 sprintf (p
, "%lu", (unsigned long) t
);
842 /* Append nanoseconds as a fraction, but remove trailing zeros.
843 We don't know the actual timestamp resolution, since clock_getres
844 applies only to local times, whereas this timestamp might come
845 from a remote filesystem. So removing trailing zeros is the
846 best guess that we can do. */
847 sprintf (p
, ".%09d", FILE_TIMESTAMP_NS (ts
));
856 /* Print the data base of files. */
859 print_file (const void *item
)
861 struct file
*f
= (struct file
*) item
;
867 puts (_("# Not a target:"));
868 printf ("%s:%s", f
->name
, f
->double_colon
? ":" : "");
870 /* Print all normal dependencies; note any order-only deps. */
871 for (d
= f
->deps
; d
!= 0; d
= d
->next
)
872 if (! d
->ignore_mtime
)
873 printf (" %s", dep_name (d
));
877 /* Print order-only deps, if we have any. */
880 printf (" | %s", dep_name (ood
));
881 for (d
= ood
->next
; d
!= 0; d
= d
->next
)
883 printf (" %s", dep_name (d
));
889 puts (_("# Precious file (prerequisite of .PRECIOUS)."));
891 puts (_("# Phony target (prerequisite of .PHONY)."));
893 puts (_("# Command-line target."));
895 puts (_("# A default, MAKEFILES, or -include/sinclude makefile."));
896 puts (f
->tried_implicit
897 ? _("# Implicit rule search has been done.")
898 : _("# Implicit rule search has not been done."));
900 printf (_("# Implicit/static pattern stem: `%s'\n"), f
->stem
);
902 puts (_("# File is an intermediate prerequisite."));
903 if (f
->also_make
!= 0)
905 fputs (_("# Also makes:"), stdout
);
906 for (d
= f
->also_make
; d
!= 0; d
= d
->next
)
907 printf (" %s", dep_name (d
));
910 if (f
->last_mtime
== UNKNOWN_MTIME
)
911 puts (_("# Modification time never checked."));
912 else if (f
->last_mtime
== NONEXISTENT_MTIME
)
913 puts (_("# File does not exist."));
914 else if (f
->last_mtime
== OLD_MTIME
)
915 puts (_("# File is very old."));
918 char buf
[FILE_TIMESTAMP_PRINT_LEN_BOUND
+ 1];
919 file_timestamp_sprintf (buf
, f
->last_mtime
);
920 printf (_("# Last modified %s\n"), buf
);
923 ? _("# File has been updated.") : _("# File has not been updated."));
924 switch (f
->command_state
)
927 puts (_("# Commands currently running (THIS IS A BUG)."));
929 case cs_deps_running
:
930 puts (_("# Dependencies commands running (THIS IS A BUG)."));
934 switch (f
->update_status
)
939 puts (_("# Successfully updated."));
942 assert (question_flag
);
943 puts (_("# Needs to be updated (-q is set)."));
946 puts (_("# Failed to be updated."));
949 puts (_("# Invalid value in `update_status' member!"));
956 puts (_("# Invalid value in `command_state' member!"));
962 if (f
->variables
!= 0)
963 print_file_variables (f
);
966 print_commands (f
->cmds
);
969 print_file ((const void *) f
->prev
);
973 print_file_data_base (void)
975 puts (_("\n# Files"));
977 hash_map (&files
, print_file
);
979 fputs (_("\n# files hash-table stats:\n# "), stdout
);
980 hash_print_stats (&files
, stdout
);
983 #define EXPANSION_INCREMENT(_l) ((((_l) / 500) + 1) * 500)
986 build_target_list (char *value
)
988 static unsigned long last_targ_count
= 0;
990 if (files
.ht_fill
!= last_targ_count
)
992 unsigned long max
= EXPANSION_INCREMENT (strlen (value
));
995 struct file
**fp
= (struct file
**) files
.ht_vec
;
996 struct file
**end
= &fp
[files
.ht_size
];
998 /* Make sure we have at least MAX bytes in the allocated buffer. */
999 value
= xrealloc (value
, max
);
1003 for (; fp
< end
; ++fp
)
1004 if (!HASH_VACANT (*fp
) && (*fp
)->is_target
)
1006 struct file
*f
= *fp
;
1007 int l
= strlen (f
->name
);
1012 unsigned long off
= p
- value
;
1014 max
+= EXPANSION_INCREMENT (l
+ 1);
1015 value
= xrealloc (value
, max
);
1019 bcopy (f
->name
, p
, l
);
1025 last_targ_count
= files
.ht_fill
;
1032 init_hash_files (void)
1034 hash_init (&files
, 1000, file_hash_1
, file_hash_2
, file_hash_cmp
);