cosmetic fixes

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3463 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2006-05-01 17:14:25 +00:00
parent 2ca3fc9fa6
commit af9052d7c7
2 changed files with 22 additions and 20 deletions

View File

@ -603,7 +603,7 @@ void do_delete(void);
void do_backspace(void); void do_backspace(void);
void do_tab(void); void do_tab(void);
#ifndef NANO_TINY #ifndef NANO_TINY
void do_indent_marked(ssize_t len); void do_indent_marked(ssize_t cols);
void do_indent_marked_void(void); void do_indent_marked_void(void);
void do_unindent_marked_void(void); void do_unindent_marked_void(void);
#endif #endif

View File

@ -194,12 +194,12 @@ void do_tab(void)
} }
#ifndef NANO_TINY #ifndef NANO_TINY
/* Indent or unindent all lines covered by the mark len characters, /* Indent or unindent all lines covered by the mark len columns,
* depending on whether len is positive or negative. If the * depending on whether len is positive or negative. If the
* TABS_TO_SPACES flag is set, indent/unindent by len spaces. * TABS_TO_SPACES flag is set, indent/unindent by len spaces.
* Otherwise, indent/unindent by (len / tabsize) tabs and (len % * Otherwise, indent/unindent by (len / tabsize) tabs and (len %
* tabsize) spaces. */ * tabsize) spaces. */
void do_indent_marked(ssize_t len) void do_indent_marked(ssize_t cols)
{ {
bool indent_changed = FALSE; bool indent_changed = FALSE;
/* Whether any indenting or unindenting was done. */ /* Whether any indenting or unindenting was done. */
@ -224,13 +224,14 @@ void do_indent_marked(ssize_t len)
return; return;
} }
/* If len is zero, get out. */ /* If cols is zero, get out. */
if (len == 0) if (cols == 0)
return; return;
/* If len is negative, make it positive and set unindent to TRUE. */ /* If cols is negative, make it positive and set unindent to
if (len < 0) { * TRUE. */
len = -len; if (cols < 0) {
cols = -cols;
unindent = TRUE; unindent = TRUE;
/* Otherwise, we're indenting, in which case the file will always be /* Otherwise, we're indenting, in which case the file will always be
* modified, so set indent_changed to TRUE. */ * modified, so set indent_changed to TRUE. */
@ -242,17 +243,17 @@ void do_indent_marked(ssize_t len)
(const filestruct **)&bot, &bot_x, NULL); (const filestruct **)&bot, &bot_x, NULL);
/* Set up the text we'll be using as indentation. */ /* Set up the text we'll be using as indentation. */
line_indent = charalloc(len + 1); line_indent = charalloc(cols + 1);
if (ISSET(TABS_TO_SPACES)) { if (ISSET(TABS_TO_SPACES)) {
/* Set the indentation to len spaces. */ /* Set the indentation to cols spaces. */
charset(line_indent, ' ', len); charset(line_indent, ' ', cols);
line_indent_len = len; line_indent_len = cols;
} else { } else {
/* Set the indentation to (len / tabsize) tabs and (len % /* Set the indentation to (cols / tabsize) tabs and (cols %
* tabsize) spaces. */ * tabsize) spaces. */
size_t num_tabs = len / tabsize; size_t num_tabs = cols / tabsize;
size_t num_spaces = len % tabsize; size_t num_spaces = cols % tabsize;
charset(line_indent, '\t', num_tabs); charset(line_indent, '\t', num_tabs);
charset(line_indent + num_tabs, ' ', num_spaces); charset(line_indent + num_tabs, ' ', num_spaces);
@ -270,11 +271,12 @@ void do_indent_marked(ssize_t len)
if (unindent) { if (unindent) {
size_t indent_col = strnlenpt(f->data, indent_len); size_t indent_col = strnlenpt(f->data, indent_len);
if (len <= indent_col) { if (cols <= indent_col) {
size_t indent_new = actual_x(f->data, indent_col - len); size_t indent_new = actual_x(f->data, indent_col -
cols);
size_t indent_shift = indent_len - indent_new; size_t indent_shift = indent_len - indent_new;
/* If we're unindenting, and there's at least len /* If we're unindenting, and there's at least cols
* columns' worth of indentation at the beginning of the * columns' worth of indentation at the beginning of the
* non-whitespace text of this line, remove it. */ * non-whitespace text of this line, remove it. */
charmove(&f->data[indent_new], &f->data[indent_len], charmove(&f->data[indent_new], &f->data[indent_len],
@ -330,13 +332,13 @@ void do_indent_marked(ssize_t len)
} }
} }
/* Indent all lines covered by the mark tabsize characters. */ /* Indent all lines covered by the mark tabsize columns. */
void do_indent_marked_void(void) void do_indent_marked_void(void)
{ {
do_indent_marked(tabsize); do_indent_marked(tabsize);
} }
/* Unindent all lines covered by the mark tabsize characters. */ /* Unindent all lines covered by the mark tabsize columns. */
void do_unindent_marked_void(void) void do_unindent_marked_void(void)
{ {
do_indent_marked(-tabsize); do_indent_marked(-tabsize);