Blob Blame History Raw
To: vim-dev@vim.org
Subject: Patch 7.1.293
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------

Patch 7.1.293
Problem:    Spell checking considers super- and subscript characters as word
	    characters.
Solution:   Recognize the Unicode super and subscript characters.
Files:	    src/spell.c


*** ../vim-7.1.292/src/spell.c	Tue Apr  1 17:13:54 2008
--- src/spell.c	Wed Apr  9 15:47:06 2008
***************
*** 753,758 ****
--- 753,759 ----
  static int spell_iswordp __ARGS((char_u *p, buf_T *buf));
  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, buf_T *buf));
  #endif
  static int write_spell_prefcond __ARGS((FILE *fd, garray_T *gap));
***************
*** 9789,9795 ****
  
  	c = mb_ptr2char(s);
  	if (c > 255)
! 	    return mb_get_class(s) >= 2;
  	return spelltab.st_isw[c];
      }
  #endif
--- 9790,9796 ----
  
  	c = mb_ptr2char(s);
  	if (c > 255)
! 	    return spell_mb_isword_class(mb_get_class(s));
  	return spelltab.st_isw[c];
      }
  #endif
***************
*** 9812,9818 ****
      {
  	c = mb_ptr2char(p);
  	if (c > 255)
! 	    return mb_get_class(p) >= 2;
  	return spelltab.st_isw[c];
      }
  #endif
--- 9813,9819 ----
      {
  	c = mb_ptr2char(p);
  	if (c > 255)
! 	    return spell_mb_isword_class(mb_get_class(p));
  	return spelltab.st_isw[c];
      }
  #endif
***************
*** 9821,9826 ****
--- 9822,9839 ----
  
  #ifdef FEAT_MBYTE
  /*
+  * 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;
+ }
+ 
+ /*
   * Return TRUE if "p" points to a word character.
   * Wide version of spell_iswordp().
   */
***************
*** 9841,9847 ****
      if (*s > 255)
      {
  	if (enc_utf8)
! 	    return utf_class(*s) >= 2;
  	if (enc_dbcs)
  	    return dbcs_class((unsigned)*s >> 8, *s & 0xff) >= 2;
  	return 0;
--- 9854,9860 ----
      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;
*** ../vim-7.1.292/src/version.c	Wed Apr  9 12:14:44 2008
--- src/version.c	Wed Apr  9 15:45:10 2008
***************
*** 668,669 ****
--- 673,676 ----
  {   /* Add new patch number below this line */
+ /**/
+     293,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
268. You get up in the morning and go online before getting your coffee.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///