Commit fe9cf6f3 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

tweaks: make advancing and retreating more symmetrical

No related merge requests found
Showing with 7 additions and 6 deletions
+7 -6
...@@ -611,20 +611,21 @@ size_t get_totsize(const filestruct *begin, const filestruct *end) ...@@ -611,20 +611,21 @@ size_t get_totsize(const filestruct *begin, const filestruct *end)
return totsize; return totsize;
} }
/* Get back a pointer given a line number in the current openfilestruct. */ /* Given a line number, return a pointer to the corresponding struct. */
filestruct *fsfromline(ssize_t lineno) filestruct *fsfromline(ssize_t lineno)
{ {
filestruct *f = openfile->current; filestruct *f = openfile->current;
if (lineno <= openfile->current->lineno) if (lineno <= openfile->current->lineno)
for (; f->lineno != lineno && f != openfile->fileage; f = f->prev) while (f->lineno != lineno && f->prev != NULL)
; f = f->prev;
else else
for (; f->lineno != lineno && f->next != NULL; f = f->next) while (f->lineno != lineno && f->next != NULL)
; f = f->next;
if (f->lineno != lineno) if (f->lineno != lineno)
f = NULL; return NULL;
return f; return f;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment