diff options
author | Karl Berry <karl@freefriends.org> | 2018-06-10 22:13:16 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-06-10 22:13:16 +0000 |
commit | 407ba94a3472d34da2cac80b6eb9e3ff77fe5f2e (patch) | |
tree | 62b201431f9173bd930179b02f9247c4dbabd0cc /Build/source/texk/web2c/lib | |
parent | df7ae27df461a7a5058a1edb9ed53dc630d51082 (diff) |
bibtex: fallback check for subsidiary aux files in the directory of the main aux file
git-svn-id: svn://tug.org/texlive/trunk@47979 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/lib')
-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. |