when getting printable input from the edit window or statusbar prompt,
don't swallow non-ASCII control characters, since they're parts of UTF-8 sequences git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2378 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
родитель
a17a130d6c
Коммит
496488c5d2
26
ChangeLog
26
ChangeLog
@ -94,17 +94,17 @@ CVS code -
|
||||
support to a few more functions as well, and move multibyte
|
||||
character-specific functions to their own source file. New
|
||||
file chars.c; new functions is_alnum_char(),
|
||||
is_alnum_mbchar(), is_alnum_wchar(), is_blank_mbchar(),
|
||||
is_blank_wchar(), is_cntrl_mbchar(), is_cntrl_wchar(),
|
||||
control_mbrep(), control_wrep(), mbwidth(), mb_cur_max(),
|
||||
make_mbchar(), mbstrlen(), mbstrnlen(), mbstrcasecmp(),
|
||||
mbstrncasecmp(), mbstrcasestr(), and mbrevstrcasestr();
|
||||
changes to help_init(), is_byte() (moved to chars.c),
|
||||
is_blank_char() (moved to chars.c), is_cntrl_char() (moved to
|
||||
chars.c), nstricmp() (renamed nstrcasecmp() and moved to
|
||||
chars.c), nstrnicmp() (renamed nstrncasecmp() and moved to
|
||||
chars.c), nstristr() (renamed nstrcasestr() and moved to
|
||||
chars.c), revstrstr() (moved to chars.c), revstristr()
|
||||
is_alnum_mbchar(), is_alnum_wchar(), is_ascii_char(),
|
||||
is_blank_mbchar(), is_blank_wchar(), is_cntrl_mbchar(),
|
||||
is_cntrl_wchar(), control_mbrep(), control_wrep(), mbwidth(),
|
||||
mb_cur_max(), make_mbchar(), mbstrlen(), mbstrnlen(),
|
||||
mbstrcasecmp(), mbstrncasecmp(), mbstrcasestr(), and
|
||||
mbrevstrcasestr(); changes to help_init(), is_byte() (moved to
|
||||
chars.c), is_blank_char() (moved to chars.c), is_cntrl_char()
|
||||
(moved to chars.c), nstricmp() (renamed nstrcasecmp() and
|
||||
moved to chars.c), nstrnicmp() (renamed nstrncasecmp() and
|
||||
moved to chars.c), nstristr() (renamed nstrcasestr() and moved
|
||||
to chars.c), revstrstr() (moved to chars.c), revstristr()
|
||||
(renamed revstrcasestr() and moved to chars.c), nstrnlen()
|
||||
(moved to chars.c), parse_char() (renamed parse_mbchar() and
|
||||
moved to chars.c), move_left() (renamed move_mbleft() and
|
||||
@ -328,8 +328,8 @@ CVS code -
|
||||
obsolete and it defines a struct termio that we don't use
|
||||
anywhere. (DLR)
|
||||
- Typo fixes. (DLR)
|
||||
- Add checks for iswalnum(), iswblank() or iswspace(), mblen(),
|
||||
and wctype.h. (DLR)
|
||||
- Add checks for isascii(), iswalnum(), iswblank() or
|
||||
iswspace(), mblen(), and wctype.h. (DLR)
|
||||
- doc/faq.html:
|
||||
- Remove now-inaccurate note about verbatim input's not working
|
||||
at prompts, and update its description to mention that it
|
||||
|
@ -291,7 +291,7 @@ AC_MSG_WARN([*** Can not use slang when cross-compiling])),
|
||||
esac], [AC_MSG_RESULT(no)])
|
||||
|
||||
dnl Checks for functions
|
||||
AC_CHECK_FUNCS(snprintf vsnprintf isblank iswalnum iswblank iswspace strcasecmp strncasecmp strcasestr strnlen getline getdelim mblen mbtowc wctomb wcwidth)
|
||||
AC_CHECK_FUNCS(snprintf vsnprintf isascii isblank iswalnum iswblank iswspace strcasecmp strncasecmp strcasestr strnlen getline getdelim mblen mbtowc wctomb wcwidth)
|
||||
if test "x$ac_cv_func_snprintf" = "xno" -o "x$ac_cv_func_vsnprintf" = "xno"
|
||||
then
|
||||
AM_PATH_GLIB_2_0(2.0.0,,
|
||||
|
12
src/chars.c
12
src/chars.c
@ -81,6 +81,18 @@ bool is_alnum_wchar(wchar_t wc)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This function is equivalent to isascii(). */
|
||||
bool is_ascii_char(int c)
|
||||
{
|
||||
return
|
||||
#ifdef HAVE_ISASCII
|
||||
isascii(c)
|
||||
#else
|
||||
((unsigned int)c == (signed char)c)
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
/* This function is equivalent to isblank(). */
|
||||
bool is_blank_char(int c)
|
||||
{
|
||||
|
@ -3616,10 +3616,11 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool
|
||||
|
||||
if (allow_funcs) {
|
||||
/* If we got a character, and it isn't a shortcut, toggle, or
|
||||
* control character, it's a normal text character. Display the
|
||||
* warning if we're in view mode, or add the character to the
|
||||
* input buffer if we're not. */
|
||||
if (input != ERR && *s_or_t == FALSE && !is_cntrl_char(input)) {
|
||||
* ASCII control character, it's a normal text character.
|
||||
* Display the warning if we're in view mode, or add the
|
||||
* character to the input buffer if we're not. */
|
||||
if (input != ERR && *s_or_t == FALSE &&
|
||||
(!is_ascii_char(input) || !is_cntrl_char(input))) {
|
||||
if (ISSET(VIEW_MODE))
|
||||
print_view_warning();
|
||||
else {
|
||||
|
@ -157,6 +157,7 @@ bool is_alnum_mbchar(const char *c);
|
||||
#ifdef NANO_WIDE
|
||||
bool is_alnum_wchar(wchar_t wc);
|
||||
#endif
|
||||
bool is_ascii_char(int c);
|
||||
bool is_blank_char(int c);
|
||||
bool is_blank_mbchar(const char *c);
|
||||
#ifdef NANO_WIDE
|
||||
|
@ -1676,7 +1676,12 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t,
|
||||
*s_or_t = have_shortcut;
|
||||
|
||||
if (allow_funcs) {
|
||||
if (input != ERR && *s_or_t == FALSE && !is_cntrl_char(input)) {
|
||||
/* If we got a character, and it isn't a shortcut, toggle, or
|
||||
* ASCII control character, it's a normal text character.
|
||||
* Display the warning if we're in view mode, or add the
|
||||
* character to the input buffer if we're not. */
|
||||
if (input != ERR && *s_or_t == FALSE &&
|
||||
(!is_ascii_char(input) || !is_cntrl_char(input))) {
|
||||
/* If we're using restricted mode, the filename isn't blank,
|
||||
* and we're at the "Write File" prompt, disable text
|
||||
* input. */
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user