texlive[67168] trunk: bibcop (20may23)

commits+karl at tug.org commits+karl at tug.org
Sat May 20 22:16:26 CEST 2023


Revision: 67168
          http://tug.org/svn/texlive?view=revision&revision=67168
Author:   karl
Date:     2023-05-20 22:16:26 +0200 (Sat, 20 May 2023)
Log Message:
-----------
bibcop (20may23)

Modified Paths:
--------------
    trunk/Build/source/texk/texlive/linked_scripts/bibcop/bibcop.pl
    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-05-19 23:43:55 UTC (rev 67167)
+++ trunk/Build/source/texk/texlive/linked_scripts/bibcop/bibcop.pl	2023-05-20 20:16:26 UTC (rev 67168)
@@ -92,13 +92,25 @@
       }
       $pos = $pos + 1;
       if (exists $minors{$word}) {
-        next;
+        if ($pos eq 1) {
+          return "The minor word in the '$tag' must be upper-cased since it is the first one"
+        }
+        if (not $words[$pos - 2] =~ /^.*:$/) {
+          next;
+        }
+        return "The minor word in the '$tag' must be upper-cased, because it follows the colon"
       }
-      if (exists $minors{lc($word)} and $pos gt 1) {
-        return "All minor words in the '$tag' must be lower-cased, while '$word' (no.$pos) is not"
+      if (exists $minors{lc($word)}) {
+        if ($pos eq 1) {
+          next;
+        }
+        if ($words[$pos - 2] =~ /^.*:$/) {
+          next;
+        }
+        return "All minor words in the '$tag' must be lower-cased, while @{[as_position($pos)]} word '$word' is not"
       }
       if ($word =~ /^[a-z].*/) {
-        return "All major words in the '$tag' must be capitalized, while '$word' (no.$pos) is not"
+        return "All major words in the '$tag' must be capitalized, while @{[as_position($pos)]} word '$word' is not"
       }
     }
   }
@@ -117,12 +129,20 @@
   if (index($author, '{') != -1) {
     return;
   }
-  if (not $author =~ /^[A-Z][^ ]+(,( [A-Z][^ ]+)+)?( and [A-Z][^ ]+(,( [A-Z][^ ]+)+)?)*( and others)?$/) {
-    return "The format of the 'author' is wrong, use something like 'Knuth, Donald E. and Duane, Bibby'"
+  my @authors = split(/\s+and\s+/, $author);
+  my $pos = 0;
+  for my $a (@authors) {
+    $pos += 1;
+    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 ($author =~ /.*[A-Z]([ ,]|$).*/) {
+      return "A shortened name must have a tailing dot in @{[as_position($pos)]} 'author', as in 'Knuth, Donald E.'"
+    }
   }
-  if ($author =~ /.*[A-Z]([ ,]|$).*/) {
-    return "A shortened name must have a tailing dot, as in 'Knuth, Donald E.'"
-  }
 }
 
 # Check that titles don't have shortened words with a tailing dot.
@@ -689,6 +709,22 @@
   return $tex;
 }
 
+# Turn a number into a position, like 1 -> 1st, 2 -> 2nd, 3 -> 3rd, 4 -> 4th, and so on.
+sub as_position {
+  my ($i) = @_;
+  my $txt;
+  if ($i == 1) {
+    $txt = '1st';
+  } elsif ($i == 2) {
+    $txt = '2nd';
+  } elsif ($i == 3) {
+    $txt = '3rd';
+  } else {
+    $txt = "${i}th";
+  }
+  return "the $txt";
+}
+
 # Take a bibentry and print all its tags as a comma-separated string.
 sub listed_tags {
   my (%entry) = @_;
@@ -708,11 +744,10 @@
   my ($txt) = @_;
   if (exists $args{'--latex'}) {
     print "\\PackageError{bibcop}{$txt}{}\n";
-    exit 0;
   } else {
     print STDERR $txt . "\n";
-    exit 1;
   }
+  fail();
 }
 
 # Print DEBUG message to the console.
@@ -746,6 +781,14 @@
   }
 }
 
+sub fail {
+  if (exists $args{'--latex'}) {
+    exit(0);
+  } else {
+    exit(1);
+  }
+}
+
 if (@ARGV+0 eq 0 or exists $args{'--help'} or exists $args{'-?'}) {
   info("Bibcop is a Style Checker of BibTeX Files\n\n" .
     "Usage:\n" .
@@ -765,7 +808,7 @@
     "      --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.11');
+  info('0.0.12');
 } else {
   my ($file) = grep { not($_ =~ /^--.*$/) } @ARGV;
   if (not $file) {
@@ -812,13 +855,19 @@
     }
   } else {
     debug((@entries+0) . ' entries found in ' . $file);
+    my $found = 0;
     for my $i (0..(@entries+0 - 1)) {
       my %entry = %{ $entries[$i] };
       debug("Checking $entry{':name'} (no.$i)...");
       foreach my $err (process_entry(%entry)) {
         warning("$err, in the '$entry{':name'}' entry");
+        $found += 1;
       }
     }
+    if ($found gt 0) {
+      debug("$found problem(s) found");
+      fail();
+    }
   }
 }
 

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-05-19 23:43:55 UTC (rev 67167)
+++ trunk/Master/texmf-dist/doc/man/man1/bibcop.1	2023-05-20 20:16:26 UTC (rev 67168)
@@ -1,4 +1,4 @@
-.TH bibcop 1 "2023-05-18"
+.TH bibcop 1 "2023-05-20"
 .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-05-19 23:43:55 UTC (rev 67167)
+++ trunk/Master/texmf-dist/scripts/bibcop/bibcop.pl	2023-05-20 20:16:26 UTC (rev 67168)
@@ -92,13 +92,25 @@
       }
       $pos = $pos + 1;
       if (exists $minors{$word}) {
-        next;
+        if ($pos eq 1) {
+          return "The minor word in the '$tag' must be upper-cased since it is the first one"
+        }
+        if (not $words[$pos - 2] =~ /^.*:$/) {
+          next;
+        }
+        return "The minor word in the '$tag' must be upper-cased, because it follows the colon"
       }
-      if (exists $minors{lc($word)} and $pos gt 1) {
-        return "All minor words in the '$tag' must be lower-cased, while '$word' (no.$pos) is not"
+      if (exists $minors{lc($word)}) {
+        if ($pos eq 1) {
+          next;
+        }
+        if ($words[$pos - 2] =~ /^.*:$/) {
+          next;
+        }
+        return "All minor words in the '$tag' must be lower-cased, while @{[as_position($pos)]} word '$word' is not"
       }
       if ($word =~ /^[a-z].*/) {
-        return "All major words in the '$tag' must be capitalized, while '$word' (no.$pos) is not"
+        return "All major words in the '$tag' must be capitalized, while @{[as_position($pos)]} word '$word' is not"
       }
     }
   }
@@ -117,12 +129,20 @@
   if (index($author, '{') != -1) {
     return;
   }
-  if (not $author =~ /^[A-Z][^ ]+(,( [A-Z][^ ]+)+)?( and [A-Z][^ ]+(,( [A-Z][^ ]+)+)?)*( and others)?$/) {
-    return "The format of the 'author' is wrong, use something like 'Knuth, Donald E. and Duane, Bibby'"
+  my @authors = split(/\s+and\s+/, $author);
+  my $pos = 0;
+  for my $a (@authors) {
+    $pos += 1;
+    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 ($author =~ /.*[A-Z]([ ,]|$).*/) {
+      return "A shortened name must have a tailing dot in @{[as_position($pos)]} 'author', as in 'Knuth, Donald E.'"
+    }
   }
-  if ($author =~ /.*[A-Z]([ ,]|$).*/) {
-    return "A shortened name must have a tailing dot, as in 'Knuth, Donald E.'"
-  }
 }
 
 # Check that titles don't have shortened words with a tailing dot.
@@ -689,6 +709,22 @@
   return $tex;
 }
 
+# Turn a number into a position, like 1 -> 1st, 2 -> 2nd, 3 -> 3rd, 4 -> 4th, and so on.
+sub as_position {
+  my ($i) = @_;
+  my $txt;
+  if ($i == 1) {
+    $txt = '1st';
+  } elsif ($i == 2) {
+    $txt = '2nd';
+  } elsif ($i == 3) {
+    $txt = '3rd';
+  } else {
+    $txt = "${i}th";
+  }
+  return "the $txt";
+}
+
 # Take a bibentry and print all its tags as a comma-separated string.
 sub listed_tags {
   my (%entry) = @_;
@@ -708,11 +744,10 @@
   my ($txt) = @_;
   if (exists $args{'--latex'}) {
     print "\\PackageError{bibcop}{$txt}{}\n";
-    exit 0;
   } else {
     print STDERR $txt . "\n";
-    exit 1;
   }
+  fail();
 }
 
 # Print DEBUG message to the console.
@@ -746,6 +781,14 @@
   }
 }
 
+sub fail {
+  if (exists $args{'--latex'}) {
+    exit(0);
+  } else {
+    exit(1);
+  }
+}
+
 if (@ARGV+0 eq 0 or exists $args{'--help'} or exists $args{'-?'}) {
   info("Bibcop is a Style Checker of BibTeX Files\n\n" .
     "Usage:\n" .
@@ -765,7 +808,7 @@
     "      --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.11');
+  info('0.0.12');
 } else {
   my ($file) = grep { not($_ =~ /^--.*$/) } @ARGV;
   if (not $file) {
@@ -812,13 +855,19 @@
     }
   } else {
     debug((@entries+0) . ' entries found in ' . $file);
+    my $found = 0;
     for my $i (0..(@entries+0 - 1)) {
       my %entry = %{ $entries[$i] };
       debug("Checking $entry{':name'} (no.$i)...");
       foreach my $err (process_entry(%entry)) {
         warning("$err, in the '$entry{':name'}' entry");
+        $found += 1;
       }
     }
+    if ($found gt 0) {
+      debug("$found problem(s) found");
+      fail();
+    }
   }
 }
 

Modified: trunk/Master/texmf-dist/source/bibtex/bibcop/bibcop.dtx
===================================================================
--- trunk/Master/texmf-dist/source/bibtex/bibcop/bibcop.dtx	2023-05-19 23:43:55 UTC (rev 67167)
+++ trunk/Master/texmf-dist/source/bibtex/bibcop/bibcop.dtx	2023-05-20 20:16:26 UTC (rev 67168)
@@ -50,7 +50,7 @@
 %<package>\NeedsTeXFormat{LaTeX2e}
 %<package>\ProvidesPackage{bibcop}
 %<*package>
-[2023-05-18 0.0.11 Style Checker of Bibliography Files]
+[2023-05-20 0.0.12 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-05-19 23:43:55 UTC (rev 67167)
+++ trunk/Master/texmf-dist/tex/latex/bibcop/bibcop.sty	2023-05-20 20:16:26 UTC (rev 67168)
@@ -31,7 +31,7 @@
 
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesPackage{bibcop}
-[2023-05-18 0.0.11 Style Checker of Bibliography Files]
+[2023-05-20 0.0.12 Style Checker of Bibliography Files]
 
 
 



More information about the tex-live-commits mailing list.