check for nulls and newlines earlier in do_output(), and add a few more
cosmetic fixes git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2179 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
родитель
60448895f6
Коммит
abc9423709
22
src/nano.c
22
src/nano.c
@ -2764,8 +2764,8 @@ void do_justify(bool full_justify)
|
||||
break_pos = break_line(current->data + indent_len,
|
||||
fill - strnlenpt(current->data, indent_len),
|
||||
TRUE);
|
||||
if (break_pos == -1 || break_pos + indent_len ==
|
||||
line_len)
|
||||
if (break_pos == -1 ||
|
||||
break_pos + indent_len == line_len)
|
||||
/* We can't break the line, or don't need to, so
|
||||
* just go on to the next. */
|
||||
goto continue_loc;
|
||||
@ -3587,6 +3587,15 @@ void do_output(int *kbinput, size_t kbinput_len)
|
||||
#endif
|
||||
|
||||
for (i = 0; i < kbinput_len; i++) {
|
||||
/* Null to newline, if needed. */
|
||||
if (kbinput[i] == '\0')
|
||||
kbinput[i] = '\n';
|
||||
/* Newline to Enter, if needed. */
|
||||
else if (kbinput[i] == '\n') {
|
||||
do_enter();
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifdef NANO_WIDE
|
||||
/* Change the wide character to its multibyte value. If it's
|
||||
* invalid, go on to the next character. */
|
||||
@ -3604,15 +3613,6 @@ void do_output(int *kbinput, size_t kbinput_len)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Null to newline, if needed. */
|
||||
if (key[0] == '\0' && key_len == 1)
|
||||
key[0] = '\n';
|
||||
/* Newline to Enter, if needed. */
|
||||
else if (key[0] == '\n' && key_len == 1) {
|
||||
do_enter();
|
||||
continue;
|
||||
}
|
||||
|
||||
/* When a character is inserted on the current magicline, it
|
||||
* means we need a new one! */
|
||||
if (filebot == current)
|
||||
|
14
src/winio.c
14
src/winio.c
@ -2897,8 +2897,8 @@ void edit_add(const filestruct *fileptr, const char *converted, int
|
||||
#endif /* !NANO_SMALL */
|
||||
}
|
||||
|
||||
/* Just update one line in the edit buffer. Basically a wrapper for
|
||||
* edit_add().
|
||||
/* Just update one line in the edit buffer. This is basically a wrapper
|
||||
* for edit_add().
|
||||
*
|
||||
* If fileptr != current, then index is considered 0. The line will be
|
||||
* displayed starting with fileptr->data[index]. Likely args are
|
||||
@ -2906,7 +2906,7 @@ void edit_add(const filestruct *fileptr, const char *converted, int
|
||||
void update_line(const filestruct *fileptr, size_t index)
|
||||
{
|
||||
int line;
|
||||
/* line in the edit window for CURSES calls */
|
||||
/* The line in the edit window that we want to update. */
|
||||
char *converted;
|
||||
/* fileptr->data converted to have tabs and control characters
|
||||
* expanded. */
|
||||
@ -2922,7 +2922,7 @@ void update_line(const filestruct *fileptr, size_t index)
|
||||
if (line < 0 || line >= editwinrows)
|
||||
return;
|
||||
|
||||
/* First, blank out the line (at a minimum) */
|
||||
/* First, blank out the line. */
|
||||
mvwaddstr(edit, line, 0, hblank);
|
||||
|
||||
/* Next, convert variables that index the line to their equivalent
|
||||
@ -2930,11 +2930,11 @@ void update_line(const filestruct *fileptr, size_t index)
|
||||
index = (fileptr == current) ? strnlenpt(fileptr->data, index) : 0;
|
||||
page_start = get_page_start(index);
|
||||
|
||||
/* Expand the line, replacing Tab by spaces, and control characters
|
||||
* by their display form. */
|
||||
/* Expand the line, replacing tabs with spaces, and control
|
||||
* characters with their displayed forms. */
|
||||
converted = display_string(fileptr->data, page_start, COLS);
|
||||
|
||||
/* Now, paint the line */
|
||||
/* Paint the line. */
|
||||
edit_add(fileptr, converted, line, page_start);
|
||||
free(converted);
|
||||
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user