]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfind.cpp
Move \PassOptionsToPackage before the first package loaded
[lyx.git] / src / lyxfind.cpp
index 139e7b398e4ae7b9d47a470e8062abd39e2dc68e..f98f525cbe7f072404e5301771b1aaeca37dcd11 100644 (file)
@@ -178,7 +178,7 @@ bool parse_bool(docstring & howto)
 }
 
 
-class MatchString : public binary_function<Paragraph, pos_type, int>
+class MatchString
 {
 public:
        MatchString(docstring const & s, bool cs, bool mw)
@@ -1565,8 +1565,8 @@ int Intervall::findclosing(int start, int end, char up = '{', char down = '}', i
       depth++;
     }
     else if (c == down) {
-      repeat--;
       if (depth == 0) {
+        repeat--;
         if ((repeat <= 0) || (par[i+1] != up))
           return i;
       }
@@ -1911,12 +1911,16 @@ void LatexInfo::buildEntries(bool isPatternString)
           int endpar = 2 + interval_.findclosing(found._dataStart, interval_.par.length(), '{', '}', closings);
           found._dataStart = endpar;
           found._tokensize = found._dataStart - found._tokenstart;
-          closings = 1;
+          closings = 0;
         }
         if (interval_.par.substr(found._dataStart-1, 15).compare("\\endarguments{}") == 0) {
           found._dataStart += 15;
         }
-        size_t endpos = interval_.findclosing(found._dataStart, interval_.par.length(), '{', '}', closings);
+        size_t endpos;
+        if (closings < 1)
+          endpos = found._dataStart - 1;
+        else
+          endpos = interval_.findclosing(found._dataStart, interval_.par.length(), '{', '}', closings);
         if (found.keytype == KeyInfo::isList) {
           // Check if it really is list env
           static regex const listre("^([a-z]+)$");
@@ -2041,9 +2045,9 @@ void LatexInfo::buildKeys(bool isPatternString)
   makeKey("url|href|vref|thanks", KeyInfo(KeyInfo::isStandard, 1, false), isPatternString);
 
   // Ignore deleted text
-  makeKey("lyxdeleted", KeyInfo(KeyInfo::doRemove, 2, false), isPatternString);
+  makeKey("lyxdeleted", KeyInfo(KeyInfo::doRemove, 3, false), isPatternString);
   // but preserve added text
-  makeKey("lyxadded", KeyInfo(KeyInfo::doRemove, 1, false), isPatternString);
+  makeKey("lyxadded", KeyInfo(KeyInfo::doRemove, 2, false), isPatternString);
 
   // Macros to remove, but let the parameter survive
   // No split
@@ -3026,9 +3030,9 @@ MatchResult MatchStringAdv::operator()(DocIterator const & cur, int len, bool at
               << ", inTexted=" << cur.inTexted());
        if (res == 0 || !at_begin || !opt.matchword || !cur.inTexted())
                return mres;
-        if ((len > 0) && (res < len)) {
+       if ((len > 0) && (res < len)) {
          mres.match_len = 0;
-          return mres;
+         return mres;
        }
        Paragraph const & par = cur.paragraph();
        bool ws_left = (cur.pos() > 0)
@@ -3040,18 +3044,18 @@ MatchResult MatchStringAdv::operator()(DocIterator const & cur, int len, bool at
        LYXERR(Debug::FIND,
               "cur.pos()=" << cur.pos() << ", res=" << res
               << ", separ: " << ws_left << ", " << ws_right
-               << ", len: " << len
+              << ", len: " << len
               << endl);
        if (ws_left && ws_right) {
-          // Check for word separators inside the found 'word'
-          for (int i = 0; i < len; i++) {
-            if (par.isWordSeparator(cur.pos() + i)) {
+         // Check for word separators inside the found 'word'
+         for (int i = 0; i < len; i++) {
+           if (par.isWordSeparator(cur.pos() + i)) {
              mres.match_len = 0;
-              return mres;
+             return mres;
            }
-          }
-          return mres;
-        }
+         }
+         return mres;
+       }
        mres.match_len = 0;
        return mres;
 }
@@ -3413,10 +3417,9 @@ int findForwardAdv(DocIterator & cur, MatchStringAdv & match)
                                                match_len_zero_count = 0;
                                }
                                else {
-                                        if (++match_len_zero_count > 3) {
-                                                LYXERR(Debug::FIND, "match_len2_zero_count: " << match_len_zero_count << ", match_len was " << match_len);
-                                                match_len_zero_count = 0;
-                                        }
+                                       if (++match_len_zero_count > 3) {
+                                               LYXERR(Debug::FIND, "match_len2_zero_count: " << match_len_zero_count << ", match_len was " << match_len);
+                                       }
                                        break;
                                }
                        }