[tex-live] bug report of bibtex
Karl Berry
karl at freefriends.org
Mon Jun 11 00:25:53 CEST 2018
Hi John,
bibtex output/main.aux
Then the search for subsidiary .aux files is changed from no path to
just the path component of the top-level aux file.
I just committed a change that attempts to implement this (edited patch
below for the record, r47979). Hope I didn't break the world.
That is, when looking for a subsidiary aux file, it first checks the
current directory (no change), then the dirname of the main aux file.
It occurred to me that another approach to this might be to give BibTeX
the -output-directory option. I have the start of a patch for that, but
then turned out to require messing around with the kpse_out_name_ok
logic in bibtex.ch, and I ran out of energy. If anyone feels like giving
it a try, let me know and I'll send what I've got.
Anyway, hope the present change helps, eventually. --thanks, karl.
Index: ChangeLog
===================================================================
--- ChangeLog (revision 47973)
+++ ChangeLog (working copy)
@@ -1,3 +1,15 @@
+2018-06-08 Karl Berry <karl at freefriends.org>
+
+ * bibtex.ch (142): also try opening subsidiary .aux files
+ via a_open_in_with_dirname.
+ (bib_makecstring): new fn.
+ * cpascal.h (aopeninwithdirname): new #define.
+ * lib/openclose.c (open_input_with_dirname): new fn.
+ * tests/bibtex-auxinclude.test: new test.
+ * tests/auxinclude*.*: files for test.
+ Suggestion from John Collins. See thread from
+ http://tug.org/pipermail/tex-live/2018-May/041624.html.
+
2018-05-03 Karl Berry <karl at freefriends.org>
* patgen.ch (trie_size, triec_size): increase greatly.
Index: NEWS
===================================================================
--- NEWS (revision 47973)
+++ NEWS (working copy)
@@ -1,5 +1,9 @@
This file records noteworthy changes. (Public domain.)
+BibTeX: subsidiary .aux files are looked for in the directory of the
+main .aux file, if not found as-is (to work better with -output-directory).
+
+
2018 (for TeX Live 2018, 14 April 2018)
* Directories in the -output-directory do not mask files by the same name.
Index: bibtex.ch
===================================================================
--- bibtex.ch (revision 47973)
+++ bibtex.ch (working copy)
@@ -413,8 +413,24 @@
begin rewrite(f,name_of_file,'/O'); a_open_out:=rewrite_OK(f);
end;
@y
-@ File opening will be done in C.
+@ File opening will be done in C. But we want an auxiliary function to
+change a \BibTeX\ string into a C string, to keep string pool stuff
+out of the C code in @.{lib/openclose.c}.
+
@d no_file_path = -1
+
+@<Procedures and functions for all file...@>=
+function bib_makecstring(s:str_number):cstring;
+var cstr:cstring;
+ i:pool_pointer;
+begin
+ cstr := xmalloc_array (ASCII_code, length (s) + 1);
+ for i := 0 to length(s) - 1 do begin
+ cstr[i] := str_pool[str_start[s] + i];
+ end;
+ cstr[length(s)] := 0;
+ bib_makecstring := cstr;
+exit: end;
@z
@x [39] Do file closing in C.
@@ -1008,8 +1024,15 @@
end;
@z
-% [142] Don't pad with blanks.
-% Don't use a path to search for subsidiary aux files, either.
+% [142] Don't pad with blanks, terminate with null.
+% Don't use a path to search for subsidiary aux files,
+% but do check the directory of the main .aux file.
+%
+% This last is useful, for example, when --output-dir is used and the
+% .aux file has an \@input directive resulting from a LaTeX \include;
+% see bibtex-auxinclude.test. It's necessary because BibTeX itself does
+% not have --output-directory. Maybe it would be (have been?) better to
+% add it, but seems too intrusive now? Different bbl location.
@x
while (name_ptr <= file_name_size) do {pad with blanks}
begin
@@ -1019,8 +1042,11 @@
if (not a_open_in(cur_aux_file)) then
@y
name_of_file[name_ptr] := 0;
-if (not kpse_in_name_ok(stringcast(name_of_file+1)) or
- not a_open_in(cur_aux_file, no_file_path)) then
+if (not kpse_in_name_ok(stringcast(name_of_file+1))
+ or (not a_open_in(cur_aux_file, no_file_path)
+ and not a_open_in_with_dirname(cur_aux_file, no_file_path,
+ bib_makecstring(top_lev_str)))
+ ) then
@z
% [152] This goto gets turned into a setjmp/longjmp by ./convert --
Index: cpascal.h
===================================================================
--- cpascal.h (revision 47973)
+++ cpascal.h (working copy)
@@ -141,6 +141,9 @@
#define aopenout(f) open_output (&(f), FOPEN_W_MODE)
#define aclose close_file
+/* Used in BibTeX for subsidiary aux files. */
+#define aopeninwithdirname(f,p,s) open_input_with_dirname (&(f), p, s)
+
/* How to output to the GF or DVI file. */
#define WRITE_OUT(a, b) \
if ((size_t) fwrite ((char *) &OUT_BUF[a], sizeof (OUT_BUF[a]), \
Index: lib/openclose.c
===================================================================
--- lib/openclose.c (revision 47973)
+++ lib/openclose.c (working copy)
@@ -297,7 +297,35 @@
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.
(Actually, this also applies to the BibTeX and MetaPost output files,
Index: web2c/common.defines
===================================================================
--- web2c/common.defines (revision 47973)
+++ web2c/common.defines (working copy)
@@ -97,6 +97,7 @@
@define function abs ();
@define function addressof ();
@define function aopenin ();
+ at define function aopeninwithdirname ();
@define function aopenout ();
@define function atof ();
@define function atoi ();
More information about the tex-live
mailing list