texlive[68769] trunk: latexmk (7nov23)

commits+karl at tug.org commits+karl at tug.org
Thu Nov 9 23:13:57 CET 2023


Revision: 68769
          https://tug.org/svn/texlive?view=revision&revision=68769
Author:   karl
Date:     2023-11-09 23:13:57 +0100 (Thu, 09 Nov 2023)
Log Message:
-----------
latexmk (7nov23)

Modified Paths:
--------------
    trunk/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl
    trunk/Master/texmf-dist/doc/man/man1/latexmk.1
    trunk/Master/texmf-dist/doc/man/man1/latexmk.man1.pdf
    trunk/Master/texmf-dist/doc/support/latexmk/CHANGES
    trunk/Master/texmf-dist/doc/support/latexmk/INSTALL
    trunk/Master/texmf-dist/doc/support/latexmk/README
    trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/README-latexmk-rcfiles
    trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/pythontex-latexmkrc
    trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/xr_latexmkrc
    trunk/Master/texmf-dist/doc/support/latexmk/latexmk.pdf
    trunk/Master/texmf-dist/doc/support/latexmk/latexmk.txt
    trunk/Master/texmf-dist/scripts/latexmk/latexmk.pl

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/pdflatex_latexmkrc
    trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/schulz-texshop-latexmkrc

Removed Paths:
-------------
    trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/schultz-texshop-latexmkrc

Modified: trunk/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl	2023-11-09 22:13:34 UTC (rev 68768)
+++ trunk/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl	2023-11-09 22:13:57 UTC (rev 68769)
@@ -42,8 +42,8 @@
 
 $my_name = 'latexmk';
 $My_name = 'Latexmk';
-$version_num = '4.80';
-$version_details = "$My_name, John Collins, 4 Apr. 2023. Version $version_num";
+$version_num = '4.81';
+$version_details = "$My_name, John Collins, 6 Nov. 2023. Version $version_num";
 
 use Config;
 use File::Basename;
@@ -82,7 +82,7 @@
 use Digest::MD5;
 
 # **WARNING**: Don't import time; that overrides core function time(), and messes up
-#  
+#  somethings
 use Time::HiRes;
 
 #################################################
@@ -312,6 +312,7 @@
 # v. pdflatexmk, etc):
 (our $invoked_name) = fileparseA($0);
 
+# Save name, since I override it if I don't recognize it
 our $invoked_kind = $invoked_name;
 print "$My_name: Invoked as '$invoked_name'\n"
     if ($invoked_name ne 'latexmk');
@@ -360,6 +361,11 @@
 # It is the parameter max_print_line in the TeX program.  (tex.web)
 $log_wrap = 79;
 
+# Expected biggest construct in log file in bytes.
+# Use to limit number of (potentially) wrapped lines to combine into single line.
+$max_log_construct = 600;
+
+
 #########################################################################
 ## Default parsing and file-handling settings
 
@@ -372,8 +378,8 @@
 ##     push @file_not_found, '^No data file found `([^\\\']*)\\\'';
 ## will give match to line starting "No data file found `filename'"
 @file_not_found = (
-    '^No file\\s*(.*)\\.$',
-    '^No file\\s*(.+)\s*$',
+    '^No file\\s+(.*)\\.$',
+    '^No file\\s+(.+)\s*$',
     '^\\! LaTeX Error: File `([^\\\']*)\\\' not found\\.',
     '^\\! I can\\\'t find file `([^\\\']*)\\\'\\.',
     '.*?:\\d*: LaTeX Error: File `([^\\\']*)\\\' not found\\.',
@@ -559,7 +565,7 @@
 #       and because of the possibility of extra bibtex/biber rules with
 #       non-standard basename.
 @generated_exts = ( 'aux', 'bcf', 'fls', 'idx', 'ind', 'lof', 'lot', 
-                    'out', 'toc',
+                    'out', 'run.xml', 'toc',
                     'blg', 'ilg', 'log',
                     'xdv'
                   );
@@ -1459,7 +1465,7 @@
 
 
 # Data for 1 run and global (ending in '0'):
-our ( $processing_time1, $processing_time0, @timings1, @timings0);
+our ( $clock1, $processing_time1, $processing_time0, @timings1, @timings0);
 &init_timing_all;
 
 
@@ -1913,8 +1919,21 @@
 %rc_files_read2 = (); # Map **abs** filename to 1; used to check duplicate reads.
 
 # Options that are to be obeyed before rc files are read:
+# Also under MSWin32 and msys, CL arguments sometimes get quotes in them.
+# (Specific example: TeXLive 2023 with msys's perl and arguments containing
+# both non-ASCII character, when latexmk.exe invoked from cmd.exe. In some
+# other situations (powershell and msys's terminal+bash), it seems that both
+# space and non-ASCII character are needed to trigger a problem.)
 foreach $_ ( @ARGV )
 {
+    if ( ($^O eq "MSWin32") || ($^O eq 'msys') ) {
+        # "arg" -> arg.
+        # -..="arg" -> -..=arg.
+        # In both cases, only do this if there are no other ".  Otherwise I
+        # my run afoul of " that are intended to be there. 
+        s/^\"([^\"]+)\"$/$1/;
+        s/^(-[^\"=]+=)\"([^\"]+)\"$/$1$2/;
+    }
     if (/^-{1,2}norc$/ ) {
         $auto_rc_use = 0;
     }
@@ -2020,8 +2039,18 @@
   elsif (/^-diagnostics/) { $diagnostics = 1; }
   elsif (/^-dir-report$/)    { $aux_out_dir_report = 1; }
   elsif (/^-dir-report-$/)   { $aux_out_dir_report = 0; }
-  elsif (/^-dvi$/)    { $dvi_mode = 1; }
-  elsif (/^-dvilua$/) { $dvi_mode = 2; }
+  elsif (/^-dvi$/)    { $dvi_mode = 1;
+                        if ( ($pdf_mode != 2) && ($pdf_mode != 3) ) {
+                            # if pdf_mode is not via dvi or pdf, turn it off
+                            $pdf_mode = 0;
+                        }
+                      }
+  elsif (/^-dvilua$/) { $dvi_mode = 2;
+                        if ( ($pdf_mode != 2) && ($pdf_mode != 3) ) {
+                            # if pdf_mode is not via dvi or pdf, turn it off
+                            $pdf_mode = 0;
+                        }
+                      }
   elsif (/^-dvi-$/)   { $dvi_mode = 0; }
   elsif ( /^-dvilualatex=(.*)$/ ) {
       $dvilualatex = $1;
@@ -2101,7 +2130,10 @@
       my $format = $1;
       if ($format eq 'dvi' ) {
           $dvi_mode = 1;
-          $pdf_mode = $postscript_mode = 0;
+          if ( ($pdf_mode != 2) && ($pdf_mode != 3) ) {
+              # if pdf_mode is not via dvi or pdf, turn it off
+              $pdf_mode = 0;
+          }
       }
       elsif ($format eq 'pdf' ) {
           $pdf_mode = 1;
@@ -2117,12 +2149,12 @@
                        $preview_mode = 0;  
                      }
   elsif (/^-p-$/)    { $printout_mode = 0; }
-  elsif (/^-pdf$/)   { $pdf_mode = 1; }
+  elsif (/^-pdf$/)   { $pdf_mode = 1; $dvi_mode = $postscript_mode = 0; }
   elsif (/^-pdf-$/)  { $pdf_mode = 0; }
   elsif (/^-pdfdvi$/){ $pdf_mode = 3; }
-  elsif (/^-pdflua$/){ $pdf_mode = 4; }
+  elsif (/^-pdflua$/){ $pdf_mode = 4; $dvi_mode = $postscript_mode = 0; }
   elsif (/^-pdfps$/) { $pdf_mode = 2; }
-  elsif (/^-pdfxe$/) { $pdf_mode = 5; }
+  elsif (/^-pdfxe$/) { $pdf_mode = 5; $dvi_mode = $postscript_mode = 0; }
   elsif (/^-pdflatex$/) {
       $pdflatex = "pdflatex %O %S";
       $pdf_mode = 1;
@@ -2150,7 +2182,12 @@
           &exit_help("$My_name: unknown print type '$value' in option '$_'");
       }
   }
-  elsif (/^-ps$/)    { $postscript_mode = 1; }
+  elsif (/^-ps$/)    { $postscript_mode = 1;
+                       if ( ($pdf_mode != 2) && ($pdf_mode != 3) ) {
+                           # if pdf_mode is not via dvi or pdf, turn it off
+                           $pdf_mode = 0;
+                       }
+                      }
   elsif (/^-ps-$/)   { $postscript_mode = 0; }
   elsif (/^-pv$/)    { $preview_mode = 1; 
                        $preview_continuous_mode = 0; # to avoid conflicts
@@ -2391,7 +2428,10 @@
         push( @file_list, $file)  unless ( exists $excl{$file} );
     }    
     if ( !@file_list ) {
-        &exit_help( "No file name specified, and I couldn't find any");
+        &exit_help(
+           "No file name(s) specified on command line, and no files match the\n".
+           "patterns in the default list."
+        );
     }
 }
 
@@ -2715,10 +2755,17 @@
     $failure_msg = '';   # Indicate reason for failure
 
     if ( $do_cd ) {
-       ($filename, $path) = fileparse( $filename );
-       print "$My_name: Changing directory to '$path'\n"
-           if !$silent;
-       pushd( dirname_no_tail( $path ) );
+        # Use my fileparse routine rather than the built-in one, otherwise
+        # under msys, a directory separator \ won't be recognized by fileparse.
+        # My routines fix that.  At this point, $filename ought to have had its
+        # \s changed to /s.  But I won't leave boobytrapped code.
+        # I use fileparseB rather than fileparseA, because fileparseA changes
+        # path './' to '', but fileparseB keeps the fileparse behavior there.
+        # I have to supply an explicit pattern of '' to keep extension in $filename.
+        ($filename, $path) = fileparseB( $filename, '' );
+        print "$My_name: Changing directory to '$path'\n"
+            if !$silent;
+        pushd( dirname_no_tail( $path ) );
     }
     else {
         $path = '';
@@ -2853,7 +2900,7 @@
     &init_timing1;
 
     if ($compiling_cmd) { Run_subst( $compiling_cmd ); }
-    $failure = &rdb_make;
+    $failure = rdb_make();
     if ( ( $failure <= 0 ) || $force_mode ) {
       rdb_for_some( [keys %one_time], \&rdb_run1 );
     }
@@ -2896,7 +2943,7 @@
         push @failed_primaries, $filename;
     }
     &ifcd_popd;
-    if ($show_time) { &show_timing1; };
+    if ($show_time && ! $preview_continuous_mode) { &show_timing1; };
     print "\n";
 }
 close($deps_handle) if ( $deps_handle );
@@ -2981,6 +3028,7 @@
     # Initialize timing for one run.
     @timings1 = ();
     $processing_time1 = processing_time();    
+    $clock1 = Time::HiRes::time();
 }
 
 ############################
@@ -2997,8 +3045,17 @@
 sub show_timing1 {
     # Show timing for one run.
     my $processing_time = processing_time() - $processing_time1;
+    my $invoked_time = 0;
+    for (@timings1) {
+        if (/: time = (.*)\s$/) {
+            $invoked_time += $1;
+    }}
     print @timings1, "Processing time = ",
-          sprintf('%.2f', $processing_time), "\n";
+        sprintf('%.2f', $processing_time),
+        ", of which invoked processes = $invoked_time, other = ",
+        sprintf( '%.2f', $processing_time-$invoked_time ), ".\n";
+    print "Elapsed clock time = ",
+          sprintf( '%.2f', Time::HiRes::time()-$clock1 ), ".\n";
     print "Number of rules run = ", 1+$#timings1, "\n";
 }
 
@@ -4194,7 +4251,7 @@
         if ($compiling_cmd) {
             Run_subst( $compiling_cmd );
         }
-        $failure = &rdb_make;
+        $failure = rdb_make();
 
         if ( $MSWin_fudge_break && ($^O eq "MSWin32") ) {
             $SIG{BREAK} = $SIG{INT} = 'DEFAULT';
@@ -4381,7 +4438,16 @@
     my ($rc_file, $repeat_reaction) = @_;
     my $abs_rc = abs_path($rc_file);
     my $ret_code = 0;
-    if ( exists $rc_files_read2{$abs_rc} ) {
+    if ( (!-e $rc_file) || ( ! defined $abs_rc ) ) {
+        warn "$My_name: The rc-file '$rc_file' does not exist\n";
+        return 1;
+    }
+    elsif ( -d $rc_file ) {
+        warn "$My_name: The supposed rc-file '$rc_file' is a directory; but it\n",
+             "          should be a normal text file\n";
+        return 1;
+    }
+    elsif ( exists $rc_files_read2{$abs_rc} ) {
         if ( $repeat_reaction ) { 
             warn
                 "$My_name: A user -r option asked me to process an rc file an extra time.\n",
@@ -4407,16 +4473,7 @@
     #    current versions of Perl (Nov. 2022), so "do latexmkrc;" for
     #    latexmkrc in cwd fails.
     # So I'll read the rc file and eval its contents.
-    if ( !-e $rc_file ) {
-        warn "$My_name: The rc-file '$rc_file' does not exist\n";
-        return 1;
-    }
-    elsif ( -d $rc_file ) {
-        warn "$My_name: The supposed rc-file '$rc_file' is a directory; but it\n",
-             "          should be a normal text file\n";
-        return 1;
-    }
-    elsif ( open( my $RCH, "<", $rc_file ) ) {
+    if ( open( my $RCH, "<", $rc_file ) ) {
         my $code = '';
         # Read all contents of file into $code:
         { local $/ = undef; $code = <$RCH>;}
@@ -5188,7 +5245,7 @@
 
 #**************************************************
 
-sub correct_aux_out_files {
+sub correct_locations {
     # Deal with situations after a *latex run where files are in different
     # directories than expected (specifically aux v. output directory).
     # Do minimal fix ups to allow latexmk to analyze dependencies with log
@@ -5279,7 +5336,7 @@
             warn "$My_name: fls file doesn't appear to have been made.\n";
         }
     }
-} # END correct_aux_out_files
+} # END correct_locations
 
 #-----------------
 
@@ -6197,21 +6254,61 @@
     #                    ref to array to receive lines,
     #                    ref to hash to receive diagnostic etc informaion )
     # 3rd argument is optional
-    # Lines are unwrapped and converted to CS_system.
+    # Lines are unwrapped and converted to the CS_system coding system (so
+    #   that filenames are suitable for use in file opening calls and on
+    #   command line to invoked programs).
+    #
+    # **Complication**: When writing to the .log file, *latex converts
+    #   lines longer than a given length (by default, 79) to a sequence
+    #   of lines with at most the maximum length.
+    #   This subroutine converts such sequences of lines to the original
+    #   unwrapped form.
+    #   **However**,
+    #   1. The algorithm for line wrapping differs between all of pdflatex,
+    #      xelatex, and lualatex.  See below for details.
+    #   2. It is possible to write an unwrapped line L1 of a relevant
+    #      length followed by a shorter line L2, such that it is impossible
+    #      to distingish it from a wrapped line whose contents were those
+    #      of L1 concatenated with L2.
+    #   So when it is determined that a line is potentially wrapped,
+    #   several possibilities for the unwrapped lines are added to the
+    #   output array of lines (referenced by the second argument), so that
+    #   subsequent scanning of the lines in the subroutine parse_log picks
+    #   up the possible diagnostic messages independently of complications
+    #   in identifying wrapped lines versus unwrapped lines.
     
     my ($file, $PAlines, $PHinfo) = @_;
-
     # Where lines are wrapped at.  We'll sometimes override.
     local $log_wrap = $log_wrap;
 
+    # Lines held for wrapping:
+    my @held_lines = ();
+    # Routine for setting wrapped lines; setup by assignment to keep visibility
+    # in the enclosing subroutine, and to access its my-variables:
+    my $Pwrap_sub =
+    sub {
+        for ( my $i=0; $i <= $#held_lines; $i++ ) {
+            my $line = '';
+            for ( my $j=$i; $j <= $#held_lines; $j++ ) {
+                last if ($j-$i > 1 + ($max_log_construct /$log_wrap) );
+                $line .= $held_lines[$j];
+                push @$PAlines, $line;
+            }
+        }
+        @held_lines = ();
+    };
+
+
     my $engine = '';
     my $tex_distribution = '';
-    my ($line_num, $cont, $max_len) = ( 0, 0, 0 );
+    my ($line_num, $max_len) = ( 0, 0 );
     my $lua_mode = 0;  # Whether to use luatex-specific wrapping method.
-    my $byte_wrapping = 1;  # *latex does byte wrapping.  Modify if we find
-                            # log file is generated by a tex program that
-                            # wrapping by Unicode code points.
-
+    my $byte_wrapping = 1;  # Assume by default that the wrapping occurs at
+                            # a certain number of bytes. Modify this
+                            # variable if we find that the log file was
+                            # generated by a tex program that does wrapping
+                            # at a certain number of Unicode code points. 
+    # The details for the different programs (underlying the *latex programs):
     # File encoding: pdftex: UTF-8 but with wrapping at $log_wrap BYTES.
     #                        (So individual wrapped lines can be malformed
     #                        UTF-8, but we get valid UTF-8 after unwrapping.)
@@ -6218,7 +6315,7 @@
     #                luatex: UTF-8 but with wrapping at APPROXIMATELY
     #                        $log_wrap bytes. Rest as pdftex
     #                xetex:  UTF-8 with wrapping at $log_wrap codepoints.
-    # So we read file as bytes
+    # So we read file as bytes.  Then
     #   first line gives which program was used and hence whether to wrap
     #     according to byte or codepoint count.
     #   wrapping is always performed on the encoded byte strings, but the
@@ -6262,18 +6359,47 @@
         }
         if ($len > $max_len) { $max_len = $len }
 
-        # Is this line continuation of previous line?
-        if ($cont) { $$PAlines[$#$PAlines] .= $_; }
-        else { push @$PAlines, $_ }
-
         # Is this line wrapped? I.e., is next line to be appended to it?
-        # Allow for fact that luatex doesn't reliably wrap at std place, e.g., 79.
-        $cont = ($len == $log_wrap)
+        # 2 cases:
+        #     pdflatex and xelatex wrap at exactly length $log_wrap 
+        #         (default 79), and normally append empty line when line
+        #         is exactly of the maximimum length (so we shouldn't have a
+        #         problem of distinguishing a wrapped line from a line of
+        #         length exactly $log_wrap).
+        #     lualatex: Wrap at a variable position dependent in a complicated
+        #         way on contents.  With default settings, wrapping occurs
+        #         between 77 and 80 bytes, according to my tests.  It preserves
+        #         UTF-8 coding, and doesn't split multi-byte UTF-8 coding of
+        #         a code point between lines, unlike pdflatex. But details
+        #         of exactly where a line is wrapped is not clear.
+        #         It is not possible in all cases to distinguish whether
+        #         a pair of lines arise from wrapping of a longer line
+        #         or from actual writing of a pair of lines.
+        # Determine whether line is potentially wrapped:
+        my $cont = ($len == $log_wrap)
             || ( $lua_mode && ($len >= $log_wrap-2) && ($len <= $log_wrap+1) );
-        if ($cont && $diagnostics ) {
-            print "====Continuing line $line_num of length $len\n$_\n";
+        if ($cont) {
+            # Save lines that may be continued onto @held_lines
+            print "====Continuing line $line_num of length $len\n$_\n"
+            if $diagnostics;
+            push @held_lines, $_;
         }
+        elsif (@held_lines) {
+            # No more continuation lines after this:
+            push @held_lines, $_;
+            # Put possibilities for lines before wrapping onto the main
+            # array and then clear @held_lines
+            &$Pwrap_sub();
+        }
+        else {   
+            push @$PAlines, $_;
+        }
     }
+    if (@held_lines) {
+        # Get here if the last line of the file is of a length that
+        # it may be a wrapped.
+        &$Pwrap_sub();
+    }
     close($fh);
     foreach (@$PAlines) { $_ = utf8_to_mine($_); }
     push @$PAlines, "";  # Blank line to terminate.  So multiline blocks 
@@ -6330,7 +6456,7 @@
         #  is produced by MS-Windows program (e.g., in MiKTeX) with CRLF line ends,
         #  but is read by Unix Perl (which treats LF as line end, and preserves CRLF
         #  in read-in lines):
-        # And convert '\'
+        # And convert '\' to '/'
         s/\r?\n$//;
         s[\\][/]g;
         $line_no++;
@@ -6340,10 +6466,17 @@
         }
         else {
             # Deal with MS-Win issues when system CP isn't UTF-8
-            if ( ($^O eq 'MSWin32') && /PWD/ && ! is_valid_utf8($_) ) {
-                # TeXLive on MSWin produces PWD in CS_system not UTF-8.
-                # ???? Later get tex_distribution before analyzing fls file, so do better test.
-                print "PWD line not in UTF-8.  This is normal for TeXLive. I will handle it.\n";
+            # Situation is that the fls file should be in UTF-8 and
+            # needs to be converted to system CP to fit with latexmk's
+            # convention (determined by file-system calls).
+            # However, under Windows' TeXLive 2021 (and maybe earlier) the
+            # PWD uses the system CP while the rest of the file is UTF-8.
+            # In TeXLive 2022 and 2023, the whole file, including the PWD
+            # line is UTF-8. 
+            # So give special treatment to PWD line under Windows.
+            # Also to guard against any other problems, check for non-UTF-8 lines. 
+            if ( ($^O eq 'MSWin32') && /PWD/ && ! is_valid_utf8($_) ) {                               print
+                  "PWD line not in UTF-8.  This is normal for older TeXLives (2021 and earlier).\n".                                                                                        "I will handle it.\n";
                 # Assume in CS_system, no change needed.
             }
             elsif ( ! is_valid_utf8($_) ) {
@@ -6548,8 +6681,12 @@
 sub normalize_filename_abs {
     # Convert filename to be either
     # absolute path in canonical form
-    # or relative to cwd.
-    return normalize_filename( abs_path($_[0]) );
+    # or relative to cwd, if possible.
+    # abs_path returns undef if it doesn't know how to get an absolute path.
+    # Just work with the original path in that case.
+    my $abs = abs_path($_[0]);
+    if (! defined $abs) { $abs = $_[0]; }
+    return normalize_filename( $abs );
 }
 
 #-----------------------------
@@ -6770,7 +6907,7 @@
         return 2;
     }
 
-    show_array( "$My_name: Bibliography file(s) form .bcf file:", @$Pbib_files )
+    show_array( "$My_name: Bibliography file(s) from .bcf file:", @$Pbib_files )
         unless $silent;
     if (@not_found_bib) {
         show_array(
@@ -8175,6 +8312,10 @@
                    "   I'll try making it with allowed extensions \n";
              foreach my $try_ext ( keys %$Pinput_extensions ) {
                  my $new_dest = "$file.$try_ext";
+                 if (-e $new_dest) {
+                     # A file that exists cannot have been the missing file.
+                     next;
+                 }
                  &Run_subst( "$make $quote$new_dest$quote" );
                  if ( -e $new_dest ) {
                      print "SUCCESS in making '$new_dest'\n",
@@ -8462,31 +8603,27 @@
     #        no error in the run, the source-file-state is **not** updated
     #        after the rule is run.  Then on a subsequent pass through
     #        rdb_make's main loop, when the rule is tested for a rerun, any
-    #        change in source file contents is cause for running the rule
-    #        again.
-    #    8.  But after a run giving an error, the state of the generated
-    #        files (i.e., non-user files) is updated to the current state.
-    #        This is because the error (under normal circumstances) must be
-    #        corrected by user action: e.g., correcting a source file, and
-    #        possibly deleting some corrupted auxiliary file.  Files (e.g.,
-    #        .aux by *latex) generated by the rule just run may well have
-    #        changed, so updating their state to the current state prevents
-    #        another run before a user change.  If a file was generated by
-    #        another rule, it won't have changed its state, so updating its
-    #        state won't matter.  But a non-generated file is a
-    #        user-created file, and a rerun is entailed if its contents
-    #        changed compared with the start of the run; it's the
-    #        start-of-run contents that were used in the error run.
-    #    9.  Note: an error may be caused by a problem with a file
-    #        generated by another rule, e.g., a bbl file created by bibtex
-    #        and read by *latex, but with no error reported by bibtex.  To
-    #        correct the error a source file (possibly more than once
-    #        removed must be changed).  That triggers a rerun of the
-    #        producing rule, and after that the resulting change causes a
-    #        rerun of the original rule that had the error.  E.g.,
-    #        correcting a .bib file causes bibtex to run, producing a
-    #        corrected .bbl file, after which *latex is caused to be run.
-    #    10. With circular dependencies, there is a choice of which order
+    #        change in source file contents since the start of the previous
+    #        run is cause for running the rule again.
+    #    8.  When there is an error, and force_mode is off, processing of
+    #        all further rules is terminated.  A problem is then caused for
+    #        a later invocation of latexmk (or, in -pvc mode, the next
+    #        scanning of source-file status): It may be that a generated
+    #        file from a run of some rule changed compared with its status
+    #        before the run.  Because of the termination of processing
+    #        there was no rerun of the rule. New runs should only be made
+    #        after a change in the user-written files, which give the
+    #        possibility of correcting the error.  But on a subsequent
+    #        invocation of latexmk it could appear that some rule(s) is/are
+    #        out-of-date because of the changed generated files, which
+    #        would result in unneeded extra runs, which will tend to
+    #        pollute the screen output with misleading downstream
+    #        consequences of the original error.
+    #        To avoid this problem, after an error-generating round of
+    #        compilations, the cached state of generated files is updated
+    #        to their state after the compilations.  Then only user-caused
+    #        file changes will be cause for new runs.
+    #    9.  With circular dependencies, there is a choice of which order
     #        to examine the rules.  Generally, primary rules are more 
     #        time-consuming than most others, so the choice of the order of
     #        examination of rules to check out-of-dateness is to try to
@@ -8495,7 +8632,7 @@
     #        graphics. These are normally outside a dependency loop, so
     #        those are left to last.  Even if they are inside a dependency
     #        loop, they need the primary rule to have been run first.
-    #    11. After rdb_make is run, all non-user source files are updated
+    #    10. After rdb_make is run, all non-user source files are updated
     #        to their current state.  Rules are considered up-to-date
     #        here. On a subsequent call to rdb_make, subsequent changes are
     #        relevant to what is to be done.  Note: the states of user
@@ -8625,7 +8762,7 @@
         }
         if ( ($runs > 0) && ! $too_many_passes ) {
             $retry_msg = 0;
-            if ( $force_mode || (! $failure) || $switched_primary_output ) {
+            if ( $force_mode || (! $failure) ) {
                 next PASS;
             }
             # Get here on failure, without being in force_mode
@@ -8673,8 +8810,32 @@
          # but do not change primaries.
          # Problem is that %current_primaries gets altered
          &rdb_set_rule_net;
-    }  #End PASS
+     }  #End PASS
 
+    if ($failure ) {
+        # Update state of generated source files, but not non-generated,
+        # i.e., user source files.  Without that, when there was a termination of
+        # processing because of an error, it could be some generated files changed
+        # without reruns of the relevant rule(s) being triggered; that's because
+        # with an error and with force_mode off, the reruns are blocked.
+        # But that situation would cause reruns either when latexmk is reinvoked
+        # or at the next examination of file state (in -pvc mode). But those runs
+        # (almost certainly) won't improve the error situation in the absence of
+        # a change in user files, since the error is ultimately due to a problem
+        # with a user file.
+        # By updating the state of generated source files, reruns are not
+        # triggered until a user file is changed.
+        # Also turn $$Pout_of_date off for the rules.  It may have been set
+        # at some point to trigger a rerun, but that information is now
+        # out-of-date, given that an error occurred.
+        rdb_for_some( [&rdb_accessible()],
+                      sub{ 
+                           &rdb_update_gen_files;
+                           $$Pout_of_date = 0;
+                      }
+                    ); 
+    }
+
     rdb_for_some( [@unusual_one_time], \&rdb_make1 );
 
     #---------------------------------------
@@ -8839,7 +9000,7 @@
     # Is this needed?  Yes; rdb_make1 is called on a sequence of rules and
     # if one gives an error, then it provides source files directly or
     # indirectly to later rules, which should not be run.
-    if ($failure & ! $force_mode) {return;}
+    if ($failure && ! $force_mode) {return;}
 
     # Rule may have been created since last run.  Just in case we didn't,
     # define $pass{$rule} elsewhere, do it here:
@@ -8922,6 +9083,7 @@
         warn_running( "Run number $pass{$rule} of rule '$rule'" );
         $return = &rdb_run1;
     }
+
     if ($$Pchanged) {
         $newrule_nofile = 1;
         $return = 0;
@@ -8972,15 +9134,6 @@
         if ( !$$Plast_message ) {
             $$Plast_message = "Run of rule '$rule' gave a non-zero error code";
         }
-        # Update state of generated source files, but not non-generated,
-        # i.e., user source files. Thus any change in the rule's own
-        # generated source files during the run will not cause a
-        # rerun. Files generated by another rule should not have been
-        # changed during the run, so updating their saved state in this
-        # rule is a NOP.  But any change in user files since the **start**
-        # of the run is a cause for a rerun, so their saved state must not
-        # be updated.
-        rdb_update_gen_files();
     }
     foreach ( keys %$PHsource_rules ) {
         $$PHsource_rules{$_} = $pass{$_};
@@ -9074,7 +9227,7 @@
     #
     $$Pout_of_date = $$Pout_of_date_user = 0;
     if ($latex_like) {
-        &correct_aux_out_files;
+        &correct_locations;
         run_hooks( 'after_xlatex' );
         $return = analyze_latex_run( $return );
         run_hooks( 'after_xlatex_analysis' );
@@ -9490,7 +9643,6 @@
     #
     # ???!!!!
     # Check all uses!!!!!!!!!!!!!
-
     our ($rule, %pass);
 
     local our $PHchanges = shift;
@@ -9628,9 +9780,7 @@
     }
     $$Pno_history = 0;    # See comments in definition of %rule_db.
     if ($rerun_needed) {
-        $$Pout_of_date = 1;
         push @{$$PHchanges{rules_to_apply}}, $rule;
-        if (@{$$PHchanges{changed_user}}) {$$Pout_of_date_user = 1;}
     }
     return $rerun_needed;
 } #END rdb_rerun_needed
@@ -10500,37 +10650,6 @@
 
 #************************************************************
 
-sub analyze_string {
-    # Show information about string: utf8 flag or not, length(s!), byte content
-    my ($m,$s) = @_;
-
-    print "=== $m ";
-    my $length = length($s);
-    if (utf8::is_utf8($s)) {
-        my $encoded = encode( $CS_system, $s, Encode::FB_WARN | Encode::LEAVE_SRC );
-        my $len_chars = 0;
-        my $len_bytes = 0;
-        { no bytes; $len_chars = length($s); }
-        { use bytes; $len_bytes = length($s); }
-        print "'$encoded':\n",
-            "utf8, len = $length; chars = $len_chars; bytes = $len_bytes\n";
-    }
-    else {
-        print "'$s':\n",
-              "NOT utf8, len = $length\n";
-    }
-
-    print join ' ', to_hex($s), "\n";
-}
-
-#----------------------------
-
-sub to_hex {
-    return map { sprintf('%4X', $_) }  unpack( 'U*', shift );
-}
-
-#==================
-
 sub glob_list1 {
     # Glob a collection of filenames.  
     # But no sorting or elimination of duplicates
@@ -10691,25 +10810,31 @@
         # We won't use checksum for directory
         return 0;
     }
-    else {
-        open( $input, '<:bytes', $source )
-        or return 0;
-        my ($base, $path, $ext) = fileparseA( $source );
-        $ext =~ s/^\.//;
-        if ( exists $hash_calc_ignore_pattern{$ext} ) {
-            $ignore_pattern = $hash_calc_ignore_pattern{$ext};
-        }
+    open( $input, '<:bytes', $source )
+    or return 0;
+    my ($base, $path, $ext) = fileparseA( $source );
+    $ext =~ s/^\.//;
+    if ( exists $hash_calc_ignore_pattern{$ext} ) {
+        $ignore_pattern = $hash_calc_ignore_pattern{$ext};
     }
-    if ( defined $ignore_pattern ) {
-        while (<$input>) {
-            if ( ! /$ignore_pattern/ ){
-                $md5->add($_);
+    eval {
+        # Trap any errors that occur during reading, even though the file
+        # was successfully opened.
+        # Such errors have been known to occur under OneDrive on macOS.
+        if ( defined $ignore_pattern ) {
+            while (<$input>) {
+                if ( ! /$ignore_pattern/ ){
+                    $md5->add($_);
+                }
             }
         }
+        else {
+            $md5->addfile($input);
+        }
+    };
+    if ($@) {
+        warn "$My_name: Attempt to get md5 of '$source' failed.  Error=\n$@";
     }
-    else {
-        $md5->addfile($input);
-    }
     close $input;
     return $md5->hexdigest();
 }
@@ -11184,7 +11309,12 @@
 sub fileparseA {
     # Like fileparse but replace $path for current dir ('./' or '.\') by ''
     # Also default second argument to get normal extension.
+    # With msys, change all \ to / in given name since with msys, fileparse
+    # doesn't recognize \ as directory separator.
     my $given = $_[0];
+    if ( $^O eq 'msys' ) {
+        $given =~ s[\\][/]g;
+    }
     my $pattern = '\.[^\.]*';
     if  ($#_ > 0 ) { $pattern = $_[1]; }
     my ($base_name, $path, $ext) = fileparse( $given, $pattern );
@@ -11198,7 +11328,12 @@
 
 sub fileparseB {
     # Like fileparse but with default second argument for normal extension
+    # With msys, change all \ to / in given name since with msys, fileparse
+    # doesn't recognize \ as directory separator.
     my $given = $_[0];
+    if ( $^O eq 'msys' ) {
+        $given =~ s[\\][/]g;
+    }
     my $pattern = '\.[^\.]*';
     if  ($#_ > 0 ) { $pattern = $_[1]; }
     my ($base_name, $path, $ext) = fileparse( $given, $pattern );
@@ -11551,7 +11686,11 @@
     }
     # Normalized
     if ($normalize_names) {
-        $cwd = abs_path($cwd);
+        my $abs = abs_path($cwd);
+        # It's conceivable that abs_path doesn't know how to convert to an
+        # absolute path of a standard normalization.  Then it returns undef.
+        # In that case, it's probably good not to try normalizing $cwd.
+        if (defined $abs) { $cwd = $abs; }
     }
     $cache{cwd} = $cwd;
 }  # END cache_good_cwd

Modified: trunk/Master/texmf-dist/doc/man/man1/latexmk.1
===================================================================
--- trunk/Master/texmf-dist/doc/man/man1/latexmk.1	2023-11-09 22:13:34 UTC (rev 68768)
+++ trunk/Master/texmf-dist/doc/man/man1/latexmk.1	2023-11-09 22:13:57 UTC (rev 68769)
@@ -1,4 +1,4 @@
-.TH LATEXMK 1 "4 April 2023" ""
+.TH LATEXMK 1 "6 November 2023" ""
 .SH NAME
 latexmk \- generate LaTeX document
 .SH SYNOPSIS
@@ -2733,6 +2733,36 @@
 to change this.
 
 .TP
+.B @file_not_found
+This an array of Perl regular expressions that are patterns to find
+messages in the .log file from a run of *latex that indicate that a file
+was looked for and not found.  To see the current default set, you should
+look at the definition of \fI at file_not_found\fR in the latexmk.pl file.
+
+In the regular expression, the string for the name of the missing file
+should be enclosed in parentheses.  That carries the implication that after
+latexmk gets a succesful match to the pattern, the variable $1 is set to
+the filename, which is then picked up by latexmk.
+
+If you happen to encounter a package that gives a missing file message of a
+different form than one that matches one of the built-in patterns, you can
+add another pattern to the array.  An example would be
+
+    push @file_not_found, '^No file\\\\s+(.+)\\\\s*$';
+
+The regular expression itself is
+
+     ^Missing file\\s+(.+)\\s*$
+
+But the corresponding string specification in the push statement has to
+have the backslashes doubled.  
+
+This regular expression matches a line that starts with 'No file', then has
+one or more white space characters, then any number of characters forming
+the filename, then possible white space, and finally the end of the line.
+(See documentation on Perl regular expressions for details.)
+
+.TP
 .B $fls_uses_out_dir [0]
 This variable determines whether or not the .fls file should be in the
 output directory instead of the natural directory, which is the aux
@@ -3995,9 +4025,49 @@
 .B $$Pdest
 This gives the name of the main output file if any.  Note the double
 dollar signs.
+
 .TP
+.B pushd( path ), popd()
+These subroutines are used when it is needed to temporarily change the
+working directory, as in
+
+     pushd( 'some_directory' );
+     ... Processing done with 'some_directory' as the working directory
+     popd()
+
+They perform exactly the same function as the commands of the same names in
+operating system command shells like bash on Unix, and cmd.exe on the
+Windows.
+
+.TP
+.B rdb_add_generated( file, ... )
+This subroutine is to be used in the context of a rule, that is, from
+within a subroutine that is carrying out processing of a rule.  Such is the
+case for the subroutine implementing a custom dependency, or the subroutine
+invoked by using the "internal" keyword in the command specification like
+that in the variable \fI$latex\fR.
+
+Its arguments are a sequence of filenames which are generated during the
+running of the rule.  The names might arise from an analysis of the results
+of the run, e.g., in a log file, or from knowledge of properties of the
+specific rule.  Calling \fIrdb_add_generated\fR with these filenames
+ensures that these files are flagged as generated by the rule in
+\fIlatexmk\fR's internal data structures.  Basically, no action is taken if
+the files have already been flagged as generated.
+
+A main purpose of using this subroutine is for the situation when a
+generated file is also the source file for some rule, so that \fIlatexmk\fR
+can correctly link the dependency information in its network of rules.
+
+\fINote: Unlike some other subroutines in this section, there is no
+argument for a rule for \fRrdb_add_generated\fI. Instead, the subroutine is
+to be invoked during the processing of a rule when \fRlatexmk\fI has set up
+an appropriate context (i.e., appropriate variables).  In contrast,
+subroutines with a rule argument can be used also outside a rule context.\fR
+
+.TP
 .B rdb_ensure_file( $rule, file )
-This a subroutine that ensures that the given file is among the source
+This subroutine ensures that the given file is among the source
 files for the specified rule.  It is typically used when, during the
 processing of a rule, it is known that a particular extra file is
 among the dependencies that \fIlatexmk\fR should know, but its default
@@ -4010,17 +4080,34 @@
 cases that use this subroutine are \fIbib2gls-latexmkrc\fR,
 \fIexceltex_latexmkrc\fR and \fItexinfo-latexmkrc\fR.  These
 illustrate typical cases where \fIlatexmk\fR's normal processing fails
-to detect certain extra source files. 
+to detect certain extra source files.
+
+\fINote that \fRrdb_ensure_file\fI only has one filename argument, unlike
+other subroutines in this section.  If you want to apply its action to
+multiple files, you will need one call to \fRrdb_ensure_file\fI for each
+file.\fR
+
 .TP
 .B rdb_remove_files( $rule, file, ... )
 This subroutine removes one or more files from the dependency list for
 the given rule. 
+
 .TP
+.B rdb_remove_generated( file, ... )
+This subroutine is to be used in the context of a rule, that is, from
+within a subroutine that is carrying out processing of a rule.  It performs
+the opposite action to \fIrdb_add_generated\fR.  Its effect is to ensure
+that the given filenames are not listed in \fIlatexmk\fR's internal data
+structures as being generated by the rule.
+
+.TP
 .B rdb_list_source( $rule )
 This subroutine returns the list of source files (i.e., the dependency
 list) for the given rule. 
+
 .TP
 .B rdb_set_source( $rule, file, ... )
+
 .TP
 .B rdb_set_source( $rule, @files )
 This subroutine sets the dependency list for the given rule to be the
@@ -4028,6 +4115,7 @@
 information.  Files that were not in the list are added to it.  Files
 in the previous dependency list that are not in the newly specified
 list of files are removed from the dependency list.
+
 .TP
 .B Run_subst( command_spec )
 This subroutine runs the command specified by \fIcommand_spec\fR.  The
@@ -4296,12 +4384,12 @@
 harvested too easily.)
 .SH AUTHOR
 Current version, by John Collins 
-(Version 4.80).
+(Version 4.81).
 Report bugs etc to his e-mail (jcc8 at psu.edu).
 
 Released version can be obtained from CTAN:
 <http://www.ctan.org/pkg/latexmk/>, and from the
-author's website <http://www.personal.psu.edu/jcc8/latexmk/>.
+author's website <https://www.cantab.net/users/johncollins/latexmk/>.
 .br
 Modifications and enhancements by Evan McLean (Version 2.0)
 .br

Modified: trunk/Master/texmf-dist/doc/man/man1/latexmk.man1.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/support/latexmk/CHANGES
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/CHANGES	2023-11-09 22:13:34 UTC (rev 68768)
+++ trunk/Master/texmf-dist/doc/support/latexmk/CHANGES	2023-11-09 22:13:57 UTC (rev 68769)
@@ -857,5 +857,19 @@
   Various bug fixes and corrections, improvements in error and warning
     messages, and corrections to documentation.
 
+From v. 4.80 to 4.81
+  Fix various problems when filenames contain non-ASCII characters,
+    especially when MSYS is used.
+  Fix problems with analyzing wrapped lines in log files, especially with
+    lualatex. 
+  With options like -dvi that set the kind of output file, turn off
+    settings corresponding to incompatible options.
+  Improved warning and error messages.
+  Fix problem when using the $use_make_for_missing_files, with the search
+    over possible extensions for a missing file.
+  Add .run.xml to the list of generated extensions in @generated_exts.
+  Correct the behavior after errors.  Previously force_mode didn't work as
+    documented, terminating processing too early, while in
+    preview_continuous_mode, incorrect extra runs were sometimes made. 
+  Other bug fixes.
 
-

Modified: trunk/Master/texmf-dist/doc/support/latexmk/INSTALL
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/INSTALL	2023-11-09 22:13:34 UTC (rev 68768)
+++ trunk/Master/texmf-dist/doc/support/latexmk/INSTALL	2023-11-09 22:13:57 UTC (rev 68769)
@@ -1,6 +1,6 @@
             INSTALLING latexmk
             ==================
-      (Version 4.80, 4 Apr. 2023)
+      (Version 4.81, 6 Nov. 2023)
 
             John Collins
             Physics Department

Modified: trunk/Master/texmf-dist/doc/support/latexmk/README
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/README	2023-11-09 22:13:34 UTC (rev 68768)
+++ trunk/Master/texmf-dist/doc/support/latexmk/README	2023-11-09 22:13:57 UTC (rev 68769)
@@ -1,4 +1,4 @@
-Latexmk, version 4.80, 4 Apr 2023
+Latexmk, version 4.81, 6 Nov 2023
 ---------------------------------
 
 Latexmk completely automates the process of generating a LaTeX

Modified: trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/README-latexmk-rcfiles
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/README-latexmk-rcfiles	2023-11-09 22:13:34 UTC (rev 68768)
+++ trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/README-latexmk-rcfiles	2023-11-09 22:13:57 UTC (rev 68769)
@@ -26,7 +26,7 @@
 
    But it is preferable to leave the quotes in, since they provide
    safety against special characters in filenames.  The double quotes
-   appear not to cause problems in all situations that I have tried.
+   appear not to cause problems in all the situations that I have tried.
 
 5. Note that the files for exceltex and pythontex illustrate an answer
    to an issue that arises in the following generic situation:

Added: trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/pdflatex_latexmkrc
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/pdflatex_latexmkrc	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/pdflatex_latexmkrc	2023-11-09 22:13:57 UTC (rev 68769)
@@ -0,0 +1,6 @@
+# This shows how to configure latexmk to use pdflatex
+
+$pdf_mode = 1;
+$postscript_mode = $dvi_mode = 0;
+
+

Modified: trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/pythontex-latexmkrc
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/pythontex-latexmkrc	2023-11-09 22:13:34 UTC (rev 68768)
+++ trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/pythontex-latexmkrc	2023-11-09 22:13:57 UTC (rev 68769)
@@ -15,6 +15,13 @@
 push @generated_exts, 'pytxcode';
 
 $pythontex = 'pythontex %O %S';
+
+# Specify a rule for running the pythontex program.
+# Because of the unusual structure of input and output files, I've used
+# an internal hash variable %extra_rule_spec of latexmk to specify the
+# rule.  Currently the only documentation is in the latexmk source code.
+# Probably the following line is stable against future changes in latexmk,
+# but that isn't guaranteed.
 $extra_rule_spec{'pythontex'}  = [ 'internal', '', 'mypythontex', "%Y%R.pytxcode",  "%Ypythontex-files-%R/%R.pytxmcr",    "%R", 1 ];
 
 sub mypythontex {

Deleted: trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/schultz-texshop-latexmkrc
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/schultz-texshop-latexmkrc	2023-11-09 22:13:34 UTC (rev 68768)
+++ trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/schultz-texshop-latexmkrc	2023-11-09 22:13:57 UTC (rev 68769)
@@ -1,77 +0,0 @@
-# Use of glossaries, extra indexes, epstopdf, and other images conversions
-# Thanks to Herb Schulz
-
-
-$pdflatex = 'pdflatex --shell-escape %O %S';
-
-# Custom dependency for glossary/glossaries package
-# if you make custom glossaries you may have to add items to the @cus_dep_list and corresponding sub-routines
-add_cus_dep( 'glo', 'gls', 0, 'makeglo2gls' );
-sub makeglo2gls {
-    system( "makeindex -s \"$_[0].ist\" -t \"$_[0].glg\" -o \"$_[0].gls\" \"$_[0].glo\"" );
-}
-# The glossaries package, with the [acronym] option, produces a .acn file when processed with (xe/pdf)latex and
-# then makeindex to process the .acn into .acr and finally runs of (xe/pdf)latex to read in the .acr file. Unfortunately
-# the glossary package does just the reverse; i.e. (xe/pdf)latex processing produces a .acr files and makeindex then
-# is used to convert the .acr file to a .acn file which is then ... . This dependency assumes the glossaries package.
-add_cus_dep( 'acn', 'acr', 0, 'makeacn2acr' );
-sub makeacn2acr {
-    system( "makeindex -s \"$_[0].ist\" -t \"$_[0].alg\" -o \"$_[0].acr\" \"$_[0].acn\"" );
-}
-# for glossary package (Sigh...) --- they can co-exist!		
-add_cus_dep( 'acr', 'acn', 0, 'makeacr2acn' );
-sub makeacr2acn {
-    system( "makeindex -s \"$_[0].ist\" -t \"$_[0].alg\" -o \"$_[0].acn\" \"$_[0].acr\"" );
-}
-# example of an added custom glossary type that is used in some of the glossary/glossaries example files:
-# this is for the new glossary type command \newglossary[nlg]{notation}{not}{ntn}{Notation} from the glossaries package
-# NOTE: the glossary package uses a very different command: the <in-ext> and <out-ext>
-# are reversed in the calling sequence :-(
-add_cus_dep( 'ntn', 'not', 0, 'makentn2not' );
-sub makentn2not {
-    system("makeindex -s \"$_[0].ist\" -t \"$_[0].nlg\" -o \"$_[0].not\" \"$_[0].ntn\"" );
-}
-# for the	glossary package (Sigh...) --- they can co-exist!
-add_cus_dep( 'not', 'ntn', 0, 'makenot2ntn' );
-sub makenot2ntn {
-    system("makeindex -s \"$_[0].ist\" -t \"$_[0].nlg\" -o \"$_[0].ntn\" \"$_[0].not\"" );
-}
-
-# dependencies for custom indexes using the index package
-# examples for sample.tex for index package:
- add_cus_dep( 'adx', 'and', 0, 'makeadx2and' );
-sub makeadx2and {
-    system( "makeindex -o \"$_[0].and\" \"$_[0].adx\"" );
-}
-add_cus_dep( 'ndx', 'nnd', 0, 'makendx2nnd' );
-sub makendx2nnd {
-    system( "makeindex -o \"$_[0].nnd\" \"$_[0].ndx\"" );
-}
-add_cus_dep( 'ldx', 'lnd', 0, 'makeldx2lnd' );
-sub makeldx2lnd {
-    system( "makeindex -o \"$_[0].lnd\" \"$_[0].ldx\"" );
-}
-
-# Custom dependency and function for nomencl package
-add_cus_dep( 'nlo', 'nls', 0, 'makenlo2nls' );
-sub makenlo2nls {
-    system( "makeindex -s nomencl.ist -o \"$_[0].nls\" \"$_[0].nlo\"" );
-}
-
-# Custom dependency and function(s) for epstopdf package
-
-# FOR USERS OF epstopf v1.4 and before: should also work with v1.5 and later
-# note: you may get extras runs if you use the .eps extension in the \includgraphics command
-# deletes an outdated pdf-image, and triggers a pdflatex-run
-add_cus_dep( 'eps', 'pdf', 0, 'cus_dep_delete_dest' );
-
-# FOR USERS OF epstopdf v1.5 and later only:
-# load it as \usepackage[update,prepend]{epstopdf}
-# detects an outdated pdf-image, and triggers a pdflatex-run
-#add_cus_dep( 'eps', 'pdf', 0, 'cus_dep_require_primary_run' );
-
-# Custom dependecy to convert tif to png
-add_cus_dep( 'tif', 'png', 0, 'maketif2png' );
-sub maketif2png {
-    system( "convert \"$_[0].tif\" \"$_[0].png\"" );
-}

Added: trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/schulz-texshop-latexmkrc
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/schulz-texshop-latexmkrc	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/schulz-texshop-latexmkrc	2023-11-09 22:13:57 UTC (rev 68769)
@@ -0,0 +1,77 @@
+# Use of glossaries, extra indexes, epstopdf, and other images conversions
+# Thanks to Herb Schulz
+
+
+$pdflatex = 'pdflatex --shell-escape %O %S';
+
+# Custom dependency for glossary/glossaries package
+# if you make custom glossaries you may have to add items to the @cus_dep_list and corresponding sub-routines
+add_cus_dep( 'glo', 'gls', 0, 'makeglo2gls' );
+sub makeglo2gls {
+    system( "makeindex -s \"$_[0].ist\" -t \"$_[0].glg\" -o \"$_[0].gls\" \"$_[0].glo\"" );
+}
+# The glossaries package, with the [acronym] option, produces a .acn file when processed with (xe/pdf)latex and
+# then makeindex to process the .acn into .acr and finally runs of (xe/pdf)latex to read in the .acr file. Unfortunately
+# the glossary package does just the reverse; i.e. (xe/pdf)latex processing produces a .acr files and makeindex then
+# is used to convert the .acr file to a .acn file which is then ... . This dependency assumes the glossaries package.
+add_cus_dep( 'acn', 'acr', 0, 'makeacn2acr' );
+sub makeacn2acr {
+    system( "makeindex -s \"$_[0].ist\" -t \"$_[0].alg\" -o \"$_[0].acr\" \"$_[0].acn\"" );
+}
+# for glossary package (Sigh...) --- they can co-exist!		
+add_cus_dep( 'acr', 'acn', 0, 'makeacr2acn' );
+sub makeacr2acn {
+    system( "makeindex -s \"$_[0].ist\" -t \"$_[0].alg\" -o \"$_[0].acn\" \"$_[0].acr\"" );
+}
+# example of an added custom glossary type that is used in some of the glossary/glossaries example files:
+# this is for the new glossary type command \newglossary[nlg]{notation}{not}{ntn}{Notation} from the glossaries package
+# NOTE: the glossary package uses a very different command: the <in-ext> and <out-ext>
+# are reversed in the calling sequence :-(
+add_cus_dep( 'ntn', 'not', 0, 'makentn2not' );
+sub makentn2not {
+    system("makeindex -s \"$_[0].ist\" -t \"$_[0].nlg\" -o \"$_[0].not\" \"$_[0].ntn\"" );
+}
+# for the	glossary package (Sigh...) --- they can co-exist!
+add_cus_dep( 'not', 'ntn', 0, 'makenot2ntn' );
+sub makenot2ntn {
+    system("makeindex -s \"$_[0].ist\" -t \"$_[0].nlg\" -o \"$_[0].ntn\" \"$_[0].not\"" );
+}
+
+# dependencies for custom indexes using the index package
+# examples for sample.tex for index package:
+ add_cus_dep( 'adx', 'and', 0, 'makeadx2and' );
+sub makeadx2and {
+    system( "makeindex -o \"$_[0].and\" \"$_[0].adx\"" );
+}
+add_cus_dep( 'ndx', 'nnd', 0, 'makendx2nnd' );
+sub makendx2nnd {
+    system( "makeindex -o \"$_[0].nnd\" \"$_[0].ndx\"" );
+}
+add_cus_dep( 'ldx', 'lnd', 0, 'makeldx2lnd' );
+sub makeldx2lnd {
+    system( "makeindex -o \"$_[0].lnd\" \"$_[0].ldx\"" );
+}
+
+# Custom dependency and function for nomencl package
+add_cus_dep( 'nlo', 'nls', 0, 'makenlo2nls' );
+sub makenlo2nls {
+    system( "makeindex -s nomencl.ist -o \"$_[0].nls\" \"$_[0].nlo\"" );
+}
+
+# Custom dependency and function(s) for epstopdf package
+
+# FOR USERS OF epstopf v1.4 and before: should also work with v1.5 and later
+# note: you may get extras runs if you use the .eps extension in the \includgraphics command
+# deletes an outdated pdf-image, and triggers a pdflatex-run
+add_cus_dep( 'eps', 'pdf', 0, 'cus_dep_delete_dest' );
+
+# FOR USERS OF epstopdf v1.5 and later only:
+# load it as \usepackage[update,prepend]{epstopdf}
+# detects an outdated pdf-image, and triggers a pdflatex-run
+#add_cus_dep( 'eps', 'pdf', 0, 'cus_dep_require_primary_run' );
+
+# Custom dependecy to convert tif to png
+add_cus_dep( 'tif', 'png', 0, 'maketif2png' );
+sub maketif2png {
+    system( "convert \"$_[0].tif\" \"$_[0].png\"" );
+}

Modified: trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/xr_latexmkrc
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/xr_latexmkrc	2023-11-09 22:13:34 UTC (rev 68768)
+++ trunk/Master/texmf-dist/doc/support/latexmk/example_rcfiles/xr_latexmkrc	2023-11-09 22:13:57 UTC (rev 68769)
@@ -27,11 +27,7 @@
 #       or extra enhancements to latexmk.
 #    5. The code uses subroutines copy and fileparse that are loaded by
 #       latexmk from the Perl packages File::Copy and File::Basename.
-#    6. It also uses some not-yet-documented features of latexmk: an array
-#       variable @file_not_found and subroutines popd, pushd, and
-#       rdb_add_generated. 
 
-
 #--------------------
 # Configurable choices for compilation of external documents
 
@@ -72,14 +68,13 @@
                #    aux_dir rather than the one the cus dep is assumed by latexmk
                #    to produce, which is in the same directory as the .tex source
                #    file for this custom dependency.)
-               #    Use not-yet-documented latexmk subroutine rdb_add_generated
-               #    to do this:
+               #    Use the latexmk subroutine rdb_add_generated to do this.
                # 2. A copy of the .aux file must be in same directory as .tex file
                #    to satisfy latexmk's definition of a custom dependency.
              rdb_add_generated( "$sub_doc_output/$base_name.aux" );
              copy "$sub_doc_output/$base_name.aux", ".";
         }
-        popd;
+        popd();
         return $return;
    }
 }

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

Modified: trunk/Master/texmf-dist/doc/support/latexmk/latexmk.txt
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexmk/latexmk.txt	2023-11-09 22:13:34 UTC (rev 68768)
+++ trunk/Master/texmf-dist/doc/support/latexmk/latexmk.txt	2023-11-09 22:13:57 UTC (rev 68769)
@@ -61,7 +61,7 @@
 
 
 
-                                 4 April 2023                                1
+                                6 November 2023                              1
 
 
 
@@ -127,7 +127,7 @@
 
 
 
-                                 4 April 2023                                2
+                                6 November 2023                              2
 
 
 
@@ -193,7 +193,7 @@
 
 
 
-                                 4 April 2023                                3
+                                6 November 2023                              3
 
 
 
@@ -259,7 +259,7 @@
 
 
 
-                                 4 April 2023                                4
+                                6 November 2023                              4
 
 
 
@@ -325,7 +325,7 @@
 
 
 
-                                 4 April 2023                                5
+                                6 November 2023                              5
 
 
 
@@ -391,7 +391,7 @@
 
 
 
-                                 4 April 2023                                6
+                                6 November 2023                              6
 
 
 
@@ -457,7 +457,7 @@
 
 
 
-                                 4 April 2023                                7
+                                6 November 2023                              7
 
 
 
@@ -523,7 +523,7 @@
 
 
 
-                                 4 April 2023                                8
+                                6 November 2023                              8
 
 
 
@@ -589,7 +589,7 @@
 
 
 
-                                 4 April 2023                                9
+                                6 November 2023                              9
 
 
 
@@ -655,7 +655,7 @@
 
 
 
-                                 4 April 2023                               10
+                                6 November 2023                             10
 
 
 
@@ -721,7 +721,7 @@
 
 
 
-                                 4 April 2023                               11
+                                6 November 2023                             11
 
 
 
@@ -787,7 +787,7 @@
 
 
 
-                                 4 April 2023                               12
+                                6 November 2023                             12
 
 
 
@@ -853,7 +853,7 @@
 
 
 
-                                 4 April 2023                               13
+                                6 November 2023                             13
 
 
 
@@ -919,7 +919,7 @@
 
 
 
-                                 4 April 2023                               14
+                                6 November 2023                             14
 
 
 
@@ -985,7 +985,7 @@
 
 
 
-                                 4 April 2023                               15
+                                6 November 2023                             15
 
 
 
@@ -1051,7 +1051,7 @@
 
 
 
-                                 4 April 2023                               16
+                                6 November 2023                             16
 
 
 
@@ -1117,7 +1117,7 @@
 
 
 
-                                 4 April 2023                               17
+                                6 November 2023                             17
 
 
 
@@ -1183,7 +1183,7 @@
 
 
 
-                                 4 April 2023                               18
+                                6 November 2023                             18
 
 
 
@@ -1249,7 +1249,7 @@
 
 
 
-                                 4 April 2023                               19
+                                6 November 2023                             19
 
 
 
@@ -1315,7 +1315,7 @@
 
 
 
-                                 4 April 2023                               20
+                                6 November 2023                             20
 
 
 
@@ -1381,7 +1381,7 @@
 
 
 
-                                 4 April 2023                               21
+                                6 November 2023                             21
 
 
 
@@ -1447,7 +1447,7 @@
 
 
 
-                                 4 April 2023                               22
+                                6 November 2023                             22
 
 
 
@@ -1513,7 +1513,7 @@
 
 
 
-                                 4 April 2023                               23
+                                6 November 2023                             23
 
 
 
@@ -1579,7 +1579,7 @@
 
 
 
-                                 4 April 2023                               24
+                                6 November 2023                             24
 
 
 
@@ -1645,7 +1645,7 @@
 
 
 
-                                 4 April 2023                               25
+                                6 November 2023                             25
 
 
 
@@ -1711,7 +1711,7 @@
 
 
 
-                                 4 April 2023                               26
+                                6 November 2023                             26
 
 
 
@@ -1777,7 +1777,7 @@
 
 
 
-                                 4 April 2023                               27
+                                6 November 2023                             27
 
 
 
@@ -1843,7 +1843,7 @@
 
 
 
-                                 4 April 2023                               28
+                                6 November 2023                             28
 
 
 
@@ -1909,7 +1909,7 @@
 
 
 
-                                 4 April 2023                               29
+                                6 November 2023                             29
 
 
 
@@ -1975,7 +1975,7 @@
 
 
 
-                                 4 April 2023                               30
+                                6 November 2023                             30
 
 
 
@@ -2041,7 +2041,7 @@
 
 
 
-                                 4 April 2023                               31
+                                6 November 2023                             31
 
 
 
@@ -2107,7 +2107,7 @@
 
 
 
-                                 4 April 2023                               32
+                                6 November 2023                             32
 
 
 
@@ -2173,7 +2173,7 @@
 
 
 
-                                 4 April 2023                               33
+                                6 November 2023                             33
 
 
 
@@ -2239,7 +2239,7 @@
 
 
 
-                                 4 April 2023                               34
+                                6 November 2023                             34
 
 
 
@@ -2305,7 +2305,7 @@
 
 
 
-                                 4 April 2023                               35
+                                6 November 2023                             35
 
 
 
@@ -2371,7 +2371,7 @@
 
 
 
-                                 4 April 2023                               36
+                                6 November 2023                             36
 
 
 
@@ -2437,7 +2437,7 @@
 
 
 
-                                 4 April 2023                               37
+                                6 November 2023                             37
 
 
 
@@ -2503,7 +2503,7 @@
 
 
 
-                                 4 April 2023                               38
+                                6 November 2023                             38
 
 
 
@@ -2569,7 +2569,7 @@
 
 
 
-                                 4 April 2023                               39
+                                6 November 2023                             39
 
 
 
@@ -2635,7 +2635,7 @@
 
 
 
-                                 4 April 2023                               40
+                                6 November 2023                             40
 
 
 
@@ -2701,7 +2701,7 @@
 
 
 
-                                 4 April 2023                               41
+                                6 November 2023                             41
 
 
 
@@ -2767,7 +2767,7 @@
 
 
 
-                                 4 April 2023                               42
+                                6 November 2023                             42
 
 
 
@@ -2833,7 +2833,7 @@
 
 
 
-                                 4 April 2023                               43
+                                6 November 2023                             43
 
 
 
@@ -2899,7 +2899,7 @@
 
 
 
-                                 4 April 2023                               44
+                                6 November 2023                             44
 
 
 
@@ -2965,7 +2965,7 @@
 
 
 
-                                 4 April 2023                               45
+                                6 November 2023                             45
 
 
 
@@ -3031,7 +3031,7 @@
 
 
 
-                                 4 April 2023                               46
+                                6 November 2023                             46
 
 
 
@@ -3097,7 +3097,7 @@
 
 
 
-                                 4 April 2023                               47
+                                6 November 2023                             47
 
 
 
@@ -3163,7 +3163,7 @@
 
 
 
-                                 4 April 2023                               48
+                                6 November 2023                             48
 
 
 
@@ -3229,7 +3229,7 @@
 
 
 
-                                 4 April 2023                               49
+                                6 November 2023                             49
 
 
 
@@ -3271,6 +3271,51 @@
               need to change this.
 
 
+       @file_not_found
+              This an array of Perl regular expressions that are  patterns  to
+              find  messages  in the .log file from a run of *latex that indi-
+              cate that a file was looked for and not found.  To see the  cur-
+              rent   default  set,  you  should  look  at  the  definition  of
+              @file_not_found in the latexmk.pl file.
+
+              In the regular expression, the string for the name of the  miss-
+              ing  file  should  be enclosed in parentheses.  That carries the
+              implication that after latexmk gets a  succesful  match  to  the
+              pattern,  the  variable $1 is set to the filename, which is then
+              picked up by latexmk.
+
+              If you happen to encounter a package that gives a  missing  file
+              message  of  a  different  form than one that matches one of the
+              built-in patterns, you can add another pattern to the array.  An
+              example would be
+
+                  push @file_not_found, '^No file\\s+(.+)\\s*$';
+
+              The regular expression itself is
+
+
+
+                                6 November 2023                             50
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
+                   ^Missing file\s+(.+)\s*$
+
+              But the corresponding string specification in the push statement
+              has to have the backslashes doubled.
+
+              This regular expression matches a  line  that  starts  with  'No
+              file',  then  has  one  or more white space characters, then any
+              number of characters forming the filename, then  possible  white
+              space,  and  finally the end of the line.  (See documentation on
+              Perl regular expressions for details.)
+
+
        $fls_uses_out_dir [0]
               This variable determines whether or not the .fls file should  be
               in  the output directory instead of the natural directory, which
@@ -3291,19 +3336,6 @@
               of the .fls file to be generated.
 
 
-
-
-
-
-                                 4 April 2023                               50
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
        $force_mode [0]
               If nonzero, continue processing past minor latex errors  includ-
               ing unrecognized cross references.  Equivalent to specifying the
@@ -3325,9 +3357,21 @@
 
               After  initialization  of latexmk and the processing of its com-
               mand line, the  items  in  clean_ext  are  appended  to  @gener-
-              ated_exts.   So  these two variables have the same meaning (con-
-              trary to older versions of latexmk).
+              ated_exts.   So  these  two  variables  have  the  same  meaning
 
+
+
+                                6 November 2023                             51
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
+              (contrary to older versions of latexmk).
+
               The items in @generated_exts are normally extensions  of  files,
               whose  base  name  is  the same as the main tex file.  But it is
               also possible to specify patterns including  that  basename  ---
@@ -3359,17 +3403,6 @@
               If nonzero, process files regardless of timestamps, and is  then
               equivalent to the -g option.
 
-
-
-                                 4 April 2023                               51
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
        %hash_calc_ignore_pattern
               !!!This variable is for experts only!!!
 
@@ -3391,6 +3424,18 @@
 
               This creates a rule for files with extension .eps about lines to
               ignore.  The left-hand side is a Perl idiom for setting an  item
+
+
+
+                                6 November 2023                             52
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
               in  a hash.  Note that the file extension is specified without a
               period.  The value, on the right-hand side, is a string contain-
               ing  a  regular  expression.  (See documentation on Perl for how
@@ -3424,18 +3469,6 @@
 
               This  specifies the jobname, i.e., the basename that is used for
               generated files (.aux, .log, .dvi, .ps,  .pdf,  etc).   If  this
-
-
-
-                                 4 April 2023                               52
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
               variable  is a null string, then the basename is the basename of
               the main tex file.  (At present, the string in  $jobname  should
               not contain spaces.)
@@ -3458,6 +3491,17 @@
 
                  latexmk -pdf *.tex
 
+
+
+                                6 November 2023                             53
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
               both  files  will  be  compiled.  The .aux, .log, and .pdf files
               will have basenames test1-MSWin32 ante test2-MSWin32  on  a  MS-
               Windows system, test1-darwin and test2-darwin on an OS-X system,
@@ -3490,18 +3534,6 @@
 
        $kpsewhich_show [0]
               Whether  to show diagnostics about invocations of kpsewhich: the
-
-
-
-                                 4 April 2023                               53
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
               command line use to invoke it and the results.   These  diagnos-
               tics  are shown if $kpsewhich_show is non-zero or if diagnostics
               mode is on.  (But in the second case, lots of other  diagnostics
@@ -3524,6 +3556,18 @@
 
               To do a coordinated setting  of  all  of  $dvilualatex,  $latex,
               $pdflatex,  $lualatex,  and  $xelatex, see the section "Advanced
+
+
+
+                                6 November 2023                             54
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
               Configuration".
 
 
@@ -3555,23 +3599,11 @@
 
               add  the  extension 'asdf to latex_input_extensions.  (Naturally
               with such an extension, you should have made an appropriate cus-
-              tom  dependency  for  latexmk,  and  should  also  have done the
+              tom dependency for latexmk, and should also have done the appro-
+              priate programming in the LaTeX source file to enable  the  file
+              to  be  read.   The standard extensions are handled by LaTeX and
+              its graphics/graphicx packages.)
 
-
-
-                                 4 April 2023                               54
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
-              appropriate programming in the LaTeX source file to  enable  the
-              file  to  be read.  The standard extensions are handled by LaTeX
-              and its graphics/graphicx packages.)
-
        $latex_silent_switch ["-interaction=batchmode"]
               Switch(es) for the LaTeX processing program when silent mode  is
               on.
@@ -3590,6 +3622,18 @@
               Under MS-Windows (unlike UNIX/Linux), there is no standard  pro-
               gram for printing files.  But there are ways you can do it.  For
               example, if you have gsview installed, you could use it with the
+
+
+
+                                6 November 2023                             55
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
               option "/p":
 
                   $lpr = '"c:/Program Files/Ghostgum/gsview/gsview32.exe" /p';
@@ -3622,18 +3666,6 @@
 
        $lualatex ["lualatex %O %S"]
               Specifies the command line for the LaTeX processing program that
-
-
-
-                                 4 April 2023                               55
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
               is to be used when the lualatex program is called for (e.g.,  by
               the option -lualatex.
 
@@ -3656,6 +3688,18 @@
               fault extensions are 'tex', 'pdf', 'jpg, and 'png'.
 
               See details of the %latex_input_extensions for other information
+
+
+
+                                6 November 2023                             56
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
               that equally applies to %lualatex_input_extensions.
 
        $lualatex_silent_switch ["-interaction=batchmode"]
@@ -3688,18 +3732,6 @@
               bail  out,  rather than rerunning *latex again to resolve cross-
               references, etc.  The default value covers all normal cases.
 
-
-
-
-                                 4 April 2023                               56
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
               (Note that the "etc" covers a lot of cases where one run of *la-
               tex generates files to be read in on a later run.)
 
@@ -3721,10 +3753,22 @@
               stitution from "/" to "\", by default.
 
               However  there  are also programs on MS-Windows for which a back
-              slash "\" is interpreted differently than as a directory separa-
-              tor;  for these the directory separator should be "/".  Programs
-              with this behavior  include  all  the  *latex  programs  in  the
-              TeXLive  implementation  (but  not  the  MiKTeX implementation).
+              slash  "\"  is  interpreted  differently  than  as  a  directory
+
+
+
+                                6 November 2023                             57
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
+              separator;  for  these  the  directory  separator should be "/".
+              Programs with this behavior include all the *latex  programs  in
+              the  TeXLive implementation (but not the MiKTeX implementation).
               Hence if you use TeXLive on MS-Windows,  then  $MSWin_back_slash
               should be set to zero.
 
@@ -3755,17 +3799,6 @@
 
 
 
-
-
-                                 4 April 2023                               57
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
        $pdf_mode [0]
               If  zero,  do  NOT  generate  a pdf version of the document.  If
               equal to 1, generate a pdf version of the document using  pdfla-
@@ -3788,6 +3821,17 @@
               Specifies the command line for the LaTeX processing program in a
               version that makes a pdf file instead of a dvi file.
 
+
+
+                                6 November 2023                             58
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
               An example use of this variable is to add certain options to the
               command line for the program, e.g.,
 
@@ -3820,18 +3864,6 @@
               See details of the %latex_input_extensions for other information
               that equally applies to %pdflatex_input_extensions.
 
-
-
-
-                                 4 April 2023                               58
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
        $pdflatex_silent_switch ["-interaction=batchmode"]
               Switch(es)  for  the pdflatex program (specified in the variable
               $pdflatex) when silent mode is on.
@@ -3854,6 +3886,18 @@
               preview, which is quite satisfactory.
 
               WARNING:  Problem under MS-Windows: if acroread is used  as  the
+
+
+
+                                6 November 2023                             59
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
               pdf  previewer,  and  it is actually viewing a pdf file, the pdf
               file cannot be updated.  Thus makes acroread  a  bad  choice  of
               previewer  if you use latexmk's previous-continuous mode (option
@@ -3887,17 +3931,6 @@
               Note that acroread under MS-Windows (but not UNIX) locks the pdf
               file, so the default value is then 3.
 
-
-
-                                 4 April 2023                               59
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
               Arranging to use a command to get a previewer explicitly updated
               requires three variables to be set.  For example:
 
@@ -3918,6 +3951,19 @@
               variable $pdf_update_method.  The default value is the  one  ap-
               propriate for gv on a UNIX system.
 
+
+
+
+
+                                6 November 2023                             60
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
        $pid_position[1 under UNIX, -1 under MS-Windows]
               The  variable  $pid_position  is  used  to specify which word in
               lines of the output from $pscmd corresponds to the  process  ID.
@@ -3953,17 +3999,6 @@
 
 
 
-
-
-                                 4 April 2023                               60
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
        $preview_continuous_mode [0]
               If nonzero, run a previewer to view the document,  and  continue
               running latexmk to keep .dvi up-to-date.  Equivalent to the -pvc
@@ -3982,6 +4017,19 @@
               mended not to be set from an RC file, otherwise you could  waste
               lots of paper.
 
+
+
+
+
+                                6 November 2023                             61
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
        $print_type = ["auto"]
               Type  of  file  to  printout:  possibilities  are "auto", "dvi",
               "none", "pdf", or "ps".   See the option -print= for the meaning
@@ -4018,18 +4066,6 @@
 
               Note  that  gv  could be used with the -watch option updates its
               display whenever the postscript file changes, whereas  ghostview
-
-
-
-                                 4 April 2023                               61
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
               does  not.  However, different versions of gv have slightly dif-
               ferent ways of writing this  option.   You  can  configure  this
               variable appropriately.
@@ -4049,6 +4085,17 @@
               in yourself, whenever it is needed.
 
 
+
+
+                                6 November 2023                             62
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
        $ps_previewer_landscape  ["start gv -swap %O %S", but start %O %S under
        MS-Windows]
               The command to invoke a ps-previewer in landscape mode.
@@ -4085,17 +4132,6 @@
               The period of inactivity, in minutes, after which pvc mode times
               out.  This is used if $pvc_timeout is nonzero.
 
-
-
-                                 4 April 2023                               62
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
        $pvc_view_file_via_temporary [1]
               The same as $always_view_file_via_temporary, except that it only
               applies in preview-continuous mode (-pvc option).
@@ -4115,6 +4151,17 @@
               correctly treated by the operating system in  passing  arguments
               to programs.)
 
+
+
+                                6 November 2023                             63
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
        $rc_report [1]
               After  initialization,  whether  to  give a list of the RC files
               read.
@@ -4150,18 +4197,6 @@
 
               [Comment  to  technically savvy readers: *latex doesn't actually
               need the modified search path.  But,  surprisingly,  dvipdf  and
-
-
-
-                                 4 April 2023                               63
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
               dvips  do, because sometimes graphics files get generated in the
               output or aux directories.]
 
@@ -4181,6 +4216,18 @@
 
               Note: On MS Windows, this is clock time.  On other OSs it is the
               CPU time used (by latexmk and the child processes  it  invokes).
+
+
+
+                                6 November 2023                             64
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
               The OS-dependence is because of a limitation of Windows.  If you
               wish to force the use of clock instead of CPU time, you can set
 
@@ -4217,17 +4264,6 @@
               A  value  of  exactly 0 gives no delay, and typically results in
               100% CPU usage, which may not be desirable.
 
-
-
-                                 4 April 2023                               64
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
        $texfile_search [""]
               This is an obsolete variable,  replaced  by  the  @default_files
               variable.
@@ -4245,10 +4281,22 @@
               while running.
 
               The  default  under MSWindows (including cygwin), is to set $tm-
-              pdir to the value of the first of whichever of the system  envi-
-              ronment  variables  TMPDIR or TEMP exists, otherwise to the cur-
-              rent directory.  Under other operating systems (expected  to  be
-              UNIX/Linux,  including  OS-X),  the  default is the value of the
+              pdir to the value of  the  first  of  whichever  of  the  system
+
+
+
+                                6 November 2023                             65
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
+              environment  variables  TMPDIR  or TEMP exists, otherwise to the
+              current directory.  Under other operating systems  (expected  to
+              be  UNIX/Linux, including OS-X), the default is the value of the
               system environment  variable  TMPDIR  if  it  exists,  otherwise
               "/tmp".
 
@@ -4282,18 +4330,6 @@
 
               When  the  variable  is  non-zero, latexmk at the end of its run
               will return a non-zero status code to the  operating  system  if
-
-
-
-                                 4 April 2023                               65
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
               any  of  the files processed gives a warning about problems with
               citations or references (i.e., undefined citations or references
               or multiply defined references).  This is after latexmk has com-
@@ -4312,6 +4348,18 @@
               ings as errors that require the  overall  build  process  to  be
               aborted.  Of course, since multiple runs of *latex are generally
               needed to resolve references and citations, what matters is  not
+
+
+
+                                6 November 2023                             66
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
               the warnings on the first run, but the warnings on the last run;
               latexmk takes this into account appropriately.
 
@@ -4348,18 +4396,6 @@
 
               Note about xelatex: latexmk uses xelatex to make an .xdv  rather
               than  .pdf  file, with the .pdf file being created in a separate
-
-
-
-                                 4 April 2023                               66
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
               step.  This is enforced by the use of the -no-pdf option.  If %O
               is  part  of the command for invoking xelatex, then latexmk will
               insert the -no-pdf option automatically, otherwise you must pro-
@@ -4378,6 +4414,18 @@
               not  been  found,  and  the  file is given without an extension.
               This typically happens when LaTeX  commands  of  the  form  \in-
               put{file}  or \includegraphics{figure}, when the relevant source
+
+
+
+                                6 November 2023                             67
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
               file does not exist.
 
               In this situation, latexmk searches for custom  dependencies  to
@@ -4415,17 +4463,6 @@
        A better method is to use the subroutines that allow convenient manipu-
        lations of the custom dependency list.  These are
 
-
-
-                                 4 April 2023                               67
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
            add_cus_dep( fromextension, toextension, must, subroutine )
            remove_cus_dep( fromextension, toextension )
            show_cus_dep()
@@ -4443,6 +4480,18 @@
        must:  If non-zero, the file from which we are converting  must  exist,
               if  it doesn't exist latexmk will give an error message and exit
               unless the -f option is specified.  If must is zero and the file
+
+
+
+                                6 November 2023                             68
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
               we  are  converting from doesn't exist, then no action is taken.
               Generally, the appropriate value of must is zero.
 
@@ -4480,18 +4529,6 @@
        rule is invoked, with an argument that is the base name of the files in
        question.  Simple cases just involve a subroutine invoking an  external
        program;  this  can  be  done by following the templates below, even by
-
-
-
-                                 4 April 2023                               68
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
        those without knowledge of the Perl programming language.   Of  course,
        experts could do something much more elaborate.
 
@@ -4509,6 +4546,18 @@
        Note for advanced usage: The operating  system's  environment  variable
        TEXINPUTS can be used to specify a search path for finding files by la-
        tex etc.  Correspondingly, when a missing  file  is  reported,  latexmk
+
+
+
+                                6 November 2023                             69
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
        looks  in the directories specified in TEXINPUTS as well as in the cur-
        rent directory, to find a source file from which an instance of a  cus-
        tom dependency can be used to make the missing file.
@@ -4546,18 +4595,6 @@
        of the form of a variable name, $_[0] in this case, is  to  be  substi-
        tuted by its value.
 
-
-
-
-                                 4 April 2023                               69
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
        If  the  return  value of the subroutine is non-zero, then latexmk will
        assume an error occurred during the execution of  the  subroutine.   In
        the  above  example, no explicit return value is given, and instead the
@@ -4575,6 +4612,18 @@
            }
 
        Note 1: In the command lines given in the system commands in the  above
+
+
+
+                                6 November 2023                             70
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
        examples,  double  quotes have been inserted around the file names (im-
        plemented by '\"' in the Perl language).  They immunize the running  of
        the  program against special characters in filenames.  Very often these
@@ -4613,17 +4662,6 @@
 
            remove_cus_dep( 'fig', 'eps' );
 
-
-
-                                 4 April 2023                               70
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
        If  you  have  complicated sets of custom dependencies, you may want to
        get a listing of the custom dependencies.  This is done  by  using  the
        line
@@ -4639,14 +4677,26 @@
        file.   This  method  has been available since very old versions of la-
        texmk, and many examples can be found, e.g., on the web.
 
-       However in later versions of latexmk the internal structure of the  im-
-       plementation of its "rules" for the steps of processing, including cus-
-       tom dependencies, became much more powerful.  The function implementing
-       a custom dependency is executed within a special context where a number
-       of extra variables and subroutines are  defined.   Publicly  documented
-       ones,  intended  to  be  long-term  stable, are listed below, under the
-       heading "Variables and subroutines for processing a rule".
+       However in later versions of latexmk  the  internal  structure  of  the
 
+
+
+                                6 November 2023                             71
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
+       implementation  of  its  "rules" for the steps of processing, including
+       custom dependencies, became much more powerful.   The  function  imple-
+       menting  a custom dependency is executed within a special context where
+       a number of extra variables and subroutines are defined.  Publicly doc-
+       umented  ones, intended to be long-term stable, are listed below, under
+       the heading "Variables and subroutines for processing a rule".
+
        Examples of their use is given in the  following  examples,  concerning
        multiple index files and glossaries.
 
@@ -4678,18 +4728,6 @@
        function to simplify the definitions to use a single function:
 
            add_cus_dep( 'ndx', 'nnd', 0, 'dx2nd' );
-
-
-
-                                 4 April 2023                               71
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
            add_cus_dep( 'adx', 'and', 0, 'dx2nd' );
            sub dx2nd {
                return Run_subst( "makeindex -o %D %S" );
@@ -4706,6 +4744,18 @@
            push @generated_exts, 'ndx', 'nnd', 'adx', 'and';
 
        This last example uses the command specification in $makeindex, and  so
+
+
+
+                                6 November 2023                             72
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
        any  customization you have made for the standard index also applies to
        your extra indexes.
 
@@ -4744,18 +4794,6 @@
            }
 
        This  method  still  works,  and is almost equivalent to the code given
-
-
-
-                                 4 April 2023                               72
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
        earlier that used the add_cus_dep subroutine.  However, the old  method
        doesn't  delete any previous custom-dependency for the same conversion.
        So the new method is preferable.
@@ -4771,10 +4809,22 @@
 
        See also the section DEALING WITH ERRORS, PROBLEMS, ETC.  See also  the
        examples in the directory example_rcfiles in the latexmk distributions.
-       Even if none of the examples apply to your case, they may give you use-
-       ful ideas
+       Even if none of the examples apply to your  case,  they  may  give  you
 
 
+
+                                6 November 2023                             73
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
+       useful ideas
+
+
    Utility subroutines
        ensure_path( var, values ...)
 
@@ -4809,20 +4859,8 @@
        nal" -- see the section FORMAT OF COMMAND SPECIFICATIONS.
 
        When  you use a subroutine for processing a rule, all the possibilities
-       of Perl programming are available, of course.   In  addition,  some  of
-
-
-
-                                 4 April 2023                               73
-
-
-
-
-
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
-
-
-       latexmk's  internal  variables and subroutines are available.  The ones
+       of Perl programming are available, of course.  In addition, some of la-
+       texmk's  internal  variables  and  subroutines are available.  The ones
        listed below are intended to be  available  to  (advanced)  users,  and
        their specifications will generally have stability under upgrades. Gen-
        erally, the variables should be treated as  read-only:  Changing  their
@@ -4837,17 +4875,87 @@
               This gives the name of the primary source file.  Note the double
               dollar signs.
 
+
+
+
+
+                                6 November 2023                             74
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
        $$Pdest
               This  gives  the  name of the main output file if any.  Note the
               double dollar signs.
 
+
+       pushd( path ), popd()
+              These subroutines are used when  it  is  needed  to  temporarily
+              change the working directory, as in
+
+                   pushd( 'some_directory' );
+                   ...  Processing  done  with 'some_directory' as the working
+              directory
+                   popd()
+
+              They perform exactly the same function as the  commands  of  the
+              same names in operating system command shells like bash on Unix,
+              and cmd.exe on the Windows.
+
+
+       rdb_add_generated( file, ... )
+              This subroutine is to be used in the context of a rule, that is,
+              from  within  a  subroutine that is carrying out processing of a
+              rule.  Such is the case for the subroutine implementing a custom
+              dependency,  or  the  subroutine invoked by using the "internal"
+              keyword in the command specification like that in  the  variable
+              $latex.
+
+              Its  arguments  are  a sequence of filenames which are generated
+              during the running of the rule.  The names might arise  from  an
+              analysis of the results of the run, e.g., in a log file, or from
+              knowledge  of  properties  of  the   specific   rule.    Calling
+              rdb_add_generated  with these filenames ensures that these files
+              are flagged as generated by the rule in latexmk's internal  data
+              structures.  Basically, no action is taken if the files have al-
+              ready been flagged as generated.
+
+              A main purpose of using this subroutine  is  for  the  situation
+              when  a generated file is also the source file for some rule, so
+              that latexmk can correctly link the  dependency  information  in
+              its network of rules.
+
+              Note: Unlike some other subroutines in this section, there is no
+              argument for a rule for rdb_add_generated. Instead, the  subrou-
+              tine  is  to be invoked during the processing of a rule when la-
+              texmk has set up an appropriate context (i.e., appropriate vari-
+              ables).   In  contrast,  subroutines with a rule argument can be
+              used also outside a rule context.
+
+
        rdb_ensure_file( $rule, file )
-              This a subroutine that ensures that the given file is among  the
-              source files for the specified rule.  It is typically used when,
-              during the processing of a rule, it is known that  a  particular
-              extra  file  is among the dependencies that latexmk should know,
-              but its default methods don't find the dependency. Almost always
-              the  first argument is the name of the rule currently being pro-
+              This subroutine ensures that the given file is among the  source
+              files for the specified rule.  It is typically used when, during
+              the processing of a rule, it is known that  a  particular  extra
+              file is among the dependencies that latexmk should know, but its
+
+
+
+                                6 November 2023                             75
+
+
+
+
+
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
+
+
+              default methods don't find the  dependency.  Almost  always  the
+              first  argument  is  the  name  of the rule currently being pro-
               cessed, so it is then appropriate to specify it by $rule.
 
               For examples of its use, see some of the files in the  directory
@@ -4857,16 +4965,34 @@
               where latexmk's normal processing fails to detect certain  extra
               source files.
 
+              Note that rdb_ensure_file only has one filename argument, unlike
+              other subroutines in this section.  If you want to apply its ac-
+              tion  to  multiple  files,  you  will  need  one call to rdb_en-
+              sure_file for each file.
+
+
        rdb_remove_files( $rule, file, ... )
-              This  subroutine  removes  one or more files from the dependency
+              This subroutine removes one or more files  from  the  dependency
               list for the given rule.
 
+
+       rdb_remove_generated( file, ... )
+              This subroutine is to be used in the context of a rule, that is,
+              from within a subroutine that is carrying out  processing  of  a
+              rule.   It  performs  the  opposite action to rdb_add_generated.
+              Its effect is to ensure that the given filenames are not  listed
+              in  latexmk's internal data structures as being generated by the
+              rule.
+
+
        rdb_list_source( $rule )
               This subroutine returns the list of source files (i.e., the  de-
               pendency list) for the given rule.
 
+
        rdb_set_source( $rule, file, ... )
 
+
        rdb_set_source( $rule, @files )
               This  subroutine  sets the dependency list for the given rule to
               be the specified files.  Files that are already in the list have
@@ -4876,10 +5002,16 @@
               dency list.
 
 
+       Run_subst( command_spec )
+              This subroutine runs the command specified by command_spec.  The
+              specification  is  a  string in the format listed in the section
+              "Format of Command Specifications".  An important action of  the
+              Run_subst is to make substitutions of placeholders, e.g., %S and
+              %D for source  and  destination  files;  these  get  substituted
 
 
 
-                                 4 April 2023                               74
+                                6 November 2023                             76
 
 
 
@@ -4888,14 +5020,8 @@
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-       Run_subst( command_spec )
-              This subroutine runs the command specified by command_spec.  The
-              specification  is  a  string in the format listed in the section
-              "Format of Command Specifications".  An important action of  the
-              Run_subst is to make substitutions of placeholders, e.g., %S and
-              %D for source and destination files; these get  substituted  be-
-              fore the command is run.  In addition, the command after substi-
-              tution is printed to the screen unless  latexmk  is  running  in
+              before  the command is run.  In addition, the command after sub-
+              stitution is printed to the screen unless latexmk is running  in
               silent mode.
 
 
@@ -4942,10 +5068,16 @@
        Note that when '%O' appears after the added option,  as  here,  options
        provided on the command line to latexmk can override the supplied one.
 
+       A more general command line can be set up by using the placeholder '%C'
+       in CMD_SPEC.  The '%C' is substituted by the basic name of the command,
+       i.e., whichever of 'latex', 'pdflatex', etc is appropriate.  (More than
+       one occurrence of '%C' is allowed.)  For example to  use  the  develop-
+       ment/pre-release versions of latex, etc, which have names, 'latex-dev',
+       'pdflatex-dev', etc, you could use
 
 
 
-                                 4 April 2023                               75
+                                6 November 2023                             77
 
 
 
@@ -4954,13 +5086,6 @@
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-       A more general command line can be set up by using the placeholder '%C'
-       in CMD_SPEC.  The '%C' is substituted by the basic name of the command,
-       i.e., whichever of 'latex', 'pdflatex', etc is appropriate.  (More than
-       one occurrence of '%C' is allowed.)  For example to  use  the  develop-
-       ment/pre-release versions of latex, etc, which have names, 'latex-dev',
-       'pdflatex-dev', etc, you could use
-
          set_tex_cmds( '%C-dev %O %S' );
 
        This results in $latex = 'latex-dev %O %S', etc.  (The pre-release pro-
@@ -5008,25 +5133,25 @@
        suitable Makefile is like
 
            .PHONY : FORCE_MAKE
+           all : try.pdf
+           %.pdf : %.tex FORCE_MAKE
+               latexmk -pdf -dvi- -ps- $<
 
+       (Note: the last line must be introduced by a tab for  the  Makefile  to
+       function  correctly!)  Naturally, if making try.pdf from its associated
+       LaTeX file try.tex were the only task to be performed, a direct use  of
 
 
-                                 4 April 2023                               76
 
+                                6 November 2023                             78
 
 
 
 
+
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-           all : try.pdf
-           %.pdf : %.tex FORCE_MAKE
-               latexmk -pdf -dvi- -ps- $<
-
-       (Note: the last line must be introduced by a tab for  the  Makefile  to
-       function  correctly!)  Naturally, if making try.pdf from its associated
-       LaTeX file try.tex were the only task to be performed, a direct use  of
        latexmk  without  a  Makefile would normally be better.  The benefit of
        using a Makefile for a LaTeX document would be  in  a  larger  project,
        where lines such as the above would be only be a small part of a larger
@@ -5074,25 +5199,25 @@
        dles automatic dependency tracking of C source files.
 
        After  each  run of latexmk, dependency information is put in a file in
+       the .deps subdirectory.  The Makefile causes these dependency files  to
+       be read by make, which now has the full dependency information for each
+       target .pdf file.  To make things less trivial it  is  specificed  that
+       two  files document1.pdf and document2.pdf are the targets.  The depen-
+       dency files are .deps/document1.pdfP and .deps/document2.pdfP.
 
+       There is now no need for the phony prerequisite for the  rule  to  make
 
 
-                                 4 April 2023                               77
 
+                                6 November 2023                             79
 
 
 
 
+
 LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-       the .deps subdirectory.  The Makefile causes these dependency files  to
-       be read by make, which now has the full dependency information for each
-       target .pdf file.  To make things less trivial it  is  specificed  that
-       two  files document1.pdf and document2.pdf are the targets.  The depen-
-       dency files are .deps/document1.pdfP and .deps/document2.pdfP.
-
-       There is now no need for the phony prerequisite for the  rule  to  make
        .pdf files from .tex files.  But I have added a rule to make .pdf files
        from .fig files produced by the xfig program; these are  commonly  used
        for  graphics  insertions  in  LaTeX documents.  Latexmk is arranged to
@@ -5140,26 +5265,25 @@
        names on Windows, even though there were no corresponding  problems  on
        macOS and Linux.  These problems are corrected in the present version.
 
+       DETAILS TO BE FILLED IN
 
 
 
-                                 4 April 2023                               78
+SEE ALSO
+       latex(1), bibtex(1), lualatex(1), pdflatex(1), xelatex(1).
 
 
 
 
+                                6 November 2023                             80
 
-LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
 
-       DETAILS TO BE FILLED IN
 
 
+LATEXMK(1)                  General Commands Manual                 LATEXMK(1)
 
-SEE ALSO
-       latex(1), bibtex(1), lualatex(1), pdflatex(1), xelatex(1).
 
-
 BUGS (SELECTED)
        Sometimes a viewer (gv) tries to read an updated .ps or .pdf file after
        its creation is started but before the file is complete.  Work  around:
@@ -5186,12 +5310,12 @@
        dard form to avoid being harvested too easily.)
 
 AUTHOR
-       Current version, by John Collins (Version 4.80).  Report  bugs  etc  to
+       Current version, by John Collins (Version 4.81).  Report  bugs  etc  to
        his e-mail (jcc8 at psu.edu).
 
        Released      version      can      be      obtained     from     CTAN:
        <http://www.ctan.org/pkg/latexmk/>,  and  from  the  author's   website
-       <http://www.personal.psu.edu/jcc8/latexmk/>.
+       <https://www.cantab.net/users/johncollins/latexmk/>.
        Modifications and enhancements by Evan McLean (Version 2.0)
        Original script called "go" by David J. Musliner (RCS Version 3.2)
 
@@ -5209,6 +5333,14 @@
 
 
 
-                                 4 April 2023                               79
 
 
+
+
+
+
+
+
+                                6 November 2023                             81
+
+

Modified: trunk/Master/texmf-dist/scripts/latexmk/latexmk.pl
===================================================================
--- trunk/Master/texmf-dist/scripts/latexmk/latexmk.pl	2023-11-09 22:13:34 UTC (rev 68768)
+++ trunk/Master/texmf-dist/scripts/latexmk/latexmk.pl	2023-11-09 22:13:57 UTC (rev 68769)
@@ -42,8 +42,8 @@
 
 $my_name = 'latexmk';
 $My_name = 'Latexmk';
-$version_num = '4.80';
-$version_details = "$My_name, John Collins, 4 Apr. 2023. Version $version_num";
+$version_num = '4.81';
+$version_details = "$My_name, John Collins, 6 Nov. 2023. Version $version_num";
 
 use Config;
 use File::Basename;
@@ -82,7 +82,7 @@
 use Digest::MD5;
 
 # **WARNING**: Don't import time; that overrides core function time(), and messes up
-#  
+#  somethings
 use Time::HiRes;
 
 #################################################
@@ -312,6 +312,7 @@
 # v. pdflatexmk, etc):
 (our $invoked_name) = fileparseA($0);
 
+# Save name, since I override it if I don't recognize it
 our $invoked_kind = $invoked_name;
 print "$My_name: Invoked as '$invoked_name'\n"
     if ($invoked_name ne 'latexmk');
@@ -360,6 +361,11 @@
 # It is the parameter max_print_line in the TeX program.  (tex.web)
 $log_wrap = 79;
 
+# Expected biggest construct in log file in bytes.
+# Use to limit number of (potentially) wrapped lines to combine into single line.
+$max_log_construct = 600;
+
+
 #########################################################################
 ## Default parsing and file-handling settings
 
@@ -372,8 +378,8 @@
 ##     push @file_not_found, '^No data file found `([^\\\']*)\\\'';
 ## will give match to line starting "No data file found `filename'"
 @file_not_found = (
-    '^No file\\s*(.*)\\.$',
-    '^No file\\s*(.+)\s*$',
+    '^No file\\s+(.*)\\.$',
+    '^No file\\s+(.+)\s*$',
     '^\\! LaTeX Error: File `([^\\\']*)\\\' not found\\.',
     '^\\! I can\\\'t find file `([^\\\']*)\\\'\\.',
     '.*?:\\d*: LaTeX Error: File `([^\\\']*)\\\' not found\\.',
@@ -559,7 +565,7 @@
 #       and because of the possibility of extra bibtex/biber rules with
 #       non-standard basename.
 @generated_exts = ( 'aux', 'bcf', 'fls', 'idx', 'ind', 'lof', 'lot', 
-                    'out', 'toc',
+                    'out', 'run.xml', 'toc',
                     'blg', 'ilg', 'log',
                     'xdv'
                   );
@@ -1459,7 +1465,7 @@
 
 
 # Data for 1 run and global (ending in '0'):
-our ( $processing_time1, $processing_time0, @timings1, @timings0);
+our ( $clock1, $processing_time1, $processing_time0, @timings1, @timings0);
 &init_timing_all;
 
 
@@ -1913,8 +1919,21 @@
 %rc_files_read2 = (); # Map **abs** filename to 1; used to check duplicate reads.
 
 # Options that are to be obeyed before rc files are read:
+# Also under MSWin32 and msys, CL arguments sometimes get quotes in them.
+# (Specific example: TeXLive 2023 with msys's perl and arguments containing
+# both non-ASCII character, when latexmk.exe invoked from cmd.exe. In some
+# other situations (powershell and msys's terminal+bash), it seems that both
+# space and non-ASCII character are needed to trigger a problem.)
 foreach $_ ( @ARGV )
 {
+    if ( ($^O eq "MSWin32") || ($^O eq 'msys') ) {
+        # "arg" -> arg.
+        # -..="arg" -> -..=arg.
+        # In both cases, only do this if there are no other ".  Otherwise I
+        # my run afoul of " that are intended to be there. 
+        s/^\"([^\"]+)\"$/$1/;
+        s/^(-[^\"=]+=)\"([^\"]+)\"$/$1$2/;
+    }
     if (/^-{1,2}norc$/ ) {
         $auto_rc_use = 0;
     }
@@ -2020,8 +2039,18 @@
   elsif (/^-diagnostics/) { $diagnostics = 1; }
   elsif (/^-dir-report$/)    { $aux_out_dir_report = 1; }
   elsif (/^-dir-report-$/)   { $aux_out_dir_report = 0; }
-  elsif (/^-dvi$/)    { $dvi_mode = 1; }
-  elsif (/^-dvilua$/) { $dvi_mode = 2; }
+  elsif (/^-dvi$/)    { $dvi_mode = 1;
+                        if ( ($pdf_mode != 2) && ($pdf_mode != 3) ) {
+                            # if pdf_mode is not via dvi or pdf, turn it off
+                            $pdf_mode = 0;
+                        }
+                      }
+  elsif (/^-dvilua$/) { $dvi_mode = 2;
+                        if ( ($pdf_mode != 2) && ($pdf_mode != 3) ) {
+                            # if pdf_mode is not via dvi or pdf, turn it off
+                            $pdf_mode = 0;
+                        }
+                      }
   elsif (/^-dvi-$/)   { $dvi_mode = 0; }
   elsif ( /^-dvilualatex=(.*)$/ ) {
       $dvilualatex = $1;
@@ -2101,7 +2130,10 @@
       my $format = $1;
       if ($format eq 'dvi' ) {
           $dvi_mode = 1;
-          $pdf_mode = $postscript_mode = 0;
+          if ( ($pdf_mode != 2) && ($pdf_mode != 3) ) {
+              # if pdf_mode is not via dvi or pdf, turn it off
+              $pdf_mode = 0;
+          }
       }
       elsif ($format eq 'pdf' ) {
           $pdf_mode = 1;
@@ -2117,12 +2149,12 @@
                        $preview_mode = 0;  
                      }
   elsif (/^-p-$/)    { $printout_mode = 0; }
-  elsif (/^-pdf$/)   { $pdf_mode = 1; }
+  elsif (/^-pdf$/)   { $pdf_mode = 1; $dvi_mode = $postscript_mode = 0; }
   elsif (/^-pdf-$/)  { $pdf_mode = 0; }
   elsif (/^-pdfdvi$/){ $pdf_mode = 3; }
-  elsif (/^-pdflua$/){ $pdf_mode = 4; }
+  elsif (/^-pdflua$/){ $pdf_mode = 4; $dvi_mode = $postscript_mode = 0; }
   elsif (/^-pdfps$/) { $pdf_mode = 2; }
-  elsif (/^-pdfxe$/) { $pdf_mode = 5; }
+  elsif (/^-pdfxe$/) { $pdf_mode = 5; $dvi_mode = $postscript_mode = 0; }
   elsif (/^-pdflatex$/) {
       $pdflatex = "pdflatex %O %S";
       $pdf_mode = 1;
@@ -2150,7 +2182,12 @@
           &exit_help("$My_name: unknown print type '$value' in option '$_'");
       }
   }
-  elsif (/^-ps$/)    { $postscript_mode = 1; }
+  elsif (/^-ps$/)    { $postscript_mode = 1;
+                       if ( ($pdf_mode != 2) && ($pdf_mode != 3) ) {
+                           # if pdf_mode is not via dvi or pdf, turn it off
+                           $pdf_mode = 0;
+                       }
+                      }
   elsif (/^-ps-$/)   { $postscript_mode = 0; }
   elsif (/^-pv$/)    { $preview_mode = 1; 
                        $preview_continuous_mode = 0; # to avoid conflicts
@@ -2391,7 +2428,10 @@
         push( @file_list, $file)  unless ( exists $excl{$file} );
     }    
     if ( !@file_list ) {
-        &exit_help( "No file name specified, and I couldn't find any");
+        &exit_help(
+           "No file name(s) specified on command line, and no files match the\n".
+           "patterns in the default list."
+        );
     }
 }
 
@@ -2715,10 +2755,17 @@
     $failure_msg = '';   # Indicate reason for failure
 
     if ( $do_cd ) {
-       ($filename, $path) = fileparse( $filename );
-       print "$My_name: Changing directory to '$path'\n"
-           if !$silent;
-       pushd( dirname_no_tail( $path ) );
+        # Use my fileparse routine rather than the built-in one, otherwise
+        # under msys, a directory separator \ won't be recognized by fileparse.
+        # My routines fix that.  At this point, $filename ought to have had its
+        # \s changed to /s.  But I won't leave boobytrapped code.
+        # I use fileparseB rather than fileparseA, because fileparseA changes
+        # path './' to '', but fileparseB keeps the fileparse behavior there.
+        # I have to supply an explicit pattern of '' to keep extension in $filename.
+        ($filename, $path) = fileparseB( $filename, '' );
+        print "$My_name: Changing directory to '$path'\n"
+            if !$silent;
+        pushd( dirname_no_tail( $path ) );
     }
     else {
         $path = '';
@@ -2853,7 +2900,7 @@
     &init_timing1;
 
     if ($compiling_cmd) { Run_subst( $compiling_cmd ); }
-    $failure = &rdb_make;
+    $failure = rdb_make();
     if ( ( $failure <= 0 ) || $force_mode ) {
       rdb_for_some( [keys %one_time], \&rdb_run1 );
     }
@@ -2896,7 +2943,7 @@
         push @failed_primaries, $filename;
     }
     &ifcd_popd;
-    if ($show_time) { &show_timing1; };
+    if ($show_time && ! $preview_continuous_mode) { &show_timing1; };
     print "\n";
 }
 close($deps_handle) if ( $deps_handle );
@@ -2981,6 +3028,7 @@
     # Initialize timing for one run.
     @timings1 = ();
     $processing_time1 = processing_time();    
+    $clock1 = Time::HiRes::time();
 }
 
 ############################
@@ -2997,8 +3045,17 @@
 sub show_timing1 {
     # Show timing for one run.
     my $processing_time = processing_time() - $processing_time1;
+    my $invoked_time = 0;
+    for (@timings1) {
+        if (/: time = (.*)\s$/) {
+            $invoked_time += $1;
+    }}
     print @timings1, "Processing time = ",
-          sprintf('%.2f', $processing_time), "\n";
+        sprintf('%.2f', $processing_time),
+        ", of which invoked processes = $invoked_time, other = ",
+        sprintf( '%.2f', $processing_time-$invoked_time ), ".\n";
+    print "Elapsed clock time = ",
+          sprintf( '%.2f', Time::HiRes::time()-$clock1 ), ".\n";
     print "Number of rules run = ", 1+$#timings1, "\n";
 }
 
@@ -4194,7 +4251,7 @@
         if ($compiling_cmd) {
             Run_subst( $compiling_cmd );
         }
-        $failure = &rdb_make;
+        $failure = rdb_make();
 
         if ( $MSWin_fudge_break && ($^O eq "MSWin32") ) {
             $SIG{BREAK} = $SIG{INT} = 'DEFAULT';
@@ -4381,7 +4438,16 @@
     my ($rc_file, $repeat_reaction) = @_;
     my $abs_rc = abs_path($rc_file);
     my $ret_code = 0;
-    if ( exists $rc_files_read2{$abs_rc} ) {
+    if ( (!-e $rc_file) || ( ! defined $abs_rc ) ) {
+        warn "$My_name: The rc-file '$rc_file' does not exist\n";
+        return 1;
+    }
+    elsif ( -d $rc_file ) {
+        warn "$My_name: The supposed rc-file '$rc_file' is a directory; but it\n",
+             "          should be a normal text file\n";
+        return 1;
+    }
+    elsif ( exists $rc_files_read2{$abs_rc} ) {
         if ( $repeat_reaction ) { 
             warn
                 "$My_name: A user -r option asked me to process an rc file an extra time.\n",
@@ -4407,16 +4473,7 @@
     #    current versions of Perl (Nov. 2022), so "do latexmkrc;" for
     #    latexmkrc in cwd fails.
     # So I'll read the rc file and eval its contents.
-    if ( !-e $rc_file ) {
-        warn "$My_name: The rc-file '$rc_file' does not exist\n";
-        return 1;
-    }
-    elsif ( -d $rc_file ) {
-        warn "$My_name: The supposed rc-file '$rc_file' is a directory; but it\n",
-             "          should be a normal text file\n";
-        return 1;
-    }
-    elsif ( open( my $RCH, "<", $rc_file ) ) {
+    if ( open( my $RCH, "<", $rc_file ) ) {
         my $code = '';
         # Read all contents of file into $code:
         { local $/ = undef; $code = <$RCH>;}
@@ -5188,7 +5245,7 @@
 
 #**************************************************
 
-sub correct_aux_out_files {
+sub correct_locations {
     # Deal with situations after a *latex run where files are in different
     # directories than expected (specifically aux v. output directory).
     # Do minimal fix ups to allow latexmk to analyze dependencies with log
@@ -5279,7 +5336,7 @@
             warn "$My_name: fls file doesn't appear to have been made.\n";
         }
     }
-} # END correct_aux_out_files
+} # END correct_locations
 
 #-----------------
 
@@ -6197,21 +6254,61 @@
     #                    ref to array to receive lines,
     #                    ref to hash to receive diagnostic etc informaion )
     # 3rd argument is optional
-    # Lines are unwrapped and converted to CS_system.
+    # Lines are unwrapped and converted to the CS_system coding system (so
+    #   that filenames are suitable for use in file opening calls and on
+    #   command line to invoked programs).
+    #
+    # **Complication**: When writing to the .log file, *latex converts
+    #   lines longer than a given length (by default, 79) to a sequence
+    #   of lines with at most the maximum length.
+    #   This subroutine converts such sequences of lines to the original
+    #   unwrapped form.
+    #   **However**,
+    #   1. The algorithm for line wrapping differs between all of pdflatex,
+    #      xelatex, and lualatex.  See below for details.
+    #   2. It is possible to write an unwrapped line L1 of a relevant
+    #      length followed by a shorter line L2, such that it is impossible
+    #      to distingish it from a wrapped line whose contents were those
+    #      of L1 concatenated with L2.
+    #   So when it is determined that a line is potentially wrapped,
+    #   several possibilities for the unwrapped lines are added to the
+    #   output array of lines (referenced by the second argument), so that
+    #   subsequent scanning of the lines in the subroutine parse_log picks
+    #   up the possible diagnostic messages independently of complications
+    #   in identifying wrapped lines versus unwrapped lines.
     
     my ($file, $PAlines, $PHinfo) = @_;
-
     # Where lines are wrapped at.  We'll sometimes override.
     local $log_wrap = $log_wrap;
 
+    # Lines held for wrapping:
+    my @held_lines = ();
+    # Routine for setting wrapped lines; setup by assignment to keep visibility
+    # in the enclosing subroutine, and to access its my-variables:
+    my $Pwrap_sub =
+    sub {
+        for ( my $i=0; $i <= $#held_lines; $i++ ) {
+            my $line = '';
+            for ( my $j=$i; $j <= $#held_lines; $j++ ) {
+                last if ($j-$i > 1 + ($max_log_construct /$log_wrap) );
+                $line .= $held_lines[$j];
+                push @$PAlines, $line;
+            }
+        }
+        @held_lines = ();
+    };
+
+
     my $engine = '';
     my $tex_distribution = '';
-    my ($line_num, $cont, $max_len) = ( 0, 0, 0 );
+    my ($line_num, $max_len) = ( 0, 0 );
     my $lua_mode = 0;  # Whether to use luatex-specific wrapping method.
-    my $byte_wrapping = 1;  # *latex does byte wrapping.  Modify if we find
-                            # log file is generated by a tex program that
-                            # wrapping by Unicode code points.
-
+    my $byte_wrapping = 1;  # Assume by default that the wrapping occurs at
+                            # a certain number of bytes. Modify this
+                            # variable if we find that the log file was
+                            # generated by a tex program that does wrapping
+                            # at a certain number of Unicode code points. 
+    # The details for the different programs (underlying the *latex programs):
     # File encoding: pdftex: UTF-8 but with wrapping at $log_wrap BYTES.
     #                        (So individual wrapped lines can be malformed
     #                        UTF-8, but we get valid UTF-8 after unwrapping.)
@@ -6218,7 +6315,7 @@
     #                luatex: UTF-8 but with wrapping at APPROXIMATELY
     #                        $log_wrap bytes. Rest as pdftex
     #                xetex:  UTF-8 with wrapping at $log_wrap codepoints.
-    # So we read file as bytes
+    # So we read file as bytes.  Then
     #   first line gives which program was used and hence whether to wrap
     #     according to byte or codepoint count.
     #   wrapping is always performed on the encoded byte strings, but the
@@ -6262,18 +6359,47 @@
         }
         if ($len > $max_len) { $max_len = $len }
 
-        # Is this line continuation of previous line?
-        if ($cont) { $$PAlines[$#$PAlines] .= $_; }
-        else { push @$PAlines, $_ }
-
         # Is this line wrapped? I.e., is next line to be appended to it?
-        # Allow for fact that luatex doesn't reliably wrap at std place, e.g., 79.
-        $cont = ($len == $log_wrap)
+        # 2 cases:
+        #     pdflatex and xelatex wrap at exactly length $log_wrap 
+        #         (default 79), and normally append empty line when line
+        #         is exactly of the maximimum length (so we shouldn't have a
+        #         problem of distinguishing a wrapped line from a line of
+        #         length exactly $log_wrap).
+        #     lualatex: Wrap at a variable position dependent in a complicated
+        #         way on contents.  With default settings, wrapping occurs
+        #         between 77 and 80 bytes, according to my tests.  It preserves
+        #         UTF-8 coding, and doesn't split multi-byte UTF-8 coding of
+        #         a code point between lines, unlike pdflatex. But details
+        #         of exactly where a line is wrapped is not clear.
+        #         It is not possible in all cases to distinguish whether
+        #         a pair of lines arise from wrapping of a longer line
+        #         or from actual writing of a pair of lines.
+        # Determine whether line is potentially wrapped:
+        my $cont = ($len == $log_wrap)
             || ( $lua_mode && ($len >= $log_wrap-2) && ($len <= $log_wrap+1) );
-        if ($cont && $diagnostics ) {
-            print "====Continuing line $line_num of length $len\n$_\n";
+        if ($cont) {
+            # Save lines that may be continued onto @held_lines
+            print "====Continuing line $line_num of length $len\n$_\n"
+            if $diagnostics;
+            push @held_lines, $_;
         }
+        elsif (@held_lines) {
+            # No more continuation lines after this:
+            push @held_lines, $_;
+            # Put possibilities for lines before wrapping onto the main
+            # array and then clear @held_lines
+            &$Pwrap_sub();
+        }
+        else {   
+            push @$PAlines, $_;
+        }
     }
+    if (@held_lines) {
+        # Get here if the last line of the file is of a length that
+        # it may be a wrapped.
+        &$Pwrap_sub();
+    }
     close($fh);
     foreach (@$PAlines) { $_ = utf8_to_mine($_); }
     push @$PAlines, "";  # Blank line to terminate.  So multiline blocks 
@@ -6330,7 +6456,7 @@
         #  is produced by MS-Windows program (e.g., in MiKTeX) with CRLF line ends,
         #  but is read by Unix Perl (which treats LF as line end, and preserves CRLF
         #  in read-in lines):
-        # And convert '\'
+        # And convert '\' to '/'
         s/\r?\n$//;
         s[\\][/]g;
         $line_no++;
@@ -6340,10 +6466,17 @@
         }
         else {
             # Deal with MS-Win issues when system CP isn't UTF-8
-            if ( ($^O eq 'MSWin32') && /PWD/ && ! is_valid_utf8($_) ) {
-                # TeXLive on MSWin produces PWD in CS_system not UTF-8.
-                # ???? Later get tex_distribution before analyzing fls file, so do better test.
-                print "PWD line not in UTF-8.  This is normal for TeXLive. I will handle it.\n";
+            # Situation is that the fls file should be in UTF-8 and
+            # needs to be converted to system CP to fit with latexmk's
+            # convention (determined by file-system calls).
+            # However, under Windows' TeXLive 2021 (and maybe earlier) the
+            # PWD uses the system CP while the rest of the file is UTF-8.
+            # In TeXLive 2022 and 2023, the whole file, including the PWD
+            # line is UTF-8. 
+            # So give special treatment to PWD line under Windows.
+            # Also to guard against any other problems, check for non-UTF-8 lines. 
+            if ( ($^O eq 'MSWin32') && /PWD/ && ! is_valid_utf8($_) ) {                               print
+                  "PWD line not in UTF-8.  This is normal for older TeXLives (2021 and earlier).\n".                                                                                        "I will handle it.\n";
                 # Assume in CS_system, no change needed.
             }
             elsif ( ! is_valid_utf8($_) ) {
@@ -6548,8 +6681,12 @@
 sub normalize_filename_abs {
     # Convert filename to be either
     # absolute path in canonical form
-    # or relative to cwd.
-    return normalize_filename( abs_path($_[0]) );
+    # or relative to cwd, if possible.
+    # abs_path returns undef if it doesn't know how to get an absolute path.
+    # Just work with the original path in that case.
+    my $abs = abs_path($_[0]);
+    if (! defined $abs) { $abs = $_[0]; }
+    return normalize_filename( $abs );
 }
 
 #-----------------------------
@@ -6770,7 +6907,7 @@
         return 2;
     }
 
-    show_array( "$My_name: Bibliography file(s) form .bcf file:", @$Pbib_files )
+    show_array( "$My_name: Bibliography file(s) from .bcf file:", @$Pbib_files )
         unless $silent;
     if (@not_found_bib) {
         show_array(
@@ -8175,6 +8312,10 @@
                    "   I'll try making it with allowed extensions \n";
              foreach my $try_ext ( keys %$Pinput_extensions ) {
                  my $new_dest = "$file.$try_ext";
+                 if (-e $new_dest) {
+                     # A file that exists cannot have been the missing file.
+                     next;
+                 }
                  &Run_subst( "$make $quote$new_dest$quote" );
                  if ( -e $new_dest ) {
                      print "SUCCESS in making '$new_dest'\n",
@@ -8462,31 +8603,27 @@
     #        no error in the run, the source-file-state is **not** updated
     #        after the rule is run.  Then on a subsequent pass through
     #        rdb_make's main loop, when the rule is tested for a rerun, any
-    #        change in source file contents is cause for running the rule
-    #        again.
-    #    8.  But after a run giving an error, the state of the generated
-    #        files (i.e., non-user files) is updated to the current state.
-    #        This is because the error (under normal circumstances) must be
-    #        corrected by user action: e.g., correcting a source file, and
-    #        possibly deleting some corrupted auxiliary file.  Files (e.g.,
-    #        .aux by *latex) generated by the rule just run may well have
-    #        changed, so updating their state to the current state prevents
-    #        another run before a user change.  If a file was generated by
-    #        another rule, it won't have changed its state, so updating its
-    #        state won't matter.  But a non-generated file is a
-    #        user-created file, and a rerun is entailed if its contents
-    #        changed compared with the start of the run; it's the
-    #        start-of-run contents that were used in the error run.
-    #    9.  Note: an error may be caused by a problem with a file
-    #        generated by another rule, e.g., a bbl file created by bibtex
-    #        and read by *latex, but with no error reported by bibtex.  To
-    #        correct the error a source file (possibly more than once
-    #        removed must be changed).  That triggers a rerun of the
-    #        producing rule, and after that the resulting change causes a
-    #        rerun of the original rule that had the error.  E.g.,
-    #        correcting a .bib file causes bibtex to run, producing a
-    #        corrected .bbl file, after which *latex is caused to be run.
-    #    10. With circular dependencies, there is a choice of which order
+    #        change in source file contents since the start of the previous
+    #        run is cause for running the rule again.
+    #    8.  When there is an error, and force_mode is off, processing of
+    #        all further rules is terminated.  A problem is then caused for
+    #        a later invocation of latexmk (or, in -pvc mode, the next
+    #        scanning of source-file status): It may be that a generated
+    #        file from a run of some rule changed compared with its status
+    #        before the run.  Because of the termination of processing
+    #        there was no rerun of the rule. New runs should only be made
+    #        after a change in the user-written files, which give the
+    #        possibility of correcting the error.  But on a subsequent
+    #        invocation of latexmk it could appear that some rule(s) is/are
+    #        out-of-date because of the changed generated files, which
+    #        would result in unneeded extra runs, which will tend to
+    #        pollute the screen output with misleading downstream
+    #        consequences of the original error.
+    #        To avoid this problem, after an error-generating round of
+    #        compilations, the cached state of generated files is updated
+    #        to their state after the compilations.  Then only user-caused
+    #        file changes will be cause for new runs.
+    #    9.  With circular dependencies, there is a choice of which order
     #        to examine the rules.  Generally, primary rules are more 
     #        time-consuming than most others, so the choice of the order of
     #        examination of rules to check out-of-dateness is to try to
@@ -8495,7 +8632,7 @@
     #        graphics. These are normally outside a dependency loop, so
     #        those are left to last.  Even if they are inside a dependency
     #        loop, they need the primary rule to have been run first.
-    #    11. After rdb_make is run, all non-user source files are updated
+    #    10. After rdb_make is run, all non-user source files are updated
     #        to their current state.  Rules are considered up-to-date
     #        here. On a subsequent call to rdb_make, subsequent changes are
     #        relevant to what is to be done.  Note: the states of user
@@ -8625,7 +8762,7 @@
         }
         if ( ($runs > 0) && ! $too_many_passes ) {
             $retry_msg = 0;
-            if ( $force_mode || (! $failure) || $switched_primary_output ) {
+            if ( $force_mode || (! $failure) ) {
                 next PASS;
             }
             # Get here on failure, without being in force_mode
@@ -8673,8 +8810,32 @@
          # but do not change primaries.
          # Problem is that %current_primaries gets altered
          &rdb_set_rule_net;
-    }  #End PASS
+     }  #End PASS
 
+    if ($failure ) {
+        # Update state of generated source files, but not non-generated,
+        # i.e., user source files.  Without that, when there was a termination of
+        # processing because of an error, it could be some generated files changed
+        # without reruns of the relevant rule(s) being triggered; that's because
+        # with an error and with force_mode off, the reruns are blocked.
+        # But that situation would cause reruns either when latexmk is reinvoked
+        # or at the next examination of file state (in -pvc mode). But those runs
+        # (almost certainly) won't improve the error situation in the absence of
+        # a change in user files, since the error is ultimately due to a problem
+        # with a user file.
+        # By updating the state of generated source files, reruns are not
+        # triggered until a user file is changed.
+        # Also turn $$Pout_of_date off for the rules.  It may have been set
+        # at some point to trigger a rerun, but that information is now
+        # out-of-date, given that an error occurred.
+        rdb_for_some( [&rdb_accessible()],
+                      sub{ 
+                           &rdb_update_gen_files;
+                           $$Pout_of_date = 0;
+                      }
+                    ); 
+    }
+
     rdb_for_some( [@unusual_one_time], \&rdb_make1 );
 
     #---------------------------------------
@@ -8839,7 +9000,7 @@
     # Is this needed?  Yes; rdb_make1 is called on a sequence of rules and
     # if one gives an error, then it provides source files directly or
     # indirectly to later rules, which should not be run.
-    if ($failure & ! $force_mode) {return;}
+    if ($failure && ! $force_mode) {return;}
 
     # Rule may have been created since last run.  Just in case we didn't,
     # define $pass{$rule} elsewhere, do it here:
@@ -8922,6 +9083,7 @@
         warn_running( "Run number $pass{$rule} of rule '$rule'" );
         $return = &rdb_run1;
     }
+
     if ($$Pchanged) {
         $newrule_nofile = 1;
         $return = 0;
@@ -8972,15 +9134,6 @@
         if ( !$$Plast_message ) {
             $$Plast_message = "Run of rule '$rule' gave a non-zero error code";
         }
-        # Update state of generated source files, but not non-generated,
-        # i.e., user source files. Thus any change in the rule's own
-        # generated source files during the run will not cause a
-        # rerun. Files generated by another rule should not have been
-        # changed during the run, so updating their saved state in this
-        # rule is a NOP.  But any change in user files since the **start**
-        # of the run is a cause for a rerun, so their saved state must not
-        # be updated.
-        rdb_update_gen_files();
     }
     foreach ( keys %$PHsource_rules ) {
         $$PHsource_rules{$_} = $pass{$_};
@@ -9074,7 +9227,7 @@
     #
     $$Pout_of_date = $$Pout_of_date_user = 0;
     if ($latex_like) {
-        &correct_aux_out_files;
+        &correct_locations;
         run_hooks( 'after_xlatex' );
         $return = analyze_latex_run( $return );
         run_hooks( 'after_xlatex_analysis' );
@@ -9490,7 +9643,6 @@
     #
     # ???!!!!
     # Check all uses!!!!!!!!!!!!!
-
     our ($rule, %pass);
 
     local our $PHchanges = shift;
@@ -9628,9 +9780,7 @@
     }
     $$Pno_history = 0;    # See comments in definition of %rule_db.
     if ($rerun_needed) {
-        $$Pout_of_date = 1;
         push @{$$PHchanges{rules_to_apply}}, $rule;
-        if (@{$$PHchanges{changed_user}}) {$$Pout_of_date_user = 1;}
     }
     return $rerun_needed;
 } #END rdb_rerun_needed
@@ -10500,37 +10650,6 @@
 
 #************************************************************
 
-sub analyze_string {
-    # Show information about string: utf8 flag or not, length(s!), byte content
-    my ($m,$s) = @_;
-
-    print "=== $m ";
-    my $length = length($s);
-    if (utf8::is_utf8($s)) {
-        my $encoded = encode( $CS_system, $s, Encode::FB_WARN | Encode::LEAVE_SRC );
-        my $len_chars = 0;
-        my $len_bytes = 0;
-        { no bytes; $len_chars = length($s); }
-        { use bytes; $len_bytes = length($s); }
-        print "'$encoded':\n",
-            "utf8, len = $length; chars = $len_chars; bytes = $len_bytes\n";
-    }
-    else {
-        print "'$s':\n",
-              "NOT utf8, len = $length\n";
-    }
-
-    print join ' ', to_hex($s), "\n";
-}
-
-#----------------------------
-
-sub to_hex {
-    return map { sprintf('%4X', $_) }  unpack( 'U*', shift );
-}
-
-#==================
-
 sub glob_list1 {
     # Glob a collection of filenames.  
     # But no sorting or elimination of duplicates
@@ -10691,25 +10810,31 @@
         # We won't use checksum for directory
         return 0;
     }
-    else {
-        open( $input, '<:bytes', $source )
-        or return 0;
-        my ($base, $path, $ext) = fileparseA( $source );
-        $ext =~ s/^\.//;
-        if ( exists $hash_calc_ignore_pattern{$ext} ) {
-            $ignore_pattern = $hash_calc_ignore_pattern{$ext};
-        }
+    open( $input, '<:bytes', $source )
+    or return 0;
+    my ($base, $path, $ext) = fileparseA( $source );
+    $ext =~ s/^\.//;
+    if ( exists $hash_calc_ignore_pattern{$ext} ) {
+        $ignore_pattern = $hash_calc_ignore_pattern{$ext};
     }
-    if ( defined $ignore_pattern ) {
-        while (<$input>) {
-            if ( ! /$ignore_pattern/ ){
-                $md5->add($_);
+    eval {
+        # Trap any errors that occur during reading, even though the file
+        # was successfully opened.
+        # Such errors have been known to occur under OneDrive on macOS.
+        if ( defined $ignore_pattern ) {
+            while (<$input>) {
+                if ( ! /$ignore_pattern/ ){
+                    $md5->add($_);
+                }
             }
         }
+        else {
+            $md5->addfile($input);
+        }
+    };
+    if ($@) {
+        warn "$My_name: Attempt to get md5 of '$source' failed.  Error=\n$@";
     }
-    else {
-        $md5->addfile($input);
-    }
     close $input;
     return $md5->hexdigest();
 }
@@ -11184,7 +11309,12 @@
 sub fileparseA {
     # Like fileparse but replace $path for current dir ('./' or '.\') by ''
     # Also default second argument to get normal extension.
+    # With msys, change all \ to / in given name since with msys, fileparse
+    # doesn't recognize \ as directory separator.
     my $given = $_[0];
+    if ( $^O eq 'msys' ) {
+        $given =~ s[\\][/]g;
+    }
     my $pattern = '\.[^\.]*';
     if  ($#_ > 0 ) { $pattern = $_[1]; }
     my ($base_name, $path, $ext) = fileparse( $given, $pattern );
@@ -11198,7 +11328,12 @@
 
 sub fileparseB {
     # Like fileparse but with default second argument for normal extension
+    # With msys, change all \ to / in given name since with msys, fileparse
+    # doesn't recognize \ as directory separator.
     my $given = $_[0];
+    if ( $^O eq 'msys' ) {
+        $given =~ s[\\][/]g;
+    }
     my $pattern = '\.[^\.]*';
     if  ($#_ > 0 ) { $pattern = $_[1]; }
     my ($base_name, $path, $ext) = fileparse( $given, $pattern );
@@ -11551,7 +11686,11 @@
     }
     # Normalized
     if ($normalize_names) {
-        $cwd = abs_path($cwd);
+        my $abs = abs_path($cwd);
+        # It's conceivable that abs_path doesn't know how to convert to an
+        # absolute path of a standard normalization.  Then it returns undef.
+        # In that case, it's probably good not to try normalizing $cwd.
+        if (defined $abs) { $cwd = $abs; }
     }
     $cache{cwd} = $cwd;
 }  # END cache_good_cwd



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