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-d3aeb78583b8master
parent
a17a130d6c
commit
496488c5d2
26
ChangeLog
26
ChangeLog
|
@ -94,17 +94,17 @@ CVS code -
|
||||||
support to a few more functions as well, and move multibyte
|
support to a few more functions as well, and move multibyte
|
||||||
character-specific functions to their own source file. New
|
character-specific functions to their own source file. New
|
||||||
file chars.c; new functions is_alnum_char(),
|
file chars.c; new functions is_alnum_char(),
|
||||||
is_alnum_mbchar(), is_alnum_wchar(), is_blank_mbchar(),
|
is_alnum_mbchar(), is_alnum_wchar(), is_ascii_char(),
|
||||||
is_blank_wchar(), is_cntrl_mbchar(), is_cntrl_wchar(),
|
is_blank_mbchar(), is_blank_wchar(), is_cntrl_mbchar(),
|
||||||
control_mbrep(), control_wrep(), mbwidth(), mb_cur_max(),
|
is_cntrl_wchar(), control_mbrep(), control_wrep(), mbwidth(),
|
||||||
make_mbchar(), mbstrlen(), mbstrnlen(), mbstrcasecmp(),
|
mb_cur_max(), make_mbchar(), mbstrlen(), mbstrnlen(),
|
||||||
mbstrncasecmp(), mbstrcasestr(), and mbrevstrcasestr();
|
mbstrcasecmp(), mbstrncasecmp(), mbstrcasestr(), and
|
||||||
changes to help_init(), is_byte() (moved to chars.c),
|
mbrevstrcasestr(); changes to help_init(), is_byte() (moved to
|
||||||
is_blank_char() (moved to chars.c), is_cntrl_char() (moved to
|
chars.c), is_blank_char() (moved to chars.c), is_cntrl_char()
|
||||||
chars.c), nstricmp() (renamed nstrcasecmp() and moved to
|
(moved to chars.c), nstricmp() (renamed nstrcasecmp() and
|
||||||
chars.c), nstrnicmp() (renamed nstrncasecmp() and moved to
|
moved to chars.c), nstrnicmp() (renamed nstrncasecmp() and
|
||||||
chars.c), nstristr() (renamed nstrcasestr() and moved to
|
moved to chars.c), nstristr() (renamed nstrcasestr() and moved
|
||||||
chars.c), revstrstr() (moved to chars.c), revstristr()
|
to chars.c), revstrstr() (moved to chars.c), revstristr()
|
||||||
(renamed revstrcasestr() and moved to chars.c), nstrnlen()
|
(renamed revstrcasestr() and moved to chars.c), nstrnlen()
|
||||||
(moved to chars.c), parse_char() (renamed parse_mbchar() and
|
(moved to chars.c), parse_char() (renamed parse_mbchar() and
|
||||||
moved to chars.c), move_left() (renamed move_mbleft() 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
|
obsolete and it defines a struct termio that we don't use
|
||||||
anywhere. (DLR)
|
anywhere. (DLR)
|
||||||
- Typo fixes. (DLR)
|
- Typo fixes. (DLR)
|
||||||
- Add checks for iswalnum(), iswblank() or iswspace(), mblen(),
|
- Add checks for isascii(), iswalnum(), iswblank() or
|
||||||
and wctype.h. (DLR)
|
iswspace(), mblen(), and wctype.h. (DLR)
|
||||||
- doc/faq.html:
|
- doc/faq.html:
|
||||||
- Remove now-inaccurate note about verbatim input's not working
|
- Remove now-inaccurate note about verbatim input's not working
|
||||||
at prompts, and update its description to mention that it
|
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)])
|
esac], [AC_MSG_RESULT(no)])
|
||||||
|
|
||||||
dnl Checks for functions
|
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"
|
if test "x$ac_cv_func_snprintf" = "xno" -o "x$ac_cv_func_vsnprintf" = "xno"
|
||||||
then
|
then
|
||||||
AM_PATH_GLIB_2_0(2.0.0,,
|
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
|
#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(). */
|
/* This function is equivalent to isblank(). */
|
||||||
bool is_blank_char(int c)
|
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 (allow_funcs) {
|
||||||
/* If we got a character, and it isn't a shortcut, toggle, or
|
/* If we got a character, and it isn't a shortcut, toggle, or
|
||||||
* control character, it's a normal text character. Display the
|
* ASCII control character, it's a normal text character.
|
||||||
* warning if we're in view mode, or add the character to the
|
* Display the warning if we're in view mode, or add the
|
||||||
* input buffer if we're not. */
|
* character to the input buffer if we're not. */
|
||||||
if (input != ERR && *s_or_t == FALSE && !is_cntrl_char(input)) {
|
if (input != ERR && *s_or_t == FALSE &&
|
||||||
|
(!is_ascii_char(input) || !is_cntrl_char(input))) {
|
||||||
if (ISSET(VIEW_MODE))
|
if (ISSET(VIEW_MODE))
|
||||||
print_view_warning();
|
print_view_warning();
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -157,6 +157,7 @@ bool is_alnum_mbchar(const char *c);
|
||||||
#ifdef NANO_WIDE
|
#ifdef NANO_WIDE
|
||||||
bool is_alnum_wchar(wchar_t wc);
|
bool is_alnum_wchar(wchar_t wc);
|
||||||
#endif
|
#endif
|
||||||
|
bool is_ascii_char(int c);
|
||||||
bool is_blank_char(int c);
|
bool is_blank_char(int c);
|
||||||
bool is_blank_mbchar(const char *c);
|
bool is_blank_mbchar(const char *c);
|
||||||
#ifdef NANO_WIDE
|
#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;
|
*s_or_t = have_shortcut;
|
||||||
|
|
||||||
if (allow_funcs) {
|
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,
|
/* If we're using restricted mode, the filename isn't blank,
|
||||||
* and we're at the "Write File" prompt, disable text
|
* and we're at the "Write File" prompt, disable text
|
||||||
* input. */
|
* input. */
|
||||||
|
|
Loading…
Reference in New Issue