summaryrefslogblamecommitdiffstats
path: root/patches/source/vim/patches/7.4.088
blob: 62dc91cace455611db3a5471d41c1610183f2abf (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564



















































































































































































































































































































































































































































































































































































                                                                                        
To: vim_dev@googlegroups.com
Subject: Patch 7.4.088
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.4.088
Problem:    When spell checking is enabled Asian characters are always marked
            as error.
Solution:   When 'spelllang' contains "cjk" do not mark Asian characters as
            error. (Ken Takata)
Files:      runtime/doc/options.txt, runtime/doc/spell.txt, src/mbyte.c,
            src/option.c, src/spell.c, src/structs.h


*** ../vim-7.4.087/runtime/doc/options.txt	2013-11-06 05:26:08.000000000 +0100
--- runtime/doc/options.txt	2013-11-12 04:00:51.000000000 +0100
***************
*** 6555,6560 ****
--- 6555,6563 ----
  	region by listing them: "en_us,en_ca" supports both US and Canadian
  	English, but not words specific for Australia, New Zealand or Great
  	Britain.
+ 	If the name "cjk" is included East Asian characters are excluded from
+ 	spell checking.  This is useful when editing text that also has Asian
+ 	words.
  							*E757*
  	As a special case the name of a .spl file can be given as-is.  The
  	first "_xx" in the name is removed and used as the region name
*** ../vim-7.4.087/runtime/doc/spell.txt	2013-08-10 13:25:01.000000000 +0200
--- runtime/doc/spell.txt	2013-11-12 04:02:27.000000000 +0100
***************
*** 269,274 ****
--- 269,281 ----
  	latin1		yi		transliterated Yiddish
  	utf-8		yi-tr		transliterated Yiddish
  
+ 							*spell-cjk*
+ Chinese, Japanese and other East Asian characters are normally marked as
+ errors, because spell checking of these characters is not supported. If
+ 'spelllang' includes "cjk", these characters are not marked as errors.  This
+ is useful when editing text with spell checking while some Asian words are
+ present.
+ 
  
  SPELL FILES						*spell-load*
  
*** ../vim-7.4.087/src/mbyte.c	2013-07-05 20:07:21.000000000 +0200
--- src/mbyte.c	2013-11-12 03:55:50.000000000 +0100
***************
*** 947,954 ****
  		{
  		    case 0x2121: /* ZENKAKU space */
  			return 0;
! 		    case 0x2122: /* KU-TEN (Japanese comma) */
! 		    case 0x2123: /* TOU-TEN (Japanese period) */
  		    case 0x2124: /* ZENKAKU comma */
  		    case 0x2125: /* ZENKAKU period */
  			return 1;
--- 947,954 ----
  		{
  		    case 0x2121: /* ZENKAKU space */
  			return 0;
! 		    case 0x2122: /* TOU-TEN (Japanese comma) */
! 		    case 0x2123: /* KU-TEN (Japanese period) */
  		    case 0x2124: /* ZENKAKU comma */
  		    case 0x2125: /* ZENKAKU period */
  			return 1;
***************
*** 2477,2485 ****
      /* sorted list of non-overlapping intervals */
      static struct clinterval
      {
! 	unsigned short first;
! 	unsigned short last;
! 	unsigned short class;
      } classes[] =
      {
  	{0x037e, 0x037e, 1},		/* Greek question mark */
--- 2477,2485 ----
      /* sorted list of non-overlapping intervals */
      static struct clinterval
      {
! 	unsigned int first;
! 	unsigned int last;
! 	unsigned int class;
      } classes[] =
      {
  	{0x037e, 0x037e, 1},		/* Greek question mark */
***************
*** 2544,2549 ****
--- 2544,2553 ----
  	{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;
***************
*** 2563,2571 ****
      while (top >= bot)
      {
  	mid = (bot + top) / 2;
! 	if (classes[mid].last < c)
  	    bot = mid + 1;
! 	else if (classes[mid].first > c)
  	    top = mid - 1;
  	else
  	    return (int)classes[mid].class;
--- 2567,2575 ----
      while (top >= bot)
      {
  	mid = (bot + top) / 2;
! 	if (classes[mid].last < (unsigned int)c)
  	    bot = mid + 1;
! 	else if (classes[mid].first > (unsigned int)c)
  	    top = mid - 1;
  	else
  	    return (int)classes[mid].class;
*** ../vim-7.4.087/src/option.c	2013-11-08 04:30:06.000000000 +0100
--- src/option.c	2013-11-12 04:34:46.000000000 +0100
***************
*** 7122,7127 ****
--- 7122,7132 ----
  	if (varp == &(curwin->w_s->b_p_spl))
  	{
  	    char_u	fname[200];
+ 	    char_u	*q = curwin->w_s->b_p_spl;
+ 
+ 	    /* Skip the first name if it is "cjk". */
+ 	    if (STRNCMP(q, "cjk,", 4) == 0)
+ 		q += 4;
  
  	    /*
  	     * Source the spell/LANG.vim in 'runtimepath'.
***************
*** 7129,7139 ****
  	     * Use the first name in 'spelllang' up to '_region' or
  	     * '.encoding'.
  	     */
! 	    for (p = curwin->w_s->b_p_spl; *p != NUL; ++p)
  		if (vim_strchr((char_u *)"_.,", *p) != NULL)
  		    break;
! 	    vim_snprintf((char *)fname, 200, "spell/%.*s.vim",
! 				 (int)(p - curwin->w_s->b_p_spl), curwin->w_s->b_p_spl);
  	    source_runtime(fname, TRUE);
  	}
  #endif
--- 7134,7143 ----
  	     * Use the first name in 'spelllang' up to '_region' or
  	     * '.encoding'.
  	     */
! 	    for (p = q; *p != NUL; ++p)
  		if (vim_strchr((char_u *)"_.,", *p) != NULL)
  		    break;
! 	    vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q);
  	    source_runtime(fname, TRUE);
  	}
  #endif
*** ../vim-7.4.087/src/spell.c	2013-09-29 13:38:25.000000000 +0200
--- src/spell.c	2013-11-12 04:37:33.000000000 +0100
***************
*** 754,762 ****
  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));
  #ifdef FEAT_MBYTE
! static int spell_mb_isword_class __ARGS((int cl));
  static int spell_iswordp_w __ARGS((int *p, win_T *wp));
  #endif
  static int write_spell_prefcond __ARGS((FILE *fd, garray_T *gap));
--- 754,762 ----
  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, win_T *wp));
  #ifdef FEAT_MBYTE
! 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));
***************
*** 1149,1155 ****
  
  	/* 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))
  	{
  	    if (capcol != NULL && wp->w_s->b_cap_prog != NULL)
  	    {
--- 1149,1155 ----
  
  	/* 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, wp))
  	{
  	    if (capcol != NULL && wp->w_s->b_cap_prog != NULL)
  	    {
***************
*** 1561,1567 ****
  			 * accept a no-caps word, even when the dictionary
  			 * word specifies ONECAP. */
  			mb_ptr_back(mip->mi_word, p);
! 			if (spell_iswordp_nmw(p)
  				? capflags == WF_ONECAP
  				: (flags & WF_ONECAP) != 0
  						     && capflags != WF_ONECAP)
--- 1561,1567 ----
  			 * accept a no-caps word, even when the dictionary
  			 * word specifies ONECAP. */
  			mb_ptr_back(mip->mi_word, p);
! 			if (spell_iswordp_nmw(p, mip->mi_win)
  				? capflags == WF_ONECAP
  				: (flags & WF_ONECAP) != 0
  						     && capflags != WF_ONECAP)
***************
*** 4234,4240 ****
      if (spl_copy == NULL)
  	goto theend;
  
!     /* loop over comma separated language names. */
      for (splp = spl_copy; *splp != NUL; )
      {
  	/* Get one language name. */
--- 4234,4242 ----
      if (spl_copy == NULL)
  	goto theend;
  
!     wp->w_s->b_cjk = 0;
! 
!     /* Loop over comma separated language names. */
      for (splp = spl_copy; *splp != NUL; )
      {
  	/* Get one language name. */
***************
*** 4242,4247 ****
--- 4244,4255 ----
  	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. */
***************
*** 4601,4607 ****
      int		past_second = FALSE;	/* past second word char */
  
      /* find first letter */
!     for (p = word; !spell_iswordp_nmw(p); mb_ptr_adv(p))
  	if (end == NULL ? *p == NUL : p >= end)
  	    return 0;	    /* only non-word characters, illegal word */
  #ifdef FEAT_MBYTE
--- 4609,4615 ----
      int		past_second = FALSE;	/* past second word char */
  
      /* find first letter */
!     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
***************
*** 4617,4623 ****
       * 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))
  	{
  	    c = PTR2CHAR(p);
  	    if (!SPELL_ISUPPER(c))
--- 4625,4631 ----
       * 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, curwin))
  	{
  	    c = PTR2CHAR(p);
  	    if (!SPELL_ISUPPER(c))
***************
*** 9907,9913 ****
  
  	c = mb_ptr2char(s);
  	if (c > 255)
! 	    return spell_mb_isword_class(mb_get_class(s));
  	return spelltab.st_isw[c];
      }
  #endif
--- 9915,9921 ----
  
  	c = mb_ptr2char(s);
  	if (c > 255)
! 	    return spell_mb_isword_class(mb_get_class(s), wp);
  	return spelltab.st_isw[c];
      }
  #endif
***************
*** 9920,9927 ****
   * Unlike spell_iswordp() this doesn't check for "midword" characters.
   */
      static int
! spell_iswordp_nmw(p)
      char_u	*p;
  {
  #ifdef FEAT_MBYTE
      int		c;
--- 9928,9936 ----
   * Unlike spell_iswordp() this doesn't check for "midword" characters.
   */
      static int
! spell_iswordp_nmw(p, wp)
      char_u	*p;
+     win_T	*wp;
  {
  #ifdef FEAT_MBYTE
      int		c;
***************
*** 9930,9936 ****
      {
  	c = mb_ptr2char(p);
  	if (c > 255)
! 	    return spell_mb_isword_class(mb_get_class(p));
  	return spelltab.st_isw[c];
      }
  #endif
--- 9939,9945 ----
      {
  	c = mb_ptr2char(p);
  	if (c > 255)
! 	    return spell_mb_isword_class(mb_get_class(p), wp);
  	return spelltab.st_isw[c];
      }
  #endif
***************
*** 9942,9952 ****
   * Return TRUE if word class indicates a word character.
   * Only for characters above 255.
   * Unicode subscript and superscript are not considered word characters.
   */
      static int
! spell_mb_isword_class(cl)
!     int cl;
  {
      return cl >= 2 && cl != 0x2070 && cl != 0x2080;
  }
  
--- 9951,9966 ----
   * 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, 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;
  }
  
***************
*** 9971,9979 ****
      if (*s > 255)
      {
  	if (enc_utf8)
! 	    return spell_mb_isword_class(utf_class(*s));
  	if (enc_dbcs)
! 	    return dbcs_class((unsigned)*s >> 8, *s & 0xff) >= 2;
  	return 0;
      }
      return spelltab.st_isw[*s];
--- 9985,9994 ----
      if (*s > 255)
      {
  	if (enc_utf8)
! 	    return spell_mb_isword_class(utf_class(*s), wp);
  	if (enc_dbcs)
! 	    return spell_mb_isword_class(
! 				dbcs_class((unsigned)*s >> 8, *s & 0xff), wp);
  	return 0;
      }
      return spelltab.st_isw[*s];
***************
*** 10193,10205 ****
  	line = ml_get_curline();
  	p = line + curwin->w_cursor.col;
  	/* Backup to before start of word. */
! 	while (p > line && spell_iswordp_nmw(p))
  	    mb_ptr_back(line, p);
  	/* Forward to start of word. */
! 	while (*p != NUL && !spell_iswordp_nmw(p))
  	    mb_ptr_adv(p);
  
! 	if (!spell_iswordp_nmw(p))		/* No word found. */
  	{
  	    beep_flush();
  	    return;
--- 10208,10220 ----
  	line = ml_get_curline();
  	p = line + curwin->w_cursor.col;
  	/* Backup to before start of word. */
! 	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, curwin))
  	    mb_ptr_adv(p);
  
! 	if (!spell_iswordp_nmw(p, curwin))		/* No word found. */
  	{
  	    beep_flush();
  	    return;
***************
*** 10436,10442 ****
  	for (;;)
  	{
  	    mb_ptr_back(line, p);
! 	    if (p == line || spell_iswordp_nmw(p))
  		break;
  	    if (vim_regexec(&regmatch, p, 0)
  					 && regmatch.endp[0] == line + endcol)
--- 10451,10457 ----
  	for (;;)
  	{
  	    mb_ptr_back(line, p);
! 	    if (p == line || spell_iswordp_nmw(p, curwin))
  		break;
  	    if (vim_regexec(&regmatch, p, 0)
  					 && regmatch.endp[0] == line + endcol)
***************
*** 11645,11651 ****
  
  		/* When appending a compound word after a word character don't
  		 * use Onecap. */
! 		if (p != NULL && spell_iswordp_nmw(p))
  		    c &= ~WF_ONECAP;
  		make_case_word(tword + sp->ts_splitoff,
  					      preword + sp->ts_prewordlen, c);
--- 11660,11666 ----
  
  		/* When appending a compound word after a word character don't
  		 * use Onecap. */
! 		if (p != NULL && spell_iswordp_nmw(p, curwin))
  		    c &= ~WF_ONECAP;
  		make_case_word(tword + sp->ts_splitoff,
  					      preword + sp->ts_prewordlen, c);
***************
*** 11895,11901 ****
  			 * character when the word ends.  But only when the
  			 * good word can end. */
  			if (((!try_compound && !spell_iswordp_nmw(fword
! 							       + sp->ts_fidx))
  				    || fword_ends)
  				&& fword[sp->ts_fidx] != NUL
  				&& goodword_ends)
--- 11910,11917 ----
  			 * character when the word ends.  But only when the
  			 * good word can end. */
  			if (((!try_compound && !spell_iswordp_nmw(fword
! 							       + sp->ts_fidx,
! 							       curwin))
  				    || fword_ends)
  				&& fword[sp->ts_fidx] != NUL
  				&& goodword_ends)
***************
*** 14226,14232 ****
  	    }
  	    else
  	    {
! 		if (spell_iswordp_nmw(s))
  		    *t++ = *s;
  		++s;
  	    }
--- 14242,14248 ----
  	    }
  	    else
  	    {
! 		if (spell_iswordp_nmw(s, curwin))
  		    *t++ = *s;
  		++s;
  	    }
***************
*** 14521,14527 ****
  	    else
  	    {
  		did_white = FALSE;
! 		if (!spell_iswordp_nmw(t))
  		    continue;
  	    }
  	}
--- 14537,14543 ----
  	    else
  	    {
  		did_white = FALSE;
! 		if (!spell_iswordp_nmw(t, curwin))
  		    continue;
  	    }
  	}
***************
*** 16045,16051 ****
      for (p = line + startcol; p > line; )
      {
  	mb_ptr_back(line, p);
! 	if (spell_iswordp_nmw(p))
  	    break;
      }
  
--- 16061,16067 ----
      for (p = line + startcol; p > line; )
      {
  	mb_ptr_back(line, p);
! 	if (spell_iswordp_nmw(p, curwin))
  	    break;
      }
  
*** ../vim-7.4.087/src/structs.h	2013-11-09 05:30:18.000000000 +0100
--- src/structs.h	2013-11-12 03:55:50.000000000 +0100
***************
*** 1310,1315 ****
--- 1310,1318 ----
      regprog_T	*b_cap_prog;	/* program for 'spellcapcheck' */
      char_u	*b_p_spf;	/* 'spellfile' */
      char_u	*b_p_spl;	/* 'spelllang' */
+ # ifdef FEAT_MBYTE
+     int		b_cjk;		/* all CJK letters as OK */
+ # endif
  #endif
  #if !defined(FEAT_SYN_HL) && !defined(FEAT_SPELL)
      int		dummy;
*** ../vim-7.4.087/src/version.c	2013-11-11 23:17:31.000000000 +0100
--- src/version.c	2013-11-12 03:59:03.000000000 +0100
***************
*** 740,741 ****
--- 740,743 ----
  {   /* Add new patch number below this line */
+ /**/
+     88,
  /**/

-- 
THEOREM: VI is perfect.
PROOF: VI in roman numerals is 6.  The natural numbers < 6 which divide 6 are
1, 2, and 3. 1+2+3 = 6.  So 6 is a perfect number.  Therefore, VI is perfect.
QED
						    -- Arthur Tateishi

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///