% \iffalse meta-comment
% ======================================================================
% scrkernel-version.dtx
% Copyright (c) Markus Kohm, 2002-2025
%
% This file is part of the LaTeX2e KOMA-Script bundle.
%
% This work may be distributed and/or modified under the conditions of
% the LaTeX Project Public License, version 1.3c of the license.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX 
% version 2005/12/01 or later and of this work.
%
% This work has the LPPL maintenance status "author-maintained".
%
% The Current Maintainer and author of this work is Markus Kohm.
%
% This work consists of all files listed in MANIFEST.md.
% ======================================================================
%%% From File: $Id: scrkernel-version.dtx 4261 2026-02-02 09:02:14Z kohm $
%
% ATTENTION: In this file parts of the code and documentation are before the
% driver. This must be, because this part of the code is needed by the driver
% in this file and most of the other KOMA-Script dtx-files.
%
% \fi^^A meta-comment
%
% \changes{v2.0e}{1994/07/07}{first release of \cls*{scrartcl},
%   \cls*{scrreprt}, and \cls*{scrbook}}
% \changes{v2.95}{2002/06/25}{first version of this file by splitting of
%   \file{scrclass.dtx}}
% \changes{v3.36}{2022/02/11}{switch over from \cls*{scrdoc} to
%   \cls*{koma-script-source-doc}}
% \changes{v3.36}{2022/02/11}{whole implementation documentation in English}
% \changes{v3.99}{2022/10/25}{prepared to generate experimental \KOMAScript~4}
% \changes{v3.40}{2023/04/17}{guide names changed}
%
% \GetFileInfo{scrkernel-version.dtx}
% \title{The Version of the \href{https://komascript.de}{\KOMAScript} Kernel
%   and therefore the Classes and most of the Packages}
% \author{\href{mailto:komascript@gmx.info}{Markus Kohm}}
% \date{Version \fileversion{} of \filedate}
% \maketitle
% \begin{abstract}
%   \filename{} is not only used for the code of all \KOMAScript{} classes and
%   most of the \KOMAScript{} packages. It is also used by most of the
%   installation drivers (\file{ins}-files) for the definition of
%   \KOMAScript{} version.
% \end{abstract}
% \tableofcontents
%
%
% \section{User Manual}
%
% You can find the user documentation of the commands implemented here in the
% \KOMAScript{} manual, either the German \file{scrguide-de.pdf} or the
% English \file{scrguide-en.pdf}.
%
% \MaybeStop{\PrintIndex}
%
% \section{Implementation of the \KOMAScript{} Kernel Version Information}
%
% \begin{command}{\KOMAScriptVersion}
% \changes{v2.95}{2002/06/25}{added}
% The main purpose of this command it to prevent mixture of files of
% different \KOMAScript{} versions. But users can also use this command to
% detect \KOMAScript{}. It is added to the classes and most of the packages
% by the installation drivers. This is done using \file{scrdocstrip.tex} and
% additionally loading this file.
% \begin{macro}{\@CheckKOMAScriptVersion}
% \changes{v2.95}{2002/06/25}{added}
% \changes{v3.42}{2024/04/17}{command is defined only once but \pkg{expl3}
%   hard}
% \changes{v3.42}{2024/04/17}{command is no longer defined in \file{clo}
%   or \file{lco} files}
% Depending on \cs{KOMAScriptVersion} already defined or not, the existing
% definition is compared with the version here or \cs{KOMAScriptVersion} is
% newly and globally defined. This has to work not only in class or package
% files, but also in document files. So \cs{makeatletter} inside a group is
% needed for the internal macros. Additionally a guard \texttt{ignorethis} is
% used, to avoid adding code, that is needed only for the installation driver,
% also to classes or packages. Note, the version check is also done in
% \file{clo} or \file{lco} files, but the macros \cs{@CheckKOMAScriptVersion}
% and \cs{@@CheckKOMAScriptVersion} are not defined in those, because those
% files should not always be loaded by \KOMAScript{} classes or packages,
% which would already define the command.
%    \begin{macrocode}
%<*ignorethis>
\ifx\newcommand\undefined
  \catcode`\@11\relax
  \def\@CheckKOMAScriptVersion#1{%
    \global\KOMAdefVariable{KOMAScriptVersion}{\space\space#1}%
    \expandafter\ifx\csname ifbeta\endcsname\relax
      \def\@defbeta##1 ##2 ##3KOMA-Script{%
        \def\@cmpstrA{##3}\def\@cmpstrB{BETA }%
        \ifx\@cmpstrA\@cmpstrB
          \expandafter\expandafter\expandafter\global
          \expandafter\expandafter\expandafter\let
          \expandafter\csname ifbeta\expandafter\endcsname
          \csname iftrue\endcsname
        \fi
      }\expandafter\@defbeta\KOMAvar@KOMAScriptVersion
    \fi
% \changes{v3.49.2}{2026/01/31}{version numbers with two dots are not
%   automatically beta versions}
%    \expandafter\ifx\csname ifbeta\endcsname\relax
%      \def\@defbeta##1 ##2.##3.##4 KOMA-Script\@nil{%
%        \def\@cmpstrA{##4}\def\@cmpstrB{}%
%        \ifx\@cmpstrA\@cmpstrB\else
%          \expandafter\expandafter\expandafter\global
%          \expandafter\expandafter\expandafter\let
%          \expandafter\csname ifbeta\expandafter\endcsname
%          \csname iftrue\endcsname
%        \fi
%      }\expandafter\@defbeta\KOMAvar@KOMAScriptVersion. KOMA-Script\@nil
%    \fi
    \expandafter\ifx\csname ifbeta\endcsname\relax
      \expandafter\expandafter\expandafter\global
      \expandafter\expandafter\expandafter\let
      \expandafter\csname ifbeta\expandafter\endcsname
      \csname iffalse\endcsname
    \fi
    \KOMAifVariable{COPYRIGHTTILL}{}{%
      \def\@defCOPYRIGHTTILL##1/##2/##3 ##4\@nil{%
        \def\@tempa{##1}\def\@tempb{}\ifx\@tempa\@tempb
          \def\@defCOPYRIGHTTILL##1-##2-##3 ##4\@nil{%
            \def\@tempa{##1}\def\@tempb{}\ifx\@tempa\@tempb
            \else
              \global\KOMAdefVariable{COPYRIGHTTILL}{##1}%
            \fi
          }%
        \else
          \global\KOMAdefVariable{COPYRIGHTTILL}{##1}%
        \fi
      }%
    }\@defCOPYRIGHTTILL#1// \@nil
    \let\@CheckKOMAScriptVersion\undefined
    \endinput
  }%
\else
  \makeatletter
%</ignorethis>
%<*class|package>
\providecommand*{\@CheckKOMAScriptVersion}{%
  \begingroup
    \ExplSyntaxOff
    \@@CheckKOMAScriptVersion
}
\providecommand*{\@@CheckKOMAScriptVersion}[1]{%
    \@ifundefined{KOMAScriptVersion}{%
      \gdef\KOMAScriptVersion{#1}%
    }{%
      \def\@tempa{#1}%
      \ifx\KOMAScriptVersion\@tempa\else
        \GenericWarning{\space\@spaces\@spaces\@spaces\@spaces}{%
          Version warning:
          \noexpand\KOMAScriptVersion is 
          `\csname KOMAScriptVersion\endcsname',\MessageBreak
          but `#1' was expected!\MessageBreak
          You should not use classes, packages or files
          from\MessageBreak
          different KOMA-Script versions\@gobble
        }%
      \fi
    }%
  \endgroup
}
%</class|package>
%<*ignorethis>
\fi
%</ignorethis>
%    \end{macrocode}
% Note: Following line will be patched by \file{makebetaorrelase.sh} and
% therefore the syntax or general structure of the line must not be changed!
%    \begin{macrocode}
%<*!v4>
\@CheckKOMAScriptVersion{2026/02/02 v3.49.2 KOMA-Script}%
%</!v4>
%<v4>  \@nameuse{@CheckKOMAScriptVersion}{2022/10/25 v3.99 ALPHA KOMA-Script}%
%    \end{macrocode}
% \end{macro}
% \end{command}
%
% \iffalse
%<*dtx>
\makeatother
\ProvidesFile{scrkernel-version.dtx}[\KOMAScriptVersion (versions)]
\documentclass[USenglish]{koma-script-source-doc}
\usepackage{babel}
\begin{document}
  \DocInput{scrkernel-version.dtx}
\end{document}
%</dtx>
% \fi
%
% \subsection{Implementation of class and package names and file names}
%
% \begin{description}
% \item[ToDo] Maybe, this should be split in one file for each class. The file
%   extension code should be moved to \file{scrkernel-miscellaneous.dtx}.
% \end{description}
%
% \begin{macro}{\scr@pkgextension}
% \changes{v3.17}{2015/03/17}{added}
% \begin{macro}{\scr@clsextension}
% \changes{v3.17}{2015/03/17}{added}
% \changes{v3.18}{2015/06/17}{fixed}
% Last but not least same like \cs{@pkgextension} and \cs{@clsextension} but
% still valid after the preamble.
%    \begin{macrocode}
%<*class|package>
%<package>\providecommand*{\scr@pkgextension}{\@pkgextension}
%<class>\providecommand*{\scr@clsextension}{\@clsextension}
\AtBeginDocument{%
%<package>  \let\scr@pkgextension\@pkgextension
%<class>  \let\scr@clsextension\@clsextension
}
%</class|package>
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{command}{\KOMAClassFileName}
% \changes{v3.17}{2014/03/12}{added}
% \begin{command}{\KOMAClassName}
% \changes{v2.95}{2004/11/04}{added}
% \begin{command}{\KOMALongClassFileName,\KOMALongClassName}
% \changes{v3.27}{2019/02/16}{added}
% \begin{command}{\ClassName}
% \changes{v2.95}{2004/11/04}{added}
% We define the name of each \KOMAScript{} class and the name of the
% \emph{class} of the class (usually name of the corresponding standard class)
% once. This allows to use code, that outputs the name of the class, for
% several classes without using always class specific code.
%    \begin{macrocode}
%<*class>
%<*!v4>
%<article|(letter&long)>\newcommand*{\KOMAClassName}{scrartcl}
%<report>\newcommand*{\KOMAClassName}{scrreprt}
%<book>\newcommand*{\KOMAClassName}{scrbook}
%<letter&!long>\newcommand*{\KOMAClassName}{scrlttr2}
%<*!long>
\newcommand*{\KOMAClassFileName}{\KOMAClassName.\@clsextension}
\edef\KOMAClassFileName{\KOMAClassFileName}
%</!long>
%</!v4>
\newcommand*{\ClassName}{%
%<article|(letter&long)>  article%
%<report>  report%
%<book>  book%
%<letter&!long>  letter%
}
%<*long>
\newcommand*{\KOMALongClassName}{}
%<*!v4>
%<!letter>\edef\KOMALongClassName{scr\ClassName}
%<letter>\def\KOMALongClassName{scrletter}
%</!v4>
\newcommand*{\KOMALongClassFileName}{\KOMALongClassName.\@clsextension}
\edef\KOMALongClassFileName{\KOMALongClassFileName}
%</long>
%<*v4>
\edef\KOMAClassName{scr\ClassName4}
\edef\KOMAClassFileName{\KOMAClassName.\@clsextension}
%</v4>
%    \end{macrocode}
% \end{command}
% \end{command}
% \end{command}
% \end{command}
%    \begin{macrocode}
%<!long>\ProvidesClass{\KOMAClassName}[%
%<long>\ProvidesClass{\KOMALongClassName}[%
%!KOMAScriptVersion
  document class (\ClassName)%
]
%<*long>
\let\ClassName\relax
%<letter>\providecommand*{\@ptsize}{12}
\expandafter\let\expandafter\KOMAClassName\expandafter\relax
\expandafter\LoadClassWithOptions\expandafter{\KOMAClassName}
%<letter&!v4>\RequirePackage{scrletter}
%<letter&v4>\RequirePackage{scrletter4}
%</long>
%</class>
%    \end{macrocode}
%
%    \begin{macrocode}
%<*package&letter>
%<!v4>\ProvidesPackage{scrletter}[%
%<v4>\ProvidesPackage{scrletter4}[%
%!KOMAScriptVersion
  letter package extending any KOMA-Script class%
]
%</package&letter>
%    \end{macrocode}
%
% \Finale
% \PrintChanges
%
\endinput
% Local Variables:
% mode: doctex
% ispell-local-dictionary: "en_US"
% eval: (flyspell-mode 1)
% TeX-master: t
% TeX-engine: luatex-dev
% eval: (setcar (or (cl-member "Index" (setq-local TeX-command-list (copy-alist TeX-command-list)) :key #'car :test #'string-equal) (setq-local TeX-command-list (cons nil TeX-command-list))) '("Index" "mkindex %s" TeX-run-index nil t :help "makeindex for dtx"))
% End:
