Fix silly mistake spotted by Jurgen.

Give k a more descriptive name.
Prettify a bit of the code.
This commit is contained in:
Richard Heck 2014-02-07 10:36:55 -05:00
parent 6837345209
commit 0ded71a480

View File

@ -4228,12 +4228,10 @@ def revert_tibetan(document):
# optional argument of the inset, if the CONTENT is non-empty. # optional argument of the inset, if the CONTENT is non-empty.
def convert_chunks(document): def convert_chunks(document):
first_re = re.compile(r'<<(.*)>>=(.*)') first_re = re.compile(r'<<(.*)>>=(.*)')
k = 0 file_pos = 0
while True: while True:
# the beginning of this sequence
i = k
# find start of a block of chunks # find start of a block of chunks
i = find_token(document.body, "\\begin_layout Chunk", i) i = find_token(document.body, "\\begin_layout Chunk", file_pos)
if i == -1: if i == -1:
return return
start = i start = i
@ -4246,7 +4244,8 @@ def convert_chunks(document):
j = find_end_of_layout(document.body, i) j = find_end_of_layout(document.body, i)
if j == -1: if j == -1:
document.warning("Malformed LyX documents. Can't find end of Chunk layout!") document.warning("Malformed LyX documents. Can't find end of Chunk layout!")
break # there is no point continuing, as we will run into the same error again.
return
this_chunk = "".join(document.body[i + 1:j]) this_chunk = "".join(document.body[i + 1:j])
# there may be empty lines between chunks # there may be empty lines between chunks
@ -4265,22 +4264,14 @@ def convert_chunks(document):
break break
# look for subsequent chunk paragraph # look for subsequent chunk paragraph
i = j i = find_token(document.body, "\\begin_layout", j)
i = find_token(document.body, "\\begin_layout", i)
if i == -1: if i == -1:
break break
if get_value(document.body, "\\begin_layout", i) != "Chunk": if get_value(document.body, "\\begin_layout", i) != "Chunk":
break break
if j == -1: file_pos = end = j + 1
# error, but we can try to continue
# FIXME: Why not simply k = 0? (spitz)
k = j + 1
continue
end = j + 1
k = end
# The last chunk should simply have an "@" in it # The last chunk should simply have an "@" in it
# or at least end with "@" (can happen if @ is # or at least end with "@" (can happen if @ is
@ -4354,7 +4345,7 @@ def convert_chunks(document):
document.body[start:end] = newstuff document.body[start:end] = newstuff
k += len(newstuff) - (end - start) file_pos += len(newstuff) - (end - start)
def revert_chunks(document): def revert_chunks(document):