/* Part of CPP library. (Precompiled header reading/writing.)
- Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
#include "config.h"
#include "system.h"
-#include "coretypes.h"
#include "cpplib.h"
#include "cpphash.h"
#include "intl.h"
if (fwrite (&s, sizeof (s), 1, f) != 1
|| fwrite (defn, 1, s.definition_length, f) != s.definition_length)
{
- cpp_errno (pfile, DL_ERROR, "while writing precompiled header");
+ cpp_errno (pfile, CPP_DL_ERROR,
+ "while writing precompiled header");
return 0;
}
}
size_t hashsize;
/* Number of definitions */
size_t n_defs;
- /* Array of definitions. In cpp_write_pch_deps it is used for sorting. */
+ /* Array of definitions. In cpp_write_pch_deps it is used for sorting. */
cpp_hashnode **defs;
/* Space for the next definition. Definitions are null-terminated
strings. */
}
}
-/* Collect the identifiers into the state's string table. */
+/* Collect the identifiers into the state's string table. */
static int
write_defs (cpp_reader *pfile ATTRIBUTE_UNUSED, cpp_hashnode *hn, void *ss_p)
{
ss->n_defs = 0;
cpp_forall_identifiers (r, write_defs, ss);
- /* Sort the list, copy it into a buffer, and write it out. */
+ /* Sort the list, copy it into a buffer, and write it out. */
qsort (ss->defs, ss->n_defs, sizeof (cpp_hashnode *), &comp_hashnodes);
definedstrs = ss->definedstrs = xmalloc (ss->hashsize);
for (i = 0; i < ss->n_defs; ++i)
if (fwrite (&z, sizeof (z), 1, f) != 1
|| fwrite (ss->definedstrs, ss->hashsize, 1, f) != 1)
{
- cpp_errno (r, DL_ERROR, "while writing precompiled header");
+ cpp_errno (r, CPP_DL_ERROR, "while writing precompiled header");
return -1;
}
free (ss->definedstrs);
memset (&z, 0, sizeof (z));
if (fwrite (&z, sizeof (z), 1, f) != 1)
{
- cpp_errno (r, DL_ERROR, "while writing precompiled header");
+ cpp_errno (r, CPP_DL_ERROR, "while writing precompiled header");
return -1;
}
if (deps_save (r->deps, f) != 0)
{
- cpp_errno (r, DL_ERROR, "while writing precompiled header");
+ cpp_errno (r, CPP_DL_ERROR, "while writing precompiled header");
+ return -1;
+ }
+
+ if (! _cpp_save_file_entries (r, f))
+ {
+ cpp_errno (r, CPP_DL_ERROR, "while writing precompiled header");
return -1;
}
|| h->flags & NODE_POISONED)
{
if (CPP_OPTION (r, warn_invalid_pch))
- cpp_error (r, DL_WARNING_SYSHDR,
+ cpp_error (r, CPP_DL_WARNING_SYSHDR,
"%s: not used because `%.*s' not defined",
name, m.name_length, namebuf);
goto fail;
|| memcmp (namebuf, newdefn, m.definition_length) != 0)
{
if (CPP_OPTION (r, warn_invalid_pch))
- cpp_error (r, DL_WARNING_SYSHDR,
+ cpp_error (r, CPP_DL_WARNING_SYSHDR,
"%s: not used because `%.*s' defined as `%s' not `%.*s'",
name, m.name_length, namebuf, newdefn + m.name_length,
m.definition_length - m.name_length,
qsort (nl.defs, nl.n_defs, sizeof (cpp_hashnode *), &comp_hashnodes);
/* Loop through nl.defs and undeftab, both of which are sorted lists.
- There should be no matches. */
+ There should be no matches. */
first = undeftab;
last = undeftab + m.definition_length;
i = 0;
else if (cmp > 0)
++i;
else
- goto fail;
+ {
+ if (CPP_OPTION (r, warn_invalid_pch))
+ cpp_error (r, CPP_DL_WARNING_SYSHDR,
+ "%s: not used because `%s' is defined",
+ name, first);
+ goto fail;
+ }
}
free(nl.defs);
return 0;
error:
- cpp_errno (r, DL_ERROR, "while reading precompiled header");
+ cpp_errno (r, CPP_DL_ERROR, "while reading precompiled header");
return -1;
fail:
struct lexer_state old_state;
struct save_macro_item *d;
size_t i, mac_count;
- int saved_line = r->line;
/* Restore spec_nodes, which will be full of references to the old
hashtable entries and so will now be invalid. */
else if (m.name_length != m.definition_length)
{
if (cpp_push_buffer (r, defn + m.name_length,
- m.definition_length - m.name_length,
- true, 1) != NULL)
+ m.definition_length - m.name_length, true)
+ != NULL)
{
_cpp_clean_line (r);
if (!_cpp_create_definition (r, h))
}
r->state = old_state;
- r->line = saved_line;
free (defn);
defn = NULL;
!= 0)
goto error;
+ if (! _cpp_read_file_entries (r, f))
+ goto error;
+
return 0;
error:
- cpp_errno (r, DL_ERROR, "while reading precompiled header");
+ cpp_errno (r, CPP_DL_ERROR, "while reading precompiled header");
return -1;
}