X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2Fmath_autocorrect.C;h=4d06c78259210d21900e5463474ca64c083cfc00;hb=1ecc7b79cdf95de50f2683fb7a8f983b5dcdf0d2;hp=63315bc651ad61d35bba36244e2150a42298a6e1;hpb=75d1fb687425390a42a8768ef1560e8f2880fbb9;p=lyx.git diff --git a/src/mathed/math_autocorrect.C b/src/mathed/math_autocorrect.C index 63315bc651..4d06c78259 100644 --- a/src/mathed/math_autocorrect.C +++ b/src/mathed/math_autocorrect.C @@ -1,19 +1,33 @@ +/** + * \file math_autocorrect.C + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author André Pönitz + * + * Full author contact details are available in file CREDITS. + */ + #include -#include "LString.h" -#include "Lsstream.h" -#include "debug.h" -#include "support/filetools.h" // LibFileSearch +#include "math_autocorrect.h" #include "math_data.h" #include "math_inset.h" +#include "math_support.h" #include "math_parser.h" +#include "debug.h" + +#include "support/filetools.h" // LibFileSearch -#include #include -#include +#include + +using lyx::support::LibFileSearch; +using std::string; using std::ifstream; using std::istream; +using std::istringstream; using std::ostream; using std::endl; using std::vector; @@ -46,10 +60,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 +77,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 (asString(at) != asString(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 +153,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; + + //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); } }