{
case 0x2121: /* ZENKAKU space */
return 0;
- case 0x2122: /* KU-TEN (Japanese comma) */
- case 0x2123: /* TOU-TEN (Japanese period) */
+ case 0x2122: /* TOU-TEN (Japanese comma) */
+ case 0x2123: /* KU-TEN (Japanese period) */
case 0x2124: /* ZENKAKU comma */
case 0x2125: /* ZENKAKU period */
return 1;
/* sorted list of non-overlapping intervals */
static struct clinterval
{
- unsigned short first;
- unsigned short last;
- unsigned short class;
+ unsigned int first;
+ unsigned int last;
+ unsigned int class;
} classes[] =
{
{0x037e, 0x037e, 1}, /* Greek question mark */
{0xff1a, 0xff20, 1}, /* half/fullwidth ASCII */
{0xff3b, 0xff40, 1}, /* half/fullwidth ASCII */
{0xff5b, 0xff65, 1}, /* half/fullwidth ASCII */
+ {0x20000, 0x2a6df, 0x4e00}, /* CJK Ideographs */
+ {0x2a700, 0x2b73f, 0x4e00}, /* CJK Ideographs */
+ {0x2b740, 0x2b81f, 0x4e00}, /* CJK Ideographs */
+ {0x2f800, 0x2fa1f, 0x4e00}, /* CJK Ideographs */
};
int bot = 0;
int top = sizeof(classes) / sizeof(struct clinterval) - 1;
while (top >= bot)
{
mid = (bot + top) / 2;
- if (classes[mid].last < c)
+ if (classes[mid].last < (unsigned int)c)
bot = mid + 1;
- else if (classes[mid].first > c)
+ else if (classes[mid].first > (unsigned int)c)
top = mid - 1;
else
return (int)classes[mid].class;
static void clear_spell_chartab __ARGS((spelltab_T *sp));
static int set_spell_finish __ARGS((spelltab_T *new_st));
static int spell_iswordp __ARGS((char_u *p, win_T *wp));
-static int spell_iswordp_nmw __ARGS((char_u *p));
+static int spell_iswordp_nmw __ARGS((char_u *p, win_T *wp));
#ifdef FEAT_MBYTE
-static int spell_mb_isword_class __ARGS((int cl));
+static int spell_mb_isword_class __ARGS((int cl, win_T *wp));
static int spell_iswordp_w __ARGS((int *p, win_T *wp));
#endif
static int write_spell_prefcond __ARGS((FILE *fd, garray_T *gap));
/* When we are at a non-word character there is no error, just
* skip over the character (try looking for a word after it). */
- else if (!spell_iswordp_nmw(ptr))
+ else if (!spell_iswordp_nmw(ptr, wp))
{
if (capcol != NULL && wp->w_s->b_cap_prog != NULL)
{
* accept a no-caps word, even when the dictionary
* word specifies ONECAP. */
mb_ptr_back(mip->mi_word, p);
- if (spell_iswordp_nmw(p)
+ if (spell_iswordp_nmw(p, mip->mi_win)
? capflags == WF_ONECAP
: (flags & WF_ONECAP) != 0
&& capflags != WF_ONECAP)
if (spl_copy == NULL)
goto theend;
- /* loop over comma separated language names. */
+ wp->w_s->b_cjk = 0;
+
+ /* Loop over comma separated language names. */
for (splp = spl_copy; *splp != NUL; )
{
/* Get one language name. */
region = NULL;
len = (int)STRLEN(lang);
+ if (STRCMP(lang, "cjk") == 0)
+ {
+ wp->w_s->b_cjk = 1;
+ continue;
+ }
+
/* If the name ends in ".spl" use it as the name of the spell file.
* If there is a region name let "region" point to it and remove it
* from the name. */
int past_second = FALSE; /* past second word char */
/* find first letter */
- for (p = word; !spell_iswordp_nmw(p); mb_ptr_adv(p))
+ for (p = word; !spell_iswordp_nmw(p, curwin); mb_ptr_adv(p))
if (end == NULL ? *p == NUL : p >= end)
return 0; /* only non-word characters, illegal word */
#ifdef FEAT_MBYTE
* But a word with an upper char only at start is a ONECAP.
*/
for ( ; end == NULL ? *p != NUL : p < end; mb_ptr_adv(p))
- if (spell_iswordp_nmw(p))
+ if (spell_iswordp_nmw(p, curwin))
{
c = PTR2CHAR(p);
if (!SPELL_ISUPPER(c))
c = mb_ptr2char(s);
if (c > 255)
- return spell_mb_isword_class(mb_get_class(s));
+ return spell_mb_isword_class(mb_get_class(s), wp);
return spelltab.st_isw[c];
}
#endif
* Unlike spell_iswordp() this doesn't check for "midword" characters.
*/
static int
-spell_iswordp_nmw(p)
+spell_iswordp_nmw(p, wp)
char_u *p;
+ win_T *wp;
{
#ifdef FEAT_MBYTE
int c;
{
c = mb_ptr2char(p);
if (c > 255)
- return spell_mb_isword_class(mb_get_class(p));
+ return spell_mb_isword_class(mb_get_class(p), wp);
return spelltab.st_isw[c];
}
#endif
* Return TRUE if word class indicates a word character.
* Only for characters above 255.
* Unicode subscript and superscript are not considered word characters.
+ * See also dbcs_class() and utf_class() in mbyte.c.
*/
static int
-spell_mb_isword_class(cl)
- int cl;
+spell_mb_isword_class(cl, wp)
+ int cl;
+ win_T *wp;
{
+ if (wp->w_s->b_cjk)
+ /* East Asian characters are not considered word characters. */
+ return cl == 2 || cl == 0x2800;
return cl >= 2 && cl != 0x2070 && cl != 0x2080;
}
if (*s > 255)
{
if (enc_utf8)
- return spell_mb_isword_class(utf_class(*s));
+ return spell_mb_isword_class(utf_class(*s), wp);
if (enc_dbcs)
- return dbcs_class((unsigned)*s >> 8, *s & 0xff) >= 2;
+ return spell_mb_isword_class(
+ dbcs_class((unsigned)*s >> 8, *s & 0xff), wp);
return 0;
}
return spelltab.st_isw[*s];
line = ml_get_curline();
p = line + curwin->w_cursor.col;
/* Backup to before start of word. */
- while (p > line && spell_iswordp_nmw(p))
+ while (p > line && spell_iswordp_nmw(p, curwin))
mb_ptr_back(line, p);
/* Forward to start of word. */
- while (*p != NUL && !spell_iswordp_nmw(p))
+ while (*p != NUL && !spell_iswordp_nmw(p, curwin))
mb_ptr_adv(p);
- if (!spell_iswordp_nmw(p)) /* No word found. */
+ if (!spell_iswordp_nmw(p, curwin)) /* No word found. */
{
beep_flush();
return;
for (;;)
{
mb_ptr_back(line, p);
- if (p == line || spell_iswordp_nmw(p))
+ if (p == line || spell_iswordp_nmw(p, curwin))
break;
if (vim_regexec(®match, p, 0)
&& regmatch.endp[0] == line + endcol)
/* When appending a compound word after a word character don't
* use Onecap. */
- if (p != NULL && spell_iswordp_nmw(p))
+ if (p != NULL && spell_iswordp_nmw(p, curwin))
c &= ~WF_ONECAP;
make_case_word(tword + sp->ts_splitoff,
preword + sp->ts_prewordlen, c);
* character when the word ends. But only when the
* good word can end. */
if (((!try_compound && !spell_iswordp_nmw(fword
- + sp->ts_fidx))
+ + sp->ts_fidx,
+ curwin))
|| fword_ends)
&& fword[sp->ts_fidx] != NUL
&& goodword_ends)
}
else
{
- if (spell_iswordp_nmw(s))
+ if (spell_iswordp_nmw(s, curwin))
*t++ = *s;
++s;
}
else
{
did_white = FALSE;
- if (!spell_iswordp_nmw(t))
+ if (!spell_iswordp_nmw(t, curwin))
continue;
}
}
for (p = line + startcol; p > line; )
{
mb_ptr_back(line, p);
- if (spell_iswordp_nmw(p))
+ if (spell_iswordp_nmw(p, curwin))
break;
}