Skip to content

Commit 46a426c

Browse files
committed
patch 8.1.2081: the spell.c file is too big
Problem: The spell.c file is too big. Solution: Move the code for spell suggestions to a separate file. (Yegappan Lakshmanan, closes vim#4988)
1 parent d2842ea commit 46a426c

File tree

14 files changed

+4578
-4597
lines changed

14 files changed

+4578
-4597
lines changed

Filelist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ SRC_ALL = \
111111
src/spell.c \
112112
src/spell.h \
113113
src/spellfile.c \
114+
src/spellsuggest.c \
114115
src/structs.h \
115116
src/syntax.c \
116117
src/tag.c \
@@ -255,6 +256,7 @@ SRC_ALL = \
255256
src/proto/sound.pro \
256257
src/proto/spell.pro \
257258
src/proto/spellfile.pro \
259+
src/proto/spellsuggest.pro \
258260
src/proto/syntax.pro \
259261
src/proto/tag.pro \
260262
src/proto/term.pro \

src/Make_cyg_ming.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,7 @@ OBJ = \
778778
$(OUTDIR)/sign.o \
779779
$(OUTDIR)/spell.o \
780780
$(OUTDIR)/spellfile.o \
781+
$(OUTDIR)/spellsuggest.o \
781782
$(OUTDIR)/syntax.o \
782783
$(OUTDIR)/tag.o \
783784
$(OUTDIR)/term.o \

src/Make_morph.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ SRC = arabic.c \
9494
sign.c \
9595
spell.c \
9696
spellfile.c \
97+
spellsuggest.c \
9798
syntax.c \
9899
tag.c \
99100
term.c \

src/Make_mvc.mak

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,7 @@ OBJ = \
785785
$(OUTDIR)\sign.obj \
786786
$(OUTDIR)\spell.obj \
787787
$(OUTDIR)\spellfile.obj \
788+
$(OUTDIR)\spellsuggest.obj \
788789
$(OUTDIR)\syntax.obj \
789790
$(OUTDIR)\tag.obj \
790791
$(OUTDIR)\term.obj \
@@ -1670,6 +1671,8 @@ $(OUTDIR)/spell.obj: $(OUTDIR) spell.c $(INCL)
16701671

16711672
$(OUTDIR)/spellfile.obj: $(OUTDIR) spellfile.c $(INCL)
16721673

1674+
$(OUTDIR)/spellsuggest.obj: $(OUTDIR) spellsuggest.c $(INCL)
1675+
16731676
$(OUTDIR)/syntax.obj: $(OUTDIR) syntax.c $(INCL)
16741677

16751678
$(OUTDIR)/tag.obj: $(OUTDIR) tag.c $(INCL)
@@ -1852,6 +1855,7 @@ proto.h: \
18521855
proto/sign.pro \
18531856
proto/spell.pro \
18541857
proto/spellfile.pro \
1858+
proto/spellsuggest.pro \
18551859
proto/syntax.pro \
18561860
proto/tag.pro \
18571861
proto/term.pro \

src/Make_vms.mms

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,8 @@ SRC = arabic.c arglist.c autocmd.c beval.c blob.c blowfish.c buffer.c \
320320
ops.c \
321321
option.c optionstr.c popupmnu.c popupwin.c profiler.c quickfix.c \
322322
regexp.c register.c scriptfile.c \
323-
search.c session.c sha256.c sign.c spell.c spellfile.c syntax.c tag.c \
323+
search.c session.c sha256.c sign.c spell.c spellfile.c spellsuggest.c \
324+
syntax.c tag.c \
324325
term.c termlib.c testing.c textprop.c ui.c undo.c usercmd.c \
325326
userfunc.c version.c viminfo.c screen.c window.c os_unix.c os_vms.c \
326327
pathdef.c \
@@ -342,7 +343,8 @@ OBJ = arabic.obj arglist.obj autocmd.obj beval.obj blob.obj blowfish.obj \
342343
optionstr.obj popupmnu.obj popupwin.obj profiler.obj quickfix.obj \
343344
regexp.obj register.obj scriptfile.obj \
344345
search.obj session.obj sha256.obj sign.obj spell.obj spellfile.obj \
345-
syntax.obj tag.obj term.obj termlib.obj testing.obj textprop.obj \
346+
spellsuggest.obj syntax.obj tag.obj term.obj termlib.obj testing.obj \
347+
textprop.obj \
346348
ui.obj undo.obj usercmd.obj userfunc.obj screen.obj version.obj \
347349
viminfo.obj window.obj os_unix.obj os_vms.obj pathdef.obj if_mzsch.obj \
348350
$(GUI_OBJ) $(PERL_OBJ) $(PYTHON_OBJ) $(TCL_OBJ) \
@@ -791,6 +793,10 @@ spellfile.obj : spellfile.c vim.h [.auto]config.h feature.h os_unix.h \
791793
ascii.h keymap.h term.h macros.h option.h structs.h \
792794
regexp.h gui.h beval.h [.proto]gui_beval.pro alloc.h ex_cmds.h spell.h \
793795
proto.h globals.h
796+
spellsuggest.obj : spellsuggest.c vim.h [.auto]config.h feature.h os_unix.h \
797+
ascii.h keymap.h term.h macros.h option.h structs.h \
798+
regexp.h gui.h beval.h [.proto]gui_beval.pro alloc.h ex_cmds.h spell.h \
799+
proto.h globals.h
794800
syntax.obj : syntax.c vim.h [.auto]config.h feature.h os_unix.h \
795801
ascii.h keymap.h term.h macros.h structs.h regexp.h \
796802
gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \

src/Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,6 +1654,7 @@ BASIC_SRC = \
16541654
sound.c \
16551655
spell.c \
16561656
spellfile.c \
1657+
spellsuggest.c \
16571658
syntax.c \
16581659
tag.c \
16591660
term.c \
@@ -1789,6 +1790,7 @@ OBJ_COMMON = \
17891790
objects/sound.o \
17901791
objects/spell.o \
17911792
objects/spellfile.o \
1793+
objects/spellsuggest.o \
17921794
objects/syntax.o \
17931795
objects/tag.o \
17941796
objects/term.o \
@@ -1949,6 +1951,7 @@ PRO_AUTO = \
19491951
sound.pro \
19501952
spell.pro \
19511953
spellfile.pro \
1954+
spellsuggest.pro \
19521955
syntax.pro \
19531956
tag.pro \
19541957
term.pro \
@@ -3386,6 +3389,9 @@ objects/spell.o: spell.c
33863389
objects/spellfile.o: spellfile.c
33873390
$(CCC) -o $@ spellfile.c
33883391

3392+
objects/spellsuggest.o: spellsuggest.c
3393+
$(CCC) -o $@ spellsuggest.c
3394+
33893395
objects/syntax.o: syntax.c
33903396
$(CCC) -o $@ syntax.c
33913397

@@ -3881,6 +3887,10 @@ objects/spellfile.o: spellfile.c vim.h protodef.h auto/config.h feature.h \
38813887
os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
38823888
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
38833889
proto.h globals.h
3890+
objects/spellsuggest.o: spellsuggest.c vim.h protodef.h auto/config.h feature.h \
3891+
os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
3892+
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
3893+
proto.h globals.h
38843894
objects/syntax.o: syntax.c vim.h protodef.h auto/config.h feature.h os_unix.h \
38853895
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
38863896
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \

src/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ screen.c | lower level screen functions
6969
search.c | pattern searching
7070
session.c | sessions and views
7171
sign.c | signs
72-
spell.c | spell checking
72+
spell.c | spell checking core
73+
spellfile.c | spell file handling
74+
spellsuggest.c | spell correction suggestions
7375
syntax.c | syntax and other highlighting
7476
tag.c | tags
7577
term.c | terminal handling, termcap codes

src/proto.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ void qsort(void *base, size_t elm_count, size_t elm_size, int (*cmp)(const void
202202
# include "sound.pro"
203203
# include "spell.pro"
204204
# include "spellfile.pro"
205+
# include "spellsuggest.pro"
205206
# include "syntax.pro"
206207
# include "tag.pro"
207208
# include "term.pro"

src/proto/spell.pro

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
/* spell.c */
22
int spell_check(win_T *wp, char_u *ptr, hlf_T *attrp, int *capcol, int docount);
3+
int match_checkcompoundpattern(char_u *ptr, int wlen, garray_T *gap);
4+
int can_compound(slang_T *slang, char_u *word, char_u *flags);
5+
int match_compoundrule(slang_T *slang, char_u *compflags);
6+
int valid_word_prefix(int totprefcnt, int arridx, int flags, char_u *word, slang_T *slang, int cond_req);
7+
int spell_valid_case(int wordflags, int treeflags);
8+
int no_spell_checking(win_T *wp);
39
int spell_move_to(win_T *wp, int dir, int allwords, int curline, hlf_T *attrp);
410
void spell_cat_line(char_u *buf, char_u *line, int maxlen);
511
char_u *spell_enc(void);
@@ -19,12 +25,15 @@ buf_T *open_spellbuf(void);
1925
void close_spellbuf(buf_T *buf);
2026
void clear_spell_chartab(spelltab_T *sp);
2127
void init_spell_chartab(void);
28+
int spell_iswordp(char_u *p, win_T *wp);
29+
int spell_iswordp_nmw(char_u *p, win_T *wp);
2230
int spell_casefold(char_u *str, int len, char_u *buf, int buflen);
23-
int spell_check_sps(void);
24-
void spell_suggest(int count);
31+
int check_need_cap(linenr_T lnum, colnr_T col);
2532
void ex_spellrepall(exarg_T *eap);
26-
void spell_suggest_list(garray_T *gap, char_u *word, int maxcount, int need_cap, int interactive);
2733
void onecap_copy(char_u *word, char_u *wcopy, int upper);
34+
void allcap_copy(char_u *word, char_u *wcopy);
35+
int nofold_len(char_u *fword, int flen, char_u *word);
36+
void make_case_word(char_u *fword, char_u *cword, int flags);
2837
char_u *eval_soundfold(char_u *word);
2938
void spell_soundfold(slang_T *slang, char_u *inword, int folded, char_u *res);
3039
void ex_spellinfo(exarg_T *eap);

src/proto/spellsuggest.pro

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/* spellsuggest.c */
2+
int spell_check_sps(void);
3+
void spell_suggest(int count);
4+
void spell_suggest_list(garray_T *gap, char_u *word, int maxcount, int need_cap, int interactive);
5+
/* vim: set ft=c : */

0 commit comments

Comments
 (0)