commit ee52f45b01c0d0eeb905a1d40ab072983d5b2033
parent 2367f3d8e66b6f794850cc85b6bb85c6d789b286
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date: Mon, 10 Jul 2017 16:01:34 -0500
text: remove unneeded references to cols from the indentation routines
The parameter 'cols', that indicates how many columns to indent or
unindent, is changed to be always positive, so the check for being
negative can go. And it could never be zero anyway.
Diffstat:
1 file changed, 4 insertions(+), 20 deletions(-)
diff --git a/src/text.c b/src/text.c
@@ -298,17 +298,9 @@ void do_indent(ssize_t cols)
assert(openfile->current != NULL && openfile->current->data != NULL);
- /* If cols is zero, get out. */
- if (cols == 0)
- return;
-
- /* If cols is negative, make it positive and set unindent to TRUE. */
- if (cols < 0) {
- cols = -cols;
- unindent = TRUE;
/* Otherwise, we're indenting, in which case the file will always be
* modified, so set indent_changed to TRUE. */
- } else
+ if (!unindent)
indent_changed = TRUE;
/* If the mark is on, use all lines covered by the mark. */
@@ -449,7 +441,7 @@ void do_unindent(ssize_t cols)
{
bool indent_changed = FALSE;
/* Whether any indenting or unindenting was done. */
- bool unindent = FALSE;
+ bool unindent = TRUE;
/* Whether we're unindenting text. */
char *line_indent = NULL;
/* The text added to each line in order to indent it. */
@@ -461,17 +453,9 @@ void do_unindent(ssize_t cols)
assert(openfile->current != NULL && openfile->current->data != NULL);
- /* If cols is zero, get out. */
- if (cols == 0)
- return;
-
- /* If cols is negative, make it positive and set unindent to TRUE. */
- if (cols < 0) {
- cols = -cols;
- unindent = TRUE;
/* Otherwise, we're indenting, in which case the file will always be
* modified, so set indent_changed to TRUE. */
- } else
+ if (!unindent)
indent_changed = TRUE;
/* If the mark is on, use all lines covered by the mark. */
@@ -600,7 +584,7 @@ void do_unindent(ssize_t cols)
* is on, tabsize columns. */
void do_unindent_void(void)
{
- do_unindent(-tabsize);
+ do_unindent(tabsize);
}
#endif /* !NANO_TINY */