summaryrefslogtreecommitdiff
path: root/Build/source/texk
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk')
-rw-r--r--Build/source/texk/web2c/ChangeLog12
-rw-r--r--Build/source/texk/web2c/NEWS4
-rw-r--r--Build/source/texk/web2c/bibtex.ch36
-rw-r--r--Build/source/texk/web2c/cpascal.h3
-rw-r--r--Build/source/texk/web2c/lib/openclose.c30
-rw-r--r--Build/source/texk/web2c/tests/auxinclude.aux7
-rw-r--r--Build/source/texk/web2c/tests/auxinclude.bbl16
-rw-r--r--Build/source/texk/web2c/tests/auxinclude.bib6
-rw-r--r--Build/source/texk/web2c/tests/auxinclude.tex13
-rw-r--r--Build/source/texk/web2c/tests/auxinclude2.aux20
-rw-r--r--Build/source/texk/web2c/tests/auxinclude2.tex4
-rw-r--r--Build/source/texk/web2c/tests/bibtex-auxinclude.test22
-rw-r--r--Build/source/texk/web2c/web2c/ChangeLog4
-rw-r--r--Build/source/texk/web2c/web2c/common.defines1
14 files changed, 172 insertions, 6 deletions
diff --git a/Build/source/texk/web2c/ChangeLog b/Build/source/texk/web2c/ChangeLog
index 84abe39fcd0..e224f7f6583 100644
--- a/Build/source/texk/web2c/ChangeLog
+++ b/Build/source/texk/web2c/ChangeLog
@@ -1,3 +1,15 @@
+2018-06-08 Karl Berry <karl@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@freefriends.org>
* patgen.ch (trie_size, triec_size): increase greatly.
diff --git a/Build/source/texk/web2c/NEWS b/Build/source/texk/web2c/NEWS
index 9ec86feb0a9..fff05348406 100644
--- a/Build/source/texk/web2c/NEWS
+++ b/Build/source/texk/web2c/NEWS
@@ -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.
diff --git a/Build/source/texk/web2c/bibtex.ch b/Build/source/texk/web2c/bibtex.ch
index 344dde782ae..4b637d99d98 100644
--- a/Build/source/texk/web2c/bibtex.ch
+++ b/Build/source/texk/web2c/bibtex.ch
@@ -413,8 +413,24 @@ function a_open_out(var f:alpha_file):boolean; {open a text file for output}
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 @@ if (last_cite = max_cites) then
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 @@ while (name_ptr <= file_name_size) do {pad with blanks}
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 --
diff --git a/Build/source/texk/web2c/cpascal.h b/Build/source/texk/web2c/cpascal.h
index 1de9a44eb7c..60374d8ec01 100644
--- a/Build/source/texk/web2c/cpascal.h
+++ b/Build/source/texk/web2c/cpascal.h
@@ -141,6 +141,9 @@ typedef FILE *text;
#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]), \
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.
diff --git a/Build/source/texk/web2c/tests/auxinclude.aux b/Build/source/texk/web2c/tests/auxinclude.aux
new file mode 100644
index 00000000000..b1df8814203
--- /dev/null
+++ b/Build/source/texk/web2c/tests/auxinclude.aux
@@ -0,0 +1,7 @@
+\relax
+\citation{article-minimal}
+\@input{auxinclude2.aux}
+\bibstyle{apalike}
+\bibdata{xampl}
+\bibcite{article-minimal}{Aamport, 1986}
+\bibcite{whole-journal}{GAJ, 1986}
diff --git a/Build/source/texk/web2c/tests/auxinclude.bbl b/Build/source/texk/web2c/tests/auxinclude.bbl
new file mode 100644
index 00000000000..e6a064e206b
--- /dev/null
+++ b/Build/source/texk/web2c/tests/auxinclude.bbl
@@ -0,0 +1,16 @@
+\newcommand{\noopsort}[1]{} \newcommand{\printfirst}[2]{#1}
+ \newcommand{\singleletter}[1]{#1} \newcommand{\switchargs}[2]{#2#1}
+\begin{thebibliography}{}
+
+\bibitem[Aamport, 1986]{article-minimal}
+Aamport, L.~A. (1986).
+\newblock The gnats and gnus document preparation system.
+\newblock {\em \mbox{G-Animal's} Journal}.
+
+\bibitem[GAJ, 1986]{whole-journal}
+GAJ (1986).
+\newblock {\em \mbox{G-Animal's} Journal}, 41(7).
+\newblock The entire issue is devoted to gnats and gnus (this entry is a
+ cross-referenced ARTICLE (journal)).
+
+\end{thebibliography}
diff --git a/Build/source/texk/web2c/tests/auxinclude.bib b/Build/source/texk/web2c/tests/auxinclude.bib
new file mode 100644
index 00000000000..7bfcaf721e0
--- /dev/null
+++ b/Build/source/texk/web2c/tests/auxinclude.bib
@@ -0,0 +1,6 @@
+% $Id$
+% Bibliography test file for bibtex-auxinclude.test (q.v.).
+% Public domain. Originally written 2018, Karl Berry.
+
+@misc{rmain, title="r-main", author="R. Main"}
+@misc{rsub, title="r-sub", author="R. Sub"}
diff --git a/Build/source/texk/web2c/tests/auxinclude.tex b/Build/source/texk/web2c/tests/auxinclude.tex
new file mode 100644
index 00000000000..e36dfd191d6
--- /dev/null
+++ b/Build/source/texk/web2c/tests/auxinclude.tex
@@ -0,0 +1,13 @@
+% $Id$
+% Top-level test file for bibtex-auxinclude.test (q.v.).
+% Public domain. Originally written 2018, Karl Berry.
+% built with the usual: latex auxinclude && bibtex auxinclude &&
+% latex auxinclude && latex auxinclude
+% (although we don't use the normal output, just the .aux/bib files).
+\documentclass{article}
+\begin{document}
+article-minimal from main file: \cite{article-minimal}. Including subfile:
+\include{auxinclude2}
+\bibliographystyle{apalike}% just because we already have it in web2c/tests
+\bibliography{xampl}
+\end{document}
diff --git a/Build/source/texk/web2c/tests/auxinclude2.aux b/Build/source/texk/web2c/tests/auxinclude2.aux
new file mode 100644
index 00000000000..b8027ef29ee
--- /dev/null
+++ b/Build/source/texk/web2c/tests/auxinclude2.aux
@@ -0,0 +1,20 @@
+\relax
+\citation{whole-journal}
+\@setckpt{auxinclude2}{
+\setcounter{page}{3}
+\setcounter{equation}{0}
+\setcounter{enumi}{0}
+\setcounter{enumii}{0}
+\setcounter{enumiii}{0}
+\setcounter{enumiv}{0}
+\setcounter{footnote}{0}
+\setcounter{mpfootnote}{0}
+\setcounter{part}{0}
+\setcounter{section}{0}
+\setcounter{subsection}{0}
+\setcounter{subsubsection}{0}
+\setcounter{paragraph}{0}
+\setcounter{subparagraph}{0}
+\setcounter{figure}{0}
+\setcounter{table}{0}
+}
diff --git a/Build/source/texk/web2c/tests/auxinclude2.tex b/Build/source/texk/web2c/tests/auxinclude2.tex
new file mode 100644
index 00000000000..2ed078f9ca7
--- /dev/null
+++ b/Build/source/texk/web2c/tests/auxinclude2.tex
@@ -0,0 +1,4 @@
+% $Id$
+% Subsidiary (\include-d) test file for bibtex-auxinclude.test (q.v.).
+% Public domain. Originally written 2018, Karl Berry.
+whole-journal from included file: \cite{whole-journal}.
diff --git a/Build/source/texk/web2c/tests/bibtex-auxinclude.test b/Build/source/texk/web2c/tests/bibtex-auxinclude.test
new file mode 100644
index 00000000000..39e004b6a85
--- /dev/null
+++ b/Build/source/texk/web2c/tests/bibtex-auxinclude.test
@@ -0,0 +1,22 @@
+#! /bin/sh -vx
+# $Id$
+# Copyright 2018 Karl Berry <tex-live@tug.org>
+# You may freely use, modify and/or distribute this file.
+
+test -d tests || mkdir -p tests
+
+# in case we're invoked standalone instead of from make.
+test -z "$srcdir" && srcdir=`cd \`dirname $0\`/.. && pwd`
+
+cp $srcdir/tests/auxinclude.aux tests/xauxinclude.aux || exit 1
+cp $srcdir/tests/auxinclude2.aux tests/auxinclude2.aux || exit 1
+
+# [x]auxinclude.aux includes \@input{auxinclude2.aux}, to be found in
+# the ./tests/ (working) subdir, which should be automatically checked
+# since we invoke bibtex on tests/whatever.aux. See thread from
+# http://tug.org/pipermail/tex-live/2018-May/041624.html.
+#
+TEXMFCNF=$srcdir/../kpathsea \
+ BSTINPUTS=$srcdir/tests \
+ BIBINPUTS=$srcdir/tests \
+ ./bibtex tests/xauxinclude || exit 1
diff --git a/Build/source/texk/web2c/web2c/ChangeLog b/Build/source/texk/web2c/web2c/ChangeLog
index 7ecb7ac2e03..8f95a87ce2a 100644
--- a/Build/source/texk/web2c/web2c/ChangeLog
+++ b/Build/source/texk/web2c/web2c/ChangeLog
@@ -1,3 +1,7 @@
+2018-06-08 Karl Berry <karl@freefriends.org>
+
+ * common.defines (aopeninwithdirname): add.
+
2016-04-06 Karl Berry <karl@tug.org>
* convert: remove $pascalfile if it is empty,
diff --git a/Build/source/texk/web2c/web2c/common.defines b/Build/source/texk/web2c/web2c/common.defines
index a83950de762..86ad60f07be 100644
--- a/Build/source/texk/web2c/web2c/common.defines
+++ b/Build/source/texk/web2c/web2c/common.defines
@@ -97,6 +97,7 @@
@define function abs ();
@define function addressof ();
@define function aopenin ();
+@define function aopeninwithdirname ();
@define function aopenout ();
@define function atof ();
@define function atoi ();