]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_autocorrect.C
Jean-Marc's fix for wrong descent
[lyx.git] / src / mathed / math_autocorrect.C
index 63315bc651ad61d35bba36244e2150a42298a6e1..f5250436f80c5188fb8c7ebdc6167ba6abd7131d 100644 (file)
@@ -1,3 +1,4 @@
+
 #include <config.h>
 
 #include "LString.h"
@@ -46,10 +47,12 @@ bool Correction::read(istream & is)
        is >> s1 >> s2 >> s3;
        if (!is)
                return false;
+       if (s2.size() != 1)
+               return false;
        MathArray ar1, ar3;
        mathed_parse_cell(ar1, s1);
        mathed_parse_cell(ar3, s3);
-       if (ar1.size() != 1  ||  s2.size() != 1  ||  ar3.size() !=1)
+       if (ar1.size() != 1 || ar3.size() != 1)
                return false;
        from1_ = ar1.front();
        from2_ = s2[0];
@@ -61,21 +64,21 @@ bool Correction::read(istream & is)
 void Correction::write(ostream & os) const
 {
        os << "from: '" << from1_ << "' and '" << from2_
-          << "' to '" << to_ << "'" << endl;
+          << "' to '" << to_ << '\'' << endl;
 }
 
 
 bool Correction::correct(MathAtom & at, char c) const
 {
        //lyxerr[Debug::MATHED]
-       //      << "trying to correct ar: " << at << " from: '" << from1_ << "'" << endl;
+       //      << "trying to correct ar: " << at << " from: '" << from1_ << '\'' << endl;
        if (from2_ != c)
                return false;
-       if (!at->match(from1_.nucleus()))
+       if (!at->match(from1_))
                return false;
        lyxerr[Debug::MATHED]
                << "match found! subst in " << at
-               << " from: '" << from1_ << "' to '" << to_ << "'" << endl;
+               << " from: '" << from1_ << "' to '" << to_ << '\'' << endl;
        at = to_;
        return true;
 }
@@ -137,14 +140,15 @@ void initAutoCorrect()
        ifstream is(file.c_str());
        while (getline(is, line)) {
                if (line.size() == 0 || line[0] == '#') {
-                       //lyxerr[Debug::MATHED] << "ignoring line '" << line << "'" << endl;
+                       //lyxerr[Debug::MATHED] << "ignoring line '" << line << '\'' << endl;
                        continue;
                }
-               istringstream il(line);
-               //lyxerr[Debug::MATHED] << "line '" << line << "'" << endl;
+               istringstream il(STRCONV(line));
+
+               //lyxerr[Debug::MATHED] << "line '" << line << '\'' << endl;
                Correction corr;
                if (corr.read(il)) {
-                       //lyxerr[Debug::MATHED] << "parsed: '" << corr << "'" << endl;
+                       //lyxerr[Debug::MATHED] << "parsed: '" << corr << '\'' << endl;
                        theCorrections.insert(corr);
                }
        }