commit b7b0c644fcf12f41a2d1bfa441f98a080684d19c
Author: Enrico Forestieri <[email protected]>
Date:   Fri Jul 18 14:39:30 2025 +0200

    Allow including the symbols system file from the user one
    
    Until now, in order to make additions to the lib/symbols file
    one should have copied it to the user dir and modify the copy.
    Of course, when the system file is updated one should transfer
    the modifications to the copy. Of course, this is tedious and
    error prone. This commit introduces the possibility of including
    the system file from the one in the user directory by using the
    directive "include_system_file", which is equivalent to inserting
    the system symbols file at that point. The, one can make additions
    or modifications as desired.
---
 src/mathed/MathFactory.cpp | 40 +++++++++++++++++++++++++++++++---------
 1 file changed, 31 insertions(+), 9 deletions(-)

diff --git a/src/mathed/MathFactory.cpp b/src/mathed/MathFactory.cpp
index 10682f9061..564acb7555 100644
--- a/src/mathed/MathFactory.cpp
+++ b/src/mathed/MathFactory.cpp
@@ -142,16 +142,8 @@ bool isUnicodeSymbolAvailable(docstring const & name, 
char_type & c)
 }
 
 
-void initSymbols()
+void initSymbolsFromFile(ifstream & fs)
 {
-       FileName const filename = libFileSearch(string(), "symbols");
-       LYXERR(Debug::MATHED, "read symbols from " << filename);
-       if (filename.empty()) {
-               lyxerr << "Could not find symbols file" << endl;
-               return;
-       }
-
-       ifstream fs(filename.toFilesystemEncoding().c_str());
        // limit the size of strings we read to avoid memory problems
        fs >> setw(65636);
        string line;
@@ -182,6 +174,23 @@ void initSymbols()
                } else if (skip)
                        continue;
 
+               // special case of include_system_file
+               if (line.size() >= 19 && line.substr(0, 19) == 
"include_system_file") {
+                       string tmp;
+                       istringstream is(line);
+                       is >> setw(65536) >> tmp;
+                       FileName const sysfile = libFileSearch(string(), 
"symbols",
+                                                              string(), 
must_exist, true);
+                       LYXERR(Debug::MATHED, "read symbols from " << sysfile);
+                       if (sysfile.empty()) {
+                               lyxerr << "Could not find system symbols file" 
<< endl;
+                               continue;
+                       }
+                       ifstream sysfs(sysfile.toFilesystemEncoding().c_str());
+                       initSymbolsFromFile(sysfs);
+                       continue;
+               }
+
                // special case of pre-defined macros
                if (line.size() > 8 && line.substr(0, 5) == "\\def\\") {
                        //lyxerr << "macro definition: '" << line << '\'' << 
endl;
@@ -342,6 +351,19 @@ void initSymbols()
                        << "  requires: " << tmp.required
                        << "  hidden: " << tmp.hidden << '\'');
        }
+}
+
+
+void initSymbols()
+{
+       FileName const filename = libFileSearch(string(), "symbols");
+       LYXERR(Debug::MATHED, "read symbols from " << filename);
+       if (filename.empty()) {
+               lyxerr << "Could not find symbols file" << endl;
+               return;
+       }
+       ifstream fs(filename.toFilesystemEncoding().c_str());
+       initSymbolsFromFile(fs);
        string tmp = "cmm";
        string tmp2 = "cmsy";
        has_math_fonts = isMathFontAvailable(tmp) && isMathFontAvailable(tmp2);
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to