From d213b72978d74231df380d67648a45da168ea57d Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Sat, 14 Jan 2023 10:45:57 +0100 Subject: [PATCH] Introduce pkglist format This allows us to check and reconfigure if the pkglist format is not current --- lib/chkconfig.ltx | 2 ++ src/LaTeXPackages.cpp | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/chkconfig.ltx b/lib/chkconfig.ltx index d7c161c2ee..ff95d46558 100644 --- a/lib/chkconfig.ltx +++ b/lib/chkconfig.ltx @@ -185,6 +185,8 @@ \newwrite{\layouts} \immediate\openout \layouts = textclass.lst.tmp \newwrite{\vars} \immediate\openout \vars = chkconfig.vars \newwrite{\packages} \immediate\openout \packages = packages.lst.tmp +% Version of the packages list +\immediate\write\packages{!!fileformat 2} \immediate\write\layouts{% # This file declares layouts and their associated definition files.^^J% diff --git a/src/LaTeXPackages.cpp b/src/LaTeXPackages.cpp index bee30558d3..e708df1dfe 100644 --- a/src/LaTeXPackages.cpp +++ b/src/LaTeXPackages.cpp @@ -23,6 +23,7 @@ #include "support/FileName.h" #include "support/filetools.h" #include "support/lstrings.h" +#include "support/Package.h" using namespace std; @@ -51,6 +52,7 @@ void LaTeXPackages::getAvailable() packages_.clear(); bool finished = false; + string lstformat = "1"; // Parse config-file while (lex.isOK() && !finished) { switch (lex.lex()) { @@ -62,10 +64,20 @@ void LaTeXPackages::getAvailable() // Parse optional version info lex.eatLine(); string const v = trim(lex.getString()); + if (p == "!!fileformat") { + lstformat = v; + continue; + } packages_.insert(make_pair(p, v)); } } } + // Check if the pkglist has current format. + // Reconfigure and re-parse if not. + if (lstformat != "2") { + package().reconfigureUserLyXDir(""); + getAvailable(); + } } -- 2.39.5