texlive[46666] Build/source/texk/web2c: avoid printing .bib.bib when
commits+karl at tug.org
commits+karl at tug.org
Sun Feb 18 20:19:24 CET 2018
Revision: 46666
http://tug.org/svn/texlive?view=revision&revision=46666
Author: karl
Date: 2018-02-18 20:19:23 +0100 (Sun, 18 Feb 2018)
Log Message:
-----------
avoid printing .bib.bib when reporting database files
Modified Paths:
--------------
trunk/Build/source/texk/web2c/ChangeLog
trunk/Build/source/texk/web2c/bibtex.ch
Modified: trunk/Build/source/texk/web2c/ChangeLog
===================================================================
--- trunk/Build/source/texk/web2c/ChangeLog 2018-02-18 03:21:19 UTC (rev 46665)
+++ trunk/Build/source/texk/web2c/ChangeLog 2018-02-18 19:19:23 UTC (rev 46666)
@@ -1,3 +1,9 @@
+2018-02-18 Karl Berry <karl at tug.org>
+
+ * bibtex.ch (str_ends_with): new fn.
+ (print_bib_name, log_pr_bib_name): don't print foo.bib.bib
+ when given \bibdata{foo.bib}.
+
2018-02-03 Hironobu Yamashita <h.y.acetaminophen at gmail.com>
* lib/texmfmp.c, texmfmp.h: XeTeX properly close input pipes.
Modified: trunk/Build/source/texk/web2c/bibtex.ch
===================================================================
--- trunk/Build/source/texk/web2c/bibtex.ch 2018-02-18 03:21:19 UTC (rev 46665)
+++ trunk/Build/source/texk/web2c/bibtex.ch 2018-02-18 19:19:23 UTC (rev 46666)
@@ -831,7 +831,7 @@
@!bib_number = integer; {gives the |bib_list| range}
@z
- at x [122] Add log_pr_bib_name.
+ at x [122] Don't print extension twice; add log_pr_bib_name function.
procedure print_bib_name;
begin
print_pool_str (cur_bib_str);
@@ -839,10 +839,37 @@
print_newline;
end;
@y
+{Return true if the |ext| string is at the end of the |s| string. There
+ are surely far more clever ways to do this, but it doesn't matter.}
+function str_ends_with (@!s:str_number; @!ext:str_number) : boolean;
+var i : integer;
+ str_idx,ext_idx : integer;
+ str_char,ext_char : ASCII_code;
+begin
+ str_ends_with := false;
+ if (length (ext) > length (s)) then
+ return; {if extension is longer, they don't match}
+ str_idx := length (s) - 1;
+ ext_idx := length (ext) - 1;
+ while (ext_idx >= 0) do begin {|>=| so we check the |'.'| char.}
+ str_char := str_pool[str_start[s]+str_idx];
+ ext_char := str_pool[str_start[ext]+ext_idx];
+ if (str_char <> ext_char) then
+ return;
+ decr (str_idx);
+ decr (ext_idx);
+ end;
+ str_ends_with := true;
+exit: end;
+
+{The above is needed because the file name specified in the
+ \.{\\bibdata} command may or may not have the \.{.bib} extension. If it
+ does, we don't want to print \.{.bib} twice.}
procedure print_bib_name;
begin
print_pool_str (cur_bib_str);
-print_pool_str (s_bib_extension);
+if not str_ends_with (cur_bib_str, s_bib_extension) then
+ print_pool_str (s_bib_extension);
print_newline;
end;
@#
@@ -849,7 +876,8 @@
procedure log_pr_bib_name;
begin
log_pr_pool_str (cur_bib_str);
-log_pr_pool_str (s_bib_extension);
+if not str_ends_with (cur_bib_str, s_bib_extension) then
+ log_pr_pool_str (s_bib_extension);
log_pr_newline;
end;
@z
More information about the tex-live-commits
mailing list