diff --git a/src/chars.c b/src/chars.c index 80c6666e..cf97df6c 100644 --- a/src/chars.c +++ b/src/chars.c @@ -332,7 +332,7 @@ size_t move_mbleft(const char *buf, size_t pos) { #ifdef ENABLE_UTF8 if (use_utf8) { - size_t before, char_len = 0; + size_t before, charlen = 0; if (pos < 4) before = 0; @@ -355,11 +355,11 @@ size_t move_mbleft(const char *buf, size_t pos) /* Move forward again until we reach the original character, * so we know the length of its preceding character. */ while (before < pos) { - char_len = parse_mbchar(buf + before, NULL, NULL); - before += char_len; + charlen = parse_mbchar(buf + before, NULL, NULL); + before += charlen; } - return before - char_len; + return before - charlen; } else #endif return (pos == 0 ? 0 : pos - 1); diff --git a/src/cut.c b/src/cut.c index 6417a859..5be5cad7 100644 --- a/src/cut.c +++ b/src/cut.c @@ -35,7 +35,7 @@ void do_deletion(undo_type action) /* When in the middle of a line, delete the current character. */ if (openfile->current->data[openfile->current_x] != '\0') { - int char_len = parse_mbchar(openfile->current->data + + int charlen = parse_mbchar(openfile->current->data + openfile->current_x, NULL, NULL); size_t line_len = strlen(openfile->current->data + openfile->current_x); @@ -53,13 +53,13 @@ void do_deletion(undo_type action) #endif /* Move the remainder of the line "in", over the current character. */ charmove(&openfile->current->data[openfile->current_x], - &openfile->current->data[openfile->current_x + char_len], - line_len - char_len + 1); + &openfile->current->data[openfile->current_x + charlen], + line_len - charlen + 1); #ifndef NANO_TINY /* Adjust the mark if it is after the cursor on the current line. */ if (openfile->mark == openfile->current && openfile->mark_x > openfile->current_x) - openfile->mark_x -= char_len; + openfile->mark_x -= charlen; #endif /* Otherwise, when not at end of buffer, join this line with the next. */ } else if (openfile->current != openfile->filebot) { diff --git a/src/nano.c b/src/nano.c index 466fb5fe..232095c7 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1780,7 +1780,7 @@ void do_input(void) void do_output(char *output, size_t output_len, bool allow_cntrls) { char onechar[MAXCHARLEN]; - int char_len; + int charlen; size_t current_len = strlen(openfile->current->data); size_t i = 0; #ifndef NANO_TINY @@ -1799,23 +1799,23 @@ void do_output(char *output, size_t output_len, bool allow_cntrls) output[i] = '\n'; /* Get the next multibyte character. */ - char_len = parse_mbchar(output + i, onechar, NULL); + charlen = parse_mbchar(output + i, onechar, NULL); - i += char_len; + i += charlen; /* If controls are not allowed, ignore an ASCII control character. */ - if (!allow_cntrls && is_ascii_cntrl_char(*(output + i - char_len))) + if (!allow_cntrls && is_ascii_cntrl_char(*(output + i - charlen))) continue; /* Make room for the new character and copy it into the line. */ openfile->current->data = charealloc(openfile->current->data, - current_len + char_len + 1); - charmove(openfile->current->data + openfile->current_x + char_len, + current_len + charlen + 1); + charmove(openfile->current->data + openfile->current_x + charlen, openfile->current->data + openfile->current_x, current_len - openfile->current_x + 1); strncpy(openfile->current->data + openfile->current_x, onechar, - char_len); - current_len += char_len; + charlen); + current_len += charlen; openfile->totsize++; set_modified(); @@ -1830,7 +1830,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls) /* Note that current_x has not yet been incremented. */ if (openfile->current == openfile->mark && openfile->current_x < openfile->mark_x) - openfile->mark_x += char_len; + openfile->mark_x += charlen; /* When the cursor is on the top row and not on the first chunk * of a line, adding text there might change the preceding chunk @@ -1842,7 +1842,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls) } #endif - openfile->current_x += char_len; + openfile->current_x += charlen; #ifndef NANO_TINY update_undo(ADD); diff --git a/src/prompt.c b/src/prompt.c index e8c806ed..8a2d6225 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -190,7 +190,7 @@ void do_statusbar_output(int *the_input, size_t input_len, { char *output = charalloc(input_len + 1); char onechar[MAXCHARLEN]; - size_t char_len, i, j = 0; + size_t charlen, i, j = 0; /* Copy the typed stuff so it can be treated. */ for (i = 0; i < input_len; i++) @@ -203,21 +203,21 @@ void do_statusbar_output(int *the_input, size_t input_len, output[j] = '\n'; /* Interpret the next multibyte character. */ - char_len = parse_mbchar(output + j, onechar, NULL); + charlen = parse_mbchar(output + j, onechar, NULL); - j += char_len; + j += charlen; /* When filtering, skip any ASCII control character. */ - if (filtering && is_ascii_cntrl_char(*(output + j - char_len))) + if (filtering && is_ascii_cntrl_char(*(output + j - charlen))) continue; /* Insert the typed character into the existing answer string. */ - answer = charealloc(answer, strlen(answer) + char_len + 1); - charmove(answer + typing_x + char_len, answer + typing_x, + answer = charealloc(answer, strlen(answer) + charlen + 1); + charmove(answer + typing_x + charlen, answer + typing_x, strlen(answer) - typing_x + 1); - strncpy(answer + typing_x, onechar, char_len); + strncpy(answer + typing_x, onechar, charlen); - typing_x += char_len; + typing_x += charlen; } free(output); @@ -253,10 +253,10 @@ void do_statusbar_right(void) void do_statusbar_delete(void) { if (answer[typing_x] != '\0') { - int char_len = parse_mbchar(answer + typing_x, NULL, NULL); + int charlen = parse_mbchar(answer + typing_x, NULL, NULL); - charmove(answer + typing_x, answer + typing_x + char_len, - strlen(answer) - typing_x - char_len + 1); + charmove(answer + typing_x, answer + typing_x + charlen, + strlen(answer) - typing_x - charlen + 1); } } diff --git a/src/text.c b/src/text.c index df05c5a9..a6b7e1cb 100644 --- a/src/text.c +++ b/src/text.c @@ -1163,12 +1163,12 @@ void add_undo(undo_type action) * else purposely fall into the line-joining code. */ if (openfile->current->data[openfile->current_x] != '\0') { char *char_buf = charalloc(MAXCHARLEN + 1); - int char_len = parse_mbchar(&openfile->current->data[u->begin], + int charlen = parse_mbchar(&openfile->current->data[u->begin], char_buf, NULL); - char_buf[char_len] = '\0'; + char_buf[charlen] = '\0'; u->strdata = char_buf; if (u->type == BACK) - u->mark_begin_x += char_len; + u->mark_begin_x += charlen; break; } case JOIN: @@ -1273,7 +1273,7 @@ void update_undo(undo_type action) { undo *u = openfile->undotop; char *char_buf; - int char_len; + int charlen; if (u->type != action) statusline(ALERT, "Mismatching undo type -- please report a bug"); @@ -1283,10 +1283,10 @@ void update_undo(undo_type action) switch (u->type) { case ADD: char_buf = charalloc(MAXCHARLEN); - char_len = parse_mbchar(&openfile->current->data[u->mark_begin_x], + charlen = 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_len); + char_buf, charlen); u->mark_begin_lineno = openfile->current->lineno; u->mark_begin_x = openfile->current_x; break; @@ -1297,15 +1297,15 @@ void update_undo(undo_type action) case BACK: case DEL: char_buf = charalloc(MAXCHARLEN); - char_len = parse_mbchar(&openfile->current->data[openfile->current_x], + charlen = parse_mbchar(&openfile->current->data[openfile->current_x], char_buf, NULL); if (openfile->current_x == u->begin) { /* They deleted more: add removed character after earlier stuff. */ - u->strdata = addstrings(u->strdata, strlen(u->strdata), char_buf, char_len); + u->strdata = addstrings(u->strdata, strlen(u->strdata), char_buf, charlen); u->mark_begin_x = openfile->current_x; - } else if (openfile->current_x == u->begin - char_len) { + } else if (openfile->current_x == u->begin - charlen) { /* They backspaced further: add removed character before earlier. */ - u->strdata = addstrings(char_buf, char_len, u->strdata, strlen(u->strdata)); + u->strdata = addstrings(char_buf, charlen, u->strdata, strlen(u->strdata)); u->begin = openfile->current_x; } else { /* They deleted *elsewhere* on the line: start a new undo item. */ @@ -1512,7 +1512,7 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl) /* The index of the character we are looking at. */ size_t column = 0; /* The column position that corresponds with index. */ - int char_len = 0; + int charlen = 0; /* The length of the current character, in bytes. */ /* Find the last blank that does not overshoot the target column. */ @@ -1524,9 +1524,9 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl) break; } - char_len = parse_mbchar(line, NULL, &column); - line += char_len; - index += char_len; + charlen = parse_mbchar(line, NULL, &column); + line += charlen; + index += charlen; } /* If the whole line displays shorter than goal, we're done. */ @@ -1537,7 +1537,7 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl) /* If we're wrapping a help text and no blank was found, or was * found only as the first character, force a line break. */ if (snap_at_nl && lastblank < 1) - return (index - char_len); + return (index - charlen); #endif /* If no blank was found within the goal width, seek one after it. */ @@ -1548,9 +1548,9 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl) else if (lastblank > 0) return lastblank; - char_len = parse_mbchar(line, NULL, NULL); - line += char_len; - index += char_len; + charlen = parse_mbchar(line, NULL, NULL); + line += charlen; + index += charlen; } return -1; @@ -1558,14 +1558,14 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl) /* Move the pointer back to the last blank, and then step beyond it. */ line = line - index + lastblank; - char_len = parse_mbchar(line, NULL, NULL); - line += char_len; + charlen = parse_mbchar(line, NULL, NULL); + line += charlen; /* Skip any consecutive blanks after the last blank. */ while (*line != '\0' && is_blank_mbchar(line)) { - lastblank += char_len; - char_len = parse_mbchar(line, NULL, NULL); - line += char_len; + lastblank += charlen; + charlen = parse_mbchar(line, NULL, NULL); + line += charlen; } return lastblank;