static int write_macdef (cpp_reader *pfile, cpp_hashnode *hn, void *file_p) { FILE *f = (FILE *) file_p; switch (hn->type) { case NT_VOID: if (! (hn->flags & NODE_POISONED)) return 1; case NT_MACRO: if ((hn->flags & NODE_BUILTIN) && (!pfile->cb.user_builtin_macro || !pfile->cb.user_builtin_macro (pfile, hn))) return 1; { struct macrodef_struct s; const unsigned char *defn; s.name_length = NODE_LEN (hn); s.flags = hn->flags & NODE_POISONED; if (hn->type == NT_MACRO) { defn = cpp_macro_definition (pfile, hn); s.definition_length = ustrlen (defn); } else { defn = NODE_NAME (hn); s.definition_length = s.name_length; } if (fwrite (&s, sizeof (s), 1, f) != 1 || fwrite (defn, 1, s.definition_length, f) != s.definition_length) { cpp_errno (pfile, CPP_DL_ERROR, "while writing precompiled header"); return 0; } } return 1; case NT_ASSERTION: /* Not currently implemented. */ return 1; default: abort (); } }
static struct cpp_dir * remove_duplicates (cpp_reader *pfile, struct cpp_dir *head, struct cpp_dir *system, struct cpp_dir *join, int verbose) { struct cpp_dir **pcur, *tmp, *cur; struct stat st; for (pcur = &head; *pcur; ) { int reason = REASON_QUIET; cur = *pcur; if (stat (cur->name, &st)) { /* Dirs that don't exist are silently ignored, unless verbose. */ if (errno != ENOENT) cpp_errno (pfile, CPP_DL_ERROR, cur->name); else { /* If -Wmissing-include-dirs is given, warn. */ cpp_options *opts = cpp_get_options (pfile); if (opts->warn_missing_include_dirs && cur->user_supplied_p) cpp_errno (pfile, CPP_DL_WARNING, cur->name); reason = REASON_NOENT; } } else if (!S_ISDIR (st.st_mode)) /* APPLE LOCAL begin headermaps 3871393 */ { /* Only check for headermap if this is a regular file and if there is no path-constructor function in CUR. */ if (S_ISREG (st.st_mode) && !cur->construct) { /* Try to load the file as a headermap. We will get back NULL if this fails, and there won't be any warnings/errors emitted unless the load function is fairly sure it's dealing with a headermap file that is malformed. */ struct hmap_header_map *header_map; header_map = hmap_load_header_map (cur->name); if (header_map) { /* Successfully loaded a headermap. Store a pointer to it and set up the construct function pointer in cur. */ cur->header_map = header_map; cur->construct = hmap_construct_pathname; pcur = &cur->next; continue; } } /* If we fall through to here, it's some other kind of file. */ cpp_error_with_line (pfile, CPP_DL_ERROR, 0, 0, "%s: not a directory", cur->name); } /* APPLE LOCAL end headermaps 3871393 */ else { INO_T_COPY (cur->ino, st.st_ino); cur->dev = st.st_dev; /* Remove this one if it is in the system chain. */ reason = REASON_DUP_SYS; for (tmp = system; tmp; tmp = tmp->next) if (INO_T_EQ (tmp->ino, cur->ino) && tmp->dev == cur->dev && cur->construct == tmp->construct) break; if (!tmp) { /* Duplicate of something earlier in the same chain? */ reason = REASON_DUP; for (tmp = head; tmp != cur; tmp = tmp->next) if (INO_T_EQ (cur->ino, tmp->ino) && cur->dev == tmp->dev && cur->construct == tmp->construct) break; if (tmp == cur /* Last in the chain and duplicate of JOIN? */ && !(cur->next == NULL && join && INO_T_EQ (cur->ino, join->ino) && cur->dev == join->dev && cur->construct == join->construct)) { /* Unique, so keep this directory. */ pcur = &cur->next; continue; } } } /* Remove this entry from the chain. */ *pcur = cur->next; free_path (cur, verbose ? reason: REASON_QUIET); } *pcur = join; return head; }