@@ -24,15 +24,87 @@
/* Sets of accepted source languages like C, C++, Ada... are
represented by a bitmap. */
typedef unsigned lang_bitmap;
+/* Variable length structure representing an input file. A hash table
+ ensure uniqueness for a given input file name. The only function
+ allocating input_file-s is input_file_by_name. */
New line before comment.
+ struct outf* inpoutf; /* Cached corresponding output file, computed
+ in get_output_file_with_visibility. */
Align second line of the comment.
+ char inpname; /* a flexible array, ended by a null char. */
+/* Table of all input files, and its size. */
No comma: "...files and its..."
+input_file* input_file_by_name (const char* name);
+/* For F an input_file, return the relative path to F from $(srcdir)
One empty line.
/* An output file, suitable for definitions, that can see declarations
- made in INPUT_FILE and is linked into every language that uses
- INPUT_FILE. May return NULL in plugin mode. */
-extern outf_p get_output_file_with_visibility (const char *input_file);
+ made in INPF and is linked into every language that uses INPF. May
+ return NULL in plugin mode. The INPF argument is almost const, but
+ since the result is cached in its inpoutf field it cannot be
+ declared const, because this function stores the computed output
+ file in that field to speed it up for further invocations. */
+outf_p get_output_file_with_visibility (input_file* inpf);
Drop the last clause after "because".
@@ -1508,6 +1465,8 @@ set_gc_used (pair_p variables)
for (p = variables; p; p = p->next)
+ DBGPRINTF ("set_gc_used p %p '%s' nbvars %d",
+ (void*) p, p->name, nbvars);
set_gc_used_type (p->type, GC_USED, NULL);
Unrelated: drop or separate patch.
-/* For F a filename, return the relative path to F from $(srcdir) if the
+/* For INPF a filename, return the relative path to F from $(srcdir) if the
latter is a prefix in F, NULL otherwise. */
-static const char *
-get_file_srcdir_relative_path (const char *f)
Replace the remaining occurences of F to INPF.
+ const char* f = get_input_file_name (inpf);
const char *f =
@@ -1936,11 +1900,12 @@ close_output_files (void)
progname, nbwrittenfiles, of->name, backupname);
else if (verbosity_level >= 1)
printf ("%s write #%-3d %s\n", progname, nbwrittenfiles, of->name);
- free (backupname);
+ if (backupname)
+ free (backupname);
- /* output file remains unchanged. */
+ /* Output file remains unchanged. */
if (verbosity_level >= 2)
printf ("%s keep %s\n", progname, of->name);
Separate patches. (I'd just drop the comment change).
+input_file_by_name (const char* name)
+ PTR* slot;
+ input_file* f = NULL;
const char *name