diff options
-rw-r--r-- | src/charset.c | 4 | ||||
-rw-r--r-- | src/edit.c | 22 | ||||
-rw-r--r-- | src/ex_getln.c | 2 | ||||
-rw-r--r-- | src/file_search.c | 2 | ||||
-rw-r--r-- | src/macros.h | 11 | ||||
-rw-r--r-- | src/mbyte.c | 2 | ||||
-rw-r--r-- | src/message.c | 4 | ||||
-rw-r--r-- | src/ops.c | 10 | ||||
-rw-r--r-- | src/path.c | 6 | ||||
-rw-r--r-- | src/regexp.c | 34 | ||||
-rw-r--r-- | src/regexp_nfa.c | 20 | ||||
-rw-r--r-- | src/search.c | 2 | ||||
-rw-r--r-- | src/spell.c | 8 |
13 files changed, 59 insertions, 68 deletions
diff --git a/src/charset.c b/src/charset.c index 928886f53a..4c9784a07b 100644 --- a/src/charset.c +++ b/src/charset.c @@ -222,8 +222,8 @@ int buf_init_chartab(buf_T *buf, int global) // work properly when 'encoding' is "latin1" and the locale is // "C". if (!do_isalpha - || MB_ISLOWER(c) - || MB_ISUPPER(c) + || vim_islower(c) + || vim_isupper(c) || (p_altkeymap && (F_isalpha(c) || F_isdigit(c)))) { if (i == 0) { // (re)set ID flag diff --git a/src/edit.c b/src/edit.c index 55f9328ce0..3b263b40c8 100644 --- a/src/edit.c +++ b/src/edit.c @@ -2002,12 +2002,12 @@ int ins_compl_add_infercase(char_u *str, int len, int icase, char_u *fname, int c = mb_ptr2char_adv(&p); else c = *(p++); - if (MB_ISLOWER(c)) { + if (vim_islower(c)) { has_lower = TRUE; - if (MB_ISUPPER(wca[i])) { + if (vim_isupper(wca[i])) { /* Rule 1 is satisfied. */ for (i = actual_compl_length; i < actual_len; ++i) - wca[i] = MB_TOLOWER(wca[i]); + wca[i] = vim_tolower(wca[i]); break; } } @@ -2024,13 +2024,13 @@ int ins_compl_add_infercase(char_u *str, int len, int icase, char_u *fname, int c = mb_ptr2char_adv(&p); else c = *(p++); - if (was_letter && MB_ISUPPER(c) && MB_ISLOWER(wca[i])) { + if (was_letter && vim_isupper(c) && vim_islower(wca[i])) { /* Rule 2 is satisfied. */ for (i = actual_compl_length; i < actual_len; ++i) - wca[i] = MB_TOUPPER(wca[i]); + wca[i] = vim_toupper(wca[i]); break; } - was_letter = MB_ISLOWER(c) || MB_ISUPPER(c); + was_letter = vim_islower(c) || vim_isupper(c); } } @@ -2041,10 +2041,10 @@ int ins_compl_add_infercase(char_u *str, int len, int icase, char_u *fname, int c = mb_ptr2char_adv(&p); else c = *(p++); - if (MB_ISLOWER(c)) - wca[i] = MB_TOLOWER(wca[i]); - else if (MB_ISUPPER(c)) - wca[i] = MB_TOUPPER(wca[i]); + if (vim_islower(c)) + wca[i] = vim_tolower(wca[i]); + else if (vim_isupper(c)) + wca[i] = vim_toupper(wca[i]); } /* @@ -2231,7 +2231,7 @@ static void ins_compl_longest_match(compl_T *match) c1 = *p; c2 = *s; } - if (match->cp_icase ? (MB_TOLOWER(c1) != MB_TOLOWER(c2)) + if (match->cp_icase ? (vim_tolower(c1) != vim_tolower(c2)) : (c1 != c2)) break; if (has_mbyte) { diff --git a/src/ex_getln.c b/src/ex_getln.c index 9e0e35dd09..94daa3d4e6 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -1146,7 +1146,7 @@ getcmdline ( * command line has no uppercase characters, convert * the character to lowercase */ if (p_ic && p_scs && !pat_has_uppercase(ccline.cmdbuff)) - c = MB_TOLOWER(c); + c = vim_tolower(c); if (c != NUL) { if (c == firstc || vim_strchr((char_u *)( p_magic ? "\\^$.*[" : "\\^$"), c) diff --git a/src/file_search.c b/src/file_search.c index d5cc280c05..d435149a33 100644 --- a/src/file_search.c +++ b/src/file_search.c @@ -1123,7 +1123,7 @@ static int ff_wc_equal(char_u *s1, char_u *s2) int c1 = PTR2CHAR(s1 + i); int c2 = PTR2CHAR(s2 + i); - if ((p_fic ? MB_TOLOWER(c1) != MB_TOLOWER(c2) : c1 != c2) + if ((p_fic ? vim_tolower(c1) != vim_tolower(c2) : c1 != c2) && (prev1 != '*' || prev2 != '*')) return FAIL; prev2 = prev1; diff --git a/src/macros.h b/src/macros.h index 8199dd41a3..fbd3440c6d 100644 --- a/src/macros.h +++ b/src/macros.h @@ -51,7 +51,7 @@ * characters, first use islower() or isupper() then. * Careful: Only call TOUPPER_LOC() and TOLOWER_LOC() with a character in the * range 0 - 255. toupper()/tolower() on some systems can't handle others. - * Note: It is often better to use MB_TOLOWER() and MB_TOUPPER(), because many + * Note: It is often better to use vim_tolower() and vim_toupper(), because many * toupper() and tolower() implementations only work for ASCII. */ # ifdef BROKEN_TOUPPER @@ -66,15 +66,6 @@ # define TOUPPER_ASC(c) (((c) < 'a' || (c) > 'z') ? (c) : (c) - ('a' - 'A')) # define TOLOWER_ASC(c) (((c) < 'A' || (c) > 'Z') ? (c) : (c) + ('a' - 'A')) -/* - * MB_ISLOWER() and MB_ISUPPER() are to be used on multi-byte characters. But - * don't use them for negative values! - */ -# define MB_ISLOWER(c) vim_islower(c) -# define MB_ISUPPER(c) vim_isupper(c) -# define MB_TOLOWER(c) vim_tolower(c) -# define MB_TOUPPER(c) vim_toupper(c) - /* Use our own isdigit() replacement, because on MS-Windows isdigit() returns * non-zero for superscript 1. Also avoids that isdigit() crashes for numbers * below 0 and above 255. */ diff --git a/src/mbyte.c b/src/mbyte.c index 8278deb6f8..29964e92d5 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -2868,7 +2868,7 @@ int mb_strnicmp(char_u *s1, char_u *s2, size_t nn) if (l <= 1) { /* Single byte: first check normally, then with ignore case. */ if (s1[i] != s2[i]) { - cdiff = MB_TOLOWER(s1[i]) - MB_TOLOWER(s2[i]); + cdiff = vim_tolower(s1[i]) - vim_tolower(s2[i]); if (cdiff != 0) return cdiff; } diff --git a/src/message.c b/src/message.c index 9a130dd202..6ee608861f 100644 --- a/src/message.c +++ b/src/message.c @@ -2772,7 +2772,7 @@ do_dialog ( } /* Make the character lowercase, as chars in "hotkeys" are. */ - c = MB_TOLOWER(c); + c = vim_tolower(c); retval = 1; for (i = 0; hotkeys[i]; ++i) { if (has_mbyte) { @@ -2820,7 +2820,7 @@ copy_char ( if (has_mbyte) { if (lowercase) { - c = MB_TOLOWER((*mb_ptr2char)(from)); + c = vim_tolower((*mb_ptr2char)(from)); return (*mb_char2bytes)(c, to); } else { len = (*mb_ptr2len)(from); @@ -2032,16 +2032,16 @@ int swapchar(int op_type, pos_T *pos) if (enc_dbcs != 0 && c >= 0x100) /* No lower/uppercase letter */ return FALSE; nc = c; - if (MB_ISLOWER(c)) { + if (vim_islower(c)) { if (op_type == OP_ROT13) nc = ROT13(c, 'a'); else if (op_type != OP_LOWER) - nc = MB_TOUPPER(c); - } else if (MB_ISUPPER(c)) { + nc = vim_toupper(c); + } else if (vim_isupper(c)) { if (op_type == OP_ROT13) nc = ROT13(c, 'A'); else if (op_type != OP_UPPER) - nc = MB_TOLOWER(c); + nc = vim_tolower(c); } if (nc != c) { if (enc_utf8 && (c >= 0x80 || nc >= 0x80)) { @@ -3289,7 +3289,7 @@ void ex_display(exarg_T *eap) } else yb = &(y_regs[i]); - if (name == MB_TOLOWER(redir_reg) + if (name == vim_tolower(redir_reg) || (redir_reg == '"' && yb == y_previous)) continue; /* do not list register being written to, the * pointer can be freed */ diff --git a/src/path.c b/src/path.c index a2d69100fd..67241522f6 100644 --- a/src/path.c +++ b/src/path.c @@ -246,7 +246,7 @@ int vim_fnamencmp(char_u *x, char_u *y, size_t len) cx = PTR2CHAR(px); cy = PTR2CHAR(py); if (cx == NUL || cy == NUL - || ((p_fic ? MB_TOLOWER(cx) != MB_TOLOWER(cy) : cx != cy) + || ((p_fic ? vim_tolower(cx) != vim_tolower(cy) : cx != cy) && !(cx == '/' && cy == '\\') && !(cx == '\\' && cy == '/'))) break; @@ -1679,7 +1679,7 @@ int pathcmp(const char *p, const char *q, int maxlen) break; } - if ((p_fic ? MB_TOUPPER(c1) != MB_TOUPPER(c2) : c1 != c2) + if ((p_fic ? vim_toupper(c1) != vim_toupper(c2) : c1 != c2) #ifdef BACKSLASH_IN_FILENAME /* consider '/' and '\\' to be equal */ && !((c1 == '/' && c2 == '\\') @@ -1690,7 +1690,7 @@ int pathcmp(const char *p, const char *q, int maxlen) return -1; if (vim_ispathsep(c2)) return 1; - return p_fic ? MB_TOUPPER(c1) - MB_TOUPPER(c2) + return p_fic ? vim_toupper(c1) - vim_toupper(c2) : c1 - c2; /* no match */ } } diff --git a/src/regexp.c b/src/regexp.c index 8ce9ffef42..fe496e791c 100644 --- a/src/regexp.c +++ b/src/regexp.c @@ -2289,7 +2289,7 @@ collection: break; case CLASS_LOWER: for (cu = 1; cu <= 255; cu++) - if (MB_ISLOWER(cu)) + if (vim_islower(cu)) regc(cu); break; case CLASS_PRINT: @@ -2309,7 +2309,7 @@ collection: break; case CLASS_UPPER: for (cu = 1; cu <= 255; cu++) - if (MB_ISUPPER(cu)) + if (vim_isupper(cu)) regc(cu); break; case CLASS_XDIGIT: @@ -3513,7 +3513,7 @@ proftime_T *tm; /* timeout limit or NULL */ || (ireg_ic && (( (enc_utf8 && utf_fold(prog->regstart) == utf_fold(c))) || (c < 255 && prog->regstart < 255 && - MB_TOLOWER(prog->regstart) == MB_TOLOWER(c))))) + vim_tolower(prog->regstart) == vim_tolower(c))))) retval = regtry(prog, col); else retval = 0; @@ -4186,7 +4186,7 @@ regmatch ( if (*opnd != *reginput && (!ireg_ic || ( !enc_utf8 && - MB_TOLOWER(*opnd) != MB_TOLOWER(*reginput)))) + vim_tolower(*opnd) != vim_tolower(*reginput)))) status = RA_NOMATCH; else if (*opnd == NUL) { /* match empty string always works; happens when "~" is @@ -4598,10 +4598,10 @@ regmatch ( if (OP(next) == EXACTLY) { rst.nextb = *OPERAND(next); if (ireg_ic) { - if (MB_ISUPPER(rst.nextb)) - rst.nextb_ic = MB_TOLOWER(rst.nextb); + if (vim_isupper(rst.nextb)) + rst.nextb_ic = vim_tolower(rst.nextb); else - rst.nextb_ic = MB_TOUPPER(rst.nextb); + rst.nextb_ic = vim_toupper(rst.nextb); } else rst.nextb_ic = rst.nextb; } else { @@ -5367,8 +5367,8 @@ do_class: * would have been used for it. It does handle single-byte * characters, such as latin1. */ if (ireg_ic) { - cu = MB_TOUPPER(*opnd); - cl = MB_TOLOWER(*opnd); + cu = vim_toupper(*opnd); + cl = vim_tolower(*opnd); while (count < maxcount && (*scan == cu || *scan == cl)) { count++; scan++; @@ -6342,10 +6342,10 @@ static char_u *cstrchr(char_u *s, int c) * For UTF-8 need to use folded case. */ if (enc_utf8 && c > 0x80) cc = utf_fold(c); - else if (MB_ISUPPER(c)) - cc = MB_TOLOWER(c); - else if (MB_ISLOWER(c)) - cc = MB_TOUPPER(c); + else if (vim_isupper(c)) + cc = vim_tolower(c); + else if (vim_islower(c)) + cc = vim_toupper(c); else return vim_strchr(s, c); @@ -6393,7 +6393,7 @@ static fptr_T do_upper(d, c) int *d; int c; { - *d = MB_TOUPPER(c); + *d = vim_toupper(c); return (fptr_T)NULL; } @@ -6402,7 +6402,7 @@ static fptr_T do_Upper(d, c) int *d; int c; { - *d = MB_TOUPPER(c); + *d = vim_toupper(c); return (fptr_T)do_Upper; } @@ -6411,7 +6411,7 @@ static fptr_T do_lower(d, c) int *d; int c; { - *d = MB_TOLOWER(c); + *d = vim_tolower(c); return (fptr_T)NULL; } @@ -6420,7 +6420,7 @@ static fptr_T do_Lower(d, c) int *d; int c; { - *d = MB_TOLOWER(c); + *d = vim_tolower(c); return (fptr_T)do_Lower; } diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index bd4f0ed868..cb07272adb 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -4278,7 +4278,7 @@ static int check_char_class(int class, int c) return OK; break; case NFA_CLASS_LOWER: - if (MB_ISLOWER(c)) + if (vim_islower(c)) return OK; break; case NFA_CLASS_PRINT: @@ -4294,7 +4294,7 @@ static int check_char_class(int class, int c) return OK; break; case NFA_CLASS_UPPER: - if (MB_ISUPPER(c)) + if (vim_isupper(c)) return OK; break; case NFA_CLASS_XDIGIT: @@ -4803,7 +4803,7 @@ static long find_match_text(colnr_T startcol, int regstart, char_u *match_text) for (len1 = 0; match_text[len1] != NUL; len1 += MB_CHAR2LEN(c1)) { c1 = PTR2CHAR(match_text + len1); c2 = PTR2CHAR(regline + col + len2); - if (c1 != c2 && (!ireg_ic || MB_TOLOWER(c1) != MB_TOLOWER(c2))) { + if (c1 != c2 && (!ireg_ic || vim_tolower(c1) != vim_tolower(c2))) { match = FALSE; break; } @@ -5462,11 +5462,11 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm break; } if (ireg_ic) { - int curc_low = MB_TOLOWER(curc); + int curc_low = vim_tolower(curc); int done = FALSE; for (; c1 <= c2; ++c1) - if (MB_TOLOWER(c1) == curc_low) { + if (vim_tolower(c1) == curc_low) { result = result_if_matched; done = TRUE; break; @@ -5476,8 +5476,8 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm } } else if (state->c < 0 ? check_char_class(state->c, curc) : (curc == state->c - || (ireg_ic && MB_TOLOWER(curc) - == MB_TOLOWER(state->c)))) { + || (ireg_ic && vim_tolower(curc) + == vim_tolower(state->c)))) { result = result_if_matched; break; } @@ -5838,7 +5838,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm result = (c == curc); if (!result && ireg_ic) - result = MB_TOLOWER(c) == MB_TOLOWER(curc); + result = vim_tolower(c) == vim_tolower(curc); /* If there is a composing character which is not being * ignored there can be no match. Match with composing * character uses NFA_COMPOSING above. */ @@ -5985,8 +5985,8 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm /* Checking if the required start character matches is * cheaper than adding a state that won't match. */ c = PTR2CHAR(reginput + clen); - if (c != prog->regstart && (!ireg_ic || MB_TOLOWER(c) - != MB_TOLOWER(prog->regstart))) { + if (c != prog->regstart && (!ireg_ic || vim_tolower(c) + != vim_tolower(prog->regstart))) { #ifdef ENABLE_LOG fprintf(log_fd, " Skipping start state, regstart does not match\n"); diff --git a/src/search.c b/src/search.c index eed9457a1c..73c058fd73 100644 --- a/src/search.c +++ b/src/search.c @@ -365,7 +365,7 @@ int pat_has_uppercase(char_u *pat) p += 2; else p += 1; - } else if (MB_ISUPPER(*p)) + } else if (vim_isupper(*p)) return TRUE; else ++p; diff --git a/src/spell.c b/src/spell.c index d349b9fe80..f684e5b2b0 100644 --- a/src/spell.c +++ b/src/spell.c @@ -8685,13 +8685,13 @@ void init_spell_chartab(void) } else { /* Rough guess: use locale-dependent library functions. */ for (i = 128; i < 256; ++i) { - if (MB_ISUPPER(i)) { + if (vim_isupper(i)) { spelltab.st_isw[i] = TRUE; spelltab.st_isu[i] = TRUE; - spelltab.st_fold[i] = MB_TOLOWER(i); - } else if (MB_ISLOWER(i)) { + spelltab.st_fold[i] = vim_tolower(i); + } else if (vim_islower(i)) { spelltab.st_isw[i] = TRUE; - spelltab.st_upper[i] = MB_TOUPPER(i); + spelltab.st_upper[i] = vim_toupper(i); } } } |