1
1

tweaks: rename a parameter and invert its logic, and correct a comment

This changes the main injection routine in the same way that the prompt
injection routine was changed four years ago in commit e540053e.
Этот коммит содержится в:
Benno Schulenberg 2020-01-08 10:49:19 +01:00
родитель 9364bd6c81
Коммит c2f2c659d9
2 изменённых файлов: 11 добавлений и 13 удалений

Просмотреть файл

@ -1688,9 +1688,9 @@ void do_input(void)
if (shortcut || get_key_buffer_len() == 0) {
if (puddle != NULL) {
/* Insert all bytes in the input buffer into the edit buffer
* at once, filtering out any low control codes. */
* at once, filtering out any ASCII control codes. */
puddle[depth] = '\0';
do_output(puddle, depth, FALSE);
do_output(puddle, depth, TRUE);
/* Empty the input buffer. */
free(puddle);
@ -1775,9 +1775,8 @@ void do_input(void)
}
/* The user typed output_len multibyte characters. Add them to the edit
* buffer, filtering out all ASCII control characters if allow_cntrls is
* TRUE. */
void do_output(char *output, size_t output_len, bool allow_cntrls)
* buffer, filtering out ASCII control characters when filtering is TRUE. */
void do_output(char *output, size_t output_len, bool filtering)
{
char onechar[MAXCHARLEN];
int charlen;
@ -1804,7 +1803,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
i += charlen;
/* If controls are not allowed, ignore an ASCII control character. */
if (!allow_cntrls && is_ascii_cntrl_char(*(output + i - charlen)))
if (filtering && is_ascii_cntrl_char(*(output + i - charlen)))
continue;
/* Make room for the new character and copy it into the line. */

Просмотреть файл

@ -69,7 +69,7 @@ void do_tab(void)
{
#ifdef ENABLE_COLOR
if (openfile->syntax && openfile->syntax->tab)
do_output(openfile->syntax->tab, strlen(openfile->syntax->tab), TRUE);
do_output(openfile->syntax->tab, strlen(openfile->syntax->tab), FALSE);
else
#endif
#ifndef NANO_TINY
@ -80,12 +80,12 @@ void do_tab(void)
memset(spaces, ' ', length);
spaces[length] = '\0';
do_output(spaces, length, TRUE);
do_output(spaces, length, FALSE);
free(spaces);
} else
#endif
do_output((char *)"\t", 1, TRUE);
do_output((char *)"\t", 1, FALSE);
}
#ifndef NANO_TINY
@ -3144,8 +3144,6 @@ void do_verbatim_input(void)
else
wipe_statusbar();
/* Display all the verbatim characters at once, not filtering out
* control characters. */
output = charalloc(kbinput_len + 1);
for (i = 0; i < kbinput_len; i++)
@ -3154,7 +3152,8 @@ void do_verbatim_input(void)
free(kbinput);
do_output(output, kbinput_len, TRUE);
/* Insert the keystroke verbatim, without filtering control characters. */
do_output(output, kbinput_len, FALSE);
free(output);
}
@ -3301,7 +3300,7 @@ void complete_a_word(void)
#endif
/* Inject the completion into the buffer. */
do_output(&completion[shard_length],
strlen(completion) - shard_length, FALSE);
strlen(completion) - shard_length, TRUE);
#ifdef ENABLE_WRAPPING
/* If needed, reenable wrapping and wrap the current line. */
if (was_set_wrapping) {