epp: Remove unused USE_FILE_NAME_MAPS stuff
This commit is contained in:
parent
e1bfe5ea0d
commit
abd165bc17
194
epp/cpplib.c
194
epp/cpplib.c
|
@ -111,8 +111,6 @@ const char *version_string = "0.0.0";
|
|||
#define INCLUDE_LEN_FUDGE 0
|
||||
#endif
|
||||
|
||||
#define USE_FILE_NAME_MAPS 0
|
||||
|
||||
/* Symbols to predefine. */
|
||||
|
||||
#ifdef CPP_PREDEFINES
|
||||
|
@ -5307,197 +5305,6 @@ struct file_name_map {
|
|||
char *map_to;
|
||||
};
|
||||
|
||||
#if USE_FILE_NAME_MAPS
|
||||
|
||||
#define FILE_NAME_MAP_FILE "header.gcc"
|
||||
|
||||
/* Read a space delimited string of unlimited length from a stdio
|
||||
* file. */
|
||||
|
||||
static char *
|
||||
read_filename_string(int ch, FILE * f)
|
||||
{
|
||||
char *alloc, *set;
|
||||
int len;
|
||||
|
||||
len = 20;
|
||||
set = alloc = (char *)xmalloc(len + 1);
|
||||
if (!is_space[ch])
|
||||
{
|
||||
*set++ = ch;
|
||||
while ((ch = getc(f)) != EOF && !is_space[ch])
|
||||
{
|
||||
if (set - alloc == len)
|
||||
{
|
||||
len *= 2;
|
||||
alloc = (char *)xrealloc(alloc, len + 1);
|
||||
set = alloc + len / 2;
|
||||
}
|
||||
*set++ = ch;
|
||||
}
|
||||
}
|
||||
*set = '\0';
|
||||
ungetc(ch, f);
|
||||
return alloc;
|
||||
}
|
||||
|
||||
/* This structure holds a linked list of file name maps, one per directory. */
|
||||
struct file_name_map_list {
|
||||
struct file_name_map_list *map_list_next;
|
||||
char *map_list_name;
|
||||
struct file_name_map *map_list_map;
|
||||
};
|
||||
|
||||
/* Read the file name map file for DIRNAME. */
|
||||
|
||||
static struct file_name_map *
|
||||
read_name_map(cpp_reader * pfile, const char *dirname)
|
||||
{
|
||||
struct file_name_map_list *map_list_ptr;
|
||||
char *name;
|
||||
FILE *f;
|
||||
|
||||
for (map_list_ptr = CPP_OPTIONS(pfile)->map_list; map_list_ptr;
|
||||
map_list_ptr = map_list_ptr->map_list_next)
|
||||
if (!strcmp(map_list_ptr->map_list_name, dirname))
|
||||
return map_list_ptr->map_list_map;
|
||||
|
||||
map_list_ptr =
|
||||
((struct file_name_map_list *)xmalloc(sizeof(struct file_name_map_list)));
|
||||
|
||||
map_list_ptr->map_list_name = savestring(dirname);
|
||||
map_list_ptr->map_list_map = NULL;
|
||||
|
||||
name = (char *)alloca(strlen(dirname) + strlen(FILE_NAME_MAP_FILE) + 2);
|
||||
strcpy(name, dirname);
|
||||
if (*dirname)
|
||||
strcat(name, "/");
|
||||
strcat(name, FILE_NAME_MAP_FILE);
|
||||
f = fopen(name, "r");
|
||||
if (!f)
|
||||
map_list_ptr->map_list_map = NULL;
|
||||
else
|
||||
{
|
||||
int ch;
|
||||
int dirlen = strlen(dirname);
|
||||
|
||||
while ((ch = getc(f)) != EOF)
|
||||
{
|
||||
char *from, *to;
|
||||
struct file_name_map *ptr;
|
||||
|
||||
if (is_space[ch])
|
||||
continue;
|
||||
from = read_filename_string(ch, f);
|
||||
while ((ch = getc(f)) != EOF && is_hor_space[ch]);
|
||||
to = read_filename_string(ch, f);
|
||||
|
||||
ptr =
|
||||
((struct file_name_map *)xmalloc(sizeof(struct file_name_map)));
|
||||
|
||||
ptr->map_from = from;
|
||||
|
||||
/* Make the real filename absolute. */
|
||||
if (*to == '/')
|
||||
ptr->map_to = to;
|
||||
else
|
||||
{
|
||||
ptr->map_to = (char *)xmalloc(dirlen + strlen(to) + 2);
|
||||
strcpy(ptr->map_to, dirname);
|
||||
ptr->map_to[dirlen] = '/';
|
||||
strcpy(ptr->map_to + dirlen + 1, to);
|
||||
free(to);
|
||||
}
|
||||
|
||||
ptr->map_next = map_list_ptr->map_list_map;
|
||||
map_list_ptr->map_list_map = ptr;
|
||||
|
||||
while ((ch = getc(f)) != '\n')
|
||||
if (ch == EOF)
|
||||
break;
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
map_list_ptr->map_list_next = CPP_OPTIONS(pfile)->map_list;
|
||||
CPP_OPTIONS(pfile)->map_list = map_list_ptr;
|
||||
|
||||
return map_list_ptr->map_list_map;
|
||||
}
|
||||
|
||||
/* Try to open include file FILENAME. SEARCHPTR is the directory
|
||||
* being tried from the include file search path. This function maps
|
||||
* filenames on file systems based on information read by
|
||||
* read_name_map. */
|
||||
|
||||
static int
|
||||
open_include_file(cpp_reader * pfile, char *filename,
|
||||
file_name_list * searchptr)
|
||||
{
|
||||
struct file_name_map *map;
|
||||
const char *from;
|
||||
const char *p, *dir;
|
||||
|
||||
if (searchptr && !searchptr->got_name_map)
|
||||
{
|
||||
searchptr->name_map = read_name_map(pfile,
|
||||
searchptr->fname
|
||||
? searchptr->fname : ".");
|
||||
searchptr->got_name_map = 1;
|
||||
}
|
||||
/* First check the mapping for the directory we are using. */
|
||||
if (searchptr && searchptr->name_map)
|
||||
{
|
||||
from = filename;
|
||||
if (searchptr->fname)
|
||||
from += strlen(searchptr->fname) + 1;
|
||||
for (map = searchptr->name_map; map; map = map->map_next)
|
||||
{
|
||||
if (!strcmp(map->map_from, from))
|
||||
{
|
||||
/* Found a match. */
|
||||
return open(map->map_to, O_RDONLY, 0666);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Try to find a mapping file for the particular directory we are
|
||||
* looking in. Thus #include <sys/types.h> will look up sys/types.h
|
||||
* in /usr/include/header.gcc and look up types.h in
|
||||
* /usr/include/sys/header.gcc. */
|
||||
p = strrchr(filename, '/');
|
||||
if (!p)
|
||||
p = filename;
|
||||
if (searchptr
|
||||
&& searchptr->fname
|
||||
&& strlen(searchptr->fname) == (unsigned)(p - filename)
|
||||
&& !strncmp(searchptr->fname, filename, p - filename))
|
||||
{
|
||||
/* FILENAME is in SEARCHPTR, which we've already checked. */
|
||||
return open(filename, O_RDONLY, 0666);
|
||||
}
|
||||
if (p == filename)
|
||||
{
|
||||
dir = ".";
|
||||
from = filename;
|
||||
}
|
||||
else
|
||||
{
|
||||
char *s;
|
||||
|
||||
s = (char *)alloca(p - filename + 1);
|
||||
memcpy(s, filename, p - filename);
|
||||
s[p - filename] = '\0';
|
||||
from = p + 1;
|
||||
dir = s;
|
||||
}
|
||||
for (map = read_name_map(pfile, dir); map; map = map->map_next)
|
||||
if (!strcmp(map->map_from, from))
|
||||
return open(map->map_to, O_RDONLY, 0666);
|
||||
|
||||
return open(filename, O_RDONLY, 0666);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static int
|
||||
open_include_file(cpp_reader * pfile __UNUSED__, char *filename,
|
||||
|
@ -5506,7 +5313,6 @@ open_include_file(cpp_reader * pfile __UNUSED__, char *filename,
|
|||
return open(filename, O_RDONLY, 0666);
|
||||
}
|
||||
|
||||
#endif /* USE_FILE_NAME_MAPS */
|
||||
|
||||
/* Process the contents of include file FNAME, already open on descriptor F,
|
||||
* with output to OP.
|
||||
|
|
Loading…
Reference in New Issue