/* Don't reopen an idempotent file. */
if (DO_NOT_REREAD (file))
return file;
-
+
/* Don't reopen one which is already loaded. */
if (file->buffer != NULL)
return file;
/* For DJGPP redirected input is opened in text mode. Change it
to binary mode. */
if (! isatty (file->fd))
- setmode (file->fd, O_BINARY);
+ setmode (file->fd, O_BINARY);
#endif
}
else
sysp = MAX ((pfile->map ? pfile->map->sysp : 0),
(inc->foundhere ? inc->foundhere->sysp : 0));
- /* For -M, add the file to the dependencies on its first inclusion. */
- if (CPP_OPTION (pfile, print_deps) > sysp && !inc->include_count)
- deps_add_dep (pfile->deps, inc->name);
+ /* Add the file to the dependencies on its first inclusion. */
+ if (CPP_OPTION (pfile, deps.style) > !!sysp && !inc->include_count)
+ {
+ if (pfile->buffer || CPP_OPTION (pfile, deps.ignore_main_file) == 0)
+ deps_add_dep (pfile->deps, inc->name);
+ }
/* Not in cache? */
if (! inc->buffer)
nd = splay_tree_lookup (pfile->all_include_files, (splay_tree_key) fname);
return (nd && nd->value);
}
-
+
/* Search directory path for the file. */
name = (char *) alloca (strlen (fname) + pfile->max_include_len + 2);
for (path = CPP_OPTION (pfile, quote_include); path; path = path->next)
const char *fname;
int angle_brackets;
{
- int print_dep = CPP_PRINT_DEPS(pfile) > (angle_brackets || pfile->map->sysp);
-
- if (CPP_OPTION (pfile, print_deps_missing_files) && print_dep)
+ bool print_dep
+ = CPP_OPTION (pfile, deps.style) > (angle_brackets || pfile->map->sysp);
+
+ if (CPP_OPTION (pfile, deps.missing_files) && print_dep)
deps_add_dep (pfile->deps, fname);
/* If -M was specified, then don't count this as an error, because
we can still produce correct output. Otherwise, we can't produce
the missing file, and we don't know what directory this missing
file exists in. */
else
- cpp_errno (pfile, CPP_PRINT_DEPS (pfile) && ! print_dep
+ cpp_errno (pfile, CPP_OPTION (pfile, deps.style) && ! print_dep
? DL_WARNING: DL_ERROR, fname);
}
const cpp_token *header;
{
struct include_file *inc = find_include_file (pfile, header, 0);
-
+
if (inc == NULL || inc == NO_INCLUDE_PATH)
return -1;
close (inc->fd);
inc->fd = -1;
}
-
+
return inc->st.st_mtime > pfile->buffer->inc->st.st_mtime;
}
if (f)
{
int ch;
- int dirlen = strlen (dirname);
while ((ch = getc (f)) != EOF)
{
ptr->map_to = to;
else
{
- ptr->map_to = xmalloc (dirlen + strlen (to) + 2);
- strcpy (ptr->map_to, dirname);
- ptr->map_to[dirlen] = '/';
- strcpy (ptr->map_to + dirlen + 1, to);
+ ptr->map_to = concat (dirname, "/", to, NULL);
free (to);
- }
+ }
ptr->map_next = map_list_ptr->map_list_map;
map_list_ptr->map_list_map = ptr;
}
fclose (f);
}
-
+
/* Add this information to the cache. */
map_list_ptr->map_list_next = CPP_OPTION (pfile, map_list);
CPP_OPTION (pfile, map_list) = map_list_ptr;
return map_list_ptr->map_list_map;
-}
+}
/* Remap an unsimplified path NAME based on the file_name_map (if any)
for LOC. */
if (! loc->name_map)
return name;
}
-
+
/* This works since NAME has not been simplified yet. */
from = name + loc->len + 1;
-
+
for (map = loc->name_map; map; map = map->map_next)
if (!strcmp (map->map_from, from))
return map->map_to;
memcpy (dir, name, p - name);
dir[p - name] = '\0';
from = p + 1;
-
+
for (map = read_name_map (pfile, dir); map; map = map->map_next)
if (! strcmp (map->map_from, from))
return map->map_to;
nonzero if an error occurred when using stat () or lstat (). */
char *
_cpp_simplify_pathname (path)
- char *path;
+ char *path;
{
#ifndef VMS
char *from, *to;
/* Convert all backslashes to slashes. */
for (from = path; *from; from++)
if (*from == '\\') *from = '/';
-
+
/* Skip over leading drive letter if present. */
if (ISALPHA (path[0]) && path[1] == ':')
from = to = &path[2];
#else
from = to = path;
#endif
-
+
/* Remove redundant leading /s. */
if (*from == '/')
{
if (move_base)
base = to;
}
-
+
/* Change the empty string to "." so that it is not treated as stdin.
Null terminate. */
if (to == path)