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.
master
David Lawrence Ramsey 2017-07-10 16:01:34 -05:00 committed by Benno Schulenberg
parent 2367f3d8e6
commit ee52f45b01
1 changed files with 4 additions and 20 deletions

View File

@ -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 */