remove unnecessary variables from and add missing asserts to
control_mbrep() git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2737 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
da419bcbe4
commit
e0a0d23f78
29
ChangeLog
29
ChangeLog
|
@ -56,20 +56,21 @@ CVS code -
|
||||||
shortcut_init(), usage(), main(), search_init(), nano.1,
|
shortcut_init(), usage(), main(), search_init(), nano.1,
|
||||||
nano.texi, etc. (DLR)
|
nano.texi, etc. (DLR)
|
||||||
- Various cleanups and improvements in chars.c. Remove some
|
- Various cleanups and improvements in chars.c. Remove some
|
||||||
unnecessary w?ctype wrappers; change the wctype wrappers to
|
unnecessary w?ctype wrappers and variables; change the wctype
|
||||||
take wint_t instead of wchar_t to match the functions they
|
wrappers to take wint_t instead of wchar_t to match the
|
||||||
wrap; rename some functions for consistency; add functions to
|
functions they wrap; rename some functions for consistency;
|
||||||
detect blank characters in a string, for use in rcfile option
|
add functions to detect blank characters in a string, for use
|
||||||
parsing; and don't count matches between valid and invalid
|
in rcfile option parsing; and don't count matches between
|
||||||
multibyte sequences anymore, as it causes problems when doing
|
valid and invalid multibyte sequences anymore, as it causes
|
||||||
a replace. New functions is_valid_mbstring(),
|
problems when doing a replace. New functions
|
||||||
has_blank_chars(), and has_blank_mbchars(); changes to
|
is_valid_mbstring(), has_blank_chars(), and
|
||||||
is_alnum_mbchar(), is_blank_char() (renamed nisblank()),
|
has_blank_mbchars(); changes to is_alnum_mbchar(),
|
||||||
is_blank_mbchar(), is_blank_wchar() (renamed niswblank()),
|
is_blank_char() (renamed nisblank()), is_blank_mbchar(),
|
||||||
is_cntrl_wchar(), control_rep(), control_mbrep(),
|
is_blank_wchar() (renamed niswblank()), is_cntrl_wchar(),
|
||||||
make_mbstring() (renamed make_valid_mbstring()),
|
control_rep(), control_mbrep(), make_mbstring() (renamed
|
||||||
mbstrncasecmp(), mbstrcasestr(), mbrevstrcasestr(), etc.;
|
make_valid_mbstring()), mbstrncasecmp(), mbstrcasestr(),
|
||||||
removal of is_alnum_char() and is_alnum_wchar(). (DLR)
|
mbrevstrcasestr(), etc.; removal of is_alnum_char() and
|
||||||
|
is_alnum_wchar(). (DLR)
|
||||||
- Implement word count via Meta-D at the main window. Note that
|
- Implement word count via Meta-D at the main window. Note that
|
||||||
this is disabled when NANO_SMALL is defined. New functions
|
this is disabled when NANO_SMALL is defined. New functions
|
||||||
do_word_count() and do_next_word_void(); changes to
|
do_word_count() and do_next_word_void(); changes to
|
||||||
|
|
13
src/chars.c
13
src/chars.c
|
@ -209,26 +209,23 @@ wchar_t control_wrep(wchar_t wc)
|
||||||
* where ch is c + 64. We return that multibyte character. */
|
* where ch is c + 64. We return that multibyte character. */
|
||||||
char *control_mbrep(const char *c, char *crep, int *crep_len)
|
char *control_mbrep(const char *c, char *crep, int *crep_len)
|
||||||
{
|
{
|
||||||
assert(c != NULL);
|
assert(c != NULL && crep != NULL && crep_len != NULL);
|
||||||
|
|
||||||
#ifdef NANO_WIDE
|
#ifdef NANO_WIDE
|
||||||
if (ISSET(USE_UTF8)) {
|
if (ISSET(USE_UTF8)) {
|
||||||
wchar_t wc;
|
wchar_t wc;
|
||||||
int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX), crep_mb_len;
|
|
||||||
|
|
||||||
if (c_mb_len <= 0) {
|
if (mbtowc(&wc, c, MB_CUR_MAX) <= 0) {
|
||||||
mbtowc(NULL, NULL, 0);
|
mbtowc(NULL, NULL, 0);
|
||||||
wc = (unsigned char)*c;
|
wc = (unsigned char)*c;
|
||||||
}
|
}
|
||||||
|
|
||||||
crep_mb_len = wctomb(crep, control_wrep(wc));
|
*crep_len = wctomb(crep, control_wrep(wc));
|
||||||
|
|
||||||
if (crep_mb_len <= 0) {
|
if (*crep_mb_len <= 0) {
|
||||||
wctomb(NULL, 0);
|
wctomb(NULL, 0);
|
||||||
crep_mb_len = 0;
|
*crep_mb_len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
*crep_len = crep_mb_len;
|
|
||||||
} else {
|
} else {
|
||||||
#endif
|
#endif
|
||||||
*crep_len = 1;
|
*crep_len = 1;
|
||||||
|
|
Loading…
Reference in New Issue