-
-void
-_cpp_execute_include (pfile, fname, len, no_reinclude, search_start)
- cpp_reader *pfile;
- char *fname;
- unsigned int len;
- int no_reinclude;
- struct file_name_list *search_start;
-{
- IHASH *ihash;
- int fd;
- int angle_brackets = fname[0] == '<';
- int before;
-
- if (!search_start)
- {
- if (angle_brackets)
- search_start = CPP_OPTIONS (pfile)->bracket_include;
- else if (CPP_OPTIONS (pfile)->ignore_srcdir)
- search_start = CPP_OPTIONS (pfile)->quote_include;
- else
- search_start = CPP_BUFFER (pfile)->actual_dir;
- }
-
- if (!search_start)
- {
- cpp_error (pfile, "No include path in which to find %s", fname);
- return;
- }
-
- /* Remove quote marks. */
- fname++;
- len -= 2;
- fname[len] = '\0';
-
- fd = find_include_file (pfile, fname, search_start, &ihash, &before);
-
- if (fd == -2)
- return;
-
- if (fd == -1)
- {
- if (CPP_OPTIONS (pfile)->print_deps_missing_files
- && CPP_PRINT_DEPS (pfile) > (angle_brackets ||
- (pfile->system_include_depth > 0)))
- {
- if (!angle_brackets)
- deps_add_dep (pfile->deps, fname);
- else
- {
- char *p;
- struct file_name_list *ptr;
- /* If requested as a system header, assume it belongs in
- the first system header directory. */
- if (CPP_OPTIONS (pfile)->bracket_include)
- ptr = CPP_OPTIONS (pfile)->bracket_include;
- else
- ptr = CPP_OPTIONS (pfile)->quote_include;
-
- p = (char *) alloca (strlen (ptr->name)
- + strlen (fname) + 2);
- if (*ptr->name != '\0')
- {
- strcpy (p, ptr->name);
- strcat (p, "/");
- }
- strcat (p, fname);
- deps_add_dep (pfile->deps, p);
- }
- }
- /* If -M was specified, and this header file won't be added to
- the dependency list, then don't count this as an error,
- because we can still produce correct output. Otherwise, we
- can't produce correct output, because there may be
- dependencies we need inside the missing file, and we don't
- know what directory this missing file exists in. */
- else if (CPP_PRINT_DEPS (pfile)
- && (CPP_PRINT_DEPS (pfile)
- <= (angle_brackets || (pfile->system_include_depth > 0))))
- cpp_warning (pfile, "No include path in which to find %s", fname);
- else
- cpp_error_from_errno (pfile, fname);
-
- return;
- }
-
- /* For -M, add the file to the dependencies on its first inclusion. */
- if (!before && (CPP_PRINT_DEPS (pfile)
- > (angle_brackets || (pfile->system_include_depth > 0))))
- deps_add_dep (pfile->deps, ihash->name);
-
- /* Handle -H option. */
- if (CPP_OPTIONS(pfile)->print_include_names)
- {
- cpp_buffer *fp = CPP_BUFFER (pfile);
- while ((fp = CPP_PREV_BUFFER (fp)) != NULL)
- putc ('.', stderr);
- fprintf (stderr, " %s\n", ihash->name);
- }
-
- /* Actually process the file */
-
- if (no_reinclude)
- ihash->control_macro = (const U_CHAR *) "";
-
- if (read_include_file (pfile, fd, ihash))
- {
- _cpp_output_line_command (pfile, enter_file);
- if (angle_brackets)
- pfile->system_include_depth++; /* Decremented in file_cleanup. */
- }
-}
-
-
-/* Push an input buffer and load it up with the contents of FNAME.
- If FNAME is "" or NULL, read standard input. */
-int
-cpp_read_file (pfile, fname)
- cpp_reader *pfile;
- const char *fname;
-{
- IHASH *ih, **slot;
- IHASH dummy;
- int f;
-
- if (fname == NULL)
- fname = "";
-
- dummy.nshort = fname;
- dummy.hash = _cpp_calc_hash (fname, strlen (fname));
- slot = (IHASH **) htab_find_slot_with_hash (pfile->all_include_files,
- (const void *) &dummy,
- dummy.hash, 1);
- if (*slot && (ih = redundant_include_p (pfile, *slot, ABSOLUTE_PATH)))
- {
- if (ih == (IHASH *)-1)
- return 1; /* Already included. */
- }
- else
- {
- ih = (IHASH *) xmalloc (sizeof (IHASH) + strlen (fname));
- ih->control_macro = 0;
- ih->foundhere = ABSOLUTE_PATH; /* well sort of ... */
- ih->hash = dummy.hash;
- strcpy ((char *)ih->name, fname);
- ih->nshort = ih->name;
-
- ih->next_this_file = *slot;
- *slot = ih;
- }
-
- if (*fname == '\0')
- f = 0;
- else
- f = open_include_file (pfile, fname);
-
- return read_include_file (pfile, f, ih);
-}
-
-/* Read the contents of FD into the buffer on the top of PFILE's stack.
- IHASH points to the include hash entry for the file associated with
- FD.
-
- The caller is responsible for the cpp_push_buffer. */
-