diff options
Diffstat (limited to 'Build/source/texk/web2c/lib/openclose.c')
-rw-r--r-- | Build/source/texk/web2c/lib/openclose.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/Build/source/texk/web2c/lib/openclose.c b/Build/source/texk/web2c/lib/openclose.c index 9bb7ea148d9..2add7f05bc3 100644 --- a/Build/source/texk/web2c/lib/openclose.c +++ b/Build/source/texk/web2c/lib/openclose.c @@ -141,7 +141,7 @@ recorder_record_output (const_string name) recorder_record_name ("OUTPUT", name); } -/* Open an input file F, using the kpathsea format FILEFMT and passing +/* Open input file *F_PTR, using the kpathsea format FILEFMT and passing FOPEN_MODE to fopen. The filename is in `nameoffile+1'. We return whether or not the open succeeded. If it did, `nameoffile' is set to the full filename opened, and `namelength' to its length. */ @@ -297,6 +297,34 @@ open_input (FILE **f_ptr, int filefmt, const_string fopen_mode) return *f_ptr != NULL; } + + +/* Open input file *F_PTR (of type FILEFMT), prepending the directory + part of the string FNAME. This is called from BibTeX, to open + subsidiary .aux files, with FNAME set to the top-level aux file. The + idea is that if invoked as bibtex somedir/foo.aux, and foo.aux has an + \@input{bar} statement, we should look for somedir/bar.aux too. + (See bibtex-auxinclude.test.) */ + +boolean +open_input_with_dirname (FILE **f_ptr, int filefmt, const char *fname) +{ + boolean ret = false; + char *top_dir = xdirname (fname); + + if (top_dir && *top_dir && !STREQ (top_dir, ".")) { + char *newname = concat3 (top_dir, DIR_SEP_STRING, nameoffile+1); + free (nameoffile); + nameoffile = xmalloc (strlen (newname) + 2); + strcpy (nameoffile + 1, newname); + ret = open_input (f_ptr, filefmt, FOPEN_RBIN_MODE); + free (newname); + } + + free (top_dir); + return ret; +} + /* Open an output file F either in the current directory or in $TEXMFOUTPUT/F, if the environment variable `TEXMFOUTPUT' exists. |