To: vim_dev@googlegroups.com Subject: Patch 8.0.1490 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1490 Problem: Number of spell regions is spread out through the code. Solution: Define MAXREGIONS. Files: src/spell.h, src/spellfile.c *** ../vim-8.0.1489/src/spell.h 2016-08-29 22:42:20.000000000 +0200 --- src/spell.h 2018-02-10 13:55:21.912773084 +0100 *************** *** 34,39 **** --- 34,41 ---- byte, thus it can't be above 255. Must be >= PFD_NOTSPECIAL. */ + #define MAXREGIONS 8 /* Number of regions supported. */ + /* Type used for indexes in the word tree need to be at least 4 bytes. If int * is 8 bytes we could use something smaller, but what? */ #if VIM_SIZEOF_INT > 3 *************** *** 80,86 **** char_u *sl_info; /* infotext string or NULL */ ! char_u sl_regions[17]; /* table with up to 8 region names plus NUL */ char_u *sl_midword; /* MIDWORD string or NULL */ --- 82,89 ---- char_u *sl_info; /* infotext string or NULL */ ! char_u sl_regions[MAXREGIONS * 2 + 1]; ! /* table with up to 8 region names plus NUL */ char_u *sl_midword; /* MIDWORD string or NULL */ *** ../vim-8.0.1489/src/spellfile.c 2017-10-27 00:56:57.205291177 +0200 --- src/spellfile.c 2018-02-10 13:59:57.222895071 +0100 *************** *** 54,61 **** * website, etc) * * sectionID == SN_REGION: ... ! * 2 bytes Up to 8 region names: ca, au, etc. Lower case. ! * First is region 1. * * sectionID == SN_CHARFLAGS: * --- 54,61 ---- * website, etc) * * sectionID == SN_REGION: ... ! * 2 bytes Up to MAXREGIONS region names: ca, au, etc. Lower ! * case. First is region 1. * * sectionID == SN_CHARFLAGS: * *************** *** 832,838 **** { int i; ! if (len > 16) return SP_FORMERROR; for (i = 0; i < len; ++i) lp->sl_regions[i] = getc(fd); /* */ --- 832,838 ---- { int i; ! if (len > MAXREGIONS * 2) return SP_FORMERROR; for (i = 0; i < len; ++i) lp->sl_regions[i] = getc(fd); /* */ *************** *** 1952,1959 **** 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) */ garray_T si_rep; /* list of fromto_T entries from REP lines */ garray_T si_repsal; /* list of fromto_T entries from REPSAL lines */ --- 1952,1960 ---- 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[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,4240 **** else { line += 8; ! if (STRLEN(line) > 16) smsg((char_u *)_("Too many regions in %s line %d: %s"), fname, lnum, line); else --- 4235,4241 ---- else { line += 8; ! if (STRLEN(line) > MAXREGIONS * 2) smsg((char_u *)_("Too many regions in %s line %d: %s"), fname, lnum, line); else *************** *** 5954,5960 **** char_u *wfname; char_u **innames; int incount; ! afffile_T *(afile[8]); int i; int len; stat_T st; --- 5955,5961 ---- char_u *wfname; char_u **innames; int incount; ! afffile_T *(afile[MAXREGIONS]); int i; int len; stat_T st; *************** *** 6025,6032 **** 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 { /* Check for overwriting before doing things that may take a lot of --- 6026,6033 ---- 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 > MAXREGIONS) ! EMSGN(_("E754: Only up to %ld regions supported"), MAXREGIONS); else { /* Check for overwriting before doing things that may take a lot of *** ../vim-8.0.1489/src/version.c 2018-02-09 20:53:52.638060811 +0100 --- src/version.c 2018-02-10 14:12:00.870381694 +0100 *************** *** 773,774 **** --- 773,776 ---- { /* Add new patch number below this line */ + /**/ + 1490, /**/ -- Have you heard about the new Barbie doll? It's called Divorce Barbie. It comes with all of Ken's stuff. /// 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 ///