tweaks: remove some redundant filtering, and thus elide a parameter
The few calls of the injection routines that had 'filtering' set to TRUE have already filtered out ASCII control codes earlier on. And in the case of injecting a completion, this completion only contains word-forming characters -- and if the user somehow added a control code to the word-forming characters, then nano should NOT filter it out, so in fact that setting of 'filtering' to TRUE was mistaken. Note that this filtering did not filter out 0x7F (DEL). But that is fine: it should not occur in the input stream at that point anyway, as it gets translated to either KEY_DC or KEY_BACKSPACE earlier in the keyboard parsing routines.master
parent
6cf442e329
commit
6747142cd7
|
@ -1565,7 +1565,7 @@ void do_input(void)
|
||||||
/* Insert all bytes in the input buffer into the edit buffer
|
/* Insert all bytes in the input buffer into the edit buffer
|
||||||
* at once, filtering out any ASCII control codes. */
|
* at once, filtering out any ASCII control codes. */
|
||||||
puddle[depth] = '\0';
|
puddle[depth] = '\0';
|
||||||
inject(puddle, depth, TRUE);
|
inject(puddle, depth);
|
||||||
|
|
||||||
/* Empty the input buffer. */
|
/* Empty the input buffer. */
|
||||||
free(puddle);
|
free(puddle);
|
||||||
|
@ -1656,7 +1656,7 @@ void do_input(void)
|
||||||
|
|
||||||
/* The user typed output_len multibyte characters. Add them to the edit
|
/* The user typed output_len multibyte characters. Add them to the edit
|
||||||
* buffer, filtering out ASCII control characters when filtering is TRUE. */
|
* buffer, filtering out ASCII control characters when filtering is TRUE. */
|
||||||
void inject(char *output, size_t output_len, bool filtering)
|
void inject(char *output, size_t output_len)
|
||||||
{
|
{
|
||||||
char onechar[MAXCHARLEN];
|
char onechar[MAXCHARLEN];
|
||||||
int charlen;
|
int charlen;
|
||||||
|
@ -1682,10 +1682,6 @@ void inject(char *output, size_t output_len, bool filtering)
|
||||||
|
|
||||||
i += charlen;
|
i += charlen;
|
||||||
|
|
||||||
/* If controls are not allowed, ignore an ASCII control character. */
|
|
||||||
if (filtering && is_ascii_cntrl_char(*(output + i - charlen)))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* 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 + charlen + 1);
|
current_len + charlen + 1);
|
||||||
|
|
10
src/prompt.c
10
src/prompt.c
|
@ -115,7 +115,7 @@ int do_statusbar_input(bool *finished)
|
||||||
if ((shortcut || get_key_buffer_len() == 0) && kbinput != NULL) {
|
if ((shortcut || get_key_buffer_len() == 0) && kbinput != NULL) {
|
||||||
/* Inject all characters in the input buffer at once, filtering out
|
/* Inject all characters in the input buffer at once, filtering out
|
||||||
* control characters. */
|
* control characters. */
|
||||||
inject_into_answer(kbinput, kbinput_len, TRUE);
|
inject_into_answer(kbinput, kbinput_len);
|
||||||
|
|
||||||
/* Empty the input buffer. */
|
/* Empty the input buffer. */
|
||||||
kbinput_len = 0;
|
kbinput_len = 0;
|
||||||
|
@ -185,7 +185,7 @@ int do_statusbar_input(bool *finished)
|
||||||
|
|
||||||
/* The user typed input_len multibyte characters. Add them to the answer,
|
/* The user typed input_len multibyte characters. Add them to the answer,
|
||||||
* filtering out ASCII control characters if filtering is TRUE. */
|
* filtering out ASCII control characters if filtering is TRUE. */
|
||||||
void inject_into_answer(int *the_input, size_t input_len, bool filtering)
|
void inject_into_answer(int *the_input, size_t input_len)
|
||||||
{
|
{
|
||||||
char *output = charalloc(input_len + 1);
|
char *output = charalloc(input_len + 1);
|
||||||
char onechar[MAXCHARLEN];
|
char onechar[MAXCHARLEN];
|
||||||
|
@ -206,10 +206,6 @@ void inject_into_answer(int *the_input, size_t input_len, bool filtering)
|
||||||
|
|
||||||
j += charlen;
|
j += charlen;
|
||||||
|
|
||||||
/* When filtering, skip any ASCII control character. */
|
|
||||||
if (filtering && is_ascii_cntrl_char(*(output + j - charlen)))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* Insert the typed character into the existing answer string. */
|
/* Insert the typed character into the existing answer string. */
|
||||||
answer = charealloc(answer, strlen(answer) + charlen + 1);
|
answer = charealloc(answer, strlen(answer) + charlen + 1);
|
||||||
memmove(answer + typing_x + charlen, answer + typing_x,
|
memmove(answer + typing_x + charlen, answer + typing_x,
|
||||||
|
@ -339,7 +335,7 @@ void do_statusbar_verbatim_input(void)
|
||||||
|
|
||||||
kbinput = get_verbatim_kbinput(bottomwin, &kbinput_len);
|
kbinput = get_verbatim_kbinput(bottomwin, &kbinput_len);
|
||||||
|
|
||||||
inject_into_answer(kbinput, kbinput_len, FALSE);
|
inject_into_answer(kbinput, kbinput_len);
|
||||||
|
|
||||||
free(kbinput);
|
free(kbinput);
|
||||||
}
|
}
|
||||||
|
|
|
@ -444,10 +444,10 @@ void confirm_margin(void);
|
||||||
#endif
|
#endif
|
||||||
void unbound_key(int code);
|
void unbound_key(int code);
|
||||||
bool okay_for_view(const keystruct *shortcut);
|
bool okay_for_view(const keystruct *shortcut);
|
||||||
void inject(char *output, size_t output_len, bool filtering);
|
void inject(char *output, size_t output_len);
|
||||||
|
|
||||||
/* Most functions in prompt.c. */
|
/* Most functions in prompt.c. */
|
||||||
void inject_into_answer(int *the_input, size_t input_len, bool filtering);
|
void inject_into_answer(int *the_input, size_t input_len);
|
||||||
void do_statusbar_home(void);
|
void do_statusbar_home(void);
|
||||||
void do_statusbar_end(void);
|
void do_statusbar_end(void);
|
||||||
void do_statusbar_left(void);
|
void do_statusbar_left(void);
|
||||||
|
|
12
src/text.c
12
src/text.c
|
@ -69,7 +69,7 @@ void do_tab(void)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_COLOR
|
#ifdef ENABLE_COLOR
|
||||||
if (openfile->syntax && openfile->syntax->tab)
|
if (openfile->syntax && openfile->syntax->tab)
|
||||||
inject(openfile->syntax->tab, strlen(openfile->syntax->tab), FALSE);
|
inject(openfile->syntax->tab, strlen(openfile->syntax->tab));
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
|
@ -80,12 +80,12 @@ void do_tab(void)
|
||||||
memset(spaces, ' ', length);
|
memset(spaces, ' ', length);
|
||||||
spaces[length] = '\0';
|
spaces[length] = '\0';
|
||||||
|
|
||||||
inject(spaces, length, FALSE);
|
inject(spaces, length);
|
||||||
|
|
||||||
free(spaces);
|
free(spaces);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
inject((char *)"\t", 1, FALSE);
|
inject((char *)"\t", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
|
@ -3156,7 +3156,7 @@ void do_verbatim_input(void)
|
||||||
keycodes[count] = '\0';
|
keycodes[count] = '\0';
|
||||||
|
|
||||||
/* Insert the keystroke verbatim, without filtering control characters. */
|
/* Insert the keystroke verbatim, without filtering control characters. */
|
||||||
inject(keycodes, count, FALSE);
|
inject(keycodes, count);
|
||||||
|
|
||||||
free(keycodes);
|
free(keycodes);
|
||||||
free(kbinput);
|
free(kbinput);
|
||||||
|
@ -3303,8 +3303,8 @@ void complete_a_word(void)
|
||||||
UNSET(BREAK_LONG_LINES);
|
UNSET(BREAK_LONG_LINES);
|
||||||
#endif
|
#endif
|
||||||
/* Inject the completion into the buffer. */
|
/* Inject the completion into the buffer. */
|
||||||
inject(&completion[shard_length],
|
inject(&completion[shard_length], strlen(completion) - shard_length);
|
||||||
strlen(completion) - shard_length, TRUE);
|
|
||||||
#ifdef ENABLE_WRAPPING
|
#ifdef ENABLE_WRAPPING
|
||||||
/* If needed, reenable wrapping and wrap the current line. */
|
/* If needed, reenable wrapping and wrap the current line. */
|
||||||
if (was_set_wrapping) {
|
if (was_set_wrapping) {
|
||||||
|
|
Loading…
Reference in New Issue