X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FEncoding.cpp;h=c7ea237179e79c966c7a700cea998fa0dda8da05;hb=33f9cfb7961501b38c573eede468b011687f46de;hp=ad380d78039d69f83ffa048bb14b3ed9a54c51b5;hpb=6dd505c67aff5e529aa6127504d38fa38725a0b6;p=lyx.git diff --git a/src/Encoding.cpp b/src/Encoding.cpp index ad380d7803..c7ea237179 100644 --- a/src/Encoding.cpp +++ b/src/Encoding.cpp @@ -17,16 +17,16 @@ #include "Lexer.h" #include "support/debug.h" +#include "support/docstring.h" #include "support/gettext.h" #include "support/lstrings.h" #include "support/mutex.h" #include "support/textutils.h" #include "support/unicode.h" -#include - -#include #include +#include +#include #include using namespace std; @@ -68,7 +68,7 @@ EncodingException::EncodingException(char_type c) } -const char * EncodingException::what() const throw() +const char * EncodingException::what() const noexcept { return "Could not find LaTeX command for a character"; } @@ -229,8 +229,7 @@ pair Encoding::latexString(docstring const & input, bool d docstring result; docstring uncodable; bool terminate = false; - for (size_t n = 0; n < input.size(); ++n) { - char_type const c = input[n]; + for (char_type const c : input) { try { pair latex_char = latexChar(c); docstring const latex = latex_char.first; @@ -253,10 +252,10 @@ pair Encoding::latexString(docstring const & input, bool d if (dryrun) { result += "<" + _("LyX Warning: ") + _("uncodable character") + " '"; - result += docstring(1, input[n]); + result += docstring(1, c); result += "'>"; } else - uncodable += input[n]; + uncodable += c; } } return make_pair(result, uncodable); @@ -275,7 +274,7 @@ vector Encoding::symbolsList() const // add all encodable characters copy(encodable_.begin(), encodable_.end(), back_inserter(symbols)); // now the ones from the unicodesymbols file that are not already there - for (pair const & elem : unicodesymbols) { + for (auto const & elem : unicodesymbols) { if (find(symbols.begin(), symbols.end(), elem.first) == symbols.end()) symbols.push_back(elem.first); } @@ -637,15 +636,15 @@ Encodings::fromLyXName(string const & name, bool allowUnsafe) const { EncodingList::const_iterator const it = encodinglist.find(name); if (it == encodinglist.end()) - return 0; + return nullptr; if (!allowUnsafe && it->second.unsafe()) - return 0; + return nullptr; return &it->second; } Encoding const * -Encodings::fromLaTeXName(string const & n, int const & p, bool allowUnsafe) const +Encodings::fromLaTeXName(string const & n, int p, bool allowUnsafe) const { string name = n; // FIXME: if we have to test for too many of these synonyms, @@ -663,19 +662,19 @@ Encodings::fromLaTeXName(string const & n, int const & p, bool allowUnsafe) cons if ((it->second.latexName() == name) && (it->second.package() & p) && (!it->second.unsafe() || allowUnsafe)) return &it->second; - return 0; + return nullptr; } Encoding const * -Encodings::fromIconvName(string const & n, int const & p, bool allowUnsafe) const +Encodings::fromIconvName(string const & n, int p, bool allowUnsafe) const { EncodingList::const_iterator const end = encodinglist.end(); for (EncodingList::const_iterator it = encodinglist.begin(); it != end; ++it) if ((it->second.iconvName() == n) && (it->second.package() & p) && (!it->second.unsafe() || allowUnsafe)) return &it->second; - return 0; + return nullptr; } @@ -703,7 +702,7 @@ void Encodings::read(FileName const & encfile, FileName const & symbolsfile) istringstream is(symbolslex.getString()); // reading symbol directly does not work if // char_type == wchar_t. - boost::uint32_t tmp; + uint32_t tmp; if(!(is >> hex >> tmp)) break; symbol = tmp; @@ -734,14 +733,14 @@ void Encodings::read(FileName const & encfile, FileName const & symbolsfile) } else if (prefixIs(flag, "force=")) { vector encs = getVectorFromString(flag.substr(6), ";"); - for (size_t i = 0; i < encs.size(); ++i) - forcedselected[encs[i]].insert(symbol); + for (auto const & enc : encs) + forcedselected[enc].insert(symbol); flags |= CharInfoForceSelected; } else if (prefixIs(flag, "force!=")) { vector encs = getVectorFromString(flag.substr(7), ";"); - for (size_t i = 0; i < encs.size(); ++i) - forcednotselected[encs[i]].insert(symbol); + for (auto const & enc : encs) + forcednotselected[enc].insert(symbol); flags |= CharInfoForceSelected; } else if (flag == "mathalpha") { mathalpha.insert(symbol);