From 7eb30a835344e72d32b7fae34b4796b8efd35e72 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Sun, 17 Jul 2005 02:40:07 +0000 Subject: [PATCH] change NANO_WIDE #define to ENABLE_UTF8, as the latter is clearer git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2881 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 4 ++++ configure.ac | 2 +- src/chars.c | 46 +++++++++++++++++++++++----------------------- src/nano.c | 4 ++-- src/proto.h | 6 +++--- src/winio.c | 12 ++++++------ 6 files changed, 39 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6af21bc0..36a10ec9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -68,6 +68,8 @@ CVS code - read_file(), move_to_filestruct(), copy_from_filestruct(), do_justify(), get_totals() (renamed get_totsize()), and do_cursorpos(). (DLR) + - Change the NANO_WIDE #define to ENABLE_UTF8, as the latter is + clearer. (DLR) - files.c: open_file() - Assert that filename isn't NULL, and don't do anything special @@ -168,6 +170,8 @@ CVS code - - configure.ac: - Since we only use vsnprintf() now, remove the tests for snprintf(). (DLR) + - Change the description of "sufficient wide character support" + to "sufficient UTF-8 support", as the latter is clearer. (DLR) - doc/faq.html: - Update section 4.10 to mention that pasting from the X clipboard via the middle mouse button also works when the diff --git a/configure.ac b/configure.ac index 20de1fbd..296abe2d 100644 --- a/configure.ac +++ b/configure.ac @@ -480,7 +480,7 @@ if test x$enable_utf8 != xno && \ test x$ac_cv_func_mbtowc = xyes && \ test x$ac_cv_func_wctomb = xyes && \ test x$ac_cv_func_wcwidth = xyes; then - AC_DEFINE(NANO_WIDE, 1, [Define this if your system has sufficient wide character support (a wide curses library, iswalnum(), iswpunct(), iswblank() or iswspace(), mblen(), mbstowcs(), mbtowc(), wctomb(), and wcwidth()).]) + AC_DEFINE(ENABLE_UTF8, 1, [Define this if your system has sufficient UTF-8 support (a wide curses library, iswalnum(), iswpunct(), iswblank() or iswspace(), mblen(), mbstowcs(), mbtowc(), wctomb(), and wcwidth()).]) else if test x$enable_utf8 = xyes; then AC_MSG_ERROR([ diff --git a/src/chars.c b/src/chars.c index 336c29c2..0d3a9ddf 100644 --- a/src/chars.c +++ b/src/chars.c @@ -30,7 +30,7 @@ #include #include "proto.h" -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 #ifdef HAVE_WCHAR_H #include #endif @@ -47,7 +47,7 @@ bool nisblank(int c) } #endif -#if !defined(HAVE_ISWBLANK) && defined(NANO_WIDE) +#if !defined(HAVE_ISWBLANK) && defined(ENABLE_UTF8) /* This function is equivalent to iswblank(). */ bool niswblank(wchar_t wc) { @@ -67,7 +67,7 @@ bool is_alnum_mbchar(const char *c) { assert(c != NULL); -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 if (ISSET(USE_UTF8)) { wchar_t wc; int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX); @@ -88,7 +88,7 @@ bool is_blank_mbchar(const char *c) { assert(c != NULL); -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 if (ISSET(USE_UTF8)) { wchar_t wc; int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX); @@ -112,7 +112,7 @@ bool is_cntrl_char(int c) (127 <= c && c < 160); } -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 /* This function is equivalent to iscntrl() for wide characters, except * in that it also handles wide control characters with their high bits * set. */ @@ -129,7 +129,7 @@ bool is_cntrl_mbchar(const char *c) { assert(c != NULL); -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 if (ISSET(USE_UTF8)) { wchar_t wc; int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX); @@ -150,7 +150,7 @@ bool is_punct_mbchar(const char *c) { assert(c != NULL); -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 if (ISSET(USE_UTF8)) { wchar_t wc; int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX); @@ -190,7 +190,7 @@ char control_rep(char c) return c + 64; } -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 /* c is a wide control character. It displays as ^@, ^?, or ^[ch], * where ch is (c + 64). We return that wide character. */ wchar_t control_wrep(wchar_t wc) @@ -211,7 +211,7 @@ char *control_mbrep(const char *c, char *crep, int *crep_len) { assert(c != NULL && crep != NULL && crep_len != NULL); -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 if (ISSET(USE_UTF8)) { wchar_t wc; @@ -230,7 +230,7 @@ char *control_mbrep(const char *c, char *crep, int *crep_len) #endif *crep_len = 1; *crep = control_rep(*c); -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 } #endif @@ -242,7 +242,7 @@ int mbwidth(const char *c) { assert(c != NULL); -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 if (ISSET(USE_UTF8)) { wchar_t wc; int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX), width; @@ -267,7 +267,7 @@ int mbwidth(const char *c) int mb_cur_max(void) { return -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 ISSET(USE_UTF8) ? MB_CUR_MAX : #endif 1; @@ -284,7 +284,7 @@ char *make_mbchar(int chr, int *chr_mb_len) assert(chr_mb_len != NULL); -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 if (ISSET(USE_UTF8)) { chr_mb = charalloc(MB_CUR_MAX); *chr_mb_len = wctomb(chr_mb, chr); @@ -297,7 +297,7 @@ char *make_mbchar(int chr, int *chr_mb_len) #endif *chr_mb_len = 1; chr_mb = mallocstrncpy(NULL, (char *)&chr, 1); -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 } #endif @@ -319,7 +319,7 @@ int parse_mbchar(const char *buf, char *chr, bool *bad_chr, size_t if (bad_chr != NULL) *bad_chr = FALSE; -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 if (ISSET(USE_UTF8)) { /* Get the number of bytes in the multibyte character. */ buf_mb_len = mblen(buf, MB_CUR_MAX); @@ -393,7 +393,7 @@ int parse_mbchar(const char *buf, char *chr, bool *bad_chr, size_t else (*col)++; } -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 } #endif @@ -466,7 +466,7 @@ int nstrncasecmp(const char *s1, const char *s2, size_t n) * strings. */ int mbstrncasecmp(const char *s1, const char *s2, size_t n) { -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 if (ISSET(USE_UTF8)) { char *s1_mb = charalloc(MB_CUR_MAX); char *s2_mb = charalloc(MB_CUR_MAX); @@ -536,7 +536,7 @@ const char *nstrcasestr(const char *haystack, const char *needle) /* This function is equivalent to strcasestr() for multibyte strings. */ const char *mbstrcasestr(const char *haystack, const char *needle) { -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 if (ISSET(USE_UTF8)) { char *r_mb = charalloc(MB_CUR_MAX); char *q_mb = charalloc(MB_CUR_MAX); @@ -642,7 +642,7 @@ const char *revstrcasestr(const char *haystack, const char *needle, const char *mbrevstrcasestr(const char *haystack, const char *needle, const char *rev_start) { -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 if (ISSET(USE_UTF8)) { char *r_mb = charalloc(MB_CUR_MAX); char *q_mb = charalloc(MB_CUR_MAX); @@ -730,7 +730,7 @@ size_t mbstrnlen(const char *s, size_t maxlen) { assert(s != NULL); -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 if (ISSET(USE_UTF8)) { size_t n = 0; int s_mb_len; @@ -774,7 +774,7 @@ bool has_blank_mbchars(const char *s) { assert(s != NULL); -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 if (ISSET(USE_UTF8)) { char *chr_mb = charalloc(MB_CUR_MAX); bool retval = FALSE; @@ -806,7 +806,7 @@ char *mbstrchr(const char *s, char *c) { assert(s != NULL && c != NULL); -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 if (ISSET(USE_UTF8)) { char *s_mb = charalloc(MB_CUR_MAX); const char *q = s; @@ -853,7 +853,7 @@ bool is_valid_mbstring(const char *s) assert(s != NULL); return -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 ISSET(USE_UTF8) ? (mbstowcs(NULL, s, 0) != (size_t)-1) : #endif diff --git a/src/nano.c b/src/nano.c index 79982ac3..d8022221 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1141,7 +1141,7 @@ void version(void) #ifdef NANO_SMALL printf(" --enable-tiny"); #endif -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 printf(" --enable-utf8"); #endif #ifdef USE_SLANG @@ -4256,7 +4256,7 @@ int main(int argc, char **argv) }; #endif -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 { /* If the locale set exists and includes the case-insensitive * string "UTF8" or "UTF-8", we should use UTF-8. */ diff --git a/src/proto.h b/src/proto.h index a93b108a..e8a5c609 100644 --- a/src/proto.h +++ b/src/proto.h @@ -144,21 +144,21 @@ extern char *homedir; #ifndef HAVE_ISBLANK bool nisblank(int c); #endif -#if !defined(HAVE_ISWBLANK) && defined(NANO_WIDE) +#if !defined(HAVE_ISWBLANK) && defined(ENABLE_UTF8) bool niswblank(wchar_t wc); #endif bool is_byte(int c); bool is_alnum_mbchar(const char *c); bool is_blank_mbchar(const char *c); bool is_cntrl_char(int c); -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 bool is_cntrl_wchar(wchar_t wc); #endif bool is_cntrl_mbchar(const char *c); bool is_punct_mbchar(const char *c); bool is_word_mbchar(const char *c, bool allow_punct); char control_rep(char c); -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 wchar_t control_wrep(wchar_t c); #endif char *control_mbrep(const char *c, char *crep, int *crep_len); diff --git a/src/winio.c b/src/winio.c index d8a24c2c..0a99eeaf 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2285,7 +2285,7 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool /* Current position in converted. */ bool bad_char; /* Whether we have an invalid multibyte character. */ -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 const char *bad_buf_mb = "\xEF\xBF\xBD"; /* What to display when we have an invalid multibyte * character: Unicode 0xFFFD (Replacement Character). */ @@ -2341,7 +2341,7 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool start_index += buf_mb_len; } } -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 else if (ISSET(USE_UTF8) && mbwidth(buf_mb) > 1) { converted[index++] = ' '; start_col++; @@ -2378,7 +2378,7 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool converted[index++] = '^'; start_col++; -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 /* If buf contains an invalid multibyte control character, * display it as such. */ if (ISSET(USE_UTF8) && bad_char) { @@ -2419,7 +2419,7 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool } else { int i; -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 /* If buf contains an invalid multibyte non-control * character, display it as such. */ if (ISSET(USE_UTF8) && bad_char) { @@ -2433,7 +2433,7 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool converted[index++] = buf[start_index + i]; start_col += mbwidth(buf_mb); -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 } #endif } @@ -4192,7 +4192,7 @@ void do_credits(void) * can't dynamically assign it above, using Unicode 00F6 (Latin * Small Letter O with Diaresis) if applicable. */ credits[14] = -#ifdef NANO_WIDE +#ifdef ENABLE_UTF8 ISSET(USE_UTF8) ? "Florian K\xC3\xB6nig" : #endif "Florian K\xF6nig"; -- 2.39.5