%%
%% This is file `rerunfilecheck.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% rerunfilecheck.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Project: rerunfilecheck
%% Version: 2022-07-10 v1.10
%% 
%% Copyright (C)
%%    2009-2011 Heiko Oberdiek
%%    2016-2022 Oberdiek Package Support Group
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. This version of this license is in
%%    https://www.latex-project.org/lppl/lppl-1-3c.txt
%% and the latest version of this license is in
%%    https://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%% 
%% This work has the LPPL maintenance status "maintained".
%% 
%% The Current Maintainers of this work are
%% Heiko Oberdiek and the Oberdiek Package Support Group
%% https://github.com/ho-tex/rerunfilecheck/issues
%% 
%% This work consists of the main source file rerunfilecheck.dtx
%% and the derived files
%%    rerunfilecheck.sty, rerunfilecheck.pdf, rerunfilecheck.ins,
%%    rerunfilecheck.drv, rerunfilecheck-example.cfg,
%%    rerunfilecheck-test1.tex.
%% 
\begingroup\catcode61\catcode48\catcode32=10\relax%
  \catcode13=5 % ^^M
  \endlinechar=13 %
  \catcode123=1 % {
  \catcode125=2 % }
  \catcode64=11 % @
  \def\x{\endgroup
    \expandafter\edef\csname ReFiCh@AtEnd\endcsname{%
      \endlinechar=\the\endlinechar\relax
      \catcode13=\the\catcode13\relax
      \catcode32=\the\catcode32\relax
      \catcode35=\the\catcode35\relax
      \catcode61=\the\catcode61\relax
      \catcode64=\the\catcode64\relax
      \catcode123=\the\catcode123\relax
      \catcode125=\the\catcode125\relax
    }%
  }%
\x\catcode61\catcode48\catcode32=10\relax%
\catcode13=5 % ^^M
\endlinechar=13 %
\catcode35=6 % #
\catcode64=11 % @
\catcode123=1 % {
\catcode125=2 % }
\def\TMP@EnsureCode#1#2{%
  \edef\ReFiCh@AtEnd{%
    \ReFiCh@AtEnd
    \catcode#1=\the\catcode#1\relax
  }%
  \catcode#1=#2\relax
}
\TMP@EnsureCode{39}{12}% '
\TMP@EnsureCode{40}{12}% (
\TMP@EnsureCode{41}{12}% )
\TMP@EnsureCode{42}{12}% *
\TMP@EnsureCode{44}{12}% ,
\TMP@EnsureCode{46}{12}% .
\TMP@EnsureCode{47}{12}% /
\TMP@EnsureCode{58}{12}% :
\TMP@EnsureCode{59}{12}% ;
\TMP@EnsureCode{60}{12}% <
\TMP@EnsureCode{62}{12}% >
\TMP@EnsureCode{91}{12}% [
\TMP@EnsureCode{93}{12}% ]
\TMP@EnsureCode{96}{12}% `
\edef\ReFiCh@AtEnd{\ReFiCh@AtEnd\noexpand\endinput}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{rerunfilecheck}%
  [2022-07-10 v1.10 Rerun checks for auxiliary files (HO)]
\RequirePackage{kvoptions}[2010/02/22]
\SetupKeyvalOptions{%
  family=rerunfilecheck,%
  prefix=ReFiCh@%
}
\newcommand*{\RerunFileCheckSetup}{%
  \setkeys{rerunfilecheck}%
}
\DeclareBoolOption{mainaux}
\DeclareBoolOption{partaux}
\DeclareBoolOption{starttoc}
\DeclareBoolOption{index}
\DeclareBoolOption{glossary}
\define@key{rerunfilecheck}{aux}[true]{%
  \RerunFileCheckSetup{%
    mainaux={#1},%
    partaux={#1},%
    starttoc={#1},%
    index={#1},%
    glossary={#1}%
  }%
}
\InputIfFileExists{rerunfilecheck.cfg}{}{}
\ProcessLocalKeyvalOptions*
\def\ReFiCh@DisableOption{%
  \DisableKeyvalOption[%
    action=warning,%
    package=rerunfilecheck%
  ]{rerunfilecheck}%
}
\RequirePackage{infwarerr}[2007/09/09]
\RequirePackage{pdftexcmds}[2009/04/10]
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname pdf@filemdfivesum\endcsname\relax
  \@PackageInfoNoLine{rerunfilecheck}{%
    Feature \string\pdfmdfivesum\space is not available\MessageBreak
    (e.g. pdfTeX or LuaTeX with package `pdftexcmds').\MessageBreak
    Therefore file contents cannot be checked efficiently\MessageBreak
    and the loading of the package is aborted%
  }%
  \newcommand*{\RerunFileCheck}[3]{}%
  \renewcommand*{\RerunFileCheckSetup}[1]{}%
  \expandafter\ReFiCh@AtEnd
\fi%
\ifReFiCh@partaux
  \let\ReFiCh@org@include\@include
  \def\@include#1 {%
    \if@filesw
      \RerunFileCheck{#1.aux}{}{}%
    \fi
    \ReFiCh@org@include{#1} %
  }%
\fi
\ifReFiCh@mainaux
  \AtBeginDocument{%
    \ReFiCh@mainauxfalse
  }%
  \ifReFiCh@mainaux
    \AtEndOfPackage{%
      \RerunFileCheck{\jobname.aux}{}{}%
    }%
  \else
    \if@filesw
      \@PackageWarningNoLine{rerunfilecheck}{%
        Main aux file check is disabled,\MessageBreak
        because the file is already opened.\MessageBreak
        Load the package before \string\begin{document}%
      }%
    \fi
  \fi
\fi
\ifReFiCh@starttoc
  \let\ReFiCh@org@starttoc\@starttoc
  \def\@starttoc#1{%
    \if@filesw
      \RerunFileCheck{\jobname.#1}{%
        \@ifundefined{tf@#1}{%
        }{%
          \immediate\closeout\csname tf@#1\endcsname
        }%
      }{}%
    \fi
    \ReFiCh@org@starttoc{#1}%
  }%
\fi
\ifReFiCh@index
  \ifx\makeindex\@empty
    \@PackageWarningNoLine{rerunfilecheck}{%
      Option `index' ignored,\MessageBreak
      because \string\makeindex\space has already been called%
    }%
  \else
    \def\ReFiCh@temp{%
      \newwrite\@indexfile
      \immediate\openout\@indexfile=\jobname.idx %
      \def\index{%
        \@bsphack
        \begingroup
        \@sanitize
        \@wrindex
      }%
      \typeout{Writing index file \jobname.idx}%
      \let\makeindex\@empty
    }%
    \ifx\ReFiCh@temp\makeindex
      \def\makeindex{%
        \newwrite\@indexfile
        \RerunFileCheck{\jobname.idx}{%
          \immediate\closeout\@indexfile
        }{%
          Rerun LaTeX/makeindex to get index right%
        }%
        \immediate\openout\@indexfile=\jobname.idx %
        \def\index{%
          \@bsphack
          \begingroup
          \@sanitize
          \@wrindex
        }%
        \typeout{Writing index file \jobname.idx}%
        \let\makeindex\@empty
      }%
    \else
      \@PackageInfoNoLine{rerunfilecheck}{%
        Option `index': unsupported version of \string\makeindex
      }%
    \fi
  \fi
\fi
\ifReFiCh@glossary
  \ifx\makeglossary\@empty
    \@PackageWarningNoLine{rerunfilecheck}{%
      Option `glossary' ignored,\MessageBreak
      because \string\makeglossary\space has already been called%
    }%
  \else
    \def\ReFiCh@temp{%
      \newwrite\@glossaryfile
      \immediate\openout\@glossaryfile=\jobname.glo %
      \def\glossary{%
        \@bsphack
        \begingroup
        \@sanitize
        \@wrglossary
      }%
      \typeout{Writing glossary file \jobname.glo }%
      \let\makeglossary\@empty
    }%
    \ifx\ReFiCh@temp\makeglossary
      \def\makeglossary{%
        \newwrite\@glossaryfile
        \RerunFileCheck{\jobname.glo}{%
          \immediate\closeout\@glossaryfile
        }{%
          Rerun LaTeX/makeindex to get glossary right%
        }%
        \immediate\openout\@glossaryfile=\jobname.glo %
        \def\glossary{%
          \@bsphack
          \begingroup
          \@sanitize
          \@wrglossary
        }%
        \typeout{Writing glossary file \jobname.glo}%
        \let\makeglossary\@empty
      }%
    \else
      \@PackageInfoNoLine{rerunfilecheck}{%
        Option `glossary': unsupported version of \string\makeglossary
      }%
    \fi
  \fi
\fi
\ReFiCh@DisableOption{mainaux}
\ReFiCh@DisableOption{partaux}
\ReFiCh@DisableOption{starttoc}
\ReFiCh@DisableOption{index}
\ReFiCh@DisableOption{glossary}
\ReFiCh@DisableOption{aux}
\RequirePackage{atveryend}[2019/12/05]
\RequirePackage{uniquecounter}[2009/12/18]
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname pdf@filesize\endcsname\relax
  \def\ReFiCh@CheckSum{%
    \pdf@filemdfivesum
  }%
\else
  \def\ReFiCh@CheckSum#1{%
    \pdf@filemdfivesum{#1}%
    \ReFiCh@Separator
    \pdf@filesize{#1}%
  }%
\fi
\def\ReFiCh@Separator{;}
\def\ReFiCh@NoFile{<no file>}
\UniqueCounterNew{rerunfilecheck}
\newcommand*{\RerunFileCheck}{%
  \UniqueCounterCall{rerunfilecheck}\ReFiCh@RerunFileCheck
}
\def\ReFiCh@RerunFileCheck#1{%
  \expandafter\ReFiCh@@RerunFileCheck\csname ReFiCh@#1\endcsname
}
\def\ReFiCh@Check#1#2#3{%
    #1\edef#2{\ReFiCh@CheckSum{#3}}%
    \ifx#2\ReFiCh@Separator
      #1\let#2\ReFiCh@NoFile
    \fi
}
\def\ReFiCh@@RerunFileCheck#1#2#3#4{%
  \ReFiCh@Check\global#1{#2}%
  \AtEndAfterFileList{%
    \begingroup
      #3%
      \ReFiCh@Check{}\x{#2}%
      \ifx#1\x
        \@PackageInfoNoLine{rerunfilecheck}{%
          File `#2' has not changed.\MessageBreak
          Checksum: \x
        }%
      \else
        \ifnum
          \ReFiCh@IsAux#2\relax.aux\relax\@nil
          \ifx#1\ReFiCh@NoFile 1\else 0\fi
          \ifx\x\ReFiCh@AuxEmptyUnix 1%
          \else
            \ifx\x\ReFiCh@AuxEmptyDos 1\fi
          \fi
        =111 %
          \@PackageInfoNoLine{rerunfilecheck}{%
            File `#2' is empty .aux file.\MessageBreak
            Before: #1\MessageBreak
            After: \space\x
          }%
        \else
          \@PackageWarningNoLine{rerunfilecheck}{%
            File `#2' has changed.%
            \ifx\\#4\\%
              \space Rerun%
            \else
              \MessageBreak
              #4%
            \fi
          }%
          \@PackageInfoNoLine{rerunfilecheck}{%
            Checksums for `#2':\MessageBreak
            Before: #1\MessageBreak
            After: \space\x
          }%
        \fi
      \fi
    \endgroup
  }%
}
\def\ReFiCh@IsAux#1.aux\relax#2\@nil{%
  \ifx\hbox#2\hbox
    0%
  \else
    1%
  \fi
}
\def\ReFiCh@AuxEmptyUnix{A94A2480D3289E625EEA47CD1B285758;8}%
\@onelevel@sanitize\ReFiCh@AuxEmptyUnix
\def\ReFiCh@AuxEmptyDos{A62A15ECE803E2EBE94952FCC9933BC0;9}%
\@onelevel@sanitize\ReFiCh@AuxEmptyDos
\ReFiCh@AtEnd%
%% \section{Installation}
\endinput
%%
%% End of file `rerunfilecheck.sty'.
