Eliding a variable -- there is no need to optimize for calls of strlen(),
as this is typing speed, no need to hurry. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5663 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
7c0e433305
commit
3ed08c568f
|
@ -6,6 +6,7 @@
|
||||||
src/move.c (do_prev_word, do_next_word): Sort these in standard way.
|
src/move.c (do_prev_word, do_next_word): Sort these in standard way.
|
||||||
* src/prompt.c (do_statusbar_output): Don't move too many bytes.
|
* src/prompt.c (do_statusbar_output): Don't move too many bytes.
|
||||||
This fixes Savannah bug #47219 (uncovered by r5655).
|
This fixes Savannah bug #47219 (uncovered by r5655).
|
||||||
|
* src/prompt.c (do_statusbar_output): Elide a variable.
|
||||||
|
|
||||||
2016-02-21 Benno Schulenberg <bensberg@justemail.net>
|
2016-02-21 Benno Schulenberg <bensberg@justemail.net>
|
||||||
* src/files.c (input_tab): If the first Tab added the part that all
|
* src/files.c (input_tab): If the first Tab added the part that all
|
||||||
|
|
14
src/prompt.c
14
src/prompt.c
|
@ -246,10 +246,9 @@ int do_statusbar_mouse(void)
|
||||||
void do_statusbar_output(int *the_input, size_t input_len,
|
void do_statusbar_output(int *the_input, size_t input_len,
|
||||||
bool filtering, bool *got_enter)
|
bool filtering, bool *got_enter)
|
||||||
{
|
{
|
||||||
size_t answer_len, i;
|
|
||||||
char *output = charalloc(input_len + 1);
|
char *output = charalloc(input_len + 1);
|
||||||
char *char_buf = charalloc(mb_cur_max());
|
char *char_buf = charalloc(mb_cur_max());
|
||||||
int char_buf_len;
|
int i, char_buf_len;
|
||||||
|
|
||||||
assert(answer != NULL);
|
assert(answer != NULL);
|
||||||
|
|
||||||
|
@ -258,7 +257,6 @@ void do_statusbar_output(int *the_input, size_t input_len,
|
||||||
output[i] = (char)the_input[i];
|
output[i] = (char)the_input[i];
|
||||||
output[i] = '\0';
|
output[i] = '\0';
|
||||||
|
|
||||||
answer_len = strlen(answer);
|
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
while (i < input_len) {
|
while (i < input_len) {
|
||||||
|
@ -284,15 +282,13 @@ void do_statusbar_output(int *the_input, size_t input_len,
|
||||||
if (filtering && is_ascii_cntrl_char(*(output + i - char_buf_len)))
|
if (filtering && is_ascii_cntrl_char(*(output + i - char_buf_len)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* More dangerousness fun. =) */
|
assert(statusbar_x <= strlen(answer));
|
||||||
answer = charealloc(answer, answer_len + char_buf_len + 1);
|
|
||||||
|
|
||||||
assert(statusbar_x <= answer_len);
|
|
||||||
|
|
||||||
|
/* Insert the typed character into the existing answer string. */
|
||||||
|
answer = charealloc(answer, strlen(answer) + char_buf_len + 1);
|
||||||
charmove(answer + statusbar_x + char_buf_len, answer + statusbar_x,
|
charmove(answer + statusbar_x + char_buf_len, answer + statusbar_x,
|
||||||
answer_len - statusbar_x + 1);
|
strlen(answer) - statusbar_x + 1);
|
||||||
strncpy(answer + statusbar_x, char_buf, char_buf_len);
|
strncpy(answer + statusbar_x, char_buf, char_buf_len);
|
||||||
answer_len += char_buf_len;
|
|
||||||
|
|
||||||
statusbar_x += char_buf_len;
|
statusbar_x += char_buf_len;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue