aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2005-02-09 01:23:56 +0000
committerMike Stump <mrs@apple.com>2005-02-09 01:23:56 +0000
commit1cc49330e6698a3e858ddaa618aa887604e3ae8b (patch)
tree6d440928c64118350df14897f5c21a8300aea58c /libcpp
parent911687f178ad94149a65ab74c8de16b0d598ed88 (diff)
* files.c (pchf_adder): Remove.
(struct pchf_adder_info): Likewise. (_cpp_save_file_entries): Write out all files so that #import works. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@94755 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog6
-rw-r--r--libcpp/files.c97
2 files changed, 46 insertions, 57 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index 49055bd51bd..35e5369137d 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,9 @@
+2005-02-08 Mike Stump <mrs@apple.com>
+
+ * files.c (pchf_adder): Remove.
+ (struct pchf_adder_info): Likewise.
+ (_cpp_save_file_entries): Write out all files so that #import works.
+
2005-01-23 Joseph S. Myers <joseph@codesourcery.com>
* configure: Regenerate.
diff --git a/libcpp/files.c b/libcpp/files.c
index df5d9d7c972..4ef72cd6111 100644
--- a/libcpp/files.c
+++ b/libcpp/files.c
@@ -173,7 +173,6 @@ static void read_name_map (cpp_dir *dir);
static char *remap_filename (cpp_reader *pfile, _cpp_file *file);
static char *append_file_to_dir (const char *fname, cpp_dir *dir);
static bool validate_pch (cpp_reader *, _cpp_file *file, const char *pchname);
-static int pchf_adder (void **slot, void *data);
static int pchf_save_compare (const void *e1, const void *e2);
static int pchf_compare (const void *d_p, const void *e_p);
static bool check_file_against_entries (cpp_reader *, _cpp_file *, bool);
@@ -1448,38 +1447,54 @@ struct pchf_data {
static struct pchf_data *pchf;
-/* Data for pchf_addr. */
-struct pchf_adder_info
+/* A qsort ordering function for pchf_entry structures. */
+
+static int
+pchf_save_compare (const void *e1, const void *e2)
{
- cpp_reader *pfile;
- struct pchf_data *d;
-};
+ return memcmp (e1, e2, sizeof (struct pchf_entry));
+}
-/* A hash traversal function to add entries into DATA->D. */
+/* Create and write to F a pchf_data structure. */
-static int
-pchf_adder (void **slot, void *data)
+bool
+_cpp_save_file_entries (cpp_reader *pfile, FILE *fp)
{
- struct file_hash_entry *h = (struct file_hash_entry *) *slot;
- struct pchf_adder_info *i = (struct pchf_adder_info *) data;
+ size_t count = 0;
+ struct pchf_data *result;
+ size_t result_size;
+ _cpp_file *f;
- if (h->start_dir != NULL && h->u.file->stack_count != 0)
+ for (f = pfile->all_files; f; f = f->next_file)
+ ++count;
+
+ result_size = (sizeof (struct pchf_data)
+ + sizeof (struct pchf_entry) * (count - 1));
+ result = xcalloc (result_size, 1);
+
+ result->count = 0;
+ result->have_once_only = false;
+
+ for (f = pfile->all_files; f; f = f->next_file)
{
- struct pchf_data *d = i->d;
- _cpp_file *f = h->u.file;
- size_t count = d->count++;
+ size_t count;
/* This should probably never happen, since if a read error occurred
the PCH file shouldn't be written... */
if (f->dont_read || f->err_no)
- return 1;
+ continue;
+
+ if (f->stack_count == 0)
+ continue;
- d->entries[count].once_only = f->once_only;
+ count = result->count++;
+
+ result->entries[count].once_only = f->once_only;
/* |= is avoided in the next line because of an HP C compiler bug */
- d->have_once_only = d->have_once_only | f->once_only;
+ result->have_once_only = result->have_once_only | f->once_only;
if (f->buffer_valid)
- md5_buffer ((const char *)f->buffer,
- f->st.st_size, d->entries[count].sum);
+ md5_buffer ((const char *)f->buffer,
+ f->st.st_size, result->entries[count].sum);
else
{
FILE *ff;
@@ -1487,48 +1502,16 @@ pchf_adder (void **slot, void *data)
if (!open_file (f))
{
- open_file_failed (i->pfile, f);
- return 0;
+ open_file_failed (pfile, f);
+ return false;
}
ff = fdopen (f->fd, "rb");
- md5_stream (ff, d->entries[count].sum);
+ md5_stream (ff, result->entries[count].sum);
fclose (ff);
f->fd = oldfd;
}
- d->entries[count].size = f->st.st_size;
+ result->entries[count].size = f->st.st_size;
}
- return 1;
-}
-
-/* A qsort ordering function for pchf_entry structures. */
-
-static int
-pchf_save_compare (const void *e1, const void *e2)
-{
- return memcmp (e1, e2, sizeof (struct pchf_entry));
-}
-
-/* Create and write to F a pchf_data structure. */
-
-bool
-_cpp_save_file_entries (cpp_reader *pfile, FILE *f)
-{
- size_t count = 0;
- struct pchf_data *result;
- size_t result_size;
- struct pchf_adder_info pai;
-
- count = htab_elements (pfile->file_hash);
- result_size = (sizeof (struct pchf_data)
- + sizeof (struct pchf_entry) * (count - 1));
- result = xcalloc (result_size, 1);
-
- result->count = 0;
- result->have_once_only = false;
-
- pai.pfile = pfile;
- pai.d = result;
- htab_traverse (pfile->file_hash, pchf_adder, &pai);
result_size = (sizeof (struct pchf_data)
+ sizeof (struct pchf_entry) * (result->count - 1));
@@ -1536,7 +1519,7 @@ _cpp_save_file_entries (cpp_reader *pfile, FILE *f)
qsort (result->entries, result->count, sizeof (struct pchf_entry),
pchf_save_compare);
- return fwrite (result, result_size, 1, f) == 1;
+ return fwrite (result, result_size, 1, fp) == 1;
}
/* Read the pchf_data structure from F. */