diff options
author | Andreas Scherer <andreas_tex@freenet.de> | 2023-10-29 13:15:04 +0000 |
---|---|---|
committer | Andreas Scherer <andreas_tex@freenet.de> | 2023-10-29 13:15:04 +0000 |
commit | f2f34147350143acc449967e7dde72c3d8b53ecb (patch) | |
tree | 56a6e8625d5c0a9ebbbb4f387d196b60e05c3155 /Build/source/texk/web2c/cwebdir | |
parent | 7f535c1370959619280791860da81b16d6f9b0c0 (diff) |
[CWEB] Make 'proofsort' like 'refsort'.
Read input from <STDIN> and write output to <STDOUT>.
git-svn-id: svn://tug.org/texlive/trunk@68690 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/cwebdir')
-rw-r--r-- | Build/source/texk/web2c/cwebdir/ChangeLog | 5 | ||||
-rwxr-xr-x | Build/source/texk/web2c/cwebdir/ctwill-proofsort | 32 | ||||
-rwxr-xr-x | Build/source/texk/web2c/cwebdir/ctwill.test | 2 |
3 files changed, 15 insertions, 24 deletions
diff --git a/Build/source/texk/web2c/cwebdir/ChangeLog b/Build/source/texk/web2c/cwebdir/ChangeLog index ceb6ed51ed9..be1de8cb1b1 100644 --- a/Build/source/texk/web2c/cwebdir/ChangeLog +++ b/Build/source/texk/web2c/cwebdir/ChangeLog @@ -1,3 +1,8 @@ +2023-10-29 Andreas Scherer <https://ascherer.github.io> + + * ctwill-proofsort, + * ctwill.test: Make 'proofsort' like 'refsort'. + 2023-10-25 Andreas Scherer <https://ascherer.github.io> * cwebmac.tex, diff --git a/Build/source/texk/web2c/cwebdir/ctwill-proofsort b/Build/source/texk/web2c/cwebdir/ctwill-proofsort index 71e71dd4b3a..9dc8d9d9cc7 100755 --- a/Build/source/texk/web2c/cwebdir/ctwill-proofsort +++ b/Build/source/texk/web2c/cwebdir/ctwill-proofsort @@ -22,17 +22,9 @@ BEGIN { }; } -# We expect a TeX file as the single command-line parameter. -my $usage = "Usage: $progname input_file\n"; -if (@ARGV > 1) { - my $first = shift @ARGV; - $usage .= "extra file argument(s): @ARGV\n"; - unshift @ARGV, $first; -} -$usage .= "try --help if you need it.\n"; - -die $usage unless scalar @ARGV == 1; +my $usage = "Usage: $progname < input_file > output_file\n"; +# Standard options for TeX Live. Getopt::Long::GetOptions( 'help|?' => \&help_handler, 'version' => sub { print version(); exit 0; } @@ -50,14 +42,7 @@ sub version { return $progname.' $Revision$ $Date$'."\n"; } -my $tex = $ARGV[0]; - -open(TEX, $tex) or die "$0: Could not open input file $tex.\n"; - -my %mini_index; # storage for index entries of a section -my $print_index = 0; # do we collect and print a mini-index? - -# Scroll through the input file and look for blocks like +# Read input from the console and look for blocks like # \mini # [LOCATION KEY TEXPART]* # }\FI @@ -68,7 +53,9 @@ my $print_index = 0; # do we collect and print a mini-index? # or as a single identifier in $math_mode$; the latter come from '@f'ormat # definitions. All internal backslashes are removed from the KEY before it # is used in the storage. -foreach my $line (<TEX>) +my %mini_index; # storage for index entries of a section +my $print_index = 0; # do we collect and print a mini-index? +foreach my $line (<STDIN>) { if ("\\mini\n" eq $line) { # start of mini-index $print_index = 1; @@ -92,8 +79,6 @@ foreach my $line (<TEX>) print $line; } -close(TEX); - exit 0; =pod @@ -109,12 +94,13 @@ ctwill-proofsort - Sort mini-indexes alphabetically This small Perl script 'ctwill-proofsort' sorts the mini-indexes for each section in the TeX file created by 'ctwill +P', i.e., prior to formatting with the 'ctproofmac.tex' macros. +It reads its input from <STDIN> and writes its output to <STDOUT>. =over =item Run CTWILL twice on your 'input_file'.w, creating 'input_file'.tex -=item Invoke "ctwill-proofsort 'input_file'.tex > 'input_file'-sorted.tex" +=item Invoke "ctwill-proofsort < 'input_file'.tex > 'input_file'-sorted.tex" =item Invoke "mv 'input_file'-sorted.tex 'input_file'.tex" @@ -135,7 +121,7 @@ Example from MMIX (https://github.com/ascherer/mmix, 'local' branch): =item $ ctwill +P -x mmotype mmotype-twill (run this two times) -=item $ ctwill-proofsort mmotype.tex > mmotype-sorted.tex +=item $ ctwill-proofsort < mmotype.tex > mmotype-sorted.tex =item $ mv mmotype-sorted.tex mmotype.tex diff --git a/Build/source/texk/web2c/cwebdir/ctwill.test b/Build/source/texk/web2c/cwebdir/ctwill.test index 26697ce121d..219f6eb54aa 100755 --- a/Build/source/texk/web2c/cwebdir/ctwill.test +++ b/Build/source/texk/web2c/cwebdir/ctwill.test @@ -36,7 +36,7 @@ $DIFF index.tex $testdir/index.tex || exit 6 # Perl script not available in builddir, and requires Unicode::Collate; # if that module is not available, just quit testing. perl -e 'use Unicode::Collate; Unicode::Collate->new();' 2>/dev/null || exit 0 -$testdir/../ctwill-proofsort ham.tex > ham-sorted.tex || exit 7 +$testdir/../ctwill-proofsort < ham.tex > ham-sorted.tex || exit 7 $DIFF ham-sorted.tex $testdir/ham-sorted.tex || exit 8 exit 0 |