diff options
-rw-r--r-- | src/charset.c | 71 | ||||
-rw-r--r-- | src/globals.h | 3 | ||||
-rw-r--r-- | src/macros.h | 5 | ||||
-rw-r--r-- | src/main.c | 4 | ||||
-rw-r--r-- | src/option.c | 4 | ||||
-rw-r--r-- | src/screen.c | 2 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim.h | 8 |
8 files changed, 48 insertions, 51 deletions
diff --git a/src/charset.c b/src/charset.c index 1000692cc..8a4fb7d6c 100644 --- a/src/charset.c +++ b/src/charset.c @@ -30,21 +30,32 @@ static int chartab_initialized = FALSE; #define RESET_CHARTAB(buf, c) (buf)->b_chartab[(unsigned)(c) >> 3] &= ~(1 << ((c) & 0x7)) #define GET_CHARTAB(buf, c) ((buf)->b_chartab[(unsigned)(c) >> 3] & (1 << ((c) & 0x7))) +/* table used below, see init_chartab() for an explanation */ +static char_u g_chartab[256]; + +/* + * Flags for g_chartab[]. + */ +#define CT_CELL_MASK 0x07 /* mask: nr of display cells (1, 2 or 4) */ +#define CT_PRINT_CHAR 0x10 /* flag: set for printable chars */ +#define CT_ID_CHAR 0x20 /* flag: set for ID chars */ +#define CT_FNAME_CHAR 0x40 /* flag: set for file name chars */ + /* - * Fill chartab[]. Also fills curbuf->b_chartab[] with flags for keyword + * Fill g_chartab[]. Also fills curbuf->b_chartab[] with flags for keyword * characters for current buffer. * * Depends on the option settings 'iskeyword', 'isident', 'isfname', * 'isprint' and 'encoding'. * - * The index in chartab[] depends on 'encoding': + * The index in g_chartab[] depends on 'encoding': * - For non-multi-byte index with the byte (same as the character). * - For DBCS index with the first byte. * - For UTF-8 index with the character (when first byte is up to 0x80 it is * the same as the character, if the first byte is 0x80 and above it depends * on further bytes). * - * The contents of chartab[]: + * The contents of g_chartab[]: * - The lower two bits, masked by CT_CELL_MASK, give the number of display * cells the character occupies (1 or 2). Not valid for UTF-8 above 0x80. * - CT_PRINT_CHAR bit is set when the character is printable (no need to @@ -86,18 +97,18 @@ buf_init_chartab(buf, global) */ c = 0; while (c < ' ') - chartab[c++] = (dy_flags & DY_UHEX) ? 4 : 2; + g_chartab[c++] = (dy_flags & DY_UHEX) ? 4 : 2; #ifdef EBCDIC while (c < 255) #else while (c <= '~') #endif - chartab[c++] = 1 + CT_PRINT_CHAR; + g_chartab[c++] = 1 + CT_PRINT_CHAR; #ifdef FEAT_FKMAP if (p_altkeymap) { while (c < YE) - chartab[c++] = 1 + CT_PRINT_CHAR; + g_chartab[c++] = 1 + CT_PRINT_CHAR; } #endif while (c < 256) @@ -105,17 +116,17 @@ buf_init_chartab(buf, global) #ifdef FEAT_MBYTE /* UTF-8: bytes 0xa0 - 0xff are printable (latin1) */ if (enc_utf8 && c >= 0xa0) - chartab[c++] = CT_PRINT_CHAR + 1; + g_chartab[c++] = CT_PRINT_CHAR + 1; /* euc-jp characters starting with 0x8e are single width */ else if (enc_dbcs == DBCS_JPNU && c == 0x8e) - chartab[c++] = CT_PRINT_CHAR + 1; + g_chartab[c++] = CT_PRINT_CHAR + 1; /* other double-byte chars can be printable AND double-width */ else if (enc_dbcs != 0 && MB_BYTE2LEN(c) == 2) - chartab[c++] = CT_PRINT_CHAR + 2; + g_chartab[c++] = CT_PRINT_CHAR + 2; else #endif /* the rest is unprintable by default */ - chartab[c++] = (dy_flags & DY_UHEX) ? 4 : 2; + g_chartab[c++] = (dy_flags & DY_UHEX) ? 4 : 2; } #ifdef FEAT_MBYTE @@ -124,7 +135,7 @@ buf_init_chartab(buf, global) if ((enc_dbcs != 0 && MB_BYTE2LEN(c) > 1) || (enc_dbcs == DBCS_JPNU && c == 0x8e) || (enc_utf8 && c >= 0xa0)) - chartab[c] |= CT_FNAME_CHAR; + g_chartab[c] |= CT_FNAME_CHAR; #endif } @@ -232,9 +243,9 @@ buf_init_chartab(buf, global) if (i == 0) /* (re)set ID flag */ { if (tilde) - chartab[c] &= ~CT_ID_CHAR; + g_chartab[c] &= ~CT_ID_CHAR; else - chartab[c] |= CT_ID_CHAR; + g_chartab[c] |= CT_ID_CHAR; } else if (i == 1) /* (re)set printable */ { @@ -256,23 +267,23 @@ buf_init_chartab(buf, global) { if (tilde) { - chartab[c] = (chartab[c] & ~CT_CELL_MASK) + g_chartab[c] = (g_chartab[c] & ~CT_CELL_MASK) + ((dy_flags & DY_UHEX) ? 4 : 2); - chartab[c] &= ~CT_PRINT_CHAR; + g_chartab[c] &= ~CT_PRINT_CHAR; } else { - chartab[c] = (chartab[c] & ~CT_CELL_MASK) + 1; - chartab[c] |= CT_PRINT_CHAR; + g_chartab[c] = (g_chartab[c] & ~CT_CELL_MASK) + 1; + g_chartab[c] |= CT_PRINT_CHAR; } } } else if (i == 2) /* (re)set fname flag */ { if (tilde) - chartab[c] &= ~CT_FNAME_CHAR; + g_chartab[c] &= ~CT_FNAME_CHAR; else - chartab[c] |= CT_FNAME_CHAR; + g_chartab[c] |= CT_FNAME_CHAR; } else /* i == 3 */ /* (re)set keyword flag */ { @@ -531,9 +542,9 @@ str_foldcase(str, orglen, buf, buflen) #endif /* - * Catch 22: chartab[] can't be initialized before the options are + * Catch 22: g_chartab[] can't be initialized before the options are * initialized, and initializing options may cause transchar() to be called! - * When chartab_initialized == FALSE don't use chartab[]. + * When chartab_initialized == FALSE don't use g_chartab[]. * Does NOT work for multi-byte characters, c must be <= 255. * Also doesn't work for the first byte of a multi-byte, "c" must be a * character! @@ -718,7 +729,7 @@ byte2cells(b) if (enc_utf8 && b >= 0x80) return 0; #endif - return (chartab[b] & CT_CELL_MASK); + return (g_chartab[b] & CT_CELL_MASK); } /* @@ -748,7 +759,7 @@ char2cells(c) } } #endif - return (chartab[c & 0xff] & CT_CELL_MASK); + return (g_chartab[c & 0xff] & CT_CELL_MASK); } /* @@ -765,7 +776,7 @@ ptr2cells(p) return utf_ptr2cells(p); /* For DBCS we can tell the cell count from the first byte. */ #endif - return (chartab[*p] & CT_CELL_MASK); + return (g_chartab[*p] & CT_CELL_MASK); } /* @@ -900,7 +911,7 @@ win_linetabsize(wp, line, len) vim_isIDc(c) int c; { - return (c > 0 && c < 0x100 && (chartab[c] & CT_ID_CHAR)); + return (c > 0 && c < 0x100 && (g_chartab[c] & CT_ID_CHAR)); } /* @@ -966,7 +977,7 @@ vim_iswordp_buf(p, buf) vim_isfilec(c) int c; { - return (c >= 0x100 || (c > 0 && (chartab[c] & CT_FNAME_CHAR))); + return (c >= 0x100 || (c > 0 && (g_chartab[c] & CT_FNAME_CHAR))); } /* @@ -999,7 +1010,7 @@ vim_isprintc(c) if (enc_utf8 && c >= 0x100) return utf_printable(c); #endif - return (c >= 0x100 || (c > 0 && (chartab[c] & CT_PRINT_CHAR))); + return (c >= 0x100 || (c > 0 && (g_chartab[c] & CT_PRINT_CHAR))); } /* @@ -1016,7 +1027,7 @@ vim_isprintc_strict(c) if (enc_utf8 && c >= 0x100) return utf_printable(c); #endif - return (c >= 0x100 || (c > 0 && (chartab[c] & CT_PRINT_CHAR))); + return (c >= 0x100 || (c > 0 && (g_chartab[c] & CT_PRINT_CHAR))); } /* @@ -1368,7 +1379,7 @@ getvcol(wp, pos, start, cursor, end) if (enc_utf8 && c >= 0x80) incr = utf_ptr2cells(ptr); else - incr = CHARSIZE(c); + incr = g_chartab[c] & CT_CELL_MASK; /* If a double-cell char doesn't fit at the end of a line * it wraps to the next line, it's like this char is three @@ -1382,7 +1393,7 @@ getvcol(wp, pos, start, cursor, end) } else #endif - incr = CHARSIZE(c); + incr = g_chartab[c] & CT_CELL_MASK; } if (posptr != NULL && ptr >= posptr) /* character at pos->col */ diff --git a/src/globals.h b/src/globals.h index d6abc67ed..4dc0b81a1 100644 --- a/src/globals.h +++ b/src/globals.h @@ -1012,9 +1012,6 @@ EXTERN int vgetc_im_active; /* Input Method was active for last #endif EXTERN int maptick INIT(= 0); /* tick for each non-mapped char */ -EXTERN char_u chartab[256]; /* table used in charset.c; See - init_chartab() for explanation */ - EXTERN int must_redraw INIT(= 0); /* type of redraw necessary */ EXTERN int skip_redraw INIT(= FALSE); /* skip redraw once */ EXTERN int do_redraw INIT(= FALSE); /* extra redraw once */ diff --git a/src/macros.h b/src/macros.h index 737eddf52..c4d27f80d 100644 --- a/src/macros.h +++ b/src/macros.h @@ -121,11 +121,6 @@ /* Returns empty string if it is NULL. */ #define EMPTY_IF_NULL(x) ((x) ? (x) : (u_char *)"") -/* macro version of chartab(). - * Only works with values 0-255! - * Doesn't work for UTF-8 mode with chars >= 0x80. */ -#define CHARSIZE(c) (chartab[c] & CT_CELL_MASK) - #ifdef FEAT_LANGMAP /* * Adjust chars in a language according to 'langmap' option. diff --git a/src/main.c b/src/main.c index 175bbde11..e872e3aa7 100644 --- a/src/main.c +++ b/src/main.c @@ -1582,8 +1582,8 @@ init_locale() /* Initialize the gettext library */ dyn_libintl_init(); # endif - /* expand_env() doesn't work yet, because chartab[] is not initialized - * yet, call vim_getenv() directly */ + /* expand_env() doesn't work yet, because g_chartab[] is not + * initialized yet, call vim_getenv() directly */ p = vim_getenv((char_u *)"VIMRUNTIME", &mustfree); if (p != NULL && *p != NUL) { diff --git a/src/option.c b/src/option.c index cd7064c4f..41d6cebd9 100644 --- a/src/option.c +++ b/src/option.c @@ -5934,9 +5934,9 @@ did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf, #endif /* - * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill chartab[] + * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill g_chartab[] * If the new option is invalid, use old value. 'lisp' option: refill - * chartab[] for '-' char + * g_chartab[] for '-' char */ else if ( varp == &p_isi || varp == &(curbuf->b_p_isk) diff --git a/src/screen.c b/src/screen.c index d34c4b2f2..69c1f40cf 100644 --- a/src/screen.c +++ b/src/screen.c @@ -4598,7 +4598,7 @@ win_line(wp, lnum, startrow, endrow, nochange) /* * Handling of non-printable characters. */ - if (!(chartab[c & 0xff] & CT_PRINT_CHAR)) + if (!vim_isprintc(c)) { /* * when getting a character from the file, we may have to diff --git a/src/version.c b/src/version.c index 02f34a8b5..34666f9a0 100644 --- a/src/version.c +++ b/src/version.c @@ -742,6 +742,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1147, +/**/ 1146, /**/ 1145, @@ -1111,14 +1111,6 @@ extern char *(*dyn_libintl_textdomain)(const char *domainname); #define HIST_COUNT 5 /* number of history tables */ /* - * Flags for chartab[]. - */ -#define CT_CELL_MASK 0x07 /* mask: nr of display cells (1, 2 or 4) */ -#define CT_PRINT_CHAR 0x10 /* flag: set for printable chars */ -#define CT_ID_CHAR 0x20 /* flag: set for ID chars */ -#define CT_FNAME_CHAR 0x40 /* flag: set for file name chars */ - -/* * Values for do_tag(). */ #define DT_TAG 1 /* jump to newer position or same tag again */ |