texlive[52631] trunk: chklref (3nov19)

commits+karl at tug.org commits+karl at tug.org
Sun Nov 3 23:55:12 CET 2019


Revision: 52631
          http://tug.org/svn/texlive?view=revision&revision=52631
Author:   karl
Date:     2019-11-03 23:55:12 +0100 (Sun, 03 Nov 2019)
Log Message:
-----------
chklref (3nov19)

Modified Paths:
--------------
    trunk/Build/source/texk/texlive/linked_scripts/Makefile.am
    trunk/Build/source/texk/texlive/linked_scripts/Makefile.in
    trunk/Build/source/texk/texlive/linked_scripts/scripts.lst
    trunk/Master/tlpkg/bin/tlpkg-ctan-check
    trunk/Master/tlpkg/libexec/ctan2tds
    trunk/Master/tlpkg/tlpsrc/collection-binextra.tlpsrc

Added Paths:
-----------
    trunk/Build/source/texk/texlive/linked_scripts/chklref/
    trunk/Build/source/texk/texlive/linked_scripts/chklref/chklref.pl
    trunk/Master/bin/aarch64-linux/chklref
    trunk/Master/bin/amd64-freebsd/chklref
    trunk/Master/bin/amd64-netbsd/chklref
    trunk/Master/bin/armhf-linux/chklref
    trunk/Master/bin/i386-cygwin/chklref
    trunk/Master/bin/i386-freebsd/chklref
    trunk/Master/bin/i386-linux/chklref
    trunk/Master/bin/i386-netbsd/chklref
    trunk/Master/bin/i386-solaris/chklref
    trunk/Master/bin/win32/chklref.exe
    trunk/Master/bin/x86_64-cygwin/chklref
    trunk/Master/bin/x86_64-darwin/chklref
    trunk/Master/bin/x86_64-darwinlegacy/chklref
    trunk/Master/bin/x86_64-linux/chklref
    trunk/Master/bin/x86_64-linuxmusl/chklref
    trunk/Master/bin/x86_64-solaris/chklref
    trunk/Master/texmf-dist/doc/support/chklref/
    trunk/Master/texmf-dist/doc/support/chklref/Makefile.doc
    trunk/Master/texmf-dist/doc/support/chklref/README.md
    trunk/Master/texmf-dist/doc/support/chklref/VERSION
    trunk/Master/texmf-dist/doc/support/chklref/chklref.pdf
    trunk/Master/texmf-dist/doc/support/chklref/chklref.tex
    trunk/Master/texmf-dist/doc/support/chklref/release.sh
    trunk/Master/texmf-dist/scripts/chklref/
    trunk/Master/texmf-dist/scripts/chklref/chklref.pl
    trunk/Master/texmf-dist/tex/latex/chklref/
    trunk/Master/texmf-dist/tex/latex/chklref/chklref.sty
    trunk/Master/tlpkg/tlpsrc/chklref.tlpsrc

Modified: trunk/Build/source/texk/texlive/linked_scripts/Makefile.am
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/Makefile.am	2019-11-03 22:46:06 UTC (rev 52630)
+++ trunk/Build/source/texk/texlive/linked_scripts/Makefile.am	2019-11-03 22:55:12 UTC (rev 52631)
@@ -101,6 +101,7 @@
 	bundledoc/bundledoc \
 	cachepic/cachepic.tlu \
 	checkcites/checkcites.lua \
+	chklref/chklref.pl \
 	cjk-gs-integrate/cjk-gs-integrate.pl \
 	clojure-pamphlet/pamphletangler \
 	cluttex/cluttex.lua \

Modified: trunk/Build/source/texk/texlive/linked_scripts/Makefile.in
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/Makefile.in	2019-11-03 22:46:06 UTC (rev 52630)
+++ trunk/Build/source/texk/texlive/linked_scripts/Makefile.in	2019-11-03 22:55:12 UTC (rev 52631)
@@ -314,6 +314,7 @@
 	bundledoc/bundledoc \
 	cachepic/cachepic.tlu \
 	checkcites/checkcites.lua \
+	chklref/chklref.pl \
 	cjk-gs-integrate/cjk-gs-integrate.pl \
 	clojure-pamphlet/pamphletangler \
 	cluttex/cluttex.lua \

Added: trunk/Build/source/texk/texlive/linked_scripts/chklref/chklref.pl
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/chklref/chklref.pl	                        (rev 0)
+++ trunk/Build/source/texk/texlive/linked_scripts/chklref/chklref.pl	2019-11-03 22:55:12 UTC (rev 52631)
@@ -0,0 +1,334 @@
+#!/usr/bin/env perl -w
+
+#########################################################################
+# Written and (C) by Jérôme Lelong <jerome.lelong at gmail.com>            #
+#                                                                       #
+# This program is free software; you can redistribute it and/or modify  #
+# it under the terms of the GNU General Public License as published by  #
+# the Free Software Foundation; either version 3 of the License, or     #
+# (at your option) any later version.                                   #
+#                                                                       #
+# This program is distributed in the hope that it will be useful,       #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of        #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         #
+# GNU General Public License for more details.                          #
+#                                                                       #
+# You should have received a copy of the GNU General Public License     #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>. #
+#########################################################################
+
+use strict;
+use warnings;
+use File::Basename;
+use Cwd;
+use Getopt::Long;
+# recognised math environments
+my @have_star_modes = qw( equation eqnarray align multline table gather);
+my $have_star_mode = join('|', @have_star_modes);
+$have_star_mode = "($have_star_mode)";
+
+
+my $TEX = 'pdflatex';
+my $TEXOPTIONS = ' -interaction nonstopmode ';
+my $USERTEXOPTIONS = '';
+my $RUNQUIET = 0;
+my $RUNDEBUG = 0;
+my $PARSEONLY = 0;
+my $PRINTVERSION = 0;
+my $HELP = 0;
+my $VERSION = 'Version 3.0.1';
+
+# Create a hash with three keys "str", "line", "file" and returns a
+# reference to it
+#
+# Input: 3 args
+#   a string
+#   a line number
+#   a filename
+sub new_ref {
+    my ($str, $line, $file) = @_;
+    my $ref = {};
+    $ref->{str}  = $str;
+    $ref->{line} = $line;
+    $ref->{file} = $file;
+    return $ref;
+}
+
+# Create a hash with six keys "str", "begin", "end", "star",
+# "label_line" and "label" and returns a reference to it.
+#
+# Input : 7 args
+#    a string (the env name)
+#    line of beginning
+#    line of end
+#    has the env a star?
+#    line on which the label appears
+#    value of the label
+#    file name
+sub new_math_env {
+    my ($str, $begin, $end, $star, $label_line, $label, $file) = @_;
+    my $this = {};
+    $this->{str}        = $str;
+    $this->{begin}      = $begin;
+    $this->{end}        = $end;
+    $this->{star}       = $star;
+    $this->{label_line} = $label_line;
+    $this->{label}      = $label;
+    $this->{file}       = $file;
+    return $this;
+}
+
+
+# Parse .chk file and looks for the environments defined by
+# @have_star_modes. The first and last line of the environment are stored
+# along with the name of the environment. One last variable is
+# used to remember if the star version was used.
+#
+# Input:
+#   a chk file content
+#   entries
+#   refs
+#   labels
+# the last 3 args are passed as references and are modified
+sub chk_parse {
+    my ($txt, $entries, $refs, $labels, $citations, $bibcites) = @_;
+    my ($str, $begin, $end, $star, $labelled_env, $label, $file, $entry, $l);
+
+    while (defined($l = shift(@$txt))) {
+        if ($l =~ m/^label (.+) line (\d+) file (.+)\n$/o) {
+            push(@$labels, new_ref($1, $2, $3));
+        }
+        elsif ($l =~ m/^ref (.+) line (\d+) file (.+)$/o) {
+            push(@$refs, new_ref($1, $2, $3));
+        }
+        elsif ($l =~ m/^citation (.+) line (\d+) file (.+)$/o) {
+            foreach my $c (split(/\s*,\s*/, $1)) {
+                ${$citations}{$c} = 1;
+            }
+        }
+        elsif ($l =~ m/^bibcite (.+) line (\d+) file (.+)$/o) {
+            push(@$bibcites, $1);
+        }
+        elsif ($l =~ m/^begin\{$have_star_mode(\**)\} line (\d+) file (.+)$/o) {
+            $str          = $1;
+            $star         = 1;
+            $star         = 0 unless ($2);
+            $begin        = $3;
+            $file         = $4;
+            $label        = "";
+            $labelled_env = 0;
+            while (defined($l = shift(@$txt))) {
+                if ($l =~ m/^label (.+) line (\d+) file (.+)$/o) {
+                    push(@$labels, new_ref($1, $2, $3));
+                    $label       = $1;
+                    $labelled_env = $2;
+                }
+                elsif ($l =~ m/^ref (.+) line (\d+) file (.+)$/o) {
+                    push(@$refs, new_ref($1, $2, $3));
+                }
+                elsif ($l =~ m/^end\{$str\*{$star}\} line (\d+) file (.+)$/) {
+                    $end = $1;
+                    $entry =  new_math_env($str, $begin, $end, $star, $labelled_env,
+                        $label, $file);
+                    push(@$entries, $entry);
+                    last;
+                }
+            }
+        }
+    }
+    return;
+}
+
+# Find environments with both labels and stars
+# Input : list of entries
+sub star_label {
+    my ($entries) = @_;
+    print "************************************\n";
+    print "** Labels in starred environments **\n";
+    print "************************************\n";
+    foreach my $e (@$entries) {
+        printf("-- %-20s line %4d: remove label %s \n",
+            $e->{file}, $e->{label_line}, $e->{label})
+        if (($e->{star} == 1) && ($e->{label_line} > 0));
+
+        printf("-- %-20s line %4d: consider using a STAR environment\n",
+            $e->{file}, $e->{begin})
+        if (($e->{star} == 0) && ($e->{label_line} == 0));
+    }
+    print "\n";
+    return;
+}
+
+# Find labels without any corrsponding references.
+# references must be sorted
+sub unused_label {
+    my ($labels, $refs) = @_;
+    my $found;
+
+    print "*******************\n";
+    print "** Unused Labels **\n";
+    print "*******************\n";
+    foreach my $l (@$labels) {
+        $found = 0;
+        foreach my $r (@$refs) {
+            if ($r->{str} eq $l->{str}) {
+                $found = 1;
+                last;
+            }
+            elsif ($r->{str} ge $l->{str}) {
+                last;
+            }
+        }
+        printf("-- %-20s line %4d: remove label %s\n",
+            $l->{file}, $l->{line}, $l->{str})
+        if (!$found);
+    }
+    print "\n";
+    return;
+}
+
+# Find bibitems without any corresponding \cite
+sub unused_cites {
+    my ($bibcites, $citations) = @_;
+    print "**********************************\n";
+    print "** Uncited Bibliography entries **\n";
+    print "**********************************\n";
+    foreach my $c (@$bibcites) {
+        print("remove bibitem : $c\n") unless exists ${$citations}{$c};
+    }
+    return;
+}
+
+# Find and remove duplicates in an
+# array of { str, line } entries.
+# Note that the array must be sorted according to str
+# Input : ref or label list
+# Return the corresponding list
+sub rm_duplicate {
+    my ($array) = @_;
+    my $prev = '___________not_a_true_label______';
+    my @uniq_array =
+    grep { $_->{str} ne $prev && (($prev) = $_->{str}) } @$array;
+    return \@uniq_array;
+}
+
+# Display all math envs with their characteristics
+# Input args
+#  line of beginning
+#  line of end
+#  starred or not
+#  label
+sub disp_msg {
+    my ($entries) = @_;
+    my @entries = @$entries;
+
+    foreach my $e (@entries) {
+        print("env $e->{str} \n");
+        print("\tbeginning : $e->{begin}\n\tend : $e->{end}\n");
+        print("\tstar environment\n") if ($e->{star} == 1);
+        print("\tlabelled environement\n") if ($e->{label} > 0);
+        print("\n");
+    }
+    return;
+}
+
+sub parse {
+    my ($chkfile) = @_;
+    my @entries = ();
+    my @refs    = ();
+    my @labels  = ();
+    my %citations = ();
+    my @bibcites  = ();
+    my $FIC;
+
+    # Read the whole file to an array because label and end commands
+    # generally need to be swapped.
+    open($FIC, '<', $chkfile) or die("open: $!");
+    my @txt = <$FIC>;
+    close($FIC);
+
+    chk_parse(\@txt, \@entries, \@refs, \@labels, \%citations, \@bibcites);
+
+    @labels = sort { $a->{line} cmp $b->{line} } @labels;
+    @refs   = sort { $a->{str} cmp $b->{str} } @refs;
+    my $uniq_refs = rm_duplicate(\@refs);
+    star_label(\@entries);
+    #disp_msg( \@entries );
+    unused_label(\@labels, $uniq_refs);
+    unused_cites(\@bibcites, \%citations);
+}
+
+sub usage {
+print << 'EOT';
+chklref -- Check unused labels and bibitems
+
+Copyright (C) 2005-2019 Jérôme Lelong <jerome.lelong at gmail.com>
+This program comes with ABSOLUTELY NO WARRANTY;
+This is free software, and you are welcome to redistribute it under certain conditions;
+
+Usage:
+    chklref [options] texfile
+
+Options:
+    --tex <compiler>, -t    : Specify the TeX compiler to be used. Default = pdflatex.
+    --tex-options           : List of options to pass to the TeX compiler.
+    --debug, -d             : Run in debug mode. Do not clean the generated `.chk` file.
+    --quiet, -q             : Run in quiet mode. Do not print the output of the TeX compiler.
+    --parse-only            : Do not run the LaTeX compiler but use the already existing `.chk` file. When this option is passed, the following other options are meaningless: `--tex`, `--tex-options`, `--quiet`, `--debug`.
+    --version, -v           : Print the version of this scirpt.
+    --help,h                : Print this help.
+EOT
+}
+
+sub texcompile {
+    my ($texfile, $basetexfile) = @_;
+    print "Running $TEX $TEXOPTIONS $USERTEXOPTIONS \"$texfile\" to collect labels references and environment declarations\n\n";
+    my $texoutput = `$TEX $TEXOPTIONS $USERTEXOPTIONS "$texfile" 2>&1`;
+    print($texoutput) unless $RUNQUIET;
+    unlink($basetexfile . '.chk');
+    $texoutput = `$TEX $TEXOPTIONS $USERTEXOPTIONS --jobname "$basetexfile" '\\RequirePackage{chklref}\\input' "{$texfile}"  2>&1`;
+    print($texoutput) unless $RUNQUIET;
+}
+
+Getopt::Long::Configure ("bundling");
+GetOptions (
+   'version|v!' => \$PRINTVERSION,
+   'quiet|q!' => \$RUNQUIET,
+   'debug|d!' => \$RUNDEBUG,
+   'tex|t=s' => \$TEX,
+   'texoptions=s' => \$USERTEXOPTIONS,
+   'parse-only' => \$PARSEONLY,
+   'help|h' => \$HELP
+) || usage();
+
+if ($HELP) {
+    usage();
+    exit(0);
+}
+
+if ($PRINTVERSION) {
+    print "chklref $VERSION\n";
+    exit(0)
+}
+
+if (@ARGV != 1) {
+    usage();
+    exit 0;
+}
+
+my $texfile = $ARGV[0];
+my $cwd = getcwd();
+my $dirtexfile = dirname($texfile);
+my $basetexfile = basename($texfile, '.tex');
+my $chkfile = $basetexfile . '.chk';
+chdir($dirtexfile);
+if ($PARSEONLY) {
+    parse($chkfile);
+}
+else {
+    texcompile($texfile, $basetexfile);
+    parse($chkfile);
+    if (! $RUNDEBUG) {
+        unlink($chkfile);
+    }
+}
\ No newline at end of file


Property changes on: trunk/Build/source/texk/texlive/linked_scripts/chklref/chklref.pl
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Modified: trunk/Build/source/texk/texlive/linked_scripts/scripts.lst
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/scripts.lst	2019-11-03 22:46:06 UTC (rev 52630)
+++ trunk/Build/source/texk/texlive/linked_scripts/scripts.lst	2019-11-03 22:55:12 UTC (rev 52631)
@@ -44,6 +44,7 @@
 bundledoc/bundledoc
 cachepic/cachepic.tlu
 checkcites/checkcites.lua
+chklref/chklref.pl
 cjk-gs-integrate/cjk-gs-integrate.pl
 clojure-pamphlet/pamphletangler
 cluttex/cluttex.lua

Added: trunk/Master/bin/aarch64-linux/chklref
===================================================================
--- trunk/Master/bin/aarch64-linux/chklref	                        (rev 0)
+++ trunk/Master/bin/aarch64-linux/chklref	2019-11-03 22:55:12 UTC (rev 52631)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/chklref/chklref.pl
\ No newline at end of file


Property changes on: trunk/Master/bin/aarch64-linux/chklref
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/amd64-freebsd/chklref
===================================================================
--- trunk/Master/bin/amd64-freebsd/chklref	                        (rev 0)
+++ trunk/Master/bin/amd64-freebsd/chklref	2019-11-03 22:55:12 UTC (rev 52631)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/chklref/chklref.pl
\ No newline at end of file


Property changes on: trunk/Master/bin/amd64-freebsd/chklref
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/amd64-netbsd/chklref
===================================================================
--- trunk/Master/bin/amd64-netbsd/chklref	                        (rev 0)
+++ trunk/Master/bin/amd64-netbsd/chklref	2019-11-03 22:55:12 UTC (rev 52631)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/chklref/chklref.pl
\ No newline at end of file


Property changes on: trunk/Master/bin/amd64-netbsd/chklref
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/armhf-linux/chklref
===================================================================
--- trunk/Master/bin/armhf-linux/chklref	                        (rev 0)
+++ trunk/Master/bin/armhf-linux/chklref	2019-11-03 22:55:12 UTC (rev 52631)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/chklref/chklref.pl
\ No newline at end of file


Property changes on: trunk/Master/bin/armhf-linux/chklref
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/i386-cygwin/chklref
===================================================================
--- trunk/Master/bin/i386-cygwin/chklref	                        (rev 0)
+++ trunk/Master/bin/i386-cygwin/chklref	2019-11-03 22:55:12 UTC (rev 52631)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/chklref/chklref.pl
\ No newline at end of file


Property changes on: trunk/Master/bin/i386-cygwin/chklref
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/i386-freebsd/chklref
===================================================================
--- trunk/Master/bin/i386-freebsd/chklref	                        (rev 0)
+++ trunk/Master/bin/i386-freebsd/chklref	2019-11-03 22:55:12 UTC (rev 52631)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/chklref/chklref.pl
\ No newline at end of file


Property changes on: trunk/Master/bin/i386-freebsd/chklref
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/i386-linux/chklref
===================================================================
--- trunk/Master/bin/i386-linux/chklref	                        (rev 0)
+++ trunk/Master/bin/i386-linux/chklref	2019-11-03 22:55:12 UTC (rev 52631)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/chklref/chklref.pl
\ No newline at end of file


Property changes on: trunk/Master/bin/i386-linux/chklref
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/i386-netbsd/chklref
===================================================================
--- trunk/Master/bin/i386-netbsd/chklref	                        (rev 0)
+++ trunk/Master/bin/i386-netbsd/chklref	2019-11-03 22:55:12 UTC (rev 52631)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/chklref/chklref.pl
\ No newline at end of file


Property changes on: trunk/Master/bin/i386-netbsd/chklref
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/i386-solaris/chklref
===================================================================
--- trunk/Master/bin/i386-solaris/chklref	                        (rev 0)
+++ trunk/Master/bin/i386-solaris/chklref	2019-11-03 22:55:12 UTC (rev 52631)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/chklref/chklref.pl
\ No newline at end of file


Property changes on: trunk/Master/bin/i386-solaris/chklref
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/win32/chklref.exe
===================================================================
(Binary files differ)

Index: trunk/Master/bin/win32/chklref.exe
===================================================================
--- trunk/Master/bin/win32/chklref.exe	2019-11-03 22:46:06 UTC (rev 52630)
+++ trunk/Master/bin/win32/chklref.exe	2019-11-03 22:55:12 UTC (rev 52631)

Property changes on: trunk/Master/bin/win32/chklref.exe
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added: trunk/Master/bin/x86_64-cygwin/chklref
===================================================================
--- trunk/Master/bin/x86_64-cygwin/chklref	                        (rev 0)
+++ trunk/Master/bin/x86_64-cygwin/chklref	2019-11-03 22:55:12 UTC (rev 52631)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/chklref/chklref.pl
\ No newline at end of file


Property changes on: trunk/Master/bin/x86_64-cygwin/chklref
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/x86_64-darwin/chklref
===================================================================
--- trunk/Master/bin/x86_64-darwin/chklref	                        (rev 0)
+++ trunk/Master/bin/x86_64-darwin/chklref	2019-11-03 22:55:12 UTC (rev 52631)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/chklref/chklref.pl
\ No newline at end of file


Property changes on: trunk/Master/bin/x86_64-darwin/chklref
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/x86_64-darwinlegacy/chklref
===================================================================
--- trunk/Master/bin/x86_64-darwinlegacy/chklref	                        (rev 0)
+++ trunk/Master/bin/x86_64-darwinlegacy/chklref	2019-11-03 22:55:12 UTC (rev 52631)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/chklref/chklref.pl
\ No newline at end of file


Property changes on: trunk/Master/bin/x86_64-darwinlegacy/chklref
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/x86_64-linux/chklref
===================================================================
--- trunk/Master/bin/x86_64-linux/chklref	                        (rev 0)
+++ trunk/Master/bin/x86_64-linux/chklref	2019-11-03 22:55:12 UTC (rev 52631)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/chklref/chklref.pl
\ No newline at end of file


Property changes on: trunk/Master/bin/x86_64-linux/chklref
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/x86_64-linuxmusl/chklref
===================================================================
--- trunk/Master/bin/x86_64-linuxmusl/chklref	                        (rev 0)
+++ trunk/Master/bin/x86_64-linuxmusl/chklref	2019-11-03 22:55:12 UTC (rev 52631)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/chklref/chklref.pl
\ No newline at end of file


Property changes on: trunk/Master/bin/x86_64-linuxmusl/chklref
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/x86_64-solaris/chklref
===================================================================
--- trunk/Master/bin/x86_64-solaris/chklref	                        (rev 0)
+++ trunk/Master/bin/x86_64-solaris/chklref	2019-11-03 22:55:12 UTC (rev 52631)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/chklref/chklref.pl
\ No newline at end of file


Property changes on: trunk/Master/bin/x86_64-solaris/chklref
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/support/chklref/Makefile.doc
===================================================================
--- trunk/Master/texmf-dist/doc/support/chklref/Makefile.doc	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/support/chklref/Makefile.doc	2019-11-03 22:55:12 UTC (rev 52631)
@@ -0,0 +1,13 @@
+.PHONY: all clean cleanall 
+
+all: chklref.pdf clean
+
+chklref.pdf: chklref.tex
+	pdflatex chklref.tex
+	pdflatex chklref.tex
+
+clean:
+	rm -f chklref.log chklref.aux chklref.out chklref.fls chklref.fdb_latexmk chklref.synctex.gz
+
+cleanall: clean
+	rm -f chklref.pdf

Added: trunk/Master/texmf-dist/doc/support/chklref/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/support/chklref/README.md	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/support/chklref/README.md	2019-11-03 22:55:12 UTC (rev 52631)
@@ -0,0 +1,51 @@
+# Installation
+
+## System wide installation
+
+### Installation into the TeX structure
+
+This package follows the TDS[1]
+
+- put the TeX package `chklref.sty` into `$(texmf_prefix)/tex/latex/chklref`
+- put the manual `chklref.pdf` into `$(texmf_prefix)/doc/latex/chklref`
+- put the Perl parser `chklref.pl` into `$(texmf_prefix)/scripts/chklref`
+
+Note that you will also need to make a link or copy `chklref.pl` to a location in your `PATH`. On Unix systems, you may need to set the script as executable.
+
+Depending on your OS and TeX distribution, the `TEXMF` directory `texmf_prefix` can have different values
+
+- **Single account installation under Linux** `~/texmf`.
+- **Single account installation under Mac OS X** `~/texmf` or `$HOME/Library/texmf`.
+- **System wide installation under Linux** `/usr/share/texmf-local/`.
+- **System wide installation under Mac OS X** `/usr/local/texlive/texmf-local/`.
+- **Under Windows** something like `C:\localtexmf\`. Check in your distribution settings.
+
+**You may need to run `texhash` to update your TeX Directory Structure.**
+
+The fastest way to carry out the installation is to use the file `chklref.tds.zip` included in the numbered releases (not available inside the git repository). You just have to unzip it inside the proper `texmf_prefix`. Alternatively, you can copy the files by hand. On Unix systems, you may need to set the script as executable.
+
+#### Local installation
+
+Instead of carrying out a system wide installation, you can simply copy the package file `chklref.sty` next to your main LaTeX file and put the Perl script `chklref.pl` next to it or in anywhere in your `PATH`. On Unix systems, you may need to set the script as executable.
+
+## Requirements
+
+The `chklref` tool is mainly written in TeX with a small Perl script to parse the output generated by the TeX package. It should be working with any standard Perl installation.
+
+The Perl script calls a LaTeX compiler to extract labels related information.
+
+## Usage
+
+You typically just run: `perl chklref.pl file.tex`
+
+The full calling syntax is `perl chklref.pl [options] file.tex`, where `options` can be
+
+- `--tex <compiler>`, `-t`: Specify the TeX compiler to be used. Default is `pdflatex`.
+- `--tex-options`: List of options to pass to the TeX compiler. Note that we always add `-interaction nonstopmode` on top of these options.
+- `--debug`, `-d`: Run in debug mode. Do not clean the generated `.chk` file.
+- `--quiet`, `-q`: Run in quiet mode. Do not print the output of the TeX compiler.
+- `--parse-only`: Do not run the LaTeX compiler but use the already existing `.chk` file. When this option is passed, the following other options are meaningless: `--tex`, `--tex-options`, `--quiet`, `--debug`.
+- `--version`, `-v`: Print the version of this script.
+- `--help,h`: Print this help.
+
+[1] : TeX Directory Structure http://www.tug.org/twg/tds/


Property changes on: trunk/Master/texmf-dist/doc/support/chklref/README.md
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/support/chklref/VERSION
===================================================================
--- trunk/Master/texmf-dist/doc/support/chklref/VERSION	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/support/chklref/VERSION	2019-11-03 22:55:12 UTC (rev 52631)
@@ -0,0 +1 @@
+3.0.1

Added: trunk/Master/texmf-dist/doc/support/chklref/chklref.pdf
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/doc/support/chklref/chklref.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/support/chklref/chklref.pdf	2019-11-03 22:46:06 UTC (rev 52630)
+++ trunk/Master/texmf-dist/doc/support/chklref/chklref.pdf	2019-11-03 22:55:12 UTC (rev 52631)

Property changes on: trunk/Master/texmf-dist/doc/support/chklref/chklref.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/support/chklref/chklref.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/chklref/chklref.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/support/chklref/chklref.tex	2019-11-03 22:55:12 UTC (rev 52631)
@@ -0,0 +1,136 @@
+\documentclass[a4paper,11pt,twoside]{article}
+\usepackage{a4wide}
+\usepackage{latexsym,t1enc,lmodern,url}
+\usepackage{amssymb, amsmath,indentfirst}
+\usepackage[utf8]{inputenc}
+\usepackage[english]{babel}
+
+%%--------------------------------------------
+\hbadness=10000
+\emergencystretch=\hsize
+\tolerance=9999
+\textheight=9.0in
+%%--------------------------------------------
+
+\def\chk{{\it chklref}}
+
+\title{Check \LaTeX\ references: chklref \\
+Version \input{../VERSION}}
+\date{\today}
+\author{Jérôme Lelong}
+
+\begin{document}
+\maketitle
+
+\begin{abstract} Every \LaTeX\ user has once dreamt of cleaning its \TeX\ file of any useless labels right, for instance before submitting an article. The purpose of \chk\ is precisely to help to do this.
+\end{abstract}
+
+\section{What {\it chklref} can do for a \LaTeX\ user?}
+
+While writing a \LaTeX document, it is quite common to add labels that will reveal unused in the end, this is especially true for equations or any other mathematical environments. It would be quite convenient to wipe out those labels from the final version of the document. \chk\ has been designed to help \LaTeX\ users do so.
+
+
+\chk\ parses the \LaTeX\ file to detect labels that do not have any matching reference. At the end of the program, a summary is printed with the list of labels to be removed. Obviously, this search is performed in the whole document and not only within mathematical environments. Nonetheless, there is something specifically dedicated to environments that have a star version: it looks for the non star environments not containing any label.
+
+For instance, consider you a have a \LaTeX\ file with the following piece of code
+\begin{verbatim}
+\begin{equation}
+  x^2 + x + 1 = 0
+\end{equation}
+\end{verbatim}
+\chk\ will advise you to consider using \verb!equation*! instead of \verb!equation! in order to remove the unneeded number appearing next to the equation.
+
+Star environments with labels are also tracked because with most \LaTeX\ distributions it does not even raise a warning. However if you ever refer to this label, the printed number will most likely be nonsense.
+
+The summary printed at the end of the program contains two sections (see Figure~\ref{fig:output}): the first one is about labels in star environments and the second one is about unneeded labels. Each of these output lines begins with a line number referring to the parsed \LaTeX\ file. Then, the action to take is printed: ``remove label'' or ``use a starred environment''. In the case of a ``remove label'' message, the label to be removed is also printed to avoid any possible confusion.
+
+\begin{figure}[!ht]
+  \centering
+\begin{verbatim}
+************************************
+** Labels in starred environments **
+************************************
+line  264 : remove label eq:quantified
+line  200 : consider using a STAR environment
+
+*******************
+** Unused Labels **
+*******************
+line  313 : remove label eq:prog_dyn_prix
+\end{verbatim}
+  \caption{Program output}
+  \label{fig:output}
+\end{figure}
+
+Since version 2.5, bibliography entries have also been checked to detect if some entries are not explicitly cited in the text, see Figure~\ref{fig:output}. In this case, a ``remove bibitem'' message is printed.
+\begin{figure}[!ht]
+  \centering
+\begin{verbatim}
+**********************************
+** Non cited Bibliography entries **
+**********************************
+remove bibitem : premia
+\end{verbatim}
+  \caption{Bibliography analysis}
+  \label{fig:biblio}
+\end{figure}
+
+
+\section{Usage}
+
+There are two ways of using the package.
+
+\begin{enumerate}
+  \item Directly calling \verb!perl chklref.pl file.tex!.
+  \item Adding \verb!\usepackage{chklref}! to your main \LaTeX\ file and compiling it normally. This will create a file with extension \verb!.chk!, which can then be parsed by the Perl script:
+\begin{verbatim}
+  perl chklref.pl --parse-only file.tex
+\end{verbatim}
+  Note that you need to pass the \verb!.tex! file to the parser not the \verb!.chk! file.
+\end{enumerate}
+
+
+\section{Installation}
+
+\subsection{Installation into the \TeX\ structure}
+
+This package follows the TDS\footnote{TeX Directory Structure
+  \url{http://www.tug.org/twg/tds/}}:
+\begin{itemize}
+  \item  put the \TeX\ package \verb!chklref.sty! into \verb!$(texmf_prefix)/tex/latex/chklref!
+  \item  put the manual \verb!chklref.pdf! into \verb!$(texmf_prefix)/doc/latex/chklref!
+  \item  put the Perl parser \verb!chklref.pl! into \verb!$(texmf_prefix)/scripts/chklref!
+\end{itemize}
+Note that you will also need to make a link or copy \verb!chklref.pl! to a location in your \texttt{PATH}. On Unix systems, you may need to set the script executable. \\
+
+Depending on your OS and \TeX\ distribution, the TEXMF directory \verb!texmf_prefix! can have different values
+\begin{description}
+  \item[Single account installation under Linux] \verb!~/texmf!.
+  \item[Single account installation under Mac OS X] \verb!~/texmf! or \verb!$HOME/Library/texmf!.
+  \item[System wide installation under Linux] \verb!/usr/share/texmf-local/!.
+  \item[System wide installation under Mac OS X] \verb!/usr/local/texlive/texmf-local/!.
+  \item[Under Windows] something like \verb!C:\localtexmf\!. Check in your distribution settings.
+\end{description}
+
+\noindent \textbf{You may need to run \texttt{texhash} to update your \TeX\ Directory Structure.}
+
+The fastest way to carry out the installation is to use the file \verb!chklref.tds.zip! included in the numbered releases (not available inside the git repository). You just have to unzip it inside the proper \verb!texmf_prefix!. Alternatively, you can copy the files by hand. On Unix systems, you may need to set the script as executable.
+
+\subsection{Local installation}
+
+Instead of carrying out a system wide installation, you can simply copy the package file \verb!chklref.sty! next to your main \LaTeX\ file and put the Perl script \verb!chklref.pl! next to it or in anywhere in your \texttt{PATH}. On Unix systems, you may need to set the script as executable.
+
+
+\section{Requirements}
+
+The \chk\ tool is written mainly in \TeX\ with a small Perl script to parse the output generated by the \TeX\ package. It should be working with any standard Perl installation. \\
+
+The Perl script calls a LaTeX compiler to extract labels related information.
+
+\section{Source code}
+
+The source code is available from GitHub \url{https://github.com/jlelong/chklref}. \\
+
+It is distributed under the GPL licence version 3 or any later version in the hope it will be useful but without any warranty. Should you find a bug in chklref, create an issue at \url{https://github.com/jlelong/chklref/issues} and please provide minimal a \LaTeX\ file to reproduce the problem.
+
+\end{document}


Property changes on: trunk/Master/texmf-dist/doc/support/chklref/chklref.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/support/chklref/release.sh
===================================================================
--- trunk/Master/texmf-dist/doc/support/chklref/release.sh	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/support/chklref/release.sh	2019-11-03 22:55:12 UTC (rev 52631)
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+# This script creates a new releas of chklref
+CWD="$(pwd)/$0"
+CHKLREFGIT=$(dirname $"CWD")
+DATE=$(date +%Y%m%d)
+# Local temporary directory
+LOCAL_TMPDIR="$HOME/tmp/chklref-$DATE"
+CHKLREF_DIR="$LOCAL_TMPDIR/chklref"
+
+# Perform git archive
+git_archive() {
+    cwd=$(pwd)
+    [[ -d "$LOCAL_TMPDIR" ]] && rm -rf "$LOCAL_TMPDIR"
+    mkdir -p "$CHKLREF_DIR"
+    cd "$CHKLREFGIT"
+    git archive --format=tar master | tar -x -C "$CHKLREF_DIR"
+    cd "$cwd"
+}
+
+compile_doc() {
+    cwd=$(pwd)
+    cd "$CHKLREF_DIR/doc"
+    make
+    cd "$cwd"
+}
+
+create_tds() {
+    cwd=$(pwd)
+    mkdir -p "$CHKLREF_DIR/chklref.tds"
+    cd "$CHKLREF_DIR/chklref.tds"
+    mkdir -p tex/latex/chklref
+    mkdir -p doc/latex/chklref
+    mkdir -p scripts/chklref
+    cp ../chklref.sty tex/latex/chklref
+    cp ../doc/chklref.{tex,pdf} doc/latex/chklref
+    cp ../README.md doc/latex/chklref
+    cp ../chklref.pl scripts/chklref
+    cd ..
+    zip -r chklref.tds.zip chklref.tds
+    rm -rf chklref.tds
+    cd "$cwd"
+}
+
+git_archive
+compile_doc
+create_tds
+zip -r "$CHKLREF_DIR.zip" "$CHKLREF_DIR"
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/doc/support/chklref/release.sh
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/texmf-dist/scripts/chklref/chklref.pl
===================================================================
--- trunk/Master/texmf-dist/scripts/chklref/chklref.pl	                        (rev 0)
+++ trunk/Master/texmf-dist/scripts/chklref/chklref.pl	2019-11-03 22:55:12 UTC (rev 52631)
@@ -0,0 +1,334 @@
+#!/usr/bin/env perl -w
+
+#########################################################################
+# Written and (C) by Jérôme Lelong <jerome.lelong at gmail.com>            #
+#                                                                       #
+# This program is free software; you can redistribute it and/or modify  #
+# it under the terms of the GNU General Public License as published by  #
+# the Free Software Foundation; either version 3 of the License, or     #
+# (at your option) any later version.                                   #
+#                                                                       #
+# This program is distributed in the hope that it will be useful,       #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of        #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         #
+# GNU General Public License for more details.                          #
+#                                                                       #
+# You should have received a copy of the GNU General Public License     #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>. #
+#########################################################################
+
+use strict;
+use warnings;
+use File::Basename;
+use Cwd;
+use Getopt::Long;
+# recognised math environments
+my @have_star_modes = qw( equation eqnarray align multline table gather);
+my $have_star_mode = join('|', @have_star_modes);
+$have_star_mode = "($have_star_mode)";
+
+
+my $TEX = 'pdflatex';
+my $TEXOPTIONS = ' -interaction nonstopmode ';
+my $USERTEXOPTIONS = '';
+my $RUNQUIET = 0;
+my $RUNDEBUG = 0;
+my $PARSEONLY = 0;
+my $PRINTVERSION = 0;
+my $HELP = 0;
+my $VERSION = 'Version 3.0.1';
+
+# Create a hash with three keys "str", "line", "file" and returns a
+# reference to it
+#
+# Input: 3 args
+#   a string
+#   a line number
+#   a filename
+sub new_ref {
+    my ($str, $line, $file) = @_;
+    my $ref = {};
+    $ref->{str}  = $str;
+    $ref->{line} = $line;
+    $ref->{file} = $file;
+    return $ref;
+}
+
+# Create a hash with six keys "str", "begin", "end", "star",
+# "label_line" and "label" and returns a reference to it.
+#
+# Input : 7 args
+#    a string (the env name)
+#    line of beginning
+#    line of end
+#    has the env a star?
+#    line on which the label appears
+#    value of the label
+#    file name
+sub new_math_env {
+    my ($str, $begin, $end, $star, $label_line, $label, $file) = @_;
+    my $this = {};
+    $this->{str}        = $str;
+    $this->{begin}      = $begin;
+    $this->{end}        = $end;
+    $this->{star}       = $star;
+    $this->{label_line} = $label_line;
+    $this->{label}      = $label;
+    $this->{file}       = $file;
+    return $this;
+}
+
+
+# Parse .chk file and looks for the environments defined by
+# @have_star_modes. The first and last line of the environment are stored
+# along with the name of the environment. One last variable is
+# used to remember if the star version was used.
+#
+# Input:
+#   a chk file content
+#   entries
+#   refs
+#   labels
+# the last 3 args are passed as references and are modified
+sub chk_parse {
+    my ($txt, $entries, $refs, $labels, $citations, $bibcites) = @_;
+    my ($str, $begin, $end, $star, $labelled_env, $label, $file, $entry, $l);
+
+    while (defined($l = shift(@$txt))) {
+        if ($l =~ m/^label (.+) line (\d+) file (.+)\n$/o) {
+            push(@$labels, new_ref($1, $2, $3));
+        }
+        elsif ($l =~ m/^ref (.+) line (\d+) file (.+)$/o) {
+            push(@$refs, new_ref($1, $2, $3));
+        }
+        elsif ($l =~ m/^citation (.+) line (\d+) file (.+)$/o) {
+            foreach my $c (split(/\s*,\s*/, $1)) {
+                ${$citations}{$c} = 1;
+            }
+        }
+        elsif ($l =~ m/^bibcite (.+) line (\d+) file (.+)$/o) {
+            push(@$bibcites, $1);
+        }
+        elsif ($l =~ m/^begin\{$have_star_mode(\**)\} line (\d+) file (.+)$/o) {
+            $str          = $1;
+            $star         = 1;
+            $star         = 0 unless ($2);
+            $begin        = $3;
+            $file         = $4;
+            $label        = "";
+            $labelled_env = 0;
+            while (defined($l = shift(@$txt))) {
+                if ($l =~ m/^label (.+) line (\d+) file (.+)$/o) {
+                    push(@$labels, new_ref($1, $2, $3));
+                    $label       = $1;
+                    $labelled_env = $2;
+                }
+                elsif ($l =~ m/^ref (.+) line (\d+) file (.+)$/o) {
+                    push(@$refs, new_ref($1, $2, $3));
+                }
+                elsif ($l =~ m/^end\{$str\*{$star}\} line (\d+) file (.+)$/) {
+                    $end = $1;
+                    $entry =  new_math_env($str, $begin, $end, $star, $labelled_env,
+                        $label, $file);
+                    push(@$entries, $entry);
+                    last;
+                }
+            }
+        }
+    }
+    return;
+}
+
+# Find environments with both labels and stars
+# Input : list of entries
+sub star_label {
+    my ($entries) = @_;
+    print "************************************\n";
+    print "** Labels in starred environments **\n";
+    print "************************************\n";
+    foreach my $e (@$entries) {
+        printf("-- %-20s line %4d: remove label %s \n",
+            $e->{file}, $e->{label_line}, $e->{label})
+        if (($e->{star} == 1) && ($e->{label_line} > 0));
+
+        printf("-- %-20s line %4d: consider using a STAR environment\n",
+            $e->{file}, $e->{begin})
+        if (($e->{star} == 0) && ($e->{label_line} == 0));
+    }
+    print "\n";
+    return;
+}
+
+# Find labels without any corrsponding references.
+# references must be sorted
+sub unused_label {
+    my ($labels, $refs) = @_;
+    my $found;
+
+    print "*******************\n";
+    print "** Unused Labels **\n";
+    print "*******************\n";
+    foreach my $l (@$labels) {
+        $found = 0;
+        foreach my $r (@$refs) {
+            if ($r->{str} eq $l->{str}) {
+                $found = 1;
+                last;
+            }
+            elsif ($r->{str} ge $l->{str}) {
+                last;
+            }
+        }
+        printf("-- %-20s line %4d: remove label %s\n",
+            $l->{file}, $l->{line}, $l->{str})
+        if (!$found);
+    }
+    print "\n";
+    return;
+}
+
+# Find bibitems without any corresponding \cite
+sub unused_cites {
+    my ($bibcites, $citations) = @_;
+    print "**********************************\n";
+    print "** Uncited Bibliography entries **\n";
+    print "**********************************\n";
+    foreach my $c (@$bibcites) {
+        print("remove bibitem : $c\n") unless exists ${$citations}{$c};
+    }
+    return;
+}
+
+# Find and remove duplicates in an
+# array of { str, line } entries.
+# Note that the array must be sorted according to str
+# Input : ref or label list
+# Return the corresponding list
+sub rm_duplicate {
+    my ($array) = @_;
+    my $prev = '___________not_a_true_label______';
+    my @uniq_array =
+    grep { $_->{str} ne $prev && (($prev) = $_->{str}) } @$array;
+    return \@uniq_array;
+}
+
+# Display all math envs with their characteristics
+# Input args
+#  line of beginning
+#  line of end
+#  starred or not
+#  label
+sub disp_msg {
+    my ($entries) = @_;
+    my @entries = @$entries;
+
+    foreach my $e (@entries) {
+        print("env $e->{str} \n");
+        print("\tbeginning : $e->{begin}\n\tend : $e->{end}\n");
+        print("\tstar environment\n") if ($e->{star} == 1);
+        print("\tlabelled environement\n") if ($e->{label} > 0);
+        print("\n");
+    }
+    return;
+}
+
+sub parse {
+    my ($chkfile) = @_;
+    my @entries = ();
+    my @refs    = ();
+    my @labels  = ();
+    my %citations = ();
+    my @bibcites  = ();
+    my $FIC;
+
+    # Read the whole file to an array because label and end commands
+    # generally need to be swapped.
+    open($FIC, '<', $chkfile) or die("open: $!");
+    my @txt = <$FIC>;
+    close($FIC);
+
+    chk_parse(\@txt, \@entries, \@refs, \@labels, \%citations, \@bibcites);
+
+    @labels = sort { $a->{line} cmp $b->{line} } @labels;
+    @refs   = sort { $a->{str} cmp $b->{str} } @refs;
+    my $uniq_refs = rm_duplicate(\@refs);
+    star_label(\@entries);
+    #disp_msg( \@entries );
+    unused_label(\@labels, $uniq_refs);
+    unused_cites(\@bibcites, \%citations);
+}
+
+sub usage {
+print << 'EOT';
+chklref -- Check unused labels and bibitems
+
+Copyright (C) 2005-2019 Jérôme Lelong <jerome.lelong at gmail.com>
+This program comes with ABSOLUTELY NO WARRANTY;
+This is free software, and you are welcome to redistribute it under certain conditions;
+
+Usage:
+    chklref [options] texfile
+
+Options:
+    --tex <compiler>, -t    : Specify the TeX compiler to be used. Default = pdflatex.
+    --tex-options           : List of options to pass to the TeX compiler.
+    --debug, -d             : Run in debug mode. Do not clean the generated `.chk` file.
+    --quiet, -q             : Run in quiet mode. Do not print the output of the TeX compiler.
+    --parse-only            : Do not run the LaTeX compiler but use the already existing `.chk` file. When this option is passed, the following other options are meaningless: `--tex`, `--tex-options`, `--quiet`, `--debug`.
+    --version, -v           : Print the version of this scirpt.
+    --help,h                : Print this help.
+EOT
+}
+
+sub texcompile {
+    my ($texfile, $basetexfile) = @_;
+    print "Running $TEX $TEXOPTIONS $USERTEXOPTIONS \"$texfile\" to collect labels references and environment declarations\n\n";
+    my $texoutput = `$TEX $TEXOPTIONS $USERTEXOPTIONS "$texfile" 2>&1`;
+    print($texoutput) unless $RUNQUIET;
+    unlink($basetexfile . '.chk');
+    $texoutput = `$TEX $TEXOPTIONS $USERTEXOPTIONS --jobname "$basetexfile" '\\RequirePackage{chklref}\\input' "{$texfile}"  2>&1`;
+    print($texoutput) unless $RUNQUIET;
+}
+
+Getopt::Long::Configure ("bundling");
+GetOptions (
+   'version|v!' => \$PRINTVERSION,
+   'quiet|q!' => \$RUNQUIET,
+   'debug|d!' => \$RUNDEBUG,
+   'tex|t=s' => \$TEX,
+   'texoptions=s' => \$USERTEXOPTIONS,
+   'parse-only' => \$PARSEONLY,
+   'help|h' => \$HELP
+) || usage();
+
+if ($HELP) {
+    usage();
+    exit(0);
+}
+
+if ($PRINTVERSION) {
+    print "chklref $VERSION\n";
+    exit(0)
+}
+
+if (@ARGV != 1) {
+    usage();
+    exit 0;
+}
+
+my $texfile = $ARGV[0];
+my $cwd = getcwd();
+my $dirtexfile = dirname($texfile);
+my $basetexfile = basename($texfile, '.tex');
+my $chkfile = $basetexfile . '.chk';
+chdir($dirtexfile);
+if ($PARSEONLY) {
+    parse($chkfile);
+}
+else {
+    texcompile($texfile, $basetexfile);
+    parse($chkfile);
+    if (! $RUNDEBUG) {
+        unlink($chkfile);
+    }
+}
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/scripts/chklref/chklref.pl
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/chklref/chklref.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/chklref/chklref.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/chklref/chklref.sty	2019-11-03 22:55:12 UTC (rev 52631)
@@ -0,0 +1,137 @@
+%% -*-mode: tex-mode -*-
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Written and (C) by Jérôme Lelong <jerome.lelong at gmail.com>            %%
+%%                                                                       %%
+%% This program is free software; you can redistribute it and/or modify  %%
+%% it under the terms of the GNU General Public License as published by  %%
+%% the Free Software Foundation; either version 3 of the License, or     %%
+%% (at your option) any later version.                                   %%
+%%                                                                       %%
+%% This program is distributed in the hope that it will be useful,       %%
+%% but WITHOUT ANY WARRANTY; without even the implied warranty of        %%
+%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         %%
+%% GNU General Public License for more details.                          %%
+%%                                                                       %%
+%% You should have received a copy of the GNU General Public License     %%
+%% along with this program.  If not, see <http://www.gnu.org/licenses/>. %%
+%%                                                                       %%
+%% This file is part of the chklref package.                             %%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+\NeedsTeXFormat{LaTeX2e}%
+\ProvidesPackage{chklref}%
+\RequirePackage{afterpackage}%
+
+\gdef\CHK at stack{}
+
+\newwrite\CHK at write
+\immediate\openout\CHK at write\jobname.chk%
+\def\CHK at immediate@write{\immediate\write}
+\def\CHK at print#1{%
+  \protect\CHK at immediate@write\CHK at write{#1}%
+}
+
+% Make sure the auxiliary files are still suitable for usage without the
+% chklref package.
+\RequirePackage{auxhook}
+\AddLineBeginAux{\string\let\string\CHK at immediate@write\string\@gobbletwo}
+\let\@starttoc at orig\@starttoc
+\def\@starttoc#1{%
+  \@starttoc at orig{#1}%
+  \addtocontents{#1}{\string\let\string\CHK at immediate@write\string\@gobbletwo}
+}
+
+% Track the name of the file currently processed.
+% This is successfuly done by currfile for
+% \include{toto}, \input{toto} but NOT \input toto
+% So we need an extra trick, but do it as late as possible.
+\RequirePackage{currfile}
+\def\CHK at currentfile{\expandafter\expandafter\currfilename}
+\def\CHK@@input#1 {\input{#1}}
+\AtBeginDocument{%
+  \def\input{\@ifnextchar\bgroup\@iinput\CHK@@input}
+}
+
+\def\CHK at redefine#1#2{%
+  \expandafter\let\csname CHK@#1 at orig\expandafter\endcsname\csname#1\endcsname%
+  \expandafter\def\csname#1\endcsname##1{%
+    \CHK at print{#2{##1} line \the\inputlineno\space file \CHK at currentfile}%
+    \expandafter\expandafter\csname CHK@#1 at orig\endcsname{##1}}
+}
+
+\def\CHK at redefine@#1#2{%
+  \expandafter\let\csname CHK@#1 at orig\expandafter\endcsname\csname#1\endcsname%
+  \expandafter\def\csname#1\endcsname##1{%
+    \CHK at print{#2 ##1 line \the\inputlineno\space file \CHK at currentfile}%
+    \expandafter\expandafter\csname CHK@#1 at orig\endcsname{##1}}
+}
+
+\CHK at redefine{begin}{begin}
+\CHK at redefine{end}{end}
+
+\AfterPackage{hyperref}{
+  \AtBeginDocument{%
+    \let\CHK at label@orig=\label
+    \def\label#1{%
+      \CHK at print{label #1 line \the\inputlineno\space file \CHK at currentfile}%
+      \CHK at label@orig{#1}}
+
+    \Hy at SetCatcodes
+    \def\HyPsd at ref#1{\HyPsd@@ref#1*\END}%
+    \def\HyPsd@@ref#1*#2\END{%
+      \ifx\\#2\\%
+        \HyPsd@@@ref{#1}%
+      \else
+        \expandafter\HyPsd@@@ref
+      \fi
+    }%
+    \def\HyPsd@@@ref#1{%
+      \expandafter\ifx\csname r@#1\endcsname\relax
+        ??%
+      \else
+        \expandafter\expandafter\expandafter\@car\csname r@#1\endcsname\@nil
+      \fi
+      \CHK at print{ref #1 line \the\inputlineno\space file \CHK at currentfile}%
+    }
+    \let\ref=\HyPsd at ref
+    \Hy at RestoreCatcodes
+  }
+}
+
+\AtBeginDocument{%
+  \newif\ifCHK at hyperref
+  \newif\ifCHK at amsmath
+  \@ifpackageloaded{hyperref}{\CHK at hyperreftrue}{}
+  \@ifpackageloaded{amsmath}{\CHK at amsmathtrue}{}
+
+  \ifCHK at amsmath% %With AMS-LaTeX tags
+     %%\CHK at redefine{label at in@display}{label at in@display}
+     \let\CHK at label@in at display@orig=\label at in@display
+     \def\label at in@display#1{%
+       \CHK at print{label #1 line \the\inputlineno\space file \CHK at currentfile}
+       \CHK at label@in at display@orig{#1}}
+
+     \CHK at redefine@{eqref}{ref}
+     \CHK at redefine@{ref}{ref}
+     \CHK at redefine@{label}{label}
+     \CHK at redefine@{citation}{citation}
+     \CHK at redefine@{bibcite}{bibcite}
+
+  \else
+    \ifCHK at hyperref\else
+      \CHK at redefine@{label}{label}
+      \CHK at redefine@{ref}{ref}
+      \CHK at redefine@{citation}{citation}
+      \CHK at redefine@{bibcite}{bibcite}
+    \fi
+  \fi
+}
+
+\AtEndDocument{
+  \message{\CHK at stack}
+}
+% To prevent error with packages already defining the \AfterPackage macro.
+\let\AfterPackage=\relax
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/chklref/chklref.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/tlpkg/bin/tlpkg-ctan-check
===================================================================
--- trunk/Master/tlpkg/bin/tlpkg-ctan-check	2019-11-03 22:46:06 UTC (rev 52630)
+++ trunk/Master/tlpkg/bin/tlpkg-ctan-check	2019-11-03 22:55:12 UTC (rev 52631)
@@ -155,7 +155,7 @@
     chemnum chemschemex chemsec chemstyle cherokee
     chess chess-problem-diagrams chessboard chessfss chet chextras
     chicago chicagoa chicago-annote chickenize childdoc chivo
-    chkfloat chletter chngcntr chordbars chordbox chronology
+    chkfloat chklref chletter chngcntr chordbars chordbox chronology
     chronosys chs-physics-report chscite churchslavonic
     cinzel circ circledsteps circuit-macros circuitikz
     cite citeall citeref cje cjhebrew cjk cjk-gs-integrate cjk-ko cjkpunct

Modified: trunk/Master/tlpkg/libexec/ctan2tds
===================================================================
--- trunk/Master/tlpkg/libexec/ctan2tds	2019-11-03 22:46:06 UTC (rev 52630)
+++ trunk/Master/tlpkg/libexec/ctan2tds	2019-11-03 22:55:12 UTC (rev 52631)
@@ -243,6 +243,7 @@
  'chapterbib',  "die 'skipping, update cite instead'",
  'charter',	"die 'skipping, frozen'",
  'check-parens',"die 'skipping, C++'",
+ 'chklref',	"&MAKEflatten",
  'chemarrow',   "&MAKEflatten", # check about Arrow.vfb
  'chemstruct',  "die 'skipping, old latex 2.09, never in tl'",
  'chemsym',     "die 'skipping, nonfree'",
@@ -252,7 +253,6 @@
  'china2e',     "die 'skipping, nosell license and/or too complicated'",
  'chitex',      "die 'skipping, nonfree'",
  'chivo',	"&MAKEflatten",
- 'chklref',     "die 'skipping, needs configure, etc.'",
  'chktex',      "die 'skipping, merge into Build'",
  'chngpage',    "die 'skipping, use changepage'",
  'circle',      "die 'skipping, noinfo license, author unfindable'",
@@ -2488,6 +2488,7 @@
  'burmese',             '\.pl',
  'carlisle',            '\.dtx|\.ins|ltxtable\.tex',
  'chemarrow',           '\.mp|\.vfb',
+ 'chklref',		'NULL',			# leave Makefile
  'circuit-macros',	'NULL',			# leave Makefile
  'cluttex',             'NULL',			# leave Makefile
  'cmextra',             'NULL',
@@ -3059,6 +3060,7 @@
  'bundledoc'            => '(arlatex|bundledoc)$',
  'checkcites'           => '\.lua$',
  'checklistings'        => '\.sh$',
+ 'chklref'		=> '\.pl',
  'cjk-gs-integrate'     => '\.pl$',
  'clojure-pamphlet'	=> 'pamphletangler$',
  'cluttex'		=> 'cluttex\.lua$', # moved by prehook.
@@ -3237,6 +3239,7 @@
  'bbm-macros'   => $standardclean . '|^bbm$',           # symlink
  'bundledoc'    => $standardclean . '|\.pdf$',          # regen for a4
  'catoptions'   => $standardclean . '|Thumbs.db',       # bogus file
+ 'chklref'	=> $standardclean . '|\.tds\.zip',
  'cmbright'     => 'cmbright.pdf',
  'cprotect'     => $standardclean . '|\.cpt',           # temp files for doc
  'dateiliste'   => $standardclean . '|dateiliste.README*', # already in dist

Added: trunk/Master/tlpkg/tlpsrc/chklref.tlpsrc
===================================================================
--- trunk/Master/tlpkg/tlpsrc/chklref.tlpsrc	                        (rev 0)
+++ trunk/Master/tlpkg/tlpsrc/chklref.tlpsrc	2019-11-03 22:55:12 UTC (rev 52631)
@@ -0,0 +1 @@
+binpattern f bin/${ARCH}/${PKGNAME}

Modified: trunk/Master/tlpkg/tlpsrc/collection-binextra.tlpsrc
===================================================================
--- trunk/Master/tlpkg/tlpsrc/collection-binextra.tlpsrc	2019-11-03 22:46:06 UTC (rev 52630)
+++ trunk/Master/tlpkg/tlpsrc/collection-binextra.tlpsrc	2019-11-03 22:55:12 UTC (rev 52631)
@@ -14,6 +14,7 @@
 depend bibtexu
 depend bundledoc
 depend checklistings
+depend chklref
 depend chktex
 depend clojure-pamphlet
 depend cluttex



More information about the tex-live-commits mailing list