X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fchset.C;h=965616d811d33f0d71811f8902a461e6ca338e6d;hb=91a2ea274e9c27f571a3cd4798d2e8ecc1b982a7;hp=94ed5a3b68ef7793907b76d278b635949db35a70;hpb=a040c0bc6f017d0591bbc7ad1aa590589dbc40ff;p=lyx.git diff --git a/src/chset.C b/src/chset.C index 94ed5a3b68..965616d811 100644 --- a/src/chset.C +++ b/src/chset.C @@ -5,6 +5,7 @@ #endif #include +using std::ifstream; #include "chset.h" #include "support/filetools.h" @@ -12,6 +13,8 @@ #include "support/LSubstring.h" #include "debug.h" +using std::make_pair; + bool CharacterSet::loadFile(string const & fname) { map_.clear(); @@ -22,11 +25,11 @@ bool CharacterSet::loadFile(string const & fname) // open definition file lyxerr[Debug::KBMAP] - << "Reading keymap file " << fname << ".cdef" << endl; + << "Reading character set file " << fname << ".cdef" << endl; string filename = LibFileSearch("kbd", fname.c_str(), "cdef"); ifstream ifs(filename.c_str()); if (!ifs) { - lyxerr << "Unable to open keymap file" << endl; + lyxerr << "Unable to open character set file" << endl; return true; // no definition, use 7-bit ascii } name_ = fname; @@ -34,6 +37,10 @@ bool CharacterSet::loadFile(string const & fname) string str; int n; string line; + // Ok, I'll be the first to admit that this is probably not + // the fastest way to parse the cdef files, but I though it + // was a bit neat. Anyway it is wrong to use the lyxlex parse + // without the use of a keyword table. LRegex reg("^([12][0-9][0-9])[ \t]+\"([^ ]+)\".*"); while(getline(ifs, line)) { if (reg.exact_match(line)) { @@ -52,11 +59,20 @@ bool CharacterSet::loadFile(string const & fname) } -bool CharacterSet::encodeString(string & str) const +pair CharacterSet::encodeString(string & str) const { + lyxerr[Debug::KBMAP] << "Checking if we know [" << str << "]" << endl; + bool ret = false; + int val = 0; Cdef::const_iterator cit = map_.find(str); - if (cit != map_.end()) return true; - return false; + if (cit != map_.end()) { + ret = true; + val = (*cit).second; + } + lyxerr[Debug::KBMAP] << " " + << (ret ? "yes we" : "no we don't") + << " know [" << str << "]" << endl; + return make_pair(ret, val); }