diff options
Diffstat (limited to 'src/nvim/spellfile.c')
| -rw-r--r-- | src/nvim/spellfile.c | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index 6578c7d66c..b8774bd680 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -45,7 +45,8 @@ // website, etc) // // sectionID == SN_REGION: <regionname> ... -// <regionname> 2 bytes Up to 8 region names: ca, au, etc. Lower case. +// <regionname> 2 bytes Up to MAXREGIONS region names: ca, au, etc. +// Lower case. // First <regionname> is region 1. // // sectionID == SN_CHARFLAGS: <charflagslen> <charflags> @@ -460,7 +461,8 @@ 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 + 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 @@ -878,9 +880,10 @@ void suggest_load_files(void) // don't try again and again. slang->sl_sugloaded = true; - dotp = vim_strrchr(slang->sl_fname, '.'); - if (dotp == NULL || fnamecmp(dotp, ".spl") != 0) + dotp = STRRCHR(slang->sl_fname, '.'); + if (dotp == NULL || fnamecmp(dotp, ".spl") != 0) { continue; + } STRCPY(dotp, ".sug"); fd = mch_fopen((char *)slang->sl_fname, "r"); if (fd == NULL) @@ -1003,7 +1006,7 @@ static char_u *read_cnt_string(FILE *fd, int cnt_bytes, int *cntp) // Return SP_*ERROR flags. static int read_region_section(FILE *fd, slang_T *lp, int len) { - if (len > 16) { + if (len > MAXREGIONS * 2) { return SP_FORMERROR; } SPELL_READ_NONNUL_BYTES((char *)lp->sl_regions, (size_t)len, fd, ;); @@ -1990,7 +1993,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname) return NULL; } - vim_snprintf((char *)IObuff, IOSIZE, _("Reading affix file %s ..."), fname); + vim_snprintf((char *)IObuff, IOSIZE, _("Reading affix file %s..."), fname); spell_message(spin, IObuff); // Only do REP lines when not done in another .aff file already. @@ -3029,7 +3032,7 @@ static int spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile) hash_init(&ht); vim_snprintf((char *)IObuff, IOSIZE, - _("Reading dictionary file %s ..."), fname); + _("Reading dictionary file %s..."), fname); spell_message(spin, IObuff); // start with a message for the first line @@ -3545,7 +3548,7 @@ static int spell_read_wordfile(spellinfo_T *spin, char_u *fname) return FAIL; } - vim_snprintf((char *)IObuff, IOSIZE, _("Reading word file %s ..."), fname); + vim_snprintf((char *)IObuff, IOSIZE, _("Reading word file %s..."), fname); spell_message(spin, IObuff); // Read all the lines in the file one by one. @@ -3612,10 +3615,10 @@ static int spell_read_wordfile(spellinfo_T *spin, char_u *fname) fname, lnum, line); else { line += 8; - if (STRLEN(line) > 16) + if (STRLEN(line) > MAXREGIONS * 2) { smsg(_("Too many regions in %s line %d: %s"), fname, lnum, line); - else { + } else { spin->si_region_count = (int)STRLEN(line) / 2; STRCPY(spin->si_region_name, line); @@ -4995,7 +4998,7 @@ static void sug_write(spellinfo_T *spin, char_u *fname) } vim_snprintf((char *)IObuff, IOSIZE, - _("Writing suggestion file %s ..."), fname); + _("Writing suggestion file %s..."), fname); spell_message(spin, IObuff); // <SUGHEADER>: <fileID> <versionnr> <timestamp> @@ -5077,7 +5080,7 @@ mkspell ( char_u *wfname; char_u **innames; int incount; - afffile_T *(afile[8]); + afffile_T *(afile[MAXREGIONS]); int i; int len; bool error = false; @@ -5134,13 +5137,13 @@ mkspell ( spin.si_add = true; } - if (incount <= 0) + if (incount <= 0) { EMSG(_(e_invarg)); // need at least output and input names - else if (vim_strchr(path_tail(wfname), '_') != NULL) + } else if (vim_strchr(path_tail(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 { + } 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 // time. if (!over_write && os_path_exists(wfname)) { @@ -5231,7 +5234,7 @@ mkspell ( if (!error && !got_int) { // Write the info in the spell file. vim_snprintf((char *)IObuff, IOSIZE, - _("Writing spell file %s ..."), wfname); + _("Writing spell file %s..."), wfname); spell_message(&spin, IObuff); error = write_vim_spell(&spin, wfname) == FAIL; |