X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FMathAutoCorrect.cpp;h=fc4ad440d20919fd5576c3b6820a57710dd2d079;hb=ebe6612e2661f49dcfae6103f056c27afd47751f;hp=2b384d330e0f00e0c685a8549589e1c3be5ab277;hpb=6e3a75969b97a5db4c80c46be49d4deb122abfe7;p=lyx.git diff --git a/src/mathed/MathAutoCorrect.cpp b/src/mathed/MathAutoCorrect.cpp index 2b384d330e..fc4ad440d2 100644 --- a/src/mathed/MathAutoCorrect.cpp +++ b/src/mathed/MathAutoCorrect.cpp @@ -3,7 +3,7 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author André Pönitz + * \author André Pönitz * * Full author contact details are available in file CREDITS. */ @@ -11,33 +11,32 @@ #include #include "MathAutoCorrect.h" -#include "MathArray.h" +#include "MathData.h" #include "InsetMath.h" #include "MathSupport.h" #include "MathParser.h" -#include "debug.h" +#include "support/debug.h" +#include "support/FileName.h" #include "support/filetools.h" // LibFileSearch +#include "support/docstream.h" #include #include +using namespace std; namespace lyx { using support::libFileSearch; -using std::string; -using std::ifstream; -using std::endl; -using std::vector; - namespace { class Correction { public: /// - Correction() {} + /// \brief Correction + Correction() : from2_(0) {} /// bool correct(MathAtom & at, char_type c) const; /// @@ -62,7 +61,7 @@ bool Correction::read(idocstream & is) return false; if (s2.size() != 1) return false; - MathArray ar1, ar3; + MathData ar1, ar3; mathed_parse_cell(ar1, s1); mathed_parse_cell(ar3, s3); if (ar1.size() != 1 || ar3.size() != 1) @@ -74,29 +73,29 @@ bool Correction::read(idocstream & is) } -void Correction::write(odocstream & os) const -{ - os << "from: '" << from1_ << "' and '" << from2_ - << "' to '" << to_ << '\'' << endl; -} - - bool Correction::correct(MathAtom & at, char_type c) const { - //LYXERR(Debug::MATHED) - // << "trying to correct ar: " << at << " from: '" << from1_ << '\'' << endl; + //LYXERR(Debug::MATHED, + // "trying to correct ar: " << at << " from: '" << from1_ << '\''); if (from2_ != c) return false; if (asString(at) != asString(from1_)) return false; - LYXERR(Debug::MATHED) - << "match found! subst in " << at - << " from: '" << from1_ << "' to '" << to_ << '\'' << endl; + LYXERR(Debug::MATHED, "match found! subst in " << at + << " from: '" << from1_ << "' to '" << to_ << '\''); at = to_; return true; } +#if 0 +void Correction::write(odocstream & os) const +{ + os << "from: '" << from1_ << "' and '" << from2_ + << "' to '" << to_ << '\'' << endl; +} + + idocstream & operator>>(idocstream & is, Correction & corr) { corr.read(is); @@ -109,7 +108,7 @@ odocstream & operator<<(odocstream & os, Correction & corr) corr.write(os); return os; } - +#endif @@ -142,7 +141,7 @@ Corrections theCorrections; void initAutoCorrect() { - LYXERR(Debug::MATHED) << "reading autocorrect file" << endl; + LYXERR(Debug::MATHED, "reading autocorrect file"); support::FileName const file = libFileSearch(string(), "autocorrect"); if (file.empty()) { lyxerr << "Could not find autocorrect file" << endl; @@ -152,28 +151,28 @@ void initAutoCorrect() string line; ifstream is(file.toFilesystemEncoding().c_str()); while (getline(is, line)) { - if (line.size() == 0 || line[0] == '#') { - //LYXERR(Debug::MATHED) << "ignoring line '" << line << '\'' << endl; + if (line.empty() || line[0] == '#') { + //LYXERR(Debug::MATHED, "ignoring line '" << line << '\''); continue; } idocstringstream il(from_utf8(line)); - //LYXERR(Debug::MATHED) << "line '" << line << '\'' << endl; + //LYXERR(Debug::MATHED, "line '" << line << '\''); Correction corr; if (corr.read(il)) { - //LYXERR(Debug::MATHED) << "parsed: '" << corr << '\'' << endl; + //LYXERR(Debug::MATHED, "parsed: '" << corr << '\''); theCorrections.insert(corr); } } - LYXERR(Debug::MATHED) << "done reading autocorrections." << endl; + LYXERR(Debug::MATHED, "done reading autocorrections."); } -} // namespace anon +} // namespace -bool math_autocorrect(MathAtom & at, char c) +bool math_autocorrect(MathAtom & at, char_type c) { static bool initialized = false;