static void check_deps_environment_vars (void);
static void handle_deferred_opts (void);
static void sanitize_cpp_opts (void);
-static void add_prefixed_path (const char *, size_t);
+static void add_prefixed_path (const char *, incpath_kind);
static void push_command_line_include (void);
static void cb_file_change (cpp_reader *, const line_map_ordinary *);
static void cb_dir_change (cpp_reader *, const char *);
case OPT_I:
if (strcmp (arg, "-"))
- add_path (xstrdup (arg), BRACKET, 0, true);
+ add_path (xstrdup (arg), INC_BRACKET, 0, true);
else
{
if (quote_chain_split)
break;
case OPT_idirafter:
- add_path (xstrdup (arg), AFTER, 0, true);
+ add_path (xstrdup (arg), INC_AFTER, 0, true);
break;
case OPT_imacros:
break;
case OPT_iquote:
- add_path (xstrdup (arg), QUOTE, 0, true);
+ add_path (xstrdup (arg), INC_QUOTE, 0, true);
break;
case OPT_isysroot:
break;
case OPT_isystem:
- add_path (xstrdup (arg), SYSTEM, 0, true);
+ add_path (xstrdup (arg), INC_SYSTEM, 0, true);
break;
case OPT_iwithprefix:
- add_prefixed_path (arg, SYSTEM);
+ add_prefixed_path (arg, INC_SYSTEM);
break;
case OPT_iwithprefixbefore:
- add_prefixed_path (arg, BRACKET);
+ add_prefixed_path (arg, INC_BRACKET);
break;
case OPT_lang_asm:
/* Add include path with a prefix at the front of its name. */
static void
-add_prefixed_path (const char *suffix, size_t chain)
+add_prefixed_path (const char *suffix, incpath_kind chain)
{
char *path;
const char *prefix;
static const char dir_separator_str[] = { DIR_SEPARATOR, 0 };
-static void add_env_var_paths (const char *, int);
+static void add_env_var_paths (const char *, incpath_kind);
static void add_standard_paths (const char *, const char *, const char *, int);
static void free_path (struct cpp_dir *, int);
static void merge_include_chains (const char *, cpp_reader *, int);
struct cpp_dir *, int);
/* Include chains heads and tails. */
-static struct cpp_dir *heads[4];
-static struct cpp_dir *tails[4];
+static struct cpp_dir *heads[INC_MAX];
+static struct cpp_dir *tails[INC_MAX];
+
static bool quote_ignores_source_dir;
enum { REASON_QUIET = 0, REASON_NOENT, REASON_DUP, REASON_DUP_SYS };
/* Read ENV_VAR for a PATH_SEPARATOR-separated list of file names; and
append all the names to the search path CHAIN. */
static void
-add_env_var_paths (const char *env_var, int chain)
+add_env_var_paths (const char *env_var, incpath_kind chain)
{
char *p, *q, *path;
path[q - p] = '\0';
}
- add_path (path, chain, chain == SYSTEM, false);
+ add_path (path, chain, chain == INC_SYSTEM, false);
}
}
str = reconcat (str, str, dir_separator_str,
imultiarch, NULL);
}
- add_path (str, SYSTEM, p->cxx_aware, false);
+ add_path (str, INC_SYSTEM, p->cxx_aware, false);
}
}
}
str = reconcat (str, str, dir_separator_str, imultiarch, NULL);
}
- add_path (str, SYSTEM, p->cxx_aware, false);
+ add_path (str, INC_SYSTEM, p->cxx_aware, false);
}
}
}
/* Add the sysroot to user-supplied paths starting with "=". */
if (sysroot)
{
- add_sysroot_to_chain (sysroot, QUOTE);
- add_sysroot_to_chain (sysroot, BRACKET);
- add_sysroot_to_chain (sysroot, SYSTEM);
- add_sysroot_to_chain (sysroot, AFTER);
+ add_sysroot_to_chain (sysroot, INC_QUOTE);
+ add_sysroot_to_chain (sysroot, INC_BRACKET);
+ add_sysroot_to_chain (sysroot, INC_SYSTEM);
+ add_sysroot_to_chain (sysroot, INC_AFTER);
}
/* Join the SYSTEM and AFTER chains. Remove duplicates in the
resulting SYSTEM chain. */
- if (heads[SYSTEM])
- tails[SYSTEM]->next = heads[AFTER];
+ if (heads[INC_SYSTEM])
+ tails[INC_SYSTEM]->next = heads[INC_AFTER];
else
- heads[SYSTEM] = heads[AFTER];
- heads[SYSTEM] = remove_duplicates (pfile, heads[SYSTEM], 0, 0, verbose);
+ heads[INC_SYSTEM] = heads[INC_AFTER];
+ heads[INC_SYSTEM]
+ = remove_duplicates (pfile, heads[INC_SYSTEM], 0, 0, verbose);
/* Remove duplicates from BRACKET that are in itself or SYSTEM, and
join it to SYSTEM. */
- heads[BRACKET] = remove_duplicates (pfile, heads[BRACKET], heads[SYSTEM],
- heads[SYSTEM], verbose);
+ heads[INC_BRACKET]
+ = remove_duplicates (pfile, heads[INC_BRACKET], heads[INC_SYSTEM],
+ heads[INC_SYSTEM], verbose);
/* Remove duplicates from QUOTE that are in itself or SYSTEM, and
join it to BRACKET. */
- heads[QUOTE] = remove_duplicates (pfile, heads[QUOTE], heads[SYSTEM],
- heads[BRACKET], verbose);
+ heads[INC_QUOTE]
+ = remove_duplicates (pfile, heads[INC_QUOTE], heads[INC_SYSTEM],
+ heads[INC_BRACKET], verbose);
/* If verbose, print the list of dirs to search. */
if (verbose)
struct cpp_dir *p;
fprintf (stderr, _("#include \"...\" search starts here:\n"));
- for (p = heads[QUOTE];; p = p->next)
+ for (p = heads[INC_QUOTE];; p = p->next)
{
- if (p == heads[BRACKET])
+ if (p == heads[INC_BRACKET])
fprintf (stderr, _("#include <...> search starts here:\n"));
if (!p)
break;
void
split_quote_chain (void)
{
- if (heads[QUOTE])
- free_path (heads[QUOTE], REASON_QUIET);
- if (tails[QUOTE])
- free_path (tails[QUOTE], REASON_QUIET);
- heads[QUOTE] = heads[BRACKET];
- tails[QUOTE] = tails[BRACKET];
- heads[BRACKET] = NULL;
- tails[BRACKET] = NULL;
+ if (heads[INC_QUOTE])
+ free_path (heads[INC_QUOTE], REASON_QUIET);
+ if (tails[INC_QUOTE])
+ free_path (tails[INC_QUOTE], REASON_QUIET);
+ heads[INC_QUOTE] = heads[INC_BRACKET];
+ tails[INC_QUOTE] = tails[INC_BRACKET];
+ heads[INC_BRACKET] = NULL;
+ tails[INC_BRACKET] = NULL;
/* This is NOT redundant. */
quote_ignores_source_dir = true;
}
/* Add P to the chain specified by CHAIN. */
void
-add_cpp_dir_path (cpp_dir *p, int chain)
+add_cpp_dir_path (cpp_dir *p, incpath_kind chain)
{
if (tails[chain])
tails[chain]->next = p;
/* Add PATH to the include chain CHAIN. PATH must be malloc-ed and
NUL-terminated. */
void
-add_path (char *path, int chain, int cxx_aware, bool user_supplied_p)
+add_path (char *path, incpath_kind chain, int cxx_aware, bool user_supplied_p)
{
cpp_dir *p;
#ifndef INO_T_EQ
p->canonical_name = lrealpath (path);
#endif
- if (chain == SYSTEM || chain == AFTER)
+ if (chain == INC_SYSTEM || chain == INC_AFTER)
p->sysp = 1 + !cxx_aware;
else
p->sysp = 0;
/* CPATH and language-dependent environment variables may add to the
include chain. */
- add_env_var_paths ("CPATH", BRACKET);
- add_env_var_paths (lang_env_vars[idx], SYSTEM);
+ add_env_var_paths ("CPATH", INC_BRACKET);
+ add_env_var_paths (lang_env_vars[idx], INC_SYSTEM);
target_c_incpath.extra_pre_includes (sysroot, iprefix, stdinc);
merge_include_chains (sysroot, pfile, verbose);
- cpp_set_include_chains (pfile, heads[QUOTE], heads[BRACKET],
+ cpp_set_include_chains (pfile, heads[INC_QUOTE], heads[INC_BRACKET],
quote_ignores_source_dir);
}
/* Return the current chain of cpp dirs. */
struct cpp_dir *
-get_added_cpp_dirs (int chain)
+get_added_cpp_dirs (incpath_kind chain)
{
return heads[chain];
}
#ifndef GCC_INCPATH_H
#define GCC_INCPATH_H
+/* Various fragments of include path. */
+enum incpath_kind {
+ INC_QUOTE = 0, /* include "foo" */
+ INC_BRACKET, /* include <foo> */
+ INC_SYSTEM, /* sysinclude */
+ INC_AFTER, /* post-sysinclude. */
+ INC_MAX
+};
+
extern void split_quote_chain (void);
-extern void add_path (char *, int, int, bool);
+extern void add_path (char *, incpath_kind, int, bool);
extern void register_include_chains (cpp_reader *, const char *,
const char *, const char *,
int, int, int);
-extern void add_cpp_dir_path (struct cpp_dir *, int);
-extern struct cpp_dir *get_added_cpp_dirs (int);
+extern void add_cpp_dir_path (struct cpp_dir *, incpath_kind);
+extern struct cpp_dir *get_added_cpp_dirs (incpath_kind);
struct target_c_incpath_s {
/* Do extra includes processing. STDINC is false iff -nostdinc was given. */
extern struct target_c_incpath_s target_c_incpath;
-enum { QUOTE = 0, BRACKET, SYSTEM, AFTER };
-
#endif /* GCC_INCPATH_H */