commit 539a18e4c7f43f4787070727c1a7a76d1c7c0608
parent a7083d632bdbaaebf223a536bff6ec0c501adebe
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 22 Nov 2018 20:00:18 +0100
tweaks: condense and improve a handful of comments, and rewrap two lines
Diffstat:
2 files changed, 18 insertions(+), 30 deletions(-)
diff --git a/src/move.c b/src/move.c
@@ -170,8 +170,7 @@ void do_page_down(void)
}
#ifdef ENABLE_JUSTIFY
-/* Move to the beginning of the first-found beginning-of-paragraph line
- * before the current line. */
+/* Move to the first beginning of a paragraph before the current line. */
void do_para_begin(filestruct **line)
{
if ((*line)->prev != NULL)
@@ -181,25 +180,18 @@ void do_para_begin(filestruct **line)
*line = (*line)->prev;
}
-/* Move down to the beginning of the last line of the current paragraph.
- * Then move down one line farther if there is such a line, or to the
- * end of the current line if not.
- * A line is the last line of a paragraph if it is
- * in a paragraph, and the next line either is the beginning line of a
- * paragraph or isn't in a paragraph. Return whether the last line of
- * the paragraph is part of the paragraph (instead of the line following
- * the paragraph). */
+/* Move down to the beginning of the last line of the current paragraph;
+ * then move down one line farther if there is such a line, or to the
+ * end of the last line if not. Return FALSE when we stepped to the
+ * line beyond the last line of the paragraph, and TRUE otherwise. */
bool do_para_end(filestruct **line)
{
- while ((*line)->next != NULL &&
- !inpar(*line))
+ while ((*line)->next != NULL && !inpar(*line))
*line = (*line)->next;
- while ((*line)->next != NULL &&
- inpar((*line)->next) &&
- !begpar((*line)->next, 0)) {
+ while ((*line)->next != NULL && inpar((*line)->next) &&
+ !begpar((*line)->next, 0))
*line = (*line)->next;
- }
if ((*line)->next != NULL) {
*line = (*line)->next;
diff --git a/src/text.c b/src/text.c
@@ -2028,14 +2028,12 @@ bool inpar(const filestruct *const line)
return (line->data[quote_len + indent_len] != '\0');
}
-/* Find the beginning of the current paragraph if we're in one, or the
- * beginning of the next paragraph if we're not. Afterwards, save the
- * first line of the paragraph in firstline, whether the last line of
- * the paragraph is part of the paragraph (instead of the line following
- * the paragraph) in bot_inpar, and
- * quote length and paragraph length in *quote and *par. Return TRUE if
- * we found a paragraph, and FALSE if there was an error or we didn't
- * find a paragraph. */
+/* Determine the beginning, length, and quoting of either the current
+ * paragraph (when we're in one) or the next paragraph (when we're not).
+ * Return TRUE if we found a paragraph, and FALSE otherwise. Furthermore,
+ * return in firstline the first line of the paragraph, in bot_inpar whether
+ * the last line of the buffer is part of the paragraph, and in *quote the
+ * length of the quoting and in *par the length of the paragraph. */
bool find_paragraph(filestruct **firstline, bool *bot_inpar,
size_t *const quote, size_t *const par)
{
@@ -2051,9 +2049,8 @@ bool find_paragraph(filestruct **firstline, bool *bot_inpar,
return FALSE;
}
- /* If we're at the end of the last line of the file, and we're not in a
- * paragraph, it means that there aren't any paragraphs left, so get
- * out. */
+ /* When at the end of the buffer and not in a paragraph, there aren't
+ * any paragraphs left, so get out. */
if (parline->next == NULL && !inpar(parline))
return FALSE;
@@ -2097,9 +2094,8 @@ bool find_paragraph(filestruct **firstline, bool *bot_inpar,
quote_len = quote_length((*firstline)->data);
par_len = parline->lineno - (*firstline)->lineno;
- /* If bot_inpar is TRUE, it means that we're at
- * the end of the last line of the file, and the line isn't blank, in
- * which case the last line of the file is part of the paragraph. */
+ /* When the last line of the buffer is part of the current paragraph,
+ * it means the paragraph is one line longer than computed. */
if (*bot_inpar == TRUE)
par_len++;