From 1be131a9f90a75617a95b8fead0fba1df1e83c1a Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Fri, 11 Nov 2005 03:55:52 +0000 Subject: [PATCH] fix more find_paragraph() breakage git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3159 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- src/text.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/text.c b/src/text.c index af22303e..145f1903 100644 --- a/src/text.c +++ b/src/text.c @@ -1057,13 +1057,18 @@ bool find_paragraph(size_t *const quote, size_t *const par) assert(openfile->current != NULL); - /* Find the first line of the current or next paragraph. First, if - * the current line isn't in a paragraph, move forward to the line - * after the last line of the next paragraph, if any. If we end up - * on the same line, or the line before that isn't in a paragraph, it - * means that there aren't any paragraphs left, so get out. - * Otherwise, move back to the last line of the paragraph. If the - * current line is in a paragraph and it isn't the first line of + /* If we're at the end of the last line of the file, it means that + * there aren't any paragraphs left, so get out. */ + if (openfile->current == openfile->filebot && openfile->current_x == + strlen(openfile->filebot->data)) + return FALSE; + + /* If the current line isn't in a paragraph, move forward to the + * line after the last line of the next paragraph, if any. If we + * end up on the same line, or the line before that isn't in a + * paragraph, it means that there aren't any paragraphs left, so get + * out. Otherwise, move back to the last line of the paragraph. If + * the current line is in a paragraph and it isn't the first line of * that paragraph, move back to the first line. */ if (!inpar(openfile->current)) { current_save = openfile->current; @@ -1080,8 +1085,8 @@ bool find_paragraph(size_t *const quote, size_t *const par) /* Now current is the first line of the paragraph. Set quote_len to * the quotation length of that line, and set par_len to the number * of lines in this paragraph. If, while calculating the latter, we - * end up past the beginning of the line, it means that we're on the - * last line of the file, and the file doesn't end in a newline. If + * end up past the beginning of the line, it means that we're at the + * end of the last line of the file, and the line isn't blank. If * we were at the same place before, there aren't any paragraphs * left, so get out. Otherwise, the last line of the file is part * of this paragraph. */