Commit 7a4aaa53 authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

change the NO_UTF8 flag to the USE_UTF8 flag, and reverse its meaning

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2691 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
parent 77d0feae
Showing with 28 additions and 29 deletions
+28 -29
...@@ -95,6 +95,8 @@ CVS code - ...@@ -95,6 +95,8 @@ CVS code -
toggle_init(), usage(), do_tab(), main(), nanorc.sample, toggle_init(), usage(), do_tab(), main(), nanorc.sample,
nano.1, nanorc.5, and nano.texi. (DLR, suggested by many nano.1, nanorc.5, and nano.texi. (DLR, suggested by many
people) people)
- Change the NO_UTF8 flag to the USE_UTF8 flag, and reverse its
meaning. (DLR)
- chars.c: - chars.c:
make_mbstring() make_mbstring()
- Change erroneous ENABLE_EXTRA #ifdef to NANO_EXTRA to fix a - Change erroneous ENABLE_EXTRA #ifdef to NANO_EXTRA to fix a
......
...@@ -68,7 +68,7 @@ bool is_alnum_mbchar(const char *c) ...@@ -68,7 +68,7 @@ bool is_alnum_mbchar(const char *c)
assert(c != NULL); assert(c != NULL);
#ifdef NANO_WIDE #ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) { if (ISSET(USE_UTF8)) {
wchar_t wc; wchar_t wc;
int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX); int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX);
...@@ -89,7 +89,7 @@ bool is_blank_mbchar(const char *c) ...@@ -89,7 +89,7 @@ bool is_blank_mbchar(const char *c)
assert(c != NULL); assert(c != NULL);
#ifdef NANO_WIDE #ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) { if (ISSET(USE_UTF8)) {
wchar_t wc; wchar_t wc;
int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX); int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX);
...@@ -130,7 +130,7 @@ bool is_cntrl_mbchar(const char *c) ...@@ -130,7 +130,7 @@ bool is_cntrl_mbchar(const char *c)
assert(c != NULL); assert(c != NULL);
#ifdef NANO_WIDE #ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) { if (ISSET(USE_UTF8)) {
wchar_t wc; wchar_t wc;
int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX); int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX);
...@@ -151,7 +151,7 @@ bool is_punct_mbchar(const char *c) ...@@ -151,7 +151,7 @@ bool is_punct_mbchar(const char *c)
assert(c != NULL); assert(c != NULL);
#ifdef NANO_WIDE #ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) { if (ISSET(USE_UTF8)) {
wchar_t wc; wchar_t wc;
int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX); int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX);
...@@ -212,7 +212,7 @@ char *control_mbrep(const char *c, char *crep, int *crep_len) ...@@ -212,7 +212,7 @@ char *control_mbrep(const char *c, char *crep, int *crep_len)
assert(c != NULL); assert(c != NULL);
#ifdef NANO_WIDE #ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) { if (ISSET(USE_UTF8)) {
wchar_t wc; wchar_t wc;
int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX), crep_mb_len; int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX), crep_mb_len;
...@@ -246,7 +246,7 @@ int mbwidth(const char *c) ...@@ -246,7 +246,7 @@ int mbwidth(const char *c)
assert(c != NULL); assert(c != NULL);
#ifdef NANO_WIDE #ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) { if (ISSET(USE_UTF8)) {
wchar_t wc; wchar_t wc;
int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX), width; int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX), width;
...@@ -271,7 +271,7 @@ int mb_cur_max(void) ...@@ -271,7 +271,7 @@ int mb_cur_max(void)
{ {
return return
#ifdef NANO_WIDE #ifdef NANO_WIDE
!ISSET(NO_UTF8) ? MB_CUR_MAX : ISSET(USE_UTF8) ? MB_CUR_MAX :
#endif #endif
1; 1;
} }
...@@ -288,7 +288,7 @@ char *make_mbchar(int chr, int *chr_mb_len) ...@@ -288,7 +288,7 @@ char *make_mbchar(int chr, int *chr_mb_len)
assert(chr_mb_len != NULL); assert(chr_mb_len != NULL);
#ifdef NANO_WIDE #ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) { if (ISSET(USE_UTF8)) {
chr_mb = charalloc(MB_CUR_MAX); chr_mb = charalloc(MB_CUR_MAX);
*chr_mb_len = wctomb(chr_mb, chr); *chr_mb_len = wctomb(chr_mb, chr);
...@@ -323,7 +323,7 @@ int parse_mbchar(const char *buf, char *chr, bool *bad_chr, size_t ...@@ -323,7 +323,7 @@ int parse_mbchar(const char *buf, char *chr, bool *bad_chr, size_t
*bad_chr = FALSE; *bad_chr = FALSE;
#ifdef NANO_WIDE #ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) { if (ISSET(USE_UTF8)) {
/* Get the number of bytes in the multibyte character. */ /* Get the number of bytes in the multibyte character. */
buf_mb_len = mblen(buf, MB_CUR_MAX); buf_mb_len = mblen(buf, MB_CUR_MAX);
...@@ -470,7 +470,7 @@ int nstrncasecmp(const char *s1, const char *s2, size_t n) ...@@ -470,7 +470,7 @@ int nstrncasecmp(const char *s1, const char *s2, size_t n)
int mbstrncasecmp(const char *s1, const char *s2, size_t n) int mbstrncasecmp(const char *s1, const char *s2, size_t n)
{ {
#ifdef NANO_WIDE #ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) { if (ISSET(USE_UTF8)) {
char *s1_mb = charalloc(MB_CUR_MAX); char *s1_mb = charalloc(MB_CUR_MAX);
char *s2_mb = charalloc(MB_CUR_MAX); char *s2_mb = charalloc(MB_CUR_MAX);
wchar_t ws1, ws2; wchar_t ws1, ws2;
...@@ -540,7 +540,7 @@ const char *nstrcasestr(const char *haystack, const char *needle) ...@@ -540,7 +540,7 @@ const char *nstrcasestr(const char *haystack, const char *needle)
const char *mbstrcasestr(const char *haystack, const char *needle) const char *mbstrcasestr(const char *haystack, const char *needle)
{ {
#ifdef NANO_WIDE #ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) { if (ISSET(USE_UTF8)) {
char *r_mb = charalloc(MB_CUR_MAX); char *r_mb = charalloc(MB_CUR_MAX);
char *q_mb = charalloc(MB_CUR_MAX); char *q_mb = charalloc(MB_CUR_MAX);
wchar_t wr, wq; wchar_t wr, wq;
...@@ -646,7 +646,7 @@ const char *mbrevstrcasestr(const char *haystack, const char *needle, ...@@ -646,7 +646,7 @@ const char *mbrevstrcasestr(const char *haystack, const char *needle,
const char *rev_start) const char *rev_start)
{ {
#ifdef NANO_WIDE #ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) { if (ISSET(USE_UTF8)) {
char *r_mb = charalloc(MB_CUR_MAX); char *r_mb = charalloc(MB_CUR_MAX);
char *q_mb = charalloc(MB_CUR_MAX); char *q_mb = charalloc(MB_CUR_MAX);
wchar_t wr, wq; wchar_t wr, wq;
...@@ -734,7 +734,7 @@ size_t mbstrnlen(const char *s, size_t maxlen) ...@@ -734,7 +734,7 @@ size_t mbstrnlen(const char *s, size_t maxlen)
assert(s != NULL); assert(s != NULL);
#ifdef NANO_WIDE #ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) { if (ISSET(USE_UTF8)) {
size_t n = 0; size_t n = 0;
int s_mb_len; int s_mb_len;
...@@ -778,7 +778,7 @@ bool has_blank_mbchars(const char *s) ...@@ -778,7 +778,7 @@ bool has_blank_mbchars(const char *s)
assert(str != NULL); assert(str != NULL);
#ifdef NANO_WIDE #ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) { if (ISSET(USE_UTF8)) {
char *chr_mb = charalloc(MB_CUR_MAX); char *chr_mb = charalloc(MB_CUR_MAX);
bool retval = FALSE; bool retval = FALSE;
...@@ -810,7 +810,7 @@ char *mbstrchr(const char *s, char *c) ...@@ -810,7 +810,7 @@ char *mbstrchr(const char *s, char *c)
assert(s != NULL && c != NULL); assert(s != NULL && c != NULL);
#ifdef NANO_WIDE #ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) { if (ISSET(USE_UTF8)) {
char *s_mb = charalloc(MB_CUR_MAX); char *s_mb = charalloc(MB_CUR_MAX);
const char *q = s; const char *q = s;
wchar_t ws, wc; wchar_t ws, wc;
...@@ -857,7 +857,7 @@ bool is_valid_mbstring(const char *s) ...@@ -857,7 +857,7 @@ bool is_valid_mbstring(const char *s)
return return
#ifdef NANO_WIDE #ifdef NANO_WIDE
!ISSET(NO_UTF8) ? ISSET(USE_UTF8) ?
(mbstowcs(NULL, s, (size_t)-1) != (size_t)-1) : (mbstowcs(NULL, s, (size_t)-1) != (size_t)-1) :
#endif #endif
...@@ -874,7 +874,7 @@ char *make_valid_mbstring(const char *s) ...@@ -874,7 +874,7 @@ char *make_valid_mbstring(const char *s)
assert(s != NULL); assert(s != NULL);
#ifdef NANO_WIDE #ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) { if (ISSET(USE_UTF8)) {
char *chr_mb = charalloc(MB_CUR_MAX); char *chr_mb = charalloc(MB_CUR_MAX);
char *s_mb = charalloc((MB_CUR_MAX * strlen(s)) + 1); char *s_mb = charalloc((MB_CUR_MAX * strlen(s)) + 1);
size_t s_mb_len = 0; size_t s_mb_len = 0;
......
...@@ -4163,20 +4163,17 @@ int main(int argc, char **argv) ...@@ -4163,20 +4163,17 @@ int main(int argc, char **argv)
#ifdef NANO_WIDE #ifdef NANO_WIDE
{ {
/* If the locale set doesn't exist, or it exists but doesn't /* If the locale set exists and includes the case-insensitive
* include the case-insensitive string "UTF8" or "UTF-8", we * string "UTF8" or "UTF-8", we should use UTF-8. */
* shouldn't go into UTF-8 mode. */
char *locale = setlocale(LC_ALL, ""); char *locale = setlocale(LC_ALL, "");
if (locale == NULL || (locale != NULL && if (locale != NULL && (strcasestr(locale, "UTF8") != NULL ||
strcasestr(locale, "UTF8") == NULL && strcasestr(locale, "UTF-8") != NULL)) {
strcasestr(locale, "UTF-8") == NULL)) SET(USE_UTF8);
SET(NO_UTF8);
#ifdef USE_SLANG #ifdef USE_SLANG
if (!ISSET(NO_UTF8))
SLutf8_enable(TRUE); SLutf8_enable(TRUE);
#endif #endif
}
} }
#else #else
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
......
...@@ -304,7 +304,7 @@ typedef struct syntaxtype { ...@@ -304,7 +304,7 @@ typedef struct syntaxtype {
#define WHITESPACE_DISPLAY (1<<27) #define WHITESPACE_DISPLAY (1<<27)
#define MORE_SPACE (1<<28) #define MORE_SPACE (1<<28)
#define TABS_TO_SPACES (1<<29) #define TABS_TO_SPACES (1<<29)
#define NO_UTF8 (1<<30) #define USE_UTF8 (1<<30)
/* Control key sequences. Changing these would be very, very bad. */ /* Control key sequences. Changing these would be very, very bad. */
#define NANO_CONTROL_SPACE 0 #define NANO_CONTROL_SPACE 0
......
...@@ -2287,7 +2287,7 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool ...@@ -2287,7 +2287,7 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool
} }
} }
#ifdef NANO_WIDE #ifdef NANO_WIDE
else if (!ISSET(NO_UTF8) && mbwidth(buf_mb) > 1) { else if (ISSET(USE_UTF8) && mbwidth(buf_mb) > 1) {
converted[index++] = ' '; converted[index++] = ' ';
start_col++; start_col++;
...@@ -2353,7 +2353,7 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool ...@@ -2353,7 +2353,7 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool
/* If buf contains an invalid multibyte non-control /* If buf contains an invalid multibyte non-control
* character, interpret that character as though it's a * character, interpret that character as though it's a
* normal non-control character. */ * normal non-control character. */
if (!ISSET(NO_UTF8) && bad_char) { if (ISSET(USE_UTF8) && bad_char) {
char *bad_buf_mb; char *bad_buf_mb;
int bad_buf_mb_len; int bad_buf_mb_len;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment