summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2002-08-01 13:16:57 +0000
committerPaul Smith <psmith@gnu.org>2002-08-01 13:16:57 +0000
commitbccb277dda1a4dcc6729824a7c9d544086f147c3 (patch)
tree693bb06d69dd6e4829d8d1b1d339a694ff162ad3 /file.c
parenta56563badd9b3cab2624c35f3a8104a3bb3b5f52 (diff)
downloadgunmake-bccb277dda1a4dcc6729824a7c9d544086f147c3.tar.gz
New variables, .VARIABLES and .TARGETS.
Diffstat (limited to 'file.c')
-rw-r--r--file.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/file.c b/file.c
index cfb11bb..ecb83d8 100644
--- a/file.c
+++ b/file.c
@@ -765,6 +765,55 @@ print_file_data_base ()
hash_print_stats (&files, stdout);
}
+#define EXPANSION_INCREMENT(_l) ((((_l) / 500) + 1) * 500)
+
+char *
+build_target_list (value)
+ char *value;
+{
+ static unsigned long last_targ_count = 0;
+
+ if (files.ht_fill != last_targ_count)
+ {
+ unsigned long max = EXPANSION_INCREMENT (strlen (value));
+ unsigned long len;
+ char *p;
+ struct file **fp = (struct file **) files.ht_vec;
+ struct file **end = &fp[files.ht_size];
+
+ /* Make sure we have at least MAX bytes in the allocated buffer. */
+ value = xrealloc (value, max);
+
+ p = value;
+ len = 0;
+ for (; fp < end; ++fp)
+ if (!HASH_VACANT (*fp) && (*fp)->is_target)
+ {
+ struct file *f = *fp;
+ int l = strlen (f->name);
+
+ len += l + 1;
+ if (len > max)
+ {
+ unsigned long off = p - value;
+
+ max += EXPANSION_INCREMENT (l + 1);
+ value = xrealloc (value, max);
+ p = &value[off];
+ }
+
+ bcopy (f->name, p, l);
+ p += l;
+ *(p++) = ' ';
+ }
+ *(p-1) = '\0';
+
+ last_targ_count = files.ht_fill;
+ }
+
+ return value;
+}
+
void
init_hash_files ()
{