Skip to content

Commit 2993ac5

Browse files
committed
patch 8.0.1490: number of spell regions is spread out through the code
Problem: Number of spell regions is spread out through the code. Solution: Define MAXREGIONS.
1 parent 7254067 commit 2993ac5

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

src/spell.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
byte, thus it can't be above 255.
3535
Must be >= PFD_NOTSPECIAL. */
3636

37+
#define MAXREGIONS 8 /* Number of regions supported. */
38+
3739
/* Type used for indexes in the word tree need to be at least 4 bytes. If int
3840
* is 8 bytes we could use something smaller, but what? */
3941
#if VIM_SIZEOF_INT > 3
@@ -80,7 +82,8 @@ struct slang_S
8082

8183
char_u *sl_info; /* infotext string or NULL */
8284

83-
char_u sl_regions[17]; /* table with up to 8 region names plus NUL */
85+
char_u sl_regions[MAXREGIONS * 2 + 1];
86+
/* table with up to 8 region names plus NUL */
8487

8588
char_u *sl_midword; /* MIDWORD string or NULL */
8689

src/spellfile.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
* website, etc)
5555
*
5656
* sectionID == SN_REGION: <regionname> ...
57-
* <regionname> 2 bytes Up to 8 region names: ca, au, etc. Lower case.
58-
* First <regionname> is region 1.
57+
* <regionname> 2 bytes Up to MAXREGIONS region names: ca, au, etc. Lower
58+
* case. First <regionname> is region 1.
5959
*
6060
* sectionID == SN_CHARFLAGS: <charflagslen> <charflags>
6161
* <folcharslen> <folchars>
@@ -832,7 +832,7 @@ read_region_section(FILE *fd, slang_T *lp, int len)
832832
{
833833
int i;
834834

835-
if (len > 16)
835+
if (len > MAXREGIONS * 2)
836836
return SP_FORMERROR;
837837
for (i = 0; i < len; ++i)
838838
lp->sl_regions[i] = getc(fd); /* <regionname> */
@@ -1952,8 +1952,9 @@ typedef struct spellinfo_S
19521952
char_u *si_info; /* info text chars or NULL */
19531953
int si_region_count; /* number of regions supported (1 when there
19541954
are no regions) */
1955-
char_u si_region_name[17]; /* region names; used only if
1956-
* si_region_count > 1) */
1955+
char_u si_region_name[MAXREGIONS * 2 + 1];
1956+
/* region names; used only if
1957+
* si_region_count > 1) */
19571958

19581959
garray_T si_rep; /* list of fromto_T entries from REP lines */
19591960
garray_T si_repsal; /* list of fromto_T entries from REPSAL lines */
@@ -4234,7 +4235,7 @@ spell_read_wordfile(spellinfo_T *spin, char_u *fname)
42344235
else
42354236
{
42364237
line += 8;
4237-
if (STRLEN(line) > 16)
4238+
if (STRLEN(line) > MAXREGIONS * 2)
42384239
smsg((char_u *)_("Too many regions in %s line %d: %s"),
42394240
fname, lnum, line);
42404241
else
@@ -5954,7 +5955,7 @@ mkspell(
59545955
char_u *wfname;
59555956
char_u **innames;
59565957
int incount;
5957-
afffile_T *(afile[8]);
5958+
afffile_T *(afile[MAXREGIONS]);
59585959
int i;
59595960
int len;
59605961
stat_T st;
@@ -6025,8 +6026,8 @@ mkspell(
60256026
EMSG(_(e_invarg)); /* need at least output and input names */
60266027
else if (vim_strchr(gettail(wfname), '_') != NULL)
60276028
EMSG(_("E751: Output file name must not have region name"));
6028-
else if (incount > 8)
6029-
EMSG(_("E754: Only up to 8 regions supported"));
6029+
else if (incount > MAXREGIONS)
6030+
EMSGN(_("E754: Only up to %ld regions supported"), MAXREGIONS);
60306031
else
60316032
{
60326033
/* Check for overwriting before doing things that may take a lot of

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,8 @@ static char *(features[]) =
771771

772772
static int included_patches[] =
773773
{ /* Add new patch number below this line */
774+
/**/
775+
1490,
774776
/**/
775777
1489,
776778
/**/

0 commit comments

Comments
 (0)