]> git.lyx.org Git - features.git/commitdiff
FindAdv: Amend b21c8b21: Expand the list for handled latin characters
authorKornel Benko <kornel@lyx.org>
Mon, 4 Mar 2019 13:05:44 +0000 (14:05 +0100)
committerKornel Benko <kornel@lyx.org>
Mon, 4 Mar 2019 13:05:44 +0000 (14:05 +0100)
1.) Added for 'breve' and 'grave' accents
2.) Corrected handling for 'i'-accents (allowed \hat{i} _and_ \hat{\imath})
because of problems with ignoring case
3.) Spaces: Changed some indents in source

src/lyxfind.cpp

index f3cbd153a3ea3127fe784a7c3b539f617801dcf6..eeb4829510b4763ed19783ba50539c7ff6052d82 100644 (file)
@@ -1262,19 +1262,22 @@ static void buildaccent(string n, string param, string values)
       string key = name + "{" + param[i] + "}";
       // get the corresponding utf8-value
       if ((values[start] & 0xc0) != 0xc0) {
-       // should not happen, utf8 encoding starts at least with 11xxxxxx
-       start++;
-       continue;
+        // should not happen, utf8 encoding starts at least with 11xxxxxx
+        start++;
+        continue;
       }
       for (int j = 1; ;j++) {
-       if (start + j >= values.size())
-         break;
-       if ((values[start+j] & 0xc0) == 0xc0) {
-         // This is the first byte of following utf8 char
-         accents[key] = values.substr(start, j);
-         start += j;
-         break;
-       }
+        if (start + j >= values.size()) {
+          accents[key] = values.substr(start, j);
+          start = values.size() - 1;
+          break;
+        }
+        else if ((values[start+j] & 0xc0) == 0xc0) {
+          // This is the first byte of following utf8 char
+          accents[key] = values.substr(start, j);
+          start += j;
+          break;
+        }
       }
     }
   }
@@ -1283,32 +1286,39 @@ static void buildaccent(string n, string param, string values)
 static void buildAccentsMap()
 {
   accents["imath"] = "ı";
+  accents["i"] = "ı";
   accents["jmath"] = "ȷ";
   accents["lyxmathsym{ß}"] = "ß";
   accents["ddot{\\imath}"] = "ï";
-  buildaccent("ddot", "aAeEIoOuUyY",
-                      "äÃ\84ëÃ\8bÃ\8föÃ\96üÃ\9cÿŸ");       // umlaut
-  buildaccent("dot|.", "cCeEgGIzZaAoObBdDfFyY",
-                     "ċĊėĖġĠİżŻȧȦȯȮḃḂḋḊḟḞẏẎ");
+  buildaccent("ddot", "aAeEiIoOuUyY",
+                      "äÃ\84ëÃ\8bïÃ\8föÃ\96üÃ\9cÿŸ");     // umlaut
+  buildaccent("dot|.", "cCeEgGiIzZaAoObBdDfFyY",
+                       "ċĊėĖġĠiİżŻȧȦȯȮḃḂḋḊḟḞẏẎ");
   accents["acute{\\imath}"] = "í";
-  buildaccent("acute", "aAcCeElLoOnNrRsSuUyYzZI",
-                       "áÁćĆéÉĺĹóÓńŃŕŔśŚúÚýÝźŹÍ");
+  buildaccent("acute", "aAcCeElLoOnNrRsSuUyYzZiI",
+                       "áÃ\81Ä\87Ä\86éÃ\89ĺĹóÃ\93Å\84Å\83Å\95Å\94Å\9bÅ\9aúÃ\9aýÃ\9dźŹíÃ\8d");
   buildaccent("dacute|H|h", "oOuU", "őŐűŰ");       // double acute
   buildaccent("mathring|r", "uU", "ůŮ");
   accents["check{\\imath}"] = "ǐ";
   accents["check{\\jmath}"] = "ǰ";
-  buildaccent("check|v", "cCdDaAeEIoOuUgGkKhHlLnNrRsSTzZ",
-                         "Ä\8dÄ\8cÄ\8fÄ\8eÇ\8eÇ\8dÄ\9bÄ\9aÇ\8fÇ\92Ç\91Ç\94Ç\93ǧǦǩǨÈ\9fÈ\9eľĽÅ\88Å\87Å\99Å\98šŠŤžŽ");      // caron
+  buildaccent("check|v", "cCdDaAeEiIoOuUgGkKhHlLnNrRsSTzZ",
+                         "Ä\8dÄ\8cÄ\8fÄ\8eÇ\8eÇ\8dÄ\9bÄ\9aÇ\90Ç\8fÇ\92Ç\91Ç\94Ç\93ǧǦǩǨÈ\9fÈ\9eľĽÅ\88Å\87Å\99Å\98šŠŤžŽ");    // caron
   accents["hat{\\imath}"] = "î";
   accents["hat{\\jmath}"] = "ĵ";
-  buildaccent("hat|^", "aAeEiIcCgGhHJsSwWyYzZoOuU",
-                       "âÃ\82êÃ\8aîÃ\8eÄ\89Ä\88Ä\9dÄ\9cĥĤĴÅ\9dÅ\9cŵŴŷŶáº\91áº\90ôÃ\94ûÃ\9b");        // circ
+  buildaccent("hat|^", "aAeEiIcCgGhHjJsSwWyYzZoOuU",
+                       "âÃ\82êÃ\8aîÃ\8eÄ\89Ä\88Ä\9dÄ\9cĥĤĵĴÅ\9dÅ\9cŵŴŷŶáº\91áº\90ôÃ\94ûÃ\9b");      // circ
   accents["bar{\\imath}"] = "ī";
-  buildaccent("bar|=", "aAeEIoOuUyY",
-                       "Ä\81Ä\80Ä\93Ä\92ĪÅ\8dÅ\8cūŪȳȲ");      // macron
+  buildaccent("bar|=", "aAeEiIoOuUyY",
+                       "Ä\81Ä\80Ä\93Ä\92īĪÅ\8dÅ\8cūŪȳȲ");    // macron
   accents["tilde{\\imath}"] = "ĩ";
-  buildaccent("tilde", "aAnNoOIuU",
-                       "ãÃñÑõÕĨũŨ");  // tilde
+  buildaccent("tilde", "aAnNoOiIuU",
+                       "ãÃñÑõÕĩĨũŨ");        // tilde
+  accents["breve{\\imath}"] = "ĭ";
+  buildaccent("breve|u", "aAeEgGiIoOuU",
+                         "ăĂĕĔğĞĭĬŏŎŭŬ");    // breve
+  accents["grave{\\imath}"] = "ì";
+  buildaccent("grave|`", "aAeEiIoOuUnNwWyY",
+                         "àÀèÈìÌòÒùÙǹǸẁẀỳỲ");                // grave
 }
 
 /*
@@ -1319,7 +1329,7 @@ void Intervall::removeAccents()
 {
   if (accents.empty())
     buildAccentsMap();
-  static regex const accre("\\\\((lyxmathsym|ddot|dot|.|acute|dacute|h|H|mathring|r|check|v|hat|^|bar|=|tilde)\\{[^\\{\\}]+\\}|imath|jmath)");
+  static regex const accre("\\\\((.|grave|breve|u|lyxmathsym|ddot|dot|acute|dacute|mathring|check|hat|bar|tilde)\\{[^\\{\\}]+\\}|i|imath|jmath)");
   smatch sub;
   for (sregex_iterator itacc(par.begin(), par.end(), accre), end; itacc != end; ++itacc) {
     sub = *itacc;
@@ -2569,14 +2579,14 @@ static string correctlanguagesetting(string par, bool isPatternString, bool with
                missed = 0;
                if (withformat) {
                        regex_f = identifyFeatures(result);
-                        string features = "";
+                       string features = "";
                        for (auto it = regex_f.cbegin(); it != regex_f.cend(); ++it) {
                                string a = it->first;
                                regex_with_format = true;
-                                features += " " + a;
+                               features += " " + a;
                                // LYXERR0("Identified regex format:" << a);
                        }
-                        LYXERR(Debug::FIND, "Identified Features" << features);
+                       LYXERR(Debug::FIND, "Identified Features" << features);
 
                }
        } else if (regex_with_format) {