[LyX/master] Introduce pkglist format

Juergen Spitzmueller spitz at lyx.org
Sat Jan 14 08:47:57 UTC 2023


commit d213b72978d74231df380d67648a45da168ea57d
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Sat Jan 14 10:45:57 2023 +0100

    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(+), 0 deletions(-)

diff --git a/lib/chkconfig.ltx b/lib/chkconfig.ltx
index d7c161c..ff95d46 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 bee3055..e708df1 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();
+	}
 }
 
 


More information about the lyx-cvs mailing list