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-d3aeb78583b8
master
David Lawrence Ramsey 2005-06-20 20:58:41 +00:00
parent da419bcbe4
commit e0a0d23f78
2 changed files with 20 additions and 22 deletions

View File

@ -56,20 +56,21 @@ CVS code -
shortcut_init(), usage(), main(), search_init(), nano.1,
nano.texi, etc. (DLR)
- Various cleanups and improvements in chars.c. Remove some
unnecessary w?ctype wrappers; change the wctype wrappers to
take wint_t instead of wchar_t to match the functions they
wrap; rename some functions for consistency; add functions to
detect blank characters in a string, for use in rcfile option
parsing; and don't count matches between valid and invalid
multibyte sequences anymore, as it causes problems when doing
a replace. New functions is_valid_mbstring(),
has_blank_chars(), and has_blank_mbchars(); changes to
is_alnum_mbchar(), is_blank_char() (renamed nisblank()),
is_blank_mbchar(), is_blank_wchar() (renamed niswblank()),
is_cntrl_wchar(), control_rep(), control_mbrep(),
make_mbstring() (renamed make_valid_mbstring()),
mbstrncasecmp(), mbstrcasestr(), mbrevstrcasestr(), etc.;
removal of is_alnum_char() and is_alnum_wchar(). (DLR)
unnecessary w?ctype wrappers and variables; change the wctype
wrappers to take wint_t instead of wchar_t to match the
functions they wrap; rename some functions for consistency;
add functions to detect blank characters in a string, for use
in rcfile option parsing; and don't count matches between
valid and invalid multibyte sequences anymore, as it causes
problems when doing a replace. New functions
is_valid_mbstring(), has_blank_chars(), and
has_blank_mbchars(); changes to is_alnum_mbchar(),
is_blank_char() (renamed nisblank()), is_blank_mbchar(),
is_blank_wchar() (renamed niswblank()), is_cntrl_wchar(),
control_rep(), control_mbrep(), make_mbstring() (renamed
make_valid_mbstring()), mbstrncasecmp(), mbstrcasestr(),
mbrevstrcasestr(), etc.; removal of is_alnum_char() and
is_alnum_wchar(). (DLR)
- Implement word count via Meta-D at the main window. Note that
this is disabled when NANO_SMALL is defined. New functions
do_word_count() and do_next_word_void(); changes to

View File

@ -209,26 +209,23 @@ wchar_t control_wrep(wchar_t wc)
* where ch is c + 64. We return that multibyte character. */
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
if (ISSET(USE_UTF8)) {
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);
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);
crep_mb_len = 0;
*crep_mb_len = 0;
}
*crep_len = crep_mb_len;
} else {
#endif
*crep_len = 1;