darwin-c.c (add_framework): Copy the directory name as it can be freed later.
* config/darwin-c.c (add_framework): Copy the directory name as it can be freed later. Also, ensure we always allocate enough room for the cached framework information. (find_subframework_header): Keep track of the directory where the subframework header was found. (framework_construct_pathname): Speed up by not trying to re-add a framework. * cppfiles.c (search_path_exhausted): Arrange for the missing header callback to be able to set the directory where the header was found. (cpp_get_dir): Add. * cpplib.h (missing_header_cb): Add a parameter. (cpp_get_dir): Add. From-SVN: r81534
This commit is contained in:
parent
f08a3544c2
commit
e3c287c9f3
|
@ -1,4 +1,20 @@
|
|||
2004-05-3 Mike Stump <mrs@apple.com>
|
||||
2004-05-05 Mike Stump <mrs@apple.com>
|
||||
|
||||
* config/darwin-c.c (add_framework): Copy the directory name as it
|
||||
can be freed later. Also, ensure we always allocate enough room
|
||||
for the cached framework information.
|
||||
(find_subframework_header): Keep track of the directory where the
|
||||
subframework header was found.
|
||||
(framework_construct_pathname): Speed up by not trying to re-add a
|
||||
framework.
|
||||
* cppfiles.c (search_path_exhausted): Arrange for the missing
|
||||
header callback to be able to set the directory where the header
|
||||
was found.
|
||||
(cpp_get_dir): Add.
|
||||
* cpplib.h (missing_header_cb): Add a parameter.
|
||||
(cpp_get_dir): Add.
|
||||
|
||||
2004-05-03 Mike Stump <mrs@apple.com>
|
||||
|
||||
* doc/invoke.texi (Directory Options): Document -iquote.
|
||||
* doc/cpp.texi: Likewise.
|
||||
|
|
|
@ -44,7 +44,8 @@ static void push_field_alignment (int);
|
|||
static void pop_field_alignment (void);
|
||||
static const char *find_subframework_file (const char *, const char *);
|
||||
static void add_system_framework_path (char *);
|
||||
static const char *find_subframework_header (cpp_reader *pfile, const char *header);
|
||||
static const char *find_subframework_header (cpp_reader *pfile, const char *header,
|
||||
cpp_dir **dirp);
|
||||
|
||||
typedef struct align_stack
|
||||
{
|
||||
|
@ -166,11 +167,13 @@ static int max_frameworks = 0;
|
|||
/* Remember which frameworks have been seen, so that we can ensure
|
||||
that all uses of that framework come from the same framework. DIR
|
||||
is the place where the named framework NAME, which is of length
|
||||
LEN, was found. */
|
||||
LEN, was found. We copy the directory name from NAME, as it will be
|
||||
freed by others. */
|
||||
|
||||
static void
|
||||
add_framework (const char *name, size_t len, cpp_dir *dir)
|
||||
{
|
||||
char *dir_name;
|
||||
int i;
|
||||
for (i = 0; i < num_frameworks; ++i)
|
||||
{
|
||||
|
@ -183,10 +186,14 @@ add_framework (const char *name, size_t len, cpp_dir *dir)
|
|||
if (i >= max_frameworks)
|
||||
{
|
||||
max_frameworks = i*2;
|
||||
max_frameworks += i == 0;
|
||||
frameworks_in_use = xrealloc (frameworks_in_use,
|
||||
max_frameworks*sizeof(*frameworks_in_use));
|
||||
}
|
||||
frameworks_in_use[num_frameworks].name = name;
|
||||
dir_name = xmalloc (len + 1);
|
||||
memcpy (dir_name, name, len);
|
||||
dir_name[len] = '\0';
|
||||
frameworks_in_use[num_frameworks].name = dir_name;
|
||||
frameworks_in_use[num_frameworks].len = len;
|
||||
frameworks_in_use[num_frameworks].dir = dir;
|
||||
++num_frameworks;
|
||||
|
@ -272,6 +279,7 @@ framework_construct_pathname (const char *fname, cpp_dir *dir)
|
|||
|
||||
if (stat (frname, &st) == 0)
|
||||
{
|
||||
if (fast_dir == 0)
|
||||
add_framework (fname, fname_len, dir);
|
||||
return frname;
|
||||
}
|
||||
|
@ -445,7 +453,7 @@ darwin_register_frameworks (int stdinc)
|
|||
returns non-zero. */
|
||||
|
||||
static const char*
|
||||
find_subframework_header (cpp_reader *pfile, const char *header)
|
||||
find_subframework_header (cpp_reader *pfile, const char *header, cpp_dir **dirp)
|
||||
{
|
||||
const char *fname = header;
|
||||
struct cpp_buffer *b;
|
||||
|
@ -457,8 +465,15 @@ find_subframework_header (cpp_reader *pfile, const char *header)
|
|||
{
|
||||
n = find_subframework_file (fname, cpp_get_path (cpp_get_file (b)));
|
||||
if (n)
|
||||
{
|
||||
/* Logically, the place where we found the subframework is
|
||||
the place where we found the Framework that contains the
|
||||
subframework. This is useful for tracking wether or not
|
||||
we are in a system header. */
|
||||
*dirp = cpp_get_dir (cpp_get_file (b));
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -362,7 +362,7 @@ search_path_exhausted (cpp_reader *pfile, const char *header, _cpp_file *file)
|
|||
if (func
|
||||
&& file->dir == NULL)
|
||||
{
|
||||
if ((file->path = func (pfile, header)) != NULL)
|
||||
if ((file->path = func (pfile, header, &file->dir)) != NULL)
|
||||
{
|
||||
if (open_file (file))
|
||||
return true;
|
||||
|
@ -1316,6 +1316,14 @@ cpp_get_path (struct _cpp_file *f)
|
|||
return f->path;
|
||||
}
|
||||
|
||||
/* Get the directory associated with the _cpp_file F. */
|
||||
|
||||
cpp_dir *
|
||||
cpp_get_dir (struct _cpp_file *f)
|
||||
{
|
||||
return f->dir;
|
||||
}
|
||||
|
||||
/* Get the cpp_buffer currently associated with the cpp_reader
|
||||
PFILE. */
|
||||
|
||||
|
|
|
@ -385,7 +385,7 @@ struct cpp_options
|
|||
The return value is the malloced name of a header to try and open,
|
||||
if any, or NULL otherwise. This callback is called only if the
|
||||
header is otherwise unfound. */
|
||||
typedef const char *(*missing_header_cb)(cpp_reader *, const char *header);
|
||||
typedef const char *(*missing_header_cb)(cpp_reader *, const char *header, cpp_dir **);
|
||||
|
||||
/* Call backs to cpplib client. */
|
||||
struct cpp_callbacks
|
||||
|
@ -744,6 +744,7 @@ extern void cpp_make_system_header (cpp_reader *, int, int);
|
|||
extern bool cpp_push_include (cpp_reader *, const char *);
|
||||
extern void cpp_change_file (cpp_reader *, enum lc_reason, const char *);
|
||||
extern const char *cpp_get_path (struct _cpp_file *);
|
||||
extern cpp_dir *cpp_get_dir (struct _cpp_file *);
|
||||
extern cpp_buffer *cpp_get_buffer (cpp_reader *);
|
||||
extern struct _cpp_file *cpp_get_file (cpp_buffer *);
|
||||
extern cpp_buffer *cpp_get_prev (cpp_buffer *);
|
||||
|
|
Loading…
Reference in New Issue