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
master
David Lawrence Ramsey 2005-06-16 02:09:57 +00:00
parent 77d0feae05
commit 7a4aaa53a1
5 changed files with 28 additions and 29 deletions

View File

@ -95,6 +95,8 @@ CVS code -
toggle_init(), usage(), do_tab(), main(), nanorc.sample,
nano.1, nanorc.5, and nano.texi. (DLR, suggested by many
people)
- Change the NO_UTF8 flag to the USE_UTF8 flag, and reverse its
meaning. (DLR)
- chars.c:
make_mbstring()
- Change erroneous ENABLE_EXTRA #ifdef to NANO_EXTRA to fix a

View File

@ -68,7 +68,7 @@ bool is_alnum_mbchar(const char *c)
assert(c != NULL);
#ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) {
if (ISSET(USE_UTF8)) {
wchar_t wc;
int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX);
@ -89,7 +89,7 @@ bool is_blank_mbchar(const char *c)
assert(c != NULL);
#ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) {
if (ISSET(USE_UTF8)) {
wchar_t wc;
int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX);
@ -130,7 +130,7 @@ bool is_cntrl_mbchar(const char *c)
assert(c != NULL);
#ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) {
if (ISSET(USE_UTF8)) {
wchar_t wc;
int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX);
@ -151,7 +151,7 @@ bool is_punct_mbchar(const char *c)
assert(c != NULL);
#ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) {
if (ISSET(USE_UTF8)) {
wchar_t wc;
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)
assert(c != NULL);
#ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) {
if (ISSET(USE_UTF8)) {
wchar_t wc;
int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX), crep_mb_len;
@ -246,7 +246,7 @@ int mbwidth(const char *c)
assert(c != NULL);
#ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) {
if (ISSET(USE_UTF8)) {
wchar_t wc;
int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX), width;
@ -271,7 +271,7 @@ int mb_cur_max(void)
{
return
#ifdef NANO_WIDE
!ISSET(NO_UTF8) ? MB_CUR_MAX :
ISSET(USE_UTF8) ? MB_CUR_MAX :
#endif
1;
}
@ -288,7 +288,7 @@ char *make_mbchar(int chr, int *chr_mb_len)
assert(chr_mb_len != NULL);
#ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) {
if (ISSET(USE_UTF8)) {
chr_mb = charalloc(MB_CUR_MAX);
*chr_mb_len = wctomb(chr_mb, chr);
@ -323,7 +323,7 @@ int parse_mbchar(const char *buf, char *chr, bool *bad_chr, size_t
*bad_chr = FALSE;
#ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) {
if (ISSET(USE_UTF8)) {
/* Get the number of bytes in the multibyte character. */
buf_mb_len = mblen(buf, MB_CUR_MAX);
@ -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)
{
#ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) {
if (ISSET(USE_UTF8)) {
char *s1_mb = charalloc(MB_CUR_MAX);
char *s2_mb = charalloc(MB_CUR_MAX);
wchar_t ws1, ws2;
@ -540,7 +540,7 @@ const char *nstrcasestr(const char *haystack, const char *needle)
const char *mbstrcasestr(const char *haystack, const char *needle)
{
#ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) {
if (ISSET(USE_UTF8)) {
char *r_mb = charalloc(MB_CUR_MAX);
char *q_mb = charalloc(MB_CUR_MAX);
wchar_t wr, wq;
@ -646,7 +646,7 @@ const char *mbrevstrcasestr(const char *haystack, const char *needle,
const char *rev_start)
{
#ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) {
if (ISSET(USE_UTF8)) {
char *r_mb = charalloc(MB_CUR_MAX);
char *q_mb = charalloc(MB_CUR_MAX);
wchar_t wr, wq;
@ -734,7 +734,7 @@ size_t mbstrnlen(const char *s, size_t maxlen)
assert(s != NULL);
#ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) {
if (ISSET(USE_UTF8)) {
size_t n = 0;
int s_mb_len;
@ -778,7 +778,7 @@ bool has_blank_mbchars(const char *s)
assert(str != NULL);
#ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) {
if (ISSET(USE_UTF8)) {
char *chr_mb = charalloc(MB_CUR_MAX);
bool retval = FALSE;
@ -810,7 +810,7 @@ char *mbstrchr(const char *s, char *c)
assert(s != NULL && c != NULL);
#ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) {
if (ISSET(USE_UTF8)) {
char *s_mb = charalloc(MB_CUR_MAX);
const char *q = s;
wchar_t ws, wc;
@ -857,7 +857,7 @@ bool is_valid_mbstring(const char *s)
return
#ifdef NANO_WIDE
!ISSET(NO_UTF8) ?
ISSET(USE_UTF8) ?
(mbstowcs(NULL, s, (size_t)-1) != (size_t)-1) :
#endif
@ -874,7 +874,7 @@ char *make_valid_mbstring(const char *s)
assert(s != NULL);
#ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) {
if (ISSET(USE_UTF8)) {
char *chr_mb = charalloc(MB_CUR_MAX);
char *s_mb = charalloc((MB_CUR_MAX * strlen(s)) + 1);
size_t s_mb_len = 0;

View File

@ -4163,20 +4163,17 @@ int main(int argc, char **argv)
#ifdef NANO_WIDE
{
/* If the locale set doesn't exist, or it exists but doesn't
* include the case-insensitive string "UTF8" or "UTF-8", we
* shouldn't go into UTF-8 mode. */
/* If the locale set exists and includes the case-insensitive
* string "UTF8" or "UTF-8", we should use UTF-8. */
char *locale = setlocale(LC_ALL, "");
if (locale == NULL || (locale != NULL &&
strcasestr(locale, "UTF8") == NULL &&
strcasestr(locale, "UTF-8") == NULL))
SET(NO_UTF8);
if (locale != NULL && (strcasestr(locale, "UTF8") != NULL ||
strcasestr(locale, "UTF-8") != NULL)) {
SET(USE_UTF8);
#ifdef USE_SLANG
if (!ISSET(NO_UTF8))
SLutf8_enable(TRUE);
#endif
}
}
#else
setlocale(LC_ALL, "");

View File

@ -304,7 +304,7 @@ typedef struct syntaxtype {
#define WHITESPACE_DISPLAY (1<<27)
#define MORE_SPACE (1<<28)
#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. */
#define NANO_CONTROL_SPACE 0

View File

@ -2287,7 +2287,7 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool
}
}
#ifdef NANO_WIDE
else if (!ISSET(NO_UTF8) && mbwidth(buf_mb) > 1) {
else if (ISSET(USE_UTF8) && mbwidth(buf_mb) > 1) {
converted[index++] = ' ';
start_col++;
@ -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
* character, interpret that character as though it's a
* normal non-control character. */
if (!ISSET(NO_UTF8) && bad_char) {
if (ISSET(USE_UTF8) && bad_char) {
char *bad_buf_mb;
int bad_buf_mb_len;