texlive[68160] trunk: bibcop (3sep23)
commits+karl at tug.org
commits+karl at tug.org
Sun Sep 3 22:10:22 CEST 2023
Revision: 68160
http://tug.org/svn/texlive?view=revision&revision=68160
Author: karl
Date: 2023-09-03 22:10:22 +0200 (Sun, 03 Sep 2023)
Log Message:
-----------
bibcop (3sep23)
Modified Paths:
--------------
trunk/Build/source/texk/texlive/linked_scripts/bibcop/bibcop.pl
trunk/Master/texmf-dist/doc/bibtex/bibcop/DEPENDS.txt
trunk/Master/texmf-dist/doc/bibtex/bibcop/README.md
trunk/Master/texmf-dist/doc/bibtex/bibcop/bibcop.pdf
trunk/Master/texmf-dist/doc/man/man1/bibcop.1
trunk/Master/texmf-dist/doc/man/man1/bibcop.man1.pdf
trunk/Master/texmf-dist/scripts/bibcop/bibcop.pl
trunk/Master/texmf-dist/source/bibtex/bibcop/bibcop.dtx
trunk/Master/texmf-dist/tex/latex/bibcop/bibcop.sty
Modified: trunk/Build/source/texk/texlive/linked_scripts/bibcop/bibcop.pl
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/bibcop/bibcop.pl 2023-09-03 11:26:54 UTC (rev 68159)
+++ trunk/Build/source/texk/texlive/linked_scripts/bibcop/bibcop.pl 2023-09-03 20:10:22 UTC (rev 68160)
@@ -21,6 +21,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
+# 2023-09-03 0.0.15
package bibcop;
use warnings;
@@ -40,6 +41,7 @@
'misc' => ['title', 'author', 'year', 'eprint?', 'archiveprefix?', 'primaryclass?', 'publisher?', 'organization?', 'doi?', 'url?'],
);
+# See https://research.arizona.edu/faq/what-do-you-mean-when-you-say-use-title-case-proposalproject-titles
my %minors = map { $_ => 1 } qw/in of at to by the a an and or as if up via yet nor but off on for into/;
# Check the presence of mandatory tags.
@@ -130,9 +132,6 @@
return;
}
my $author = clean_tex($entry{'author'});
- if (index($author, '{') != -1) {
- return;
- }
my @authors = split(/\s+and\s+/, $author);
my $pos = 0;
for my $a (@authors) {
@@ -140,11 +139,25 @@
if ($a eq 'others') {
next;
}
- if (not $a =~ /^[A-Z][^ .]+( [A-Z][^ .]+)*(,( [A-Z][^ ]+)+)?$/) {
- return "The format of @{[as_position($pos)]} 'author' is wrong, use something like 'Knuth, Donald E. and Duane, Bibby'"
+ if (index($a, ' ') != -1 and index($a, ',') == -1) {
+ return "The last name should go first, all other names must follow, after a comma in @{[as_position($pos)]} 'author', as in 'Knuth, Donald E.'";
}
- if ($author =~ /.*[A-Z]([ ,]|$).*/) {
- return "A shortened name must have a tailing dot in @{[as_position($pos)]} 'author', as in 'Knuth, Donald E.'"
+ my $npos = 0;
+ for my $name (split(/[ ,]+/, $a)) {
+ $npos += 1;
+ if (index($name, '{') != -1) {
+ next;
+ }
+ if ($name =~ /^[A-Z]\.$/) {
+ next;
+ }
+ if ($name =~ /^[A-Z][^.]+$/) {
+ next
+ }
+ if ($name =~ /^[A-Z]$/) {
+ return "A shortened name must have a tailing dot in @{[as_position($pos)]} 'author', as in 'Knuth, Donald E.'";
+ }
+ return "In @{[as_position($pos)]} 'author' @{[as_position($npos)]} name looks suspicious ($name), use something like 'Knuth, Donald E. and Duane, Bibby'";
}
}
}
@@ -386,7 +399,7 @@
my (%entry) = @_;
if (exists $entry{'doi'}) {
my $doi = $entry{'doi'};
- if (not $doi =~ /^[0-9a-zA-Z.]+\/[0-9a-zA-Z._\-)(]+$/) {
+ if (not $doi =~ /^[0-9a-zA-Z.]+\/[0-9a-zA-Z._\-)(><:;]+$/) {
return "The format of the 'doi' is wrong"
}
}
@@ -553,9 +566,26 @@
if ($value =~ /^[1-9][0-9]*$/) {
return $value;
}
- my ($left, $right) = split(/---|--|-|—|\s/, $value);
+ my ($left, $right) = split(/---|--|-|–|—|\s/, $value);
+ if ($left eq '') {
+ $left = $right;
+ }
+ if ($right eq '') {
+ $right = $left;
+ }
$left =~ s/^0+//g;
$right =~ s/^0+//g;
+ if ($left !~ /^[0-9]*$/ or $right !~ /^[0-9]*$/) {
+ return $value;
+ }
+ if ($left + 0 gt $right + 0) {
+ my $tmp = $left;
+ $left = $right;
+ $right = $tmp;
+ }
+ if ($left eq $right) {
+ return $left;
+ }
return $left . '--' . $right;
}
@@ -604,8 +634,10 @@
if ($char eq ' ') {
# ignore the white space
} elsif ($char eq '%' and not($s eq 'quote')) {
- $interrupted = $s;
- $s = 'comment';
+ if ($pos eq 0 or substr($bib, $pos - 1, 1) ne '\\') {
+ $interrupted = $s;
+ $s = 'comment';
+ }
} elsif ($char eq "\n") {
# ignore the EOL
$lineno = $lineno + 1;
@@ -620,7 +652,7 @@
$s = 'start';
$acc = '';
} else {
- warning("Each BibTeX entry must start with '\@', what is '$char'?");
+ warning("Each BibTeX entry must start with '\@', what is '$char' at line no.$lineno?");
last;
}
} elsif ($char =~ /[a-zA-Z]/ and $s eq 'start') {
@@ -642,7 +674,7 @@
} elsif ($char eq '=' and $s eq 'tag') {
my $t = lc($acc);
if (exists $entry{$t}) {
- warning("The tag '$t' is seen more than once");
+ warning("The tag '$t' is seen more than once at line no.$lineno");
}
$tag = $t;
$s = 'value';
@@ -829,9 +861,9 @@
" --latex Report errors in LaTeX format using \\PackageWarningNoLine command\n\n" .
"If any issues, report to GitHub: https://github.com/yegor256/bibcop");
} elsif (exists $args{'--version'} or exists $args{'-v'}) {
- info('0.0.14');
+ info('0.0.15 2023-09-03');
} else {
- my ($file) = grep { not($_ =~ /^--.*$/) } @ARGV;
+ my ($file) = grep { not($_ =~ /^-.*$/) } @ARGV;
if (not $file) {
error('File name must be specified');
}
@@ -903,4 +935,5 @@
}
}
+# In order to finish it with success:
1;
Modified: trunk/Master/texmf-dist/doc/bibtex/bibcop/DEPENDS.txt
===================================================================
--- trunk/Master/texmf-dist/doc/bibtex/bibcop/DEPENDS.txt 2023-09-03 11:26:54 UTC (rev 68159)
+++ trunk/Master/texmf-dist/doc/bibtex/bibcop/DEPENDS.txt 2023-09-03 20:10:22 UTC (rev 68160)
@@ -1,2 +1,16 @@
hard iexec
hard pgfopts
+soft biber
+soft biblatex
+soft bibtex
+soft ffcode
+soft href-ul
+soft hypdoc
+soft l3build
+soft libertine
+soft microtype
+soft newtx
+soft pgfopts
+soft scheme-basic
+soft verbatimcopy
+soft xetex
\ No newline at end of file
Modified: trunk/Master/texmf-dist/doc/bibtex/bibcop/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/bibtex/bibcop/README.md 2023-09-03 11:26:54 UTC (rev 68159)
+++ trunk/Master/texmf-dist/doc/bibtex/bibcop/README.md 2023-09-03 20:10:22 UTC (rev 68160)
@@ -23,9 +23,9 @@
\end{document}
```
-Otherwise, you can download [`bibcop.sty`](https://raw.githubusercontent.com/yegor256/bibcop/gh-pages/bibcop/bibcop.sty) and add to your project (together with [`bibcop.pl`](https://raw.githubusercontent.com/yegor256/bibcop/master/bibcop.pl)!).
+Otherwise, you can download [`bibcop.sty`](https://raw.githubusercontent.com/yegor256/bibcop/gh-pages/bibcop.sty) and add to your project (together with [`bibcop.pl`](https://raw.githubusercontent.com/yegor256/bibcop/gh-pages/bibcop.pl)!).
-You can also download [`bibcop.pl`](https://raw.githubusercontent.com/yegor256/bibcop/master/bibcop.pl)
+You can also download [`bibcop.pl`](https://raw.githubusercontent.com/yegor256/bibcop/gh-pages/bibcop.pl)
and use it as a command line tool
to check your `.bib` files and to auto-fix them
(you should have [Perl](https://www.perl.org) installed):
@@ -62,4 +62,6 @@
$ perl tests.pl
```
-You should see the `GREAT!` message.
\ No newline at end of file
+You should see the `GREAT!` message.
+
+Copyright (c) 2022-2023 Yegor Bugayenko, MIT License
\ No newline at end of file
Modified: trunk/Master/texmf-dist/doc/bibtex/bibcop/bibcop.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/man/man1/bibcop.1
===================================================================
--- trunk/Master/texmf-dist/doc/man/man1/bibcop.1 2023-09-03 11:26:54 UTC (rev 68159)
+++ trunk/Master/texmf-dist/doc/man/man1/bibcop.1 2023-09-03 20:10:22 UTC (rev 68160)
@@ -1,4 +1,4 @@
-.TH bibcop 1 "2023-06-30"
+.TH bibcop 1 "2023-09-03"
.SH NAME
bibcop \- Style Checker and Fixer of BibTeX Files (.bib)
.SH SYNOPSIS
Modified: trunk/Master/texmf-dist/doc/man/man1/bibcop.man1.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/scripts/bibcop/bibcop.pl
===================================================================
--- trunk/Master/texmf-dist/scripts/bibcop/bibcop.pl 2023-09-03 11:26:54 UTC (rev 68159)
+++ trunk/Master/texmf-dist/scripts/bibcop/bibcop.pl 2023-09-03 20:10:22 UTC (rev 68160)
@@ -21,6 +21,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
+# 2023-09-03 0.0.15
package bibcop;
use warnings;
@@ -40,6 +41,7 @@
'misc' => ['title', 'author', 'year', 'eprint?', 'archiveprefix?', 'primaryclass?', 'publisher?', 'organization?', 'doi?', 'url?'],
);
+# See https://research.arizona.edu/faq/what-do-you-mean-when-you-say-use-title-case-proposalproject-titles
my %minors = map { $_ => 1 } qw/in of at to by the a an and or as if up via yet nor but off on for into/;
# Check the presence of mandatory tags.
@@ -130,9 +132,6 @@
return;
}
my $author = clean_tex($entry{'author'});
- if (index($author, '{') != -1) {
- return;
- }
my @authors = split(/\s+and\s+/, $author);
my $pos = 0;
for my $a (@authors) {
@@ -140,11 +139,25 @@
if ($a eq 'others') {
next;
}
- if (not $a =~ /^[A-Z][^ .]+( [A-Z][^ .]+)*(,( [A-Z][^ ]+)+)?$/) {
- return "The format of @{[as_position($pos)]} 'author' is wrong, use something like 'Knuth, Donald E. and Duane, Bibby'"
+ if (index($a, ' ') != -1 and index($a, ',') == -1) {
+ return "The last name should go first, all other names must follow, after a comma in @{[as_position($pos)]} 'author', as in 'Knuth, Donald E.'";
}
- if ($author =~ /.*[A-Z]([ ,]|$).*/) {
- return "A shortened name must have a tailing dot in @{[as_position($pos)]} 'author', as in 'Knuth, Donald E.'"
+ my $npos = 0;
+ for my $name (split(/[ ,]+/, $a)) {
+ $npos += 1;
+ if (index($name, '{') != -1) {
+ next;
+ }
+ if ($name =~ /^[A-Z]\.$/) {
+ next;
+ }
+ if ($name =~ /^[A-Z][^.]+$/) {
+ next
+ }
+ if ($name =~ /^[A-Z]$/) {
+ return "A shortened name must have a tailing dot in @{[as_position($pos)]} 'author', as in 'Knuth, Donald E.'";
+ }
+ return "In @{[as_position($pos)]} 'author' @{[as_position($npos)]} name looks suspicious ($name), use something like 'Knuth, Donald E. and Duane, Bibby'";
}
}
}
@@ -386,7 +399,7 @@
my (%entry) = @_;
if (exists $entry{'doi'}) {
my $doi = $entry{'doi'};
- if (not $doi =~ /^[0-9a-zA-Z.]+\/[0-9a-zA-Z._\-)(]+$/) {
+ if (not $doi =~ /^[0-9a-zA-Z.]+\/[0-9a-zA-Z._\-)(><:;]+$/) {
return "The format of the 'doi' is wrong"
}
}
@@ -553,9 +566,26 @@
if ($value =~ /^[1-9][0-9]*$/) {
return $value;
}
- my ($left, $right) = split(/---|--|-|—|\s/, $value);
+ my ($left, $right) = split(/---|--|-|–|—|\s/, $value);
+ if ($left eq '') {
+ $left = $right;
+ }
+ if ($right eq '') {
+ $right = $left;
+ }
$left =~ s/^0+//g;
$right =~ s/^0+//g;
+ if ($left !~ /^[0-9]*$/ or $right !~ /^[0-9]*$/) {
+ return $value;
+ }
+ if ($left + 0 gt $right + 0) {
+ my $tmp = $left;
+ $left = $right;
+ $right = $tmp;
+ }
+ if ($left eq $right) {
+ return $left;
+ }
return $left . '--' . $right;
}
@@ -604,8 +634,10 @@
if ($char eq ' ') {
# ignore the white space
} elsif ($char eq '%' and not($s eq 'quote')) {
- $interrupted = $s;
- $s = 'comment';
+ if ($pos eq 0 or substr($bib, $pos - 1, 1) ne '\\') {
+ $interrupted = $s;
+ $s = 'comment';
+ }
} elsif ($char eq "\n") {
# ignore the EOL
$lineno = $lineno + 1;
@@ -620,7 +652,7 @@
$s = 'start';
$acc = '';
} else {
- warning("Each BibTeX entry must start with '\@', what is '$char'?");
+ warning("Each BibTeX entry must start with '\@', what is '$char' at line no.$lineno?");
last;
}
} elsif ($char =~ /[a-zA-Z]/ and $s eq 'start') {
@@ -642,7 +674,7 @@
} elsif ($char eq '=' and $s eq 'tag') {
my $t = lc($acc);
if (exists $entry{$t}) {
- warning("The tag '$t' is seen more than once");
+ warning("The tag '$t' is seen more than once at line no.$lineno");
}
$tag = $t;
$s = 'value';
@@ -829,9 +861,9 @@
" --latex Report errors in LaTeX format using \\PackageWarningNoLine command\n\n" .
"If any issues, report to GitHub: https://github.com/yegor256/bibcop");
} elsif (exists $args{'--version'} or exists $args{'-v'}) {
- info('0.0.14');
+ info('0.0.15 2023-09-03');
} else {
- my ($file) = grep { not($_ =~ /^--.*$/) } @ARGV;
+ my ($file) = grep { not($_ =~ /^-.*$/) } @ARGV;
if (not $file) {
error('File name must be specified');
}
@@ -903,4 +935,5 @@
}
}
+# In order to finish it with success:
1;
Modified: trunk/Master/texmf-dist/source/bibtex/bibcop/bibcop.dtx
===================================================================
--- trunk/Master/texmf-dist/source/bibtex/bibcop/bibcop.dtx 2023-09-03 11:26:54 UTC (rev 68159)
+++ trunk/Master/texmf-dist/source/bibtex/bibcop/bibcop.dtx 2023-09-03 20:10:22 UTC (rev 68160)
@@ -50,7 +50,7 @@
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{bibcop}
%<*package>
-[2023-06-30 0.0.14 Style Checker of Bibliography Files]
+[2023-09-03 0.0.15 Style Checker of Bibliography Files]
%</package>
%<*driver>
\documentclass{ltxdoc}
Modified: trunk/Master/texmf-dist/tex/latex/bibcop/bibcop.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/bibcop/bibcop.sty 2023-09-03 11:26:54 UTC (rev 68159)
+++ trunk/Master/texmf-dist/tex/latex/bibcop/bibcop.sty 2023-09-03 20:10:22 UTC (rev 68160)
@@ -31,7 +31,7 @@
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{bibcop}
-[2023-06-30 0.0.14 Style Checker of Bibliography Files]
+[2023-09-03 0.0.15 Style Checker of Bibliography Files]
More information about the tex-live-commits
mailing list.