diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-02-10 14:12:43 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-02-10 14:12:43 +0100 |
commit | 2993ac5fce5450428322ce43aaa5e643e6994443 (patch) | |
tree | 6128c7a3b1a76db62e8e7c89fa1cdf470c78f463 /src/spellfile.c | |
parent | 7254067ee970686cc3ff4a1effc3e49e9192a5c1 (diff) | |
download | vim-git-2993ac5fce5450428322ce43aaa5e643e6994443.tar.gz |
patch 8.0.1490: number of spell regions is spread out through the codev8.0.1490
Problem: Number of spell regions is spread out through the code.
Solution: Define MAXREGIONS.
Diffstat (limited to 'src/spellfile.c')
-rw-r--r-- | src/spellfile.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/spellfile.c b/src/spellfile.c index f6d7a6432..e5cc84164 100644 --- a/src/spellfile.c +++ b/src/spellfile.c @@ -54,8 +54,8 @@ * website, etc) * * sectionID == SN_REGION: <regionname> ... - * <regionname> 2 bytes Up to 8 region names: ca, au, etc. Lower case. - * First <regionname> is region 1. + * <regionname> 2 bytes Up to MAXREGIONS region names: ca, au, etc. Lower + * case. First <regionname> is region 1. * * sectionID == SN_CHARFLAGS: <charflagslen> <charflags> * <folcharslen> <folchars> @@ -832,7 +832,7 @@ read_region_section(FILE *fd, slang_T *lp, int len) { int i; - if (len > 16) + if (len > MAXREGIONS * 2) return SP_FORMERROR; for (i = 0; i < len; ++i) lp->sl_regions[i] = getc(fd); /* <regionname> */ @@ -1952,8 +1952,9 @@ typedef struct spellinfo_S char_u *si_info; /* info text chars or NULL */ int si_region_count; /* number of regions supported (1 when there are no regions) */ - char_u si_region_name[17]; /* region names; used only if - * si_region_count > 1) */ + char_u si_region_name[MAXREGIONS * 2 + 1]; + /* region names; used only if + * si_region_count > 1) */ garray_T si_rep; /* list of fromto_T entries from REP lines */ 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) else { line += 8; - if (STRLEN(line) > 16) + if (STRLEN(line) > MAXREGIONS * 2) smsg((char_u *)_("Too many regions in %s line %d: %s"), fname, lnum, line); else @@ -5954,7 +5955,7 @@ mkspell( char_u *wfname; char_u **innames; int incount; - afffile_T *(afile[8]); + afffile_T *(afile[MAXREGIONS]); int i; int len; stat_T st; @@ -6025,8 +6026,8 @@ mkspell( EMSG(_(e_invarg)); /* need at least output and input names */ else if (vim_strchr(gettail(wfname), '_') != NULL) EMSG(_("E751: Output file name must not have region name")); - else if (incount > 8) - EMSG(_("E754: Only up to 8 regions supported")); + else if (incount > MAXREGIONS) + EMSGN(_("E754: Only up to %ld regions supported"), MAXREGIONS); else { /* Check for overwriting before doing things that may take a lot of |