diff options
author | Bram Moolenaar <Bram@vim.org> | 2005-06-06 21:59:07 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2005-06-06 21:59:07 +0000 |
commit | 45eeb13324b1d4fa80c1e4ed872bebd1202bf1f0 (patch) | |
tree | 04352cb65f7968a02df5a3ec8021feff22fdea54 /src | |
parent | cfc6c43ce2fe59ccc7e48785e6c20126f0ee9d7f (diff) | |
download | vim-git-45eeb13324b1d4fa80c1e4ed872bebd1202bf1f0.tar.gz |
updated for version 7.0081v7.0081
Diffstat (limited to 'src')
-rw-r--r-- | src/charset.c | 376 | ||||
-rw-r--r-- | src/gui_mac.c | 1 | ||||
-rw-r--r-- | src/mbyte.c | 6 | ||||
-rw-r--r-- | src/proto/spell.pro | 1 | ||||
-rw-r--r-- | src/regexp.c | 17 | ||||
-rw-r--r-- | src/syntax.c | 4 | ||||
-rw-r--r-- | src/version.h | 4 |
7 files changed, 19 insertions, 390 deletions
diff --git a/src/charset.c b/src/charset.c index 33c12f262..7ea9bbb8f 100644 --- a/src/charset.c +++ b/src/charset.c @@ -914,382 +914,6 @@ vim_iswordc_buf(p, buf) # endif return (GET_CHARTAB(buf, *p) != 0); } - -/* - * The tables used for spelling. These are only used for the first 256 - * characters. - */ -typedef struct spelltab_S -{ - char_u st_isw[256]; /* flags: is word char */ - char_u st_isu[256]; /* flags: is uppercase char */ - char_u st_fold[256]; /* chars: folded case */ -} spelltab_T; - -static spelltab_T spelltab; -static int did_set_spelltab; - -#define SPELL_ISWORD 1 -#define SPELL_ISUPPER 2 - -static void clear_spell_chartab __ARGS((spelltab_T *sp)); -static int set_spell_finish __ARGS((spelltab_T *new_st)); - -/* - * Init the chartab used for spelling for ASCII. - * EBCDIC is not supported! - */ - static void -clear_spell_chartab(sp) - spelltab_T *sp; -{ - int i; - - /* Init everything to FALSE. */ - vim_memset(sp->st_isw, FALSE, sizeof(sp->st_isw)); - vim_memset(sp->st_isu, FALSE, sizeof(sp->st_isu)); - for (i = 0; i < 256; ++i) - sp->st_fold[i] = i; - - /* We include digits. A word shouldn't start with a digit, but handling - * that is done separately. */ - for (i = '0'; i <= '9'; ++i) - sp->st_isw[i] = TRUE; - for (i = 'A'; i <= 'Z'; ++i) - { - sp->st_isw[i] = TRUE; - sp->st_isu[i] = TRUE; - sp->st_fold[i] = i + 0x20; - } - for (i = 'a'; i <= 'z'; ++i) - sp->st_isw[i] = TRUE; -} - -/* - * Init the chartab used for spelling. Only depends on 'encoding'. - * Called once while starting up and when 'encoding' changes. - * The default is to use isalpha(), but the spell file should define the word - * characters to make it possible that 'encoding' differs from the current - * locale. - */ - void -init_spell_chartab() -{ - int i; - - did_set_spelltab = FALSE; - clear_spell_chartab(&spelltab); - -#ifdef FEAT_MBYTE - if (enc_dbcs) - { - /* DBCS: assume double-wide characters are word characters. */ - for (i = 128; i <= 255; ++i) - if (MB_BYTE2LEN(i) == 2) - spelltab.st_isw[i] = TRUE; - } - else -#endif - { - /* Rough guess: use isalpha() and isupper() for characters above 128. - * */ - for (i = 128; i < 256; ++i) - { - spelltab.st_isw[i] = MB_ISUPPER(i) || MB_ISLOWER(i); - if (MB_ISUPPER(i)) - { - spelltab.st_isu[i] = TRUE; - spelltab.st_fold[i] = MB_TOLOWER(i); - } - } - } -} - -#if defined(FEAT_MBYTE) || defined(PROTO) -static char *e_affform = N_("E761: Format error in affix file FOL, LOW or UPP"); -static char *e_affrange = N_("E762: Character in FOL, LOW or UPP is out of range"); - -/* - * Set the spell character tables from strings in the affix file. - */ - int -set_spell_chartab(fol, low, upp) - char_u *fol; - char_u *low; - char_u *upp; -{ - /* We build the new tables here first, so that we can compare with the - * previous one. */ - spelltab_T new_st; - char_u *pf = fol, *pl = low, *pu = upp; - int f, l, u; - - clear_spell_chartab(&new_st); - - while (*pf != NUL) - { - if (*pl == NUL || *pu == NUL) - { - EMSG(_(e_affform)); - return FAIL; - } -#ifdef FEAT_MBYTE - f = mb_ptr2char_adv(&pf); - l = mb_ptr2char_adv(&pl); - u = mb_ptr2char_adv(&pu); -#else - f = *pf++; - l = *pl++; - u = *pu++; -#endif - /* Every character that appears is a word character. */ - if (f < 256) - new_st.st_isw[f] = TRUE; - if (l < 256) - new_st.st_isw[l] = TRUE; - if (u < 256) - new_st.st_isw[u] = TRUE; - - /* if "LOW" and "FOL" are not the same the "LOW" char needs - * case-folding */ - if (l < 256 && l != f) - { - if (f >= 256) - { - EMSG(_(e_affrange)); - return FAIL; - } - new_st.st_fold[l] = f; - } - - /* if "UPP" and "FOL" are not the same the "UPP" char needs - * case-folding and it's upper case. */ - if (u < 256 && u != f) - { - if (f >= 256) - { - EMSG(_(e_affrange)); - return FAIL; - } - new_st.st_fold[u] = f; - new_st.st_isu[u] = TRUE; - } - } - - if (*pl != NUL || *pu != NUL) - { - EMSG(_(e_affform)); - return FAIL; - } - - return set_spell_finish(&new_st); -} -#endif - -/* - * Set the spell character tables from strings in the .spl file. - */ - int -set_spell_charflags(flags, cnt, upp) - char_u *flags; - int cnt; - char_u *upp; -{ - /* We build the new tables here first, so that we can compare with the - * previous one. */ - spelltab_T new_st; - int i; - char_u *p = upp; - - clear_spell_chartab(&new_st); - - for (i = 0; i < cnt; ++i) - { - new_st.st_isw[i + 128] = (flags[i] & SPELL_ISWORD) != 0; - new_st.st_isu[i + 128] = (flags[i] & SPELL_ISUPPER) != 0; - - if (*p == NUL) - return FAIL; -#ifdef FEAT_MBYTE - new_st.st_fold[i + 128] = mb_ptr2char_adv(&p); -#else - new_st.st_fold[i + 128] = *p++; -#endif - } - - return set_spell_finish(&new_st); -} - - static int -set_spell_finish(new_st) - spelltab_T *new_st; -{ - int i; - - if (did_set_spelltab) - { - /* check that it's the same table */ - for (i = 0; i < 256; ++i) - { - if (spelltab.st_isw[i] != new_st->st_isw[i] - || spelltab.st_isu[i] != new_st->st_isu[i] - || spelltab.st_fold[i] != new_st->st_fold[i]) - { - EMSG(_("E763: Word characters differ between spell files")); - return FAIL; - } - } - } - else - { - /* copy the new spelltab into the one being used */ - spelltab = *new_st; - did_set_spelltab = TRUE; - } - - return OK; -} - -#if defined(FEAT_MBYTE) || defined(PROTO) -/* - * Write the current tables into the .spl file. - * This makes sure the same characters are recognized as word characters when - * generating an when using a spell file. - */ - void -write_spell_chartab(fd) - FILE *fd; -{ - char_u charbuf[256 * 4]; - int len = 0; - int flags; - int i; - - fputc(128, fd); /* <charflagslen> */ - for (i = 128; i < 256; ++i) - { - flags = 0; - if (spelltab.st_isw[i]) - flags |= SPELL_ISWORD; - if (spelltab.st_isu[i]) - flags |= SPELL_ISUPPER; - fputc(flags, fd); /* <charflags> */ - - len += mb_char2bytes(spelltab.st_fold[i], charbuf + len); - } - - put_bytes(fd, (long_u)len, 2); /* <fcharlen> */ - fwrite(charbuf, (size_t)len, (size_t)1, fd); /* <fchars> */ -} -#endif - -/* - * Return TRUE if "p" points to a word character for spelling. - */ - int -spell_iswordc(p) - char_u *p; -{ -# ifdef FEAT_MBYTE - if (has_mbyte && MB_BYTE2LEN(*p) > 1) - return mb_get_class(p) >= 2; -# endif - return spelltab.st_isw[*p]; -} - -/* - * Return TRUE if "c" is an upper-case character for spelling. - */ - int -spell_isupper(c) - int c; -{ -# ifdef FEAT_MBYTE - if (enc_utf8) - { - /* For Unicode we can call utf_isupper(), but don't do that for ASCII, - * because we don't want to use 'casemap' here. */ - if (c >= 128) - return utf_isupper(c); - } - else if (has_mbyte && c > 256) - { - /* For characters above 255 we don't have something specfied. - * Fall back to locale-dependent iswupper(). If not available - * simply return FALSE. */ -# ifdef HAVE_ISWUPPER - return iswupper(c); -# else - return FALSE; -# endif - } -# endif - return spelltab.st_isu[c]; -} - -/* - * case-fold "p[len]" into "buf[buflen]". Used for spell checking. - * Returns FAIL when something wrong. - */ - int -spell_casefold(p, len, buf, buflen) - char_u *p; - int len; - char_u *buf; - int buflen; -{ - int i; - - if (len >= buflen) - { - buf[0] = NUL; - return FAIL; /* result will not fit */ - } - -#ifdef FEAT_MBYTE - if (has_mbyte) - { - int c; - int outi = 0; - - /* Fold one character at a time. */ - for (i = 0; i < len; i += mb_ptr2len_check(p + i)) - { - c = mb_ptr2char(p + i); - if (enc_utf8) - /* For Unicode case folding is always the same, no need to use - * the table from the spell file. */ - c = utf_fold(c); - else if (c < 256) - /* Use the table from the spell file. */ - c = spelltab.st_fold[c]; -# ifdef HAVE_TOWLOWER - else - /* We don't know what to do, fall back to towlower(), it - * depends on the current locale. */ - c = towlower(c); -# endif - if (outi + MB_MAXBYTES > buflen) - { - buf[outi] = NUL; - return FAIL; - } - outi += mb_char2bytes(c, buf + outi); - } - buf[outi] = NUL; - } - else -#endif - { - /* Be quick for non-multibyte encodings. */ - for (i = 0; i < len; ++i) - buf[i] = spelltab.st_fold[p[i]]; - buf[i] = NUL; - } - - return OK; -} - #endif /* FEAT_SYN_HL */ /* diff --git a/src/gui_mac.c b/src/gui_mac.c index fbf9b30b7..70393be1a 100644 --- a/src/gui_mac.c +++ b/src/gui_mac.c @@ -4185,6 +4185,7 @@ gui_mch_get_color(name) {"brown", RGB(0x80, 0x40, 0x40)}, /*W*/ {"yellow", RGB(0xFC, 0xF3, 0x05)}, /*M*/ {"lightyellow", RGB(0xFF, 0xFF, 0xA0)}, /*M*/ + {"darkyellow", RGB(0xBB, 0xBB, 0x00)}, /*U*/ {"SeaGreen", RGB(0x2E, 0x8B, 0x57)}, /*W 0x4E8975 */ {"orange", RGB(0xFC, 0x80, 0x00)}, /*W 0xF87A17 */ {"Purple", RGB(0xA0, 0x20, 0xF0)}, /*W 0x8e35e5 */ diff --git a/src/mbyte.c b/src/mbyte.c index 996eb8dd5..93375bc2e 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -2192,6 +2192,7 @@ mb_strnicmp(s1, s2, nn) { int i, j, l; int cdiff; + int incomplete = FALSE; int n = nn; for (i = 0; i < n; i += l) @@ -2202,7 +2203,10 @@ mb_strnicmp(s1, s2, nn) { l = utf_byte2len(s1[i]); if (l > n - i) + { l = n - i; /* incomplete character */ + incomplete = TRUE; + } /* Check directly first, it's faster. */ for (j = 0; j < l; ++j) if (s1[i + j] != s2[i + j]) @@ -2210,7 +2214,7 @@ mb_strnicmp(s1, s2, nn) if (j < l) { /* If one of the two characters is incomplete return -1. */ - if (i + utf_byte2len(s1[i]) > n || i + utf_byte2len(s2[i]) > n) + if (incomplete || i + utf_byte2len(s2[i]) > n) return -1; cdiff = utf_fold(utf_ptr2char(s1 + i)) - utf_fold(utf_ptr2char(s2 + i)); diff --git a/src/proto/spell.pro b/src/proto/spell.pro index 45cade679..4fcb7ba3d 100644 --- a/src/proto/spell.pro +++ b/src/proto/spell.pro @@ -5,4 +5,5 @@ char_u *did_set_spelllang __ARGS((buf_T *buf)); void spell_reload __ARGS((void)); void put_bytes __ARGS((FILE *fd, long_u nr, int len)); void ex_mkspell __ARGS((exarg_T *eap)); +void init_spell_chartab __ARGS((void)); /* vim: set ft=c : */ diff --git a/src/regexp.c b/src/regexp.c index 81035af97..bc13b38ea 100644 --- a/src/regexp.c +++ b/src/regexp.c @@ -322,9 +322,9 @@ toggle_Magic(x) /* Used for an error (down from) vim_regcomp(): give the error message, set * rc_did_emsg and return NULL */ -#define EMSG_RET_NULL(m) { EMSG(m); rc_did_emsg = TRUE; return NULL; } -#define EMSG_M_RET_NULL(m, c) { EMSG2(m, c ? "" : "\\"); rc_did_emsg = TRUE; return NULL; } -#define EMSG_RET_FAIL(m) { EMSG(m); rc_did_emsg = TRUE; return FAIL; } +#define EMSG_RET_NULL(m) return (EMSG(m), rc_did_emsg = TRUE, NULL) +#define EMSG_M_RET_NULL(m, c) return (EMSG2((m), (c) ? "" : "\\"), rc_did_emsg = TRUE, NULL) +#define EMSG_RET_FAIL(m) return (EMSG(m), rc_did_emsg = TRUE, FAIL) #define EMSG_ONE_RET_NULL EMSG_M_RET_NULL(_("E369: invalid item in %s%%[]"), reg_magic == MAGIC_ALL) #define MAX_LIMIT (32767L << 16L) @@ -1246,20 +1246,20 @@ reg(paren, flagp) { #ifdef FEAT_SYN_HL if (paren == REG_ZPAREN) - EMSG_RET_NULL(_("E52: Unmatched \\z(")) + EMSG_RET_NULL(_("E52: Unmatched \\z(")); else #endif if (paren == REG_NPAREN) - EMSG_M_RET_NULL(_("E53: Unmatched %s%%("), reg_magic == MAGIC_ALL) + EMSG_M_RET_NULL(_("E53: Unmatched %s%%("), reg_magic == MAGIC_ALL); else - EMSG_M_RET_NULL(_("E54: Unmatched %s("), reg_magic == MAGIC_ALL) + EMSG_M_RET_NULL(_("E54: Unmatched %s("), reg_magic == MAGIC_ALL); } else if (paren == REG_NOPAREN && peekchr() != NUL) { if (curchr == Magic(')')) - EMSG_M_RET_NULL(_("E55: Unmatched %s)"), reg_magic == MAGIC_ALL) + EMSG_M_RET_NULL(_("E55: Unmatched %s)"), reg_magic == MAGIC_ALL); else - EMSG_RET_NULL(_(e_trailing)) /* "Can't happen". */ + EMSG_RET_NULL(_(e_trailing)); /* "Can't happen". */ /* NOTREACHED */ } /* @@ -2985,7 +2985,6 @@ typedef struct char_u *ptr; lpos_T pos; } se_u; - int se_len; } save_se_T; static char_u *reg_getline __ARGS((linenr_T lnum)); diff --git a/src/syntax.c b/src/syntax.c index c9fc19171..b4dfed49d 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -6028,7 +6028,7 @@ static char *(highlight_init_light[]) = "Folded term=standout ctermbg=Grey ctermfg=DarkBlue guibg=LightGrey guifg=DarkBlue", "FoldColumn term=standout ctermbg=Grey ctermfg=DarkBlue guibg=Grey guifg=DarkBlue", "SignColumn term=standout ctermbg=Grey ctermfg=DarkBlue guibg=Grey guifg=DarkBlue", - "Visual term=reverse ctermbg=Grey guibg=Grey", + "Visual term=reverse ctermbg=LightGrey guibg=LightGrey", "DiffAdd term=bold ctermbg=LightBlue guibg=LightBlue", "DiffChange term=bold ctermbg=LightMagenta guibg=LightMagenta", "DiffDelete term=bold ctermfg=Blue ctermbg=LightCyan gui=bold guifg=Blue guibg=LightCyan", @@ -6053,7 +6053,7 @@ static char *(highlight_init_dark[]) = "Folded term=standout ctermbg=DarkGrey ctermfg=Cyan guibg=DarkGrey guifg=Cyan", "FoldColumn term=standout ctermbg=DarkGrey ctermfg=Cyan guibg=Grey guifg=Cyan", "SignColumn term=standout ctermbg=DarkGrey ctermfg=Cyan guibg=Grey guifg=Cyan", - "Visual term=reverse ctermbg=Grey guibg=Grey", + "Visual term=reverse ctermbg=DarkGrey guibg=DarkGrey", "DiffAdd term=bold ctermbg=DarkBlue guibg=DarkBlue", "DiffChange term=bold ctermbg=DarkMagenta guibg=DarkMagenta", "DiffDelete term=bold ctermfg=Blue ctermbg=DarkCyan gui=bold guifg=Blue guibg=DarkCyan", diff --git a/src/version.h b/src/version.h index 7d49d7ff8..afb4c5fb5 100644 --- a/src/version.h +++ b/src/version.h @@ -36,5 +36,5 @@ #define VIM_VERSION_NODOT "vim70aa" #define VIM_VERSION_SHORT "7.0aa" #define VIM_VERSION_MEDIUM "7.0aa ALPHA" -#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Jun 5)" -#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Jun 5, compiled " +#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Jun 6)" +#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Jun 6, compiled " |