Commit 79a4bf81 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

tweaks: rename five variables, for uniformity with a few others

parent b77e6bd9
Showing with 24 additions and 25 deletions
+24 -25
...@@ -1813,9 +1813,8 @@ void do_output(char *output, size_t output_len, bool allow_cntrls) ...@@ -1813,9 +1813,8 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
#ifndef NANO_TINY #ifndef NANO_TINY
size_t orig_lenpt = 0; size_t orig_lenpt = 0;
#endif #endif
char *char_buf = charalloc(mb_cur_max()); char *char_buf = charalloc(mb_cur_max());
int char_buf_len; int char_len;
current_len = strlen(openfile->current->data); current_len = strlen(openfile->current->data);
...@@ -1838,12 +1837,12 @@ void do_output(char *output, size_t output_len, bool allow_cntrls) ...@@ -1838,12 +1837,12 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
} }
/* Get the next multibyte character. */ /* Get the next multibyte character. */
char_buf_len = parse_mbchar(output + i, char_buf, NULL); char_len = parse_mbchar(output + i, char_buf, NULL);
i += char_buf_len; i += char_len;
/* If controls are not allowed, ignore an ASCII control character. */ /* If controls are not allowed, ignore an ASCII control character. */
if (!allow_cntrls && is_ascii_cntrl_char(*(output + i - char_buf_len))) if (!allow_cntrls && is_ascii_cntrl_char(*(output + i - char_len)))
continue; continue;
/* If we're adding to the magicline, create a new magicline. */ /* If we're adding to the magicline, create a new magicline. */
...@@ -1857,13 +1856,13 @@ void do_output(char *output, size_t output_len, bool allow_cntrls) ...@@ -1857,13 +1856,13 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
/* Make room for the new character and copy it into the line. */ /* Make room for the new character and copy it into the line. */
openfile->current->data = charealloc(openfile->current->data, openfile->current->data = charealloc(openfile->current->data,
current_len + char_buf_len + 1); current_len + char_len + 1);
charmove(openfile->current->data + openfile->current_x + char_buf_len, charmove(openfile->current->data + openfile->current_x + char_len,
openfile->current->data + openfile->current_x, openfile->current->data + openfile->current_x,
current_len - openfile->current_x + 1); current_len - openfile->current_x + 1);
strncpy(openfile->current->data + openfile->current_x, char_buf, strncpy(openfile->current->data + openfile->current_x, char_buf,
char_buf_len); char_len);
current_len += char_buf_len; current_len += char_len;
openfile->totsize++; openfile->totsize++;
set_modified(); set_modified();
...@@ -1873,10 +1872,10 @@ void do_output(char *output, size_t output_len, bool allow_cntrls) ...@@ -1873,10 +1872,10 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
/* Note that current_x has not yet been incremented. */ /* Note that current_x has not yet been incremented. */
if (openfile->mark_set && openfile->current == openfile->mark_begin && if (openfile->mark_set && openfile->current == openfile->mark_begin &&
openfile->current_x < openfile->mark_begin_x) openfile->current_x < openfile->mark_begin_x)
openfile->mark_begin_x += char_buf_len; openfile->mark_begin_x += char_len;
#endif #endif
openfile->current_x += char_buf_len; openfile->current_x += char_len;
#ifndef NANO_TINY #ifndef NANO_TINY
update_undo(ADD); update_undo(ADD);
......
...@@ -102,7 +102,7 @@ void do_deletion(undo_type action) ...@@ -102,7 +102,7 @@ void do_deletion(undo_type action)
if (openfile->current->data[openfile->current_x] != '\0') { if (openfile->current->data[openfile->current_x] != '\0') {
/* We're in the middle of a line: delete the current character. */ /* We're in the middle of a line: delete the current character. */
int char_buf_len = parse_mbchar(openfile->current->data + int char_len = parse_mbchar(openfile->current->data +
openfile->current_x, NULL, NULL); openfile->current_x, NULL, NULL);
size_t line_len = strlen(openfile->current->data + size_t line_len = strlen(openfile->current->data +
openfile->current_x); openfile->current_x);
...@@ -118,16 +118,16 @@ void do_deletion(undo_type action) ...@@ -118,16 +118,16 @@ void do_deletion(undo_type action)
/* Move the remainder of the line "in", over the current character. */ /* Move the remainder of the line "in", over the current character. */
charmove(&openfile->current->data[openfile->current_x], charmove(&openfile->current->data[openfile->current_x],
&openfile->current->data[openfile->current_x + char_buf_len], &openfile->current->data[openfile->current_x + char_len],
line_len - char_buf_len + 1); line_len - char_len + 1);
null_at(&openfile->current->data, openfile->current_x + null_at(&openfile->current->data, openfile->current_x +
line_len - char_buf_len); line_len - char_len);
#ifndef NANO_TINY #ifndef NANO_TINY
/* Adjust the mark if it is after the cursor on the current line. */ /* Adjust the mark if it is after the cursor on the current line. */
if (openfile->mark_set && openfile->mark_begin == openfile->current && if (openfile->mark_set && openfile->mark_begin == openfile->current &&
openfile->mark_begin_x > openfile->current_x) openfile->mark_begin_x > openfile->current_x)
openfile->mark_begin_x -= char_buf_len; openfile->mark_begin_x -= char_len;
#endif #endif
/* Adjust the file size. */ /* Adjust the file size. */
openfile->totsize--; openfile->totsize--;
...@@ -1222,12 +1222,12 @@ void add_undo(undo_type action) ...@@ -1222,12 +1222,12 @@ void add_undo(undo_type action)
case DEL: case DEL:
if (u->begin != strlen(openfile->current->data)) { if (u->begin != strlen(openfile->current->data)) {
char *char_buf = charalloc(mb_cur_max() + 1); char *char_buf = charalloc(mb_cur_max() + 1);
int char_buf_len = parse_mbchar(&openfile->current->data[u->begin], int char_len = parse_mbchar(&openfile->current->data[u->begin],
char_buf, NULL); char_buf, NULL);
null_at(&char_buf, char_buf_len); null_at(&char_buf, char_len);
u->strdata = char_buf; u->strdata = char_buf;
if (u->type == BACK) if (u->type == BACK)
u->mark_begin_x += char_buf_len; u->mark_begin_x += char_len;
break; break;
} }
/* Else purposely fall into the line-joining code. */ /* Else purposely fall into the line-joining code. */
...@@ -1355,8 +1355,8 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf ...@@ -1355,8 +1355,8 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf
openfile->current->data, (unsigned long)openfile->current_x, (unsigned long)u->begin); openfile->current->data, (unsigned long)openfile->current_x, (unsigned long)u->begin);
#endif #endif
char *char_buf = charalloc(mb_cur_max()); char *char_buf = charalloc(mb_cur_max());
size_t char_buf_len = parse_mbchar(&openfile->current->data[u->mark_begin_x], char_buf, NULL); int char_len = parse_mbchar(&openfile->current->data[u->mark_begin_x], char_buf, NULL);
u->strdata = addstrings(u->strdata, u->strdata ? strlen(u->strdata) : 0, char_buf, char_buf_len); u->strdata = addstrings(u->strdata, u->strdata ? strlen(u->strdata) : 0, char_buf, char_len);
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, " >> current undo data is \"%s\"\n", u->strdata); fprintf(stderr, " >> current undo data is \"%s\"\n", u->strdata);
#endif #endif
...@@ -1367,14 +1367,14 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf ...@@ -1367,14 +1367,14 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf
case BACK: case BACK:
case DEL: { case DEL: {
char *char_buf = charalloc(mb_cur_max()); char *char_buf = charalloc(mb_cur_max());
size_t char_buf_len = parse_mbchar(&openfile->current->data[openfile->current_x], char_buf, NULL); int char_len = parse_mbchar(&openfile->current->data[openfile->current_x], char_buf, NULL);
if (openfile->current_x == u->begin) { if (openfile->current_x == u->begin) {
/* They're deleting. */ /* They're deleting. */
u->strdata = addstrings(u->strdata, strlen(u->strdata), char_buf, char_buf_len); u->strdata = addstrings(u->strdata, strlen(u->strdata), char_buf, char_len);
u->mark_begin_x = openfile->current_x; u->mark_begin_x = openfile->current_x;
} else if (openfile->current_x == u->begin - char_buf_len) { } else if (openfile->current_x == u->begin - char_len) {
/* They're backspacing. */ /* They're backspacing. */
u->strdata = addstrings(char_buf, char_buf_len, u->strdata, strlen(u->strdata)); u->strdata = addstrings(char_buf, char_len, u->strdata, strlen(u->strdata));
u->begin = openfile->current_x; u->begin = openfile->current_x;
} else { } else {
/* They deleted something else on the line. */ /* They deleted something else on the line. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment