]> git.lyx.org Git - features.git/commitdiff
Just a bit of safety here.
authorRichard Heck <rgheck@comcast.net>
Fri, 5 Nov 2010 16:43:30 +0000 (16:43 +0000)
committerRichard Heck <rgheck@comcast.net>
Fri, 5 Nov 2010 16:43:30 +0000 (16:43 +0000)
This 0 default for end is wrong. You should be able to do:
  find_token(lines, token, 0, 0)
and have that return -1. As it is, this is equivalent to:
  find_token(lines, token, 0, len(lines))
But I am afraid to change the default, in case something in lyx_1.2.py
relies upon it somehow.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36125 a592a061-630c-0410-9148-cb99ea01b6c8

lib/lyx2lyx/parser_tools.py

index f895cc3982e8fb67037b62dacd1ebd255d8e898f..6cc5c35e9ce4679a02bfcb7f41bc3647701cbb0c 100644 (file)
@@ -128,7 +128,7 @@ def find_tokens(lines, tokens, start, end = 0, exact = False):
     the first element, in lines[start, end].
 
     Return -1 on failure."""
-    if end == 0:
+    if end == 0 or end > len(lines):
         end = len(lines)
 
     for i in xrange(start, end):
@@ -158,7 +158,7 @@ def find_re(lines, rexp, start, end = 0):
 
     Return -1 on failure."""
 
-    if end == 0:
+    if end == 0 or end > len(lines):
         end = len(lines)
     for i in xrange(start, end):
         if rexp.match(lines[i]):