]> granicus.if.org Git - vim/commitdiff
patch 8.1.2268: spell file flag zero is not recognized v8.1.2268
authorBram Moolenaar <Bram@vim.org>
Thu, 7 Nov 2019 19:48:42 +0000 (20:48 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 7 Nov 2019 19:48:42 +0000 (20:48 +0100)
Problem:    Spell file flag zero is not recognized.
Solution:   Use -1 as an error value, so that zero can be used as a valid flag
            number.

src/spellfile.c
src/testdir/test_spell.vim
src/version.c

index f34d9badbe03f7ce1617aaa0168fe677f54b0e66..4b364421d4686eb1461c1c40a0a36b955177cb86 100644 (file)
                                 * follow; never used in prefix tree */
 #define BY_SPECIAL  BY_FLAGS2  /* highest special byte value */
 
+#define ZERO_FLAG      65009   // used when flag is zero: "0"
+
 /* Flags used in .spl file for soundsalike flags. */
 #define SAL_F0LLOWUP           1
 #define SAL_COLLAPSE           2
@@ -3182,6 +3184,7 @@ affitem2flag(
 
 /*
  * Get one affix name from "*pp" and advance the pointer.
+ * Returns ZERO_FLAG for "0".
  * Returns zero for an error, still advances the pointer then.
  */
     static unsigned
@@ -3197,6 +3200,8 @@ get_affitem(int flagtype, char_u **pp)
            return 0;
        }
        res = getdigits(pp);
+       if (res == 0)
+           res = ZERO_FLAG;
     }
     else
     {
@@ -3343,6 +3348,8 @@ flag_in_afflist(int flagtype, char_u *afflist, unsigned flag)
            for (p = afflist; *p != NUL; )
            {
                n = getdigits(&p);
+               if (n == 0)
+                   n = ZERO_FLAG;
                if (n == flag)
                    return TRUE;
                if (*p != NUL)  /* skip over comma */
index 146e421d030af93bbfe04d27a222534df03b42c6..c3b2d4409a3de6fee3c725024fc62f560ba335c2 100644 (file)
@@ -290,9 +290,9 @@ func Test_zz_affix()
         \ ])
 
   call LoadAffAndDic(g:test_data_aff7, g:test_data_dic7)
-  call RunGoodBad("meea1 meea\xE9 bar prebar barmeat prebarmeat  leadprebar lead tail leadtail  leadmiddletail",
+  call RunGoodBad("meea1 meezero meea\xE9 bar prebar barmeat prebarmeat  leadprebar lead tail leadtail  leadmiddletail",
         \ "bad: mee meea2 prabar probarmaat middle leadmiddle middletail taillead leadprobar",
-        \ ["bar", "barmeat", "lead", "meea1", "meea\xE9", "prebar", "prebarmeat", "tail"],
+        \ ["bar", "barmeat", "lead", "meea1", "meea\xE9", "meezero", "prebar", "prebarmeat", "tail"],
         \ [
         \   ["bad", ["bar", "lead", "tail"]],
         \   ["mee", ["meea1", "meea\xE9", "bar"]],
@@ -746,6 +746,9 @@ let g:test_data_aff7 = [
       \"SFX 61003 Y 1",
       \"SFX 61003 0 meat .",
       \"",
+      \"SFX 0 Y 1",
+      \"SFX 0 0 zero .",
+      \"",
       \"SFX 391 Y 1",
       \"SFX 391 0 a1 .",
       \"",
@@ -757,7 +760,7 @@ let g:test_data_aff7 = [
       \ ]
 let g:test_data_dic7 = [
       \"1234",
-      \"mee/391,111,9999",
+      \"mee/0,391,111,9999",
       \"bar/17,61003,123",
       \"lead/2",
       \"tail/123",
index 3cc98798c2e21758c9d83a91366c9e37aabca896..2db75aa6e0b668bc86d7a26096d7edbe59bc0a5c 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2268,
 /**/
     2267,
 /**/