]> git.pld-linux.org Git - packages/vim.git/blame - vim-ispell.patch
- removed conflict with 6.2.259
[packages/vim.git] / vim-ispell.patch
CommitLineData
0f1b3689
AG
1diff -burN vim62.orig/src/edit.c vim62/src/edit.c
2--- vim62.orig/src/edit.c 2004-03-01 22:36:43.648638472 +0100
3+++ vim62/src/edit.c 2004-03-01 22:43:14.048288704 +0100
4@@ -654,7 +654,11 @@
98f80704 5 if ((c == Ctrl_V || c == Ctrl_Q) && ctrl_x_mode == CTRL_X_CMDLINE)
24ec98f0
JB
6 goto docomplete;
7 #endif
8- if (c == Ctrl_V || c == Ctrl_Q)
9+ if (c == Ctrl_V
10+#ifndef FEAT_SPELL_HL /* WM */
11+ || c == Ctrl_Q
12+#endif
13+ )
14 {
15 ins_ctrl_v();
16 c = Ctrl_V; /* pretend CTRL-V is last typed character */
0f1b3689 17@@ -1220,6 +1224,20 @@
24ec98f0
JB
18 continue_status = 0;
19 break;
20 #endif /* FEAT_INS_EXPAND */
21+#ifdef FEAT_SPELL_HL /* WM */
22+ case Ctrl_Q:
23+ if(set_to_private_dict(
24+ ml_get_buf(curbuf, curwin->w_cursor.lnum, FALSE),
25+ curwin->w_cursor.col, FALSE))
26+ vim_beep();
27+ break;
28+ case Ctrl_S:
29+ if(set_to_private_dict(
30+ ml_get_buf(curbuf, curwin->w_cursor.lnum, FALSE),
31+ curwin->w_cursor.col, TRUE))
32+ vim_beep();
33+ break;
34+#endif
35
36 case Ctrl_Y: /* copy from previous line or scroll down */
37 case Ctrl_E: /* copy from next line or scroll up */
0f1b3689
AG
38diff -burN vim62.orig/src/eval.c vim62/src/eval.c
39--- vim62.orig/src/eval.c 2004-03-01 22:36:43.651638016 +0100
40+++ vim62/src/eval.c 2004-03-01 22:43:14.085283080 +0100
41@@ -4942,6 +4942,9 @@
41e3656f 42 #ifdef FEAT_SNIFF
43 "sniff",
44 #endif
45+#ifdef FEAT_SPELL_HL
46+ "spell",
47+#endif
48 #ifdef FEAT_STL_OPT
49 "statusline",
50 #endif
0f1b3689
AG
51diff -burN vim62.orig/src/ex_cmds.h vim62/src/ex_cmds.h
52--- vim62.orig/src/ex_cmds.h 2004-03-01 22:36:43.680633608 +0100
53+++ vim62/src/ex_cmds.h 2004-03-01 22:43:14.109279432 +0100
54@@ -726,6 +726,8 @@
24ec98f0 55 BANG|FILE1|TRLBAR|SBOXOK|CMDWIN),
24ec98f0
JB
56 EX(CMD_split, "split", ex_splitview,
57 BANG|FILE1|RANGE|NOTADR|EDITCMD|ARGOPT|TRLBAR),
27d8a8e1
MM
58+EX(CMD_spell, "spell", ex_spell,
59+ EXTRA|NOTRLCOM|CMDWIN),
24ec98f0 60 EX(CMD_sprevious, "sprevious", ex_previous,
27d8a8e1
MM
61 EXTRA|RANGE|NOTADR|COUNT|BANG|EDITCMD|ARGOPT|TRLBAR),
62 EX(CMD_srewind, "srewind", ex_rewind,
0f1b3689
AG
63diff -burN vim62.orig/src/ex_docmd.c vim62/src/ex_docmd.c
64--- vim62.orig/src/ex_docmd.c 2004-03-01 22:36:43.717627984 +0100
65+++ vim62/src/ex_docmd.c 2004-03-01 22:43:14.144274112 +0100
66@@ -214,6 +214,9 @@
24ec98f0
JB
67 #ifndef FEAT_SYN_HL
68 # define ex_syntax ex_ni
69 #endif
70+#ifndef FEAT_SPELL_HL
71+# define ex_spell ex_ni
72+#endif
73 #ifndef FEAT_PERL
74 # define ex_perl ex_ni
75 # define ex_perldo ex_ni
0f1b3689 76@@ -3389,6 +3392,12 @@
24ec98f0
JB
77 set_context_in_syntax_cmd(xp, arg);
78 break;
79 #endif
80+#ifdef FEAT_SPELL_HL
81+ case CMD_spell:
82+ return arg;
83+ break;
84+#endif
85+
86 #ifdef FEAT_EVAL
87 case CMD_let:
88 case CMD_if:
0f1b3689
AG
89diff -burN vim62.orig/src/feature.h vim62/src/feature.h
90--- vim62.orig/src/feature.h 2004-03-01 22:36:43.377679664 +0100
91+++ vim62/src/feature.h 2004-03-01 22:43:14.169270312 +0100
41e3656f 92@@ -314,6 +314,11 @@
93 # define FEAT_RIGHTLEFT
24ec98f0 94 # endif
24ec98f0
JB
95 #endif
96+#ifdef FEAT_BIG
97+#undef FEAT_RIGHTLEFT
98+#undef FEAT_FKMAP
24ec98f0
JB
99+#endif
100+/* # define FEAT_PRINTER */
101
102 /*
41e3656f 103 * +arabic Arabic keymap and shaping support.
0f1b3689
AG
104diff -burN vim62.orig/src/globals.h vim62/src/globals.h
105--- vim62.orig/src/globals.h 2004-03-01 22:36:43.705629808 +0100
106+++ vim62/src/globals.h 2004-03-01 22:43:14.172269856 +0100
41e3656f 107@@ -846,6 +846,9 @@
24ec98f0
JB
108 #ifdef USE_TERM_CONSOLE
109 EXTERN int term_console INIT(= FALSE); /* set to TRUE when console used */
110 #endif
111+#ifdef FEAT_SPELL_HL
112+EXTERN char_u hashname[MAXPATHL]; /* name of the dictionary */
113+#endif
114 EXTERN int termcap_active INIT(= FALSE); /* set by starttermcap() */
115 EXTERN int cur_tmode INIT(= TMODE_COOK); /* input terminal mode */
116 EXTERN int bangredo INIT(= FALSE); /* set to TRUE whith ! command */
0f1b3689
AG
117diff -burN vim62.orig/src/main.c vim62/src/main.c
118--- vim62.orig/src/main.c 2004-03-01 22:36:43.668635432 +0100
119+++ vim62/src/main.c 2004-03-01 22:57:05.472892952 +0100
120@@ -2222,6 +2222,10 @@
121 write_viminfo(NULL, FALSE);
122 #endif
123
24ec98f0
JB
124+#ifdef FEAT_SPELL_HL
125+ spell_save_private_dict();
126+#endif
0f1b3689 127+
24ec98f0
JB
128 #ifdef FEAT_AUTOCMD
129 apply_autocmds(EVENT_VIMLEAVE, NULL, NULL, FALSE, curbuf);
0f1b3689
AG
130 #endif
131diff -burN vim62.orig/src/Makefile vim62/src/Makefile
132--- vim62.orig/src/Makefile 2004-03-01 22:36:43.325687568 +0100
133+++ vim62/src/Makefile 2004-03-01 22:43:16.557907184 +0100
134@@ -1188,6 +1188,22 @@
41e3656f 135 # Use this for cproto 3 patchlevel 7 or above (use "cproto -V" to check):
136 PROTO_FLAGS = -m -M__ARGS -d -E"$(CPP)" $(NO_ATTR)
137
138+SPELL_SRC = spell.c \
139+ spell/good.c \
140+ spell/lookup.c \
141+ spell/hash.c \
142+ spell/makedent.c \
143+ spell/tree.c \
144+ spell/tgood.c \
145+ spell/util.c
146+SPELL_OBJ = objects/spell.o \
147+ objects/good.o \
148+ objects/lookup.o \
149+ objects/hash.o \
150+ objects/makedent.o \
151+ objects/tree.o \
152+ objects/tgood.o \
153+ objects/util.o
154
155 ################################################
156 ## no changes required below this line ##
0f1b3689 157@@ -1198,7 +1214,7 @@
41e3656f 158 .SUFFIXES:
159 .SUFFIXES: .cc .c .o .pro
160
161-PRE_DEFS = -Iproto $(DEFS) $(GUI_DEFS) $(GUI_IPATH) $(CPPFLAGS) $(EXTRA_IPATHS)
162+PRE_DEFS = -Iproto -Ispell $(DEFS) $(GUI_DEFS) $(GUI_IPATH) $(CPPFLAGS) $(EXTRA_IPATHS)
163 POST_DEFS = $(X_CFLAGS) $(PERL_CFLAGS) $(PYTHON_CFLAGS) $(TCL_CFLAGS) $(RUBY_CFLAGS) $(EXTRA_DEFS)
164
165 ALL_CFLAGS = $(PRE_DEFS) $(CFLAGS) $(PROFILE_CFLAGS) $(POST_DEFS)
0f1b3689 166@@ -1280,6 +1296,7 @@
41e3656f 167 screen.c \
168 search.c \
169 syntax.c \
170+ $(SPELL_SRC) \
171 tag.c \
172 term.c \
173 ui.c \
0f1b3689 174@@ -1346,6 +1363,7 @@
41e3656f 175 objects/screen.o \
176 objects/search.o \
177 objects/syntax.o \
178+ $(SPELL_OBJ) \
179 $(SNIFF_OBJ) \
180 objects/tag.o \
181 objects/term.o \
0f1b3689 182@@ -2300,6 +2318,9 @@
41e3656f 183 objects/undo.o: undo.c
184 $(CCC) -o $@ undo.c
185
186+objects/spell.o: spell.c spell/local.h
187+ $(CCC) -o $@ spell.c
188+
189 objects/window.o: window.c
190 $(CCC) -o $@ window.c
191
0f1b3689 192@@ -2533,6 +2554,9 @@
41e3656f 193 auto/osdef.h ascii.h keymap.h term.h macros.h structs.h regexp.h \
194 gui.h gui_beval.h proto/gui_beval.pro option.h ex_cmds.h proto.h \
195 globals.h farsi.h arabic.h
196+objects/spell.o: spell.c vim.h spell/config.h feature.h os_unix.h auto/osdef.h \
197+ ascii.h keymap.h term.h macros.h regexp.h structs.h gui.h globals.h farsi.h \
198+ option.h ex_cmds.h proto.h spell/local.h spell/wm.h spell/ispell.h
199 objects/syntax.o: syntax.c vim.h auto/config.h feature.h os_unix.h \
200 auto/osdef.h ascii.h keymap.h term.h macros.h structs.h regexp.h \
201 gui.h gui_beval.h proto/gui_beval.pro option.h ex_cmds.h proto.h \
0f1b3689 202@@ -2681,3 +2705,26 @@
41e3656f 203 auto/osdef.h ascii.h keymap.h term.h macros.h structs.h regexp.h \
204 gui.h gui_beval.h proto/gui_beval.pro option.h ex_cmds.h proto.h \
205 globals.h farsi.h arabic.h version.h
206+
207+SPELL_CFLAGS=$(CFLAGS) -pedantic -DUSG=1
208+
209+objects/good.o: spell/good.c spell/config.h spell/ispell.h spell/i_proto.h spell/msgs.h spell/local.h
210+ $(CC) -c $(SPELL_CFLAGS) spell/good.c -o objects/good.o
211+
212+objects/lookup.o: spell/lookup.c spell/config.h spell/ispell.h spell/i_proto.h spell/msgs.h spell/local.h
213+ $(CC) -c $(SPELL_CFLAGS) spell/lookup.c -o objects/lookup.o
214+
215+objects/hash.o: spell/hash.c spell/config.h spell/ispell.h spell/i_proto.h spell/local.h
216+ $(CC) -c $(SPELL_CFLAGS) spell/hash.c -o objects/hash.o
217+
218+objects/makedent.o: spell/makedent.c spell/config.h spell/ispell.h spell/i_proto.h spell/msgs.h spell/local.h
219+ $(CC) -c $(SPELL_CFLAGS) spell/makedent.c -o objects/makedent.o
220+
221+objects/tree.o: spell/tree.c spell/config.h spell/ispell.h spell/i_proto.h spell/msgs.h spell/local.h
222+ $(CC) -c $(SPELL_CFLAGS) spell/tree.c -o objects/tree.o
223+
224+objects/tgood.o: spell/tgood.c spell/config.h spell/ispell.h spell/i_proto.h spell/local.h
225+ $(CC) -c $(SPELL_CFLAGS) spell/tgood.c -o objects/tgood.o
226+
227+objects/util.o: spell/util.c spell/config.h spell/ispell.h spell/i_proto.h spell/local.h
228+ $(CC) -c $(SPELL_CFLAGS) spell/util.c -o objects/util.o
0f1b3689
AG
229diff -burN vim62.orig/src/normal.c vim62/src/normal.c
230--- vim62.orig/src/normal.c 2004-03-01 22:36:43.334686200 +0100
231+++ vim62/src/normal.c 2004-03-01 22:43:16.611898976 +0100
41e3656f 232@@ -84,6 +84,10 @@
24ec98f0
JB
233 #ifdef FEAT_VISUAL
234 static int get_visual_text __ARGS((cmdarg_T *cap, char_u **pp, int *lenp));
235 #endif
236+#ifdef FEAT_SPELL_HL
237+static void nv_settodict_q __ARGS((cmdarg_T *cap));
238+static void nv_settodict_s __ARGS((cmdarg_T *cap));
239+#endif
240 static void nv_tagpop __ARGS((cmdarg_T *cap));
241 static void nv_scroll __ARGS((cmdarg_T *cap));
98f80704 242 static void nv_right __ARGS((cmdarg_T *cap));
41e3656f 243@@ -231,9 +235,17 @@
24ec98f0
JB
244 {Ctrl_N, nv_down, NV_STS, FALSE},
245 {Ctrl_O, nv_ctrlo, 0, 0},
246 {Ctrl_P, nv_up, NV_STS, FALSE},
247+#ifdef FEAT_SPELL_HL
248+ {Ctrl_Q, nv_settodict_q, 0, 0},
249+#else
250 {Ctrl_Q, nv_ignore, 0, 0},
251+#endif
252 {Ctrl_R, nv_redo, 0, 0},
253+#ifdef FEAT_SPELL_HL
254+ {Ctrl_S, nv_settodict_s, 0, 0},
255+#else
256 {Ctrl_S, nv_ignore, 0, 0},
257+#endif
258 {Ctrl_T, nv_tagpop, NV_NCW, 0},
259 {Ctrl_U, nv_halfpage, 0, 0},
260 #ifdef FEAT_VISUAL
0f1b3689 261@@ -7686,6 +7698,28 @@
24ec98f0
JB
262 #endif
263 }
264
265+#ifdef FEAT_SPELL_HL
266+static void
267+nv_settodict_q(cap)
268+ cmdarg_T *cap;
269+{
270+ if(set_to_private_dict(
271+ ml_get_buf(curbuf, curwin->w_cursor.lnum, FALSE),
272+ curwin->w_cursor.col, FALSE))
273+ clearopbeep(cap->oap);
274+}
275+
276+static void
277+nv_settodict_s(cap)
278+ cmdarg_T *cap;
279+{
280+ if(set_to_private_dict(
281+ ml_get_buf(curbuf, curwin->w_cursor.lnum, FALSE),
282+ curwin->w_cursor.col, TRUE))
283+ clearopbeep(cap->oap);
284+}
285+#endif
286+
287 #ifdef FEAT_VISUAL
288 /*
289 * In exclusive Visual mode, may include the last character.
0f1b3689
AG
290diff -burN vim62.orig/src/option.c vim62/src/option.c
291--- vim62.orig/src/option.c 2004-03-01 22:36:43.724626920 +0100
292+++ vim62/src/option.c 2004-03-01 22:43:16.645893808 +0100
41e3656f 293@@ -121,6 +121,8 @@
24ec98f0
JB
294 , PV_SW
295 , PV_SWF
296 , PV_SYN
297+ , PV_SPELL_DIR
298+ , PV_SPELL_LANG
299 , PV_TAGS
300 , PV_TS
301 , PV_TSR
41e3656f 302@@ -221,6 +223,10 @@
24ec98f0
JB
303 #ifdef FEAT_SYN_HL
304 static char_u *p_syn;
305 #endif
306+#ifdef FEAT_SPELL_HL
307+static char_u *p_spelldirectory;
308+static char_u *p_language;
309+#endif
310 static long p_ts;
311 static long p_tw;
312 static int p_tx;
0f1b3689 313@@ -1071,7 +1077,7 @@
24ec98f0
JB
314 {(char_u *)FALSE, (char_u *)0L}},
315 {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP,
316 (char_u *)&p_hl, PV_NONE,
317- {(char_u *)"8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText",
318+ {(char_u *)"8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,Z:Spell",
319 (char_u *)0L}},
320 {"history", "hi", P_NUM|P_VIM,
321 (char_u *)&p_hi, PV_NONE,
0f1b3689 322@@ -1336,6 +1342,13 @@
24ec98f0
JB
323 (char_u *)NULL, PV_NONE,
324 #endif
325 {(char_u *)"", (char_u *)0L}},
326+ {"language", "lang", P_STRING|P_ALLOCED|P_VI_DEF,
327+#ifdef FEAT_SPELL_HL
328+ (char_u *)&p_language, PV_SPELL_LANG,
329+#else
330+ (char_u *)NULL, PV_NONE,
331+#endif
332+ {(char_u *)"", (char_u *)0L}},
333 {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
334 #ifdef FEAT_WINDOWS
335 (char_u *)&p_ls, PV_NONE,
0f1b3689 336@@ -1934,6 +1947,14 @@
24ec98f0
JB
337 {"sourceany", NULL, P_BOOL|P_VI_DEF,
338 (char_u *)NULL, PV_NONE,
339 {(char_u *)FALSE, (char_u *)0L}},
340+ {"spelldirectory", "spelldir", P_STRING|P_ALLOCED|P_VI_DEF|P_EXPAND,
341+#ifdef FEAT_SPELL_HL
342+ (char_u *)&p_spelldirectory, PV_SPELL_DIR,
343+ {(char_u *)"/usr/lib/ispell", (char_u *)0L}},
344+#else
345+ (char_u *)NULL, PV_NONE,
346+ {(char_u *)"", (char_u *)0L}},
347+#endif
348 {"splitbelow", "sb", P_BOOL|P_VI_DEF,
349 #ifdef FEAT_WINDOWS
350 (char_u *)&p_sb, PV_NONE,
0f1b3689 351@@ -4770,6 +4791,26 @@
24ec98f0
JB
352 errmsg = e_invarg;
353 }
354 #endif
355+#ifdef FEAT_SPELL_HL
356+ else if (varp == &p_spell_dir)
357+ {
358+ STRCPY(hashname, p_spell_dir);
359+ STRCAT(hashname, "/");
360+ STRCAT(hashname, p_spell_lang);
361+ STRCAT(hashname, ".hash");
362+ reload_dict();
363+ redraw_all_later(NOT_VALID);
364+ }
365+ else if (varp == &p_spell_lang)
366+ {
367+ STRCPY(hashname, p_spell_dir);
368+ STRCAT(hashname, "/");
369+ STRCAT(hashname, p_spell_lang);
370+ STRCAT(hashname, ".hash");
371+ reload_dict();
372+ redraw_all_later(NOT_VALID);
373+ }
374+#endif
375
376 #ifdef FEAT_MBYTE
377 /* 'encoding' and 'fileencoding' */
0f1b3689 378@@ -7842,6 +7883,10 @@
24ec98f0
JB
379 #ifdef FEAT_SYN_HL
380 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
98f80704 381 #endif
24ec98f0
JB
382+#ifdef FEAT_SPELL_HL
383+ case PV_SPELL_DIR: return (char_u *)&(p_spell_dir);
384+ case PV_SPELL_LANG: return (char_u *)&(p_spell_lang);
98f80704 385+#endif
24ec98f0
JB
386 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
387 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
98f80704 388 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
0f1b3689
AG
389diff -burN vim62.orig/src/option.h vim62/src/option.h
390--- vim62.orig/src/option.h 2004-03-01 22:36:43.726626616 +0100
391+++ vim62/src/option.h 2004-03-01 22:43:16.649893200 +0100
392@@ -375,6 +375,8 @@
24ec98f0
JB
393 EXTERN char_u *p_dex; /* 'diffexpr' */
394 # endif
395 #endif
396+EXTERN char_u *p_spell_dir; /* directory with spell hash*/
397+EXTERN char_u *p_spell_lang; /* name of language (spell hash file)*/
398 #ifdef FEAT_INS_EXPAND
399 EXTERN char_u *p_dict; /* 'dictionary' */
400 #endif
0f1b3689
AG
401diff -burN vim62.orig/src/proto/spell.pro vim62/src/proto/spell.pro
402--- vim62.orig/src/proto/spell.pro 1970-01-01 01:00:00.000000000 +0100
403+++ vim62/src/proto/spell.pro 2004-03-01 22:43:16.651892896 +0100
24ec98f0
JB
404@@ -0,0 +1,5 @@
405+int reload_dict(void);\r
406+void ex_spell(exarg_T *eap);\r
407+int get_spell_attr(colnr_T spell_col, colnr_T col, char_u *line);\r
408+int set_to_private_dict(char *line, int cursor_col, int convert_to_lower);\r
409+void spell_save_private_dict(void);\r
0f1b3689
AG
410diff -burN vim62.orig/src/proto.h vim62/src/proto.h
411--- vim62.orig/src/proto.h 2004-03-01 22:36:43.736625096 +0100
412+++ vim62/src/proto.h 2004-03-01 22:43:16.652892744 +0100
41e3656f 413@@ -72,6 +72,9 @@
24ec98f0
JB
414 # include "os_qnx.pro"
415 # endif
416
417+#ifdef FEAT_SPELL_HL
418+# include "spell.pro"
419+#endif
420 # include "buffer.pro"
421 # include "charset.pro"
98f80704 422 # ifdef FEAT_CSCOPE
0f1b3689
AG
423diff -burN vim62.orig/src/screen.c vim62/src/screen.c
424--- vim62.orig/src/screen.c 2004-03-01 22:36:43.642639384 +0100
425+++ vim62/src/screen.c 2004-03-01 22:43:16.681888336 +0100
24ec98f0
JB
426@@ -115,6 +115,9 @@
427 static match_T match_hl; /* used for ":match" highlight matching */
428 #endif
429
430+#ifdef FEAT_SPELL_HL
431+extern int spell_flag;
432+#endif
433 #ifdef FEAT_FOLDING
434 static foldinfo_T win_foldinfo; /* info for 'foldcolumn' */
435 #endif
0f1b3689 436@@ -2468,6 +2471,9 @@
24ec98f0 437 int has_syntax = FALSE; /* this buffer has syntax highl. */
98f80704 438 int save_did_emsg;
24ec98f0
JB
439 #endif
440+#ifdef FEAT_SPELL_HL
441+ int spell_attr = 0;
442+#endif
443 int extra_check; /* has syntax or linebreak */
444 #ifdef FEAT_MBYTE
445 int multi_attr = 0; /* attributes desired by multibyte */
0f1b3689 446@@ -2546,8 +2552,18 @@
24ec98f0
JB
447 #else
448 extra_check = 0;
449 #endif
450+#if defined(FEAT_SYN_HL) || defined(FEAT_SPELL_HL)
451+ if (
452 #ifdef FEAT_SYN_HL
453- if (syntax_present(wp->w_buffer))
454+ syntax_present(wp->w_buffer)
455+#else
456+ 0
457+#endif
458+#ifdef FEAT_SPELL_HL
459+ ||
460+ spell_flag
461+#endif
462+ )
463 {
98f80704 464 /* Prepare for syntax highlighting in this line. When there is an
465 * error, stop syntax highlighting. */
0f1b3689 466@@ -3198,6 +3214,10 @@
24ec98f0
JB
467 else if (search_attr == 0 && has_syntax)
468 char_attr = syntax_attr;
469 #endif
470+#ifdef FEAT_SPELL_HL
471+ else if (spell_flag)
472+ char_attr = spell_attr;
473+#endif
474 else
475 char_attr = search_attr;
476
0f1b3689 477@@ -3512,6 +3532,17 @@
24ec98f0 478 char_attr = syntax_attr;
27d8a8e1
MM
479 }
480 #endif
24ec98f0 481+#ifdef FEAT_SPELL_HL
27d8a8e1 482+ if (spell_flag)
24ec98f0
JB
483+ {
484+ v = ptr - line;
27d8a8e1
MM
485+ spell_attr = get_spell_attr((colnr_T)v - 1, col,
486+ ml_get_buf(wp->w_buffer,
487+ lnum, FALSE));
488+ if (area_attr == 0 && search_attr == 0 && spell_attr)
489+ char_attr = spell_attr;
490+ }
491+#endif
24ec98f0 492 #ifdef FEAT_LINEBREAK
27d8a8e1
MM
493 /*
494 * Found last space before word: check for line break
0f1b3689
AG
495diff -burN vim62.orig/src/spell/config.h vim62/src/spell/config.h
496--- vim62.orig/src/spell/config.h 1970-01-01 01:00:00.000000000 +0100
497+++ vim62/src/spell/config.h 2004-03-01 22:43:16.704884840 +0100
24ec98f0
JB
498@@ -0,0 +1,846 @@
499+#include "local.h" /* local definitions for options */
500+
501+/*
502+** Major-differences selection. The default system is BSD; for USG
503+** or non-UNIX systems you should add the appropriate #define to local.h.
504+*/
505+#ifndef USG
506+#undef USG /* Define this in local.h for System V machines */
507+#endif /* USG */
508+
509+#ifndef WIN32
510+#include <sys/param.h>
511+#include <sys/types.h>
512+#endif
513+#ifndef USG
514+# ifndef FEAT_SPELL_HL
515+# if HAVE_DIRENT_H
516+# include <dirent.h>
517+# ifndef NAMLEN
518+# define NAMLEN(dirent) strlen((dirent)->d_name)
519+# endif
520+# else
521+# define dirent direct
522+# define NAMLEN(dirent) (dirent)->d_namlen
523+# if HAVE_SYS_NDIR_H
524+# include <sys/ndir.h>
525+# endif
526+# if HAVE_SYS_DIR_H
527+# include <sys/dir.h>
528+# endif
529+# if HAVE_NDIR_H
530+# include <ndir.h>
531+# endif
532+# endif
533+# endif
534+#endif /* USG */
535+
536+/*
537+** Things that normally go in a Makefile. Define these just like you
538+** might in the Makefile, except you should use #define instead of
539+** make's assignment syntax. Everything must be double-quoted, and
540+** (unlike make) you can't use any sort of $-syntax to pick up the
541+** values of other definitions.
542+*/
543+#ifndef CC
544+#define CC "cc"
545+#endif /* CC */
546+#ifndef EMACS
547+#define EMACS "emacs"
548+#endif /* EMACS */
549+#ifndef LINT
550+#define LINT "lint"
551+#endif /* LINT */
552+#ifndef CFLAGS
553+#define CFLAGS "-O"
554+#endif /* CFLAGS */
555+#ifndef LINTFLAGS
556+#define LINTFLAGS ""
557+#endif /* LINTFLAGS */
558+#ifndef YACC
559+#define YACC "yacc"
560+#endif /* YACC */
561+
562+/*
563+** Libraries that may need to be added to the cc line to get ispell to
564+** link. Normally, this should be null.
565+*/
566+#ifndef LIBES
567+#define LIBES ""
568+#endif
569+
570+/*
571+** TERMLIB - where to get the termcap library. Should be -ltermcap or
572+** -lcurses on most systems.
573+*/
574+#ifndef TERMLIB
575+#define TERMLIB "-lncurses"
576+#endif
577+
578+/*
579+** REGLIB - where to get the regular-expression routines, if
580+** REGEX_LOOKUP is defined. Should be -lPW on USG systems, null on
581+** BSD systems.
582+*/
583+#ifndef REGLIB
584+#define REGLIB ""
585+#endif
586+
587+/*
588+** Where to install various components of ispell. BINDIR contains
589+** binaries. LIBDIR contains hash tables and affix files. ELISPDIR
590+** contains emacs lisp files (if any) and TEXINFODIR contains emacs
591+** TeXinfo files. MAN1DIR and MAN4DIR will hold the chapter-1 and
592+** chapter-4 manual pages, respectively.
593+**
594+** If you intend to use multiple dictionary files, I would suggest
595+** LIBDIR be a directory which will contain nothing else, so sensible
596+** names can be constructed for the -d option without conflict.
597+*/
598+#ifndef BINDIR
599+#define BINDIR "/usr/bin"
600+#endif
601+#ifndef LIBDIR
602+#define LIBDIR "/usr/lib/ispell"
603+#endif
604+#ifndef ELISPDIR
605+#define ELISPDIR "/usr/lib/emacs/site-lisp"
606+#endif
607+#ifndef TEXINFODIR
608+#define TEXINFODIR "/usr/share/info"
609+#endif
610+#ifndef MAN1DIR
611+#define MAN1DIR "/usr/share/man/man1"
612+#endif
613+#ifndef MAN4DIR
614+#define MAN4DIR "/usr/share/man/man4"
615+#endif
616+
617+/*
618+** Extensions to put on manual pages. Usually these are ".1" or ".1l".
619+*/
620+#ifndef MAN1EXT
621+#define MAN1EXT ".1"
622+#endif
623+#ifndef MAN4EXT
624+#define MAN4EXT ".4"
625+#endif
626+
627+/*
628+** List of all hash files (languages) which will be supported by ispell.
629+**
630+** This variable has a complex format so that many options can be
631+** specified. The format is as follows:
632+**
633+** <language>[,<make-options>...] [<language> [,<make-options> ...] ...]
634+**
635+** where
636+**
637+** language is the name of a subdirectory of the
638+** "languages" directory
639+** make-options are options that are to be passed to "make" in
640+** the specified directory. The make-options
641+** should not, in general, specify a target, as
642+** this will be provided by the make process.
643+**
644+** For example, if LANGUAGES is:
645+**
646+** "{american,MASTERDICTS=american.med+,HASHFILES=americanmed+.hash,EXTRADICT=/usr/dict/words /usr/dict/web2} {deutsch,DICTALWAYS=deutsch.sml,DICTOPTIONS=}"
647+**
648+** then the American-English and Deutsch (German) languages will be supported,
649+** and the following variable settings will be passed to the two Makefiles:
650+**
651+** American:
652+**
653+** MASTERDICTS='american.med+'
654+** HASHFILES='americanmed+.hash'
655+** EXTRADICT='/usr/dict/words /usr/dict/web2'
656+**
657+** Deutsch:
658+**
659+** DICTALWAYS='deutsch.sml'
660+** DICTOPTIONS=''
661+**
662+** Notes on the syntax: The makefile is not very robust. If you have
663+** make problems, or if make seems to fail in the language-subdirs
664+** dependency, check your syntax. The makefile adds single quotes to
665+** the individual variables in the LANGUAGES specification, so don't
666+** use quotes of any kind.
667+**
668+** In the future, the first language listed in this variable will
669+** become the default, and the DEFHASH, DEFLANG, and DEFPAFF,
670+** variables will all become obsolete. So be sure to put your default
671+** language first, to make later conversion easier!
672+**
673+** Notes on options for the various languages will be found in the
674+** Makefiles for those languages. Some of those languages may require
675+** you to also change various limits limits like MASKBITS or the
676+** length parameters.
677+**
678+** A special note on the English language: because the British and
679+** American dialects use different spelling, you should usually select
680+** one or the other of these. If you select both, the setting of
681+** MASTERHASH will determine which becomes the language linked to
682+** DEFHASH (which will usually be named english.hash).
683+**
684+** On MSDOS systems you must use names which are consistent with the
685+** 8+3 filename restrictions, or you will risk filename collision. See
686+** the file pc/local.djgpp for details.
687+*/
688+#ifndef LANGUAGES
689+#define LANGUAGES "{american,MASTERDICTS=american.med+,HASHFILES=americanmed+.hash,EXTRADICT=/usr/dict/words}"
690+#endif /* LANGUAGES */
691+
692+/*
693+** Master hash file for DEFHASH. This is the name of a hash file
694+** built by a language Makefile. It should be the most-popular hash
695+** file on your system, because it is the one that will be used by
696+** default. It must be listed in LANGUAGES, above.
697+*/
698+#ifndef MASTERHASH
699+#define MASTERHASH "polish+.hash"
700+#endif
701+
702+/*
703+** Default native-language hash file. This is the name given to the
704+** hash table that will be used if no language is specified to
705+** ispell. It is a link to MASTERHASH, above.
706+*/
707+#ifndef DEFHASH
708+#define DEFHASH "polish.hash"
709+#endif
710+
711+/*
712+** Language tables for the default language. This must be the name of
713+** the affix file that was used to generate the MASTERHASH/DEFHASH,
714+** above.
715+*/
716+#ifndef DEFLANG
717+#define DEFLANG "polish.aff"
718+#endif
719+
720+/*
721+** Language to use for error messages. If there are no messages in this
722+** language, English will be used instead.
723+*/
724+#ifndef MSGLANG
725+#define MSGLANG "polish"
726+#endif /* MSGLANG */
727+
728+/*
729+** If your sort command accepts the -T switch to set temp file
730+** locations (try it out; it exists but is undocumented on some
731+** systems), make the following variable the null string. Otherwise
732+** leave it as the sed script.
733+*/
734+#ifndef SORTTMP
735+#define SORTTMP "-e '/!!SORTTMP!!/s/=.*$/=/'"
736+#endif
737+
738+/*
739+** If your sort command accepts the -T switch (see above), make the
740+** following variable refer to a temporary directory with lots of
741+** space. Otherwise make it the null string.
742+*/
743+#ifndef MAKE_SORTTMP
744+#define MAKE_SORTTMP "-T ${TMPDIR-/usr/tmp}"
745+#endif
746+
747+/*
748+** If your shell needs ": Use /bin/sh" at the first line of a shell
749+** script, make the following variable the null string. Otherwise
750+** leave it as this sed script which will put a "#!/bin/sh" there.
751+*/
752+#ifndef MAKE_POUND_BANG
753+#define MAKE_POUND_BANG "-e 1s,^:.*Use.*/bin/sh,#!/bin/sh,"
754+#endif
755+
756+
757+/*
758+** INSTALL program. Could be a copy program like cp or something fancier
759+** like /usr/ucb/install -c
760+*/
761+#ifndef INSTALL
762+#define INSTALL "cp"
763+#endif
764+
765+/*
766+** If your system has the rename(2) system call, define HAS_RENAME and
767+** ispell will use that call to rename backup files. Otherwise, it
768+** will use link/unlink. There is no harm in this except on MS-DOS,
769+** which doesn't support link/unlink.
770+*/
771+#ifndef HAS_RENAME
772+#undef HAS_RENAME
773+#endif /* HAS_RENAME */
774+
775+/* type given to signal() by signal.h */
776+#ifndef SIGNAL_TYPE
777+#define SIGNAL_TYPE void
778+#endif
779+
780+/* environment variable for user's word list */
781+#ifndef PDICTVAR
782+#define PDICTVAR "WORDLIST"
783+#endif
784+
785+/* prefix part of default word list */
786+#ifndef DEFPDICT
787+#define DEFPDICT ".ispell_"
788+#endif
789+
790+/*
791+** suffix part of default word list
792+*/
793+#ifndef DEFPAFF
794+#define DEFPAFF "words"
795+#endif
796+
797+/* old place to look for default word list */
798+#ifndef OLDPDICT
799+#define OLDPDICT ".ispell_"
800+#endif /* OLDPDICT */
801+#ifndef OLDPAFF
802+#define OLDPAFF "words"
803+#endif /* OLDPAFF */
804+
805+/* environment variable for include file string */
806+#ifndef INCSTRVAR
807+#define INCSTRVAR "INCLUDE_STRING"
808+#endif
809+
810+/* default include string */
811+#ifndef DEFINCSTR
812+#define DEFINCSTR "&Include_File&"
813+#endif
814+
815+/* mktemp template for temporary file - MUST contain 6 consecutive X's */
816+#ifndef TEMPNAME
817+#define TEMPNAME "/tmp/ispellXXXXXX"
818+#endif
819+
820+/*
821+** If REGEX_LOOKUP is undefined, the lookup command (L) will use the look(1)
822+** command (if available) or the egrep command. If REGEX_LOOKUP is defined,
823+** the lookup command will use the internal dictionary and the
824+** regular-expression library (which you must supply separately. There is
825+** a public-domain library available; libraries are also distributed with
826+** both BSD and System V.
827+**
828+** The advantage of no REGEX_LOOKUP is that it is often much faster, especially
829+** if the look(1) command is available, that the words found are presented
830+** in alphabetical order, and that the list of words searched is larger.
831+** The advantage of REGEX_LOOKUP is that ispell doesn't need to spawn another
832+** program, and the list of words searched is exactly the list of (root) words
833+** that ispell will accept. (However, note that words formed with affixes will
834+** not be found; this can produce some artifacts. For example, since
835+** "brother" can be formed as "broth+er", a lookup command might fail to
836+** find "brother.")
837+*/
838+#ifndef REGEX_LOOKUP
839+#undef REGEX_LOOKUP
840+#endif /* REGEX_LOOKUP */
841+
842+/*
843+** Choose the proper type of regular-expression routines here. BSD
844+** and public-domain systems have routines called re_comp and re_exec;
845+** System V uses regcmp and regex.
846+**
847+** REGCTYPE is the type of a variable to hold the compiled regexp
848+** REGCMP(re,str) is the function which compiles a regexp in `str' into
849+** a compiled regexp `re' declared as REGCTYPE and
850+** returns `re'.
851+** REGEX(re,str,dummy) is a function which matches `str' against a compiled
852+** regexp in `re' and returns a non-NULL pointer if it
853+** matches, NULL otherwise.
854+** REGFREE(re) is anything that should be done when the compiled
855+** regexp `re' is no longer needed. It can be also used
856+** to allocate any structures required to compile a
857+** regexp, since it is called *before* compiling a new
858+** regexp (that's where we know that the old one will no
859+** longer be used).
860+**
861+** Here is one way of defining these if you have POSIX regexp functions:
862+**
863+** #include <sys/types.h>
864+** #include <regex.h>
865+** #define REGCTYPE regex_t *
866+** #define REGCMP(re,str) (regcomp (re, str, 0), re)
867+** #define REGEX(re, str, dummy) \
868+** (re != 0 && regexec (re, str, 0, 0, 0) == 0 ? (char *)1 : NULL)
869+** #define REGFREE(re) \
870+** do { \
871+** if (re == 0) \
872+** re = (regex_t *)calloc (1, sizeof (regex_t)); \
873+** else \
874+** regfree(re); \
875+** } while (0)
876+**
877+*/
878+#ifdef REGEX_LOOKUP
879+#ifndef REGCMP
880+#ifdef USG
881+#define REGCTYPE char *
882+#define REGCMP(re,str) regcmp (str, (char *) 0)
883+#define REGEX(re, str, dummy) regex (re, str, dummy, dummy, dummy, dummy, \
884+ dummy, dummy, dummy, dummy, dummy, dummy)
885+#define REGFREE(re) do {if (re != NULL) free (re); re = NULL;} \
886+ while (0)
887+#else /* USG */
888+#define REGCTYPE char *
889+#define REGFREE(re) (void)0
890+#define REGCMP(re,str) re_comp (str)
891+#define REGEX(re, str, dummy) re_exec (str)
892+#endif /* USG */
893+#endif /* REGCMP */
894+#endif /* REGEX_LOOKUP */
895+
896+/* look command (if look(1) MAY BE available - ignored if not) */
897+#ifndef REGEX_LOOKUP
898+#ifndef LOOK
899+#define LOOK "look -df"
900+#endif
901+#endif /* REGEX_LOOKUP */
902+
903+/* path to egrep (use speeded up version if available) */
904+#ifndef EGREPCMD
905+#ifdef USG
906+#define EGREPCMD "/bin/egrep"
907+#else
908+#define EGREPCMD "/usr/bin/egrep -i"
909+#endif
910+#endif
911+
912+/* path to wordlist for Lookup command (typically /usr/dict/{words|web2}) */
913+/* note that /usr/dict/web2 is usually a bad idea due to obscure words */
914+#ifndef WORDS
915+#define WORDS "/usr/dict/words"
916+#endif
917+
918+/* buffer size to use for file names if not in sys/param.h */
919+#ifndef MAXPATHLEN
920+#define MAXPATHLEN 240
921+#endif
922+
923+/* max file name length (will truncate to fit BAKEXT) if not in sys/param.h */
924+#ifndef MAXNAMLEN
925+#define MAXNAMLEN 14
926+#endif
927+
928+/* define if you want .bak file names truncated to MAXNAMLEN characters */
929+#ifndef TRUNCATEBAK
930+#undef TRUNCATEBAK
931+#endif /* TRUNCATEBAK */
932+
933+/* largest word accepted from a file by any input routine, plus one */
934+#ifndef INPUTWORDLEN
935+#define INPUTWORDLEN 100
936+#endif
937+
938+/* largest amount that a word might be extended by adding affixes */
939+#ifndef MAXAFFIXLEN
940+#define MAXAFFIXLEN 20
941+#endif
942+
943+/*
944+** Define the following to suppress the 8-bit character feature.
945+** Unfortunately, this doesn't work as well as it might, because ispell
946+** only strips the 8th bit in some places. For example, it calls strcmp()
947+** quite often without first stripping parity. However, I really wonder
948+** about the utility of this option, so I haven't bothered to fix it. If
949+** you think the stripping feature of NO8BIT is useful, you might let me
950+** (Geoff Kuenning) know.
951+**
952+** Nevertheless, NO8BIT is a useful option for other reasons. If NO8BIT
953+** is defined, ispell will probably use 8-bit characters internally;
954+** this improves time efficiency and saves a small amount of space
955+** in the hash file. Thus, I recommend you specify NO8BIT unless you
956+** actually expect to be spelling files which use a 256-character set.
957+*/
958+#ifndef NO8BIT
959+#undef NO8BIT
960+#endif /* NO8BIT */
961+
962+/*
963+** Number of mask bits (affix flags) supported. Must be 32, 64, 128, or
964+** 256. If MASKBITS is 32 or 64, there are really only 26 or 58 flags
965+** available, respectively. If it is 32, the flags are named with the
966+** 26 English uppercase letters; lowercase will be converted to uppercase.
967+** If MASKBITS is 64, the 58 flags are named 'A' through 'z' in ASCII
968+** order, including the 6 special characters from 'Z' to 'a': "[\]^_`".
969+** If MASKBITS is 128 or 256, all the 7-bit or 8-bit characters,
970+** respectively, are theoretically available, though a few (newline, slash,
971+** null byte) are pretty hard to actually use successfully.
972+**
973+** Note that a number of non-English affix files depend on having a
974+** larger value for MASKBITS. See the affix files for more
975+** information.
976+*/
977+#ifndef MASKBITS
978+#define MASKBITS 64
979+#endif
980+
981+/*
982+** C type to use for masks. This should be a type that the processor
983+** accesses efficiently.
984+**
985+** MASKTYPE_WIDTH must correctly reflect the number of bits in a
986+** MASKTYPE. Unfortunately, it is also required to be a constant at
987+** preprocessor time, which means you can't use the sizeof operator to
988+** define it.
989+**
990+** Note that MASKTYPE *must* match MASKTYPE_WIDTH or you may get
991+** division-by-zero errors!
992+*/
993+#ifndef MASKTYPE
994+#define MASKTYPE long
995+#endif
996+#ifndef MASKTYPE_WIDTH
997+#define MASKTYPE_WIDTH 32
998+#endif
999+#if MASKBITS < MASKTYPE_WIDTH
1000+#undef MASKBITS
1001+#define MASKBITS MASKTYPE_WIDTH
1002+#endif /* MASKBITS < MASKTYPE_WIDTH */
1003+
1004+
1005+/* maximum number of include files supported by xgets; set to 0 to disable */
1006+#ifndef MAXINCLUDEFILES
1007+#define MAXINCLUDEFILES 5
1008+#endif
1009+
1010+/*
1011+** Maximum hash table fullness percentage. Larger numbers trade space
1012+** for time.
1013+**/
1014+#ifndef MAXPCT
1015+#define MAXPCT 70 /* Expand table when 70% full */
1016+#endif
1017+
1018+/*
1019+** Maximum number of "string" characters that can be defined in a
1020+** language (affix) file. Don't forget that an upper/lower string
1021+** character counts as two!
1022+*/
1023+#ifndef MAXSTRINGCHARS
35c7515f 1024+#define MAXSTRINGCHARS 512
24ec98f0
JB
1025+#endif /* MAXSTRINGCHARS */
1026+
1027+/*
1028+** Maximum length of a "string" character. The default is appropriate for
1029+** nroff-style characters starting with a backslash.
1030+*/
1031+#ifndef MAXSTRINGCHARLEN
1032+#define MAXSTRINGCHARLEN 10
1033+#endif /* MAXSTRINGCHARLEN */
1034+
1035+/*
1036+** the S_NOPARITY mask is applied to user input characters from the terminal
1037+** in order to mask out the parity bit.
1038+*/
1039+#ifdef NO8BIT
1040+#define S_NOPARITY 0x7f
1041+#else
1042+#define S_NOPARITY 0xff
1043+#endif
1044+
1045+
1046+/*
1047+** the terminal mode for ispell, set to CBREAK or RAW
1048+**
1049+*/
1050+#ifndef TERM_MODE
1051+#define TERM_MODE CBREAK
1052+#endif
1053+
1054+/*
1055+** Define this if you want your columns of words to be of equal length.
1056+** This will spread short word lists across the screen instead of down it.
1057+*/
1058+#ifndef EQUAL_COLUMNS
1059+#undef EQUAL_COLUMNS
1060+#endif /* EQUAL_COLUMNS */
1061+
1062+/*
1063+** This is the extension that will be added to backup files
1064+*/
1065+#ifndef BAKEXT
1066+#define BAKEXT ".bak"
1067+#endif
1068+
1069+/*
1070+** Define this if you want to suppress the capitalization-checking
1071+** feature. This will reduce the size of the hashed dictionary on
1072+** most 16-bit and some 32-bit machines. This option is not
1073+** recommended.
1074+*/
1075+#ifndef NO_CAPITALIZATION_SUPPORT
1076+#undef NO_CAPITALIZATION_SUPPORT
1077+#endif /* NO_CAPITALIZATION_SUPPORT */
1078+
1079+/*
1080+** Define this if you want your personal dictionary sorted. This may take
1081+** a long time for very large dictionaries. Dictionaries larger than
1082+** SORTPERSONAL words will not be sorted. Define SORTPERSONAL as zero
1083+** to disable this feature.
1084+*/
1085+#ifndef SORTPERSONAL
1086+#define SORTPERSONAL 1000
1087+#endif
1088+
1089+/*
1090+** Define this if you want to use the shell for interpretation of commands
1091+** issued via the "L" command, "^Z" under System V, and "!". If this is
1092+** not defined then a direct fork()/exec() will be used in place of the
1093+** normal system(). This may speed up these operations greately on some
1094+** systems.
1095+*/
1096+#ifndef USESH
1097+#undef USESH
1098+#endif /* USESH */
1099+
1100+/*
1101+** Maximum language-table search size. Smaller numbers make ispell
1102+** run faster, at the expense of more memory (the lowest reasonable value
1103+** is 2). If a given character appears in a significant position in
1104+** more than MAXSEARCH suffixes, it will be given its own index table.
1105+** If you change this, define INDEXDUMP in lookup.c to be sure your
1106+** index table looks reasonable.
1107+*/
1108+#ifndef MAXSEARCH
1109+#define MAXSEARCH 4
1110+#endif
1111+
1112+/*
1113+** Define this if you want to be able to type any command at a "type space
1114+** to continue" prompt.
1115+*/
1116+#ifndef COMMANDFORSPACE
1117+#undef COMMANDFORSPACE
1118+#endif /* COMMANDFORSPACE */
1119+
1120+/*
1121+** Memory-allocation increment. Buildhash allocates memory in chunks
1122+** of this size, and then subdivides it to get its storage. This saves
1123+** much malloc execution time. A good number for this is the system
1124+** page size less the malloc storage overhead.
1125+**
1126+** Define this to zero to revert to using malloc/realloc. This is normally
1127+** useful only on systems with limited memory.
1128+*/
1129+#ifndef MALLOC_INCREMENT
1130+#define MALLOC_INCREMENT 0
1131+#endif
1132+
1133+/*
1134+** Maximum number of "hits" expected on a word. This is basically the
1135+** number of different ways different affixes can produce the same word.
1136+** For example, with "english.aff", "brothers" can be produced 3 ways:
1137+** "brothers," "brother+s", or "broth+ers". If this is too low, no major
1138+** harm will be done, but ispell may occasionally forget a capitalization.
1139+*/
1140+#ifndef MAX_HITS
1141+#define MAX_HITS 10
1142+#endif
1143+
1144+/*
1145+** Maximum number of capitalization variations expected in any word.
1146+** Besides the obvious all-lower, all-upper, and capitalized versions,
1147+** this includes followcase variants. If this is too low, no real
1148+** harm will be done, but ispell may occasionally fail to suggest a
1149+** correct capitalization.
1150+*/
1151+#ifndef MAX_CAPS
1152+#define MAX_CAPS 10
1153+#endif /* MAX_CAPS */
1154+
1155+/* Define this to ignore spelling check of entire LaTeX bibliography listings */
1156+#ifndef IGNOREBIB
1157+#undef IGNOREBIB
1158+#endif
1159+
1160+/*
1161+** Default nroff and TeX special characters. Normally, you won't want to
1162+** change this; instead you would override it in the language-definition
1163+** file.
1164+*/
1165+#ifndef TEXSPECIAL
1166+#define TEXSPECIAL "{}$*.%#&?,;:!@~-"
1167+#endif
1168+
1169+#ifndef NRSPECIAL
1170+#define NRSPECIAL "().\\*"
1171+#endif
1172+
1173+/*
1174+** Defaults for certain command-line flags.
1175+*/
1176+#ifndef DEFNOBACKUPFLAG
1177+#define DEFNOBACKUPFLAG 0 /* Don't suppress backup file */
1178+#endif
1179+#ifndef DEFTEXFLAG
1180+#define DEFTEXFLAG 0 /* Default to nroff mode */
1181+#endif
1182+
1183+/*
1184+** Define this if you want ispell to place a limitation on the maximum
1185+** size of the screen. On windowed workstations with very large windows,
1186+** the size of the window can be too much of a good thing, forcing the
1187+** user to look back and forth between the bottom and top of the screen.
1188+** If MAX_SCREEN_SIZE is nonzero, screens larger than this will be treated
1189+** as if they have only MAX_SCREEN_SIZE lines. A good value for this
1190+** variable is 24 or 30. Define it as zero to suppress the feature.
1191+*/
1192+#ifndef MAX_SCREEN_SIZE
1193+#define MAX_SCREEN_SIZE 0
1194+#endif
1195+
1196+/*
1197+** The next three variables are used to provide a variable-size context
1198+** display at the bottom of the screen. Normally, the user will see
1199+** a number of lines equal to CONTEXTPCT of his screen, rounded down
1200+** (thus, with CONTEXTPCT == 10, a 24-line screen will produce two lines
1201+** of context). The context will never be greater than MAXCONTEXT or
1202+** less than MINCONTEXT. To disable this feature entirely, set MAXCONTEXT
1203+** and MINCONTEXT to the same value. To round context percentages up,
1204+** define CONTEXTROUNDUP.
1205+**
1206+** Warning: don't set MAXCONTEXT ridiculously large. There is a
1207+** static buffer of size MAXCONTEXT*BUFSIZ; since BUFSIZ is frequently
1208+** 1K or larger, this can create a remarkably large executable.
1209+*/
1210+#ifndef CONTEXTPCT
1211+#define CONTEXTPCT 10 /* Use 10% of the screen for context */
1212+#endif
1213+#ifndef MINCONTEXT
1214+#define MINCONTEXT 2 /* Always show at least 2 lines of context */
1215+#endif
1216+#ifndef MAXCONTEXT
1217+#define MAXCONTEXT 10 /* Never show more than 10 lines of context */
1218+#endif
1219+#ifndef CONTEXTROUNDUP
1220+#undef CONTEXTROUNDUP /* Don't round context up */
1221+#endif
1222+
1223+/*
1224+** Define this if you want the context lines to be displayed at the
1225+** bottom of the screen, the way they used to be, rather than at the top.
1226+*/
1227+#ifndef BOTTOMCONTEXT
1228+#undef BOTTOMCONTEXT
1229+#endif /* BOTTOMCONTEXT */
1230+
1231+/*
1232+** Define this if you want the "mini-menu," which gives the most important
1233+** options at the bottom of the screen, to be the default (in any case, it
1234+** can be controlled with the "-M" switch).
1235+*/
1236+#ifndef MINIMENU
1237+#undef MINIMENU
1238+#endif
1239+
1240+/*
1241+** You might want to change this to zero if your users want to check
1242+** single-letter words against the dictionary. However, you should try
1243+** some sample runs using the -W switch before you try it out; you'd
1244+** be surprised how many single letters appear in documents. If you increase
1245+** MINWORD beyond 1, don't say I didn't warn you that it was a bad idea.
1246+*/
1247+#ifndef MINWORD
1248+#define MINWORD 1 /* Words this short and shorter are always ok */
1249+#endif
1250+
1251+/*
1252+** ANSI C compilers are supposed to provide an include file,
1253+** "stdlib.h", which gives function prototypes for all library
1254+** routines. Define NO_STDLIB_H if you have a compiler that claims to
1255+** be ANSI, but doesn't provide this include file.
1256+*/
1257+#ifndef NO_STDLIB_H
1258+#ifndef __STDC__
1259+#define NO_STDLIB_H
1260+#endif /* __STDC__ */
1261+#endif /* NO_STDLIB_H */
1262+
1263+/*
1264+** The following define is used by the ispell developer to help
1265+** double-check the software. Leave it undefined on other systems
1266+** unless you are especially fond of warning messages, or are pursuing
1267+** an inexplicable bug that might be related to a type mismatch.
1268+*/
1269+#ifndef GENERATE_LIBARARY_PROTOS
1270+#undef GENERATE_LIBARARY_PROTOS
1271+#endif /* GENERATE_LIBARARY_PROTOS */
1272+
1273+/*
1274+** Symbols below this point are generally intended to cater to
1275+** idiosyncracies of specific machines and operating systems.
1276+**
1277+** MS-DOS users should also define HAS_RENAME, above, if appropriate.
1278+**
1279+** Define PIECEMEAL_HASH_WRITES if your system can't handle huge write
1280+** operations. This is known to be a problem on MS-DOS systems when
1281+** a 16-bit compiler is used to compile Ispell.
1282+*/
1283+#ifndef PIECEMEAL_HASH_WRITES
1284+#undef PIECEMEAL_HASH_WRITES
1285+#endif /* PIECEMEAL_HASH_WRITES */
1286+
1287+/*
1288+** Redefine GETKEYSTROKE() to getkey() on some MS-DOS systems where
1289+** getchar() doesn't operate properly in raw mode.
1290+*/
1291+#ifndef GETKEYSTROKE
1292+#define GETKEYSTROKE() getchar ()
1293+#endif /* GETKEYSTROKE */
1294+
1295+/*
1296+** Define MSDOS_BINARY_OPEN to 0x8000 on MS-DOS systems. This can be
1297+** done by adding "#include fcntl.h" to your local.h file.
1298+*/
1299+#ifndef MSDOS_BINARY_OPEN
1300+#ifdef O_BINARY
1301+#define MSDOS_BINARY_OPEN O_BINARY
1302+#else /* O_BINARY */
1303+#define MSDOS_BINARY_OPEN 0
1304+#endif /* O_BINARY */
1305+#endif /* MSDOS_BINARY_OPEN */
1306+
1307+/*
1308+** Environment variable to use to locate the home directory. On DOS
1309+** systems you might want to set this to ISPELL_HOME to avoid
1310+** conflicts with other programs that look for a HOME environment
1311+** variable; on all other systems it should be just HOME.
1312+*/
1313+#ifndef HOME
1314+#define HOME "HOME"
1315+#endif /* HOME */
1316+
1317+/*
1318+** On MS-DOS systems, define PDICTHOME to be the name of a directory
1319+** to be used to contain the personal dictionary (.ispell_english,
1320+** etc.). On other systems, you can leave it undefined.
1321+*/
1322+#ifndef PDICTHOME
1323+#undef PDICTHOME
1324+#endif /* PDICTHOME */
1325+
1326+/*
1327+** On MS-DOS systems, you can rename the following variables so that
1328+** ispell's files have 3-character suffixes. Note that, if you do
1329+** this, you will have to redefine any variable above that incorporates
1330+** one of the suffixes. (Most MS-DOS environments will silently truncate
1331+** excess characters beyond the 8+3 limit, so you usually don't need to
1332+** change the suffixes just because they are longer than 3 characters.)
1333+*/
1334+#ifndef HASHSUFFIX
1335+#define HASHSUFFIX ".hash"
1336+#endif /* HASHSUFFIX */
1337+#ifndef STATSUFFIX
1338+#define STATSUFFIX ".sta"
1339+#endif /* STATSUFFIX */
1340+#ifndef COUNTSUFFIX
1341+#define COUNTSUFFIX ".cnt"
1342+#endif /* COUNTSUFFIX */
1343+#define SIGNAL_TYPE_STRING "void"
1344+#define MASKTYPE_STRING "long"
0f1b3689
AG
1345diff -burN vim62.orig/src/spell/good.c vim62/src/spell/good.c
1346--- vim62.orig/src/spell/good.c 1970-01-01 01:00:00.000000000 +0100
1347+++ vim62/src/spell/good.c 2004-03-01 22:43:16.721882256 +0100
24ec98f0
JB
1348@@ -0,0 +1,400 @@
1349+#ifndef lint
1350+static char Rcs_Id[] =
1351+ "$Id$";
1352+#endif
1353+
1354+/*
1355+ * good.c - see if a word or its root word
1356+ * is in the dictionary.
1357+ *
1358+ * Pace Willisson, 1983
1359+ *
1360+ * Copyright 1992, 1993, Geoff Kuenning, Granada Hills, CA
1361+ * All rights reserved.
1362+ *
1363+ * Redistribution and use in source and binary forms, with or without
1364+ * modification, are permitted provided that the following conditions
1365+ * are met:
1366+ *
1367+ * 1. Redistributions of source code must retain the above copyright
1368+ * notice, this list of conditions and the following disclaimer.
1369+ * 2. Redistributions in binary form must reproduce the above copyright
1370+ * notice, this list of conditions and the following disclaimer in the
1371+ * documentation and/or other materials provided with the distribution.
1372+ * 3. All modifications to the source code must be clearly marked as
1373+ * such. Binary redistributions based on modified source code
1374+ * must be clearly marked as modified versions in the documentation
1375+ * and/or other materials provided with the distribution.
1376+ * 4. All advertising materials mentioning features or use of this software
1377+ * must display the following acknowledgment:
1378+ * This product includes software developed by Geoff Kuenning and
1379+ * other unpaid contributors.
1380+ * 5. The name of Geoff Kuenning may not be used to endorse or promote
1381+ * products derived from this software without specific prior
1382+ * written permission.
1383+ *
1384+ * THIS SOFTWARE IS PROVIDED BY GEOFF KUENNING AND CONTRIBUTORS ``AS IS'' AND
1385+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1386+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1387+ * ARE DISCLAIMED. IN NO EVENT SHALL GEOFF KUENNING OR CONTRIBUTORS BE LIABLE
1388+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1389+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1390+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1391+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1392+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1393+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1394+ * SUCH DAMAGE.
1395+ */
1396+
1397+/*
1398+ * $Log$
1399+ * Revision 1.43 1994/11/02 06:56:05 geoff
1400+ * Remove the anyword feature, which I've decided is a bad idea.
1401+ *
1402+ * Revision 1.42 1994/10/25 05:45:59 geoff
1403+ * Add support for an affix that will work with any word, even if there's
1404+ * no explicit flag.
1405+ *
1406+ * Revision 1.41 1994/05/24 06:23:06 geoff
1407+ * Let tgood decide capitalization questions, rather than doing it ourselves.
1408+ *
1409+ * Revision 1.40 1994/05/17 06:44:10 geoff
1410+ * Add support for controlled compound formation and the COMPOUNDONLY
1411+ * option to affix flags.
1412+ *
1413+ * Revision 1.39 1994/01/25 07:11:31 geoff
1414+ * Get rid of all old RCS log lines in preparation for the 3.1 release.
1415+ *
1416+ */
1417+
1418+#include <ctype.h>
1419+#include "ispell.h"
1420+
1421+#ifndef NO_CAPITALIZATION_SUPPORT
1422+Public Logical cap_ok (ichar_t * word, struct success * hit, int len);
1423+Local Logical entryhasaffixes (struct dent * dent, struct success * hit);
1424+#endif /* NO_CAPITALIZATION_SUPPORT */
1425+Public void flagpr (ichar_t * word, int preflag, int prestrip,
1426+ int preadd, int sufflag, int sufadd);
1427+Local ichar_t * orig_word;
1428+
1429+Public int
1430+#ifndef NO_CAPITALIZATION_SUPPORT
1431+good (ichar_t *w, int ignoreflagbits, int allhits, int pfxopts, int sfxopts)
1432+#else
1433+/* ARGSUSED */
1434+good (ichar_t *w, int ignoreflagbits, int dummy, int pfxopts, int sfxopts)
1435+#define allhits 0 /* Never actually need more than one hit */
1436+#endif
1437+
1438+{
1439+ ichar_t nword[INPUTWORDLEN + MAXAFFIXLEN];
1440+ register ichar_t *p;
1441+ register ichar_t *q;
1442+ register n;
1443+ register struct dent *dp;
1444+
1445+ /*
1446+ ** Make an uppercase copy of the word we are checking.
1447+ */
1448+ for (p = w, q = nword; *p; )
1449+ *q++ = mytoupper (*p++);
1450+ *q = 0;
1451+ n = q - nword;
1452+
1453+ numhits = 0;
1454+
1455+ if (cflag)
1456+ {
1457+ (void) printf ("%s", ichartosstr (w, 0));
1458+ orig_word = w;
1459+ }
1460+ else if ((dp = lookup (nword, 1)) != NULL)
1461+ {
1462+ hits[0].dictent = dp;
1463+ hits[0].prefix = NULL;
1464+ hits[0].suffix = NULL;
1465+#ifndef NO_CAPITALIZATION_SUPPORT
1466+ if (allhits || cap_ok (w, &hits[0], n))
1467+ numhits = 1;
1468+#else
1469+ numhits = 1;
1470+#endif
1471+ /*
1472+ * If we're looking for compounds, and this root doesn't
1473+ * participate in compound formation, undo the hit.
1474+ */
1475+ if (compoundflag == COMPOUND_CONTROLLED
1476+ && ((pfxopts | sfxopts) & FF_COMPOUNDONLY) != 0
1477+ && hashheader.compoundbit >= 0
1478+ && TSTMASKBIT (dp->mask, hashheader.compoundbit) == 0)
1479+ numhits = 0;
1480+ }
1481+ if (numhits && !allhits)
1482+ return 1;
1483+
1484+ /* try stripping off affixes */
1485+
1486+#if 0
1487+ numchars = icharlen (nword);
1488+ if (numchars < 4)
1489+ {
1490+ if (cflag)
1491+ (void) putchar ('\n');
1492+ return numhits || (numchars == 1);
1493+ }
1494+#endif
1495+
1496+ chk_aff (w, nword, n, ignoreflagbits, allhits, pfxopts, sfxopts);
1497+
1498+ if (cflag)
1499+ (void) putchar ('\n');
1500+
1501+ return numhits;
1502+}
1503+
1504+#ifndef NO_CAPITALIZATION_SUPPORT
1505+Public Logical
1506+cap_ok (register ichar_t *word, register struct success *hit, int len)
1507+{
1508+ register ichar_t * dword;
1509+ register ichar_t * w;
1510+ register struct dent * dent;
1511+ ichar_t dentword[INPUTWORDLEN + MAXAFFIXLEN];
1512+ int preadd;
1513+ int prestrip;
1514+ int sufadd;
1515+ ichar_t * limit;
1516+ long thiscap;
1517+ long dentcap;
1518+
1519+ thiscap = whatcap (word);
1520+ /*
1521+ ** All caps is always legal, regardless of affixes.
1522+ */
1523+ preadd = prestrip = sufadd = 0;
1524+ if (thiscap == ALLCAPS)
1525+ return 1;
1526+ else if (thiscap == FOLLOWCASE)
1527+ {
1528+ /* Set up some constants for the while(1) loop below */
1529+ if (hit->prefix)
1530+ {
1531+ preadd = hit->prefix->affl;
1532+ prestrip = hit->prefix->stripl;
1533+ }
1534+ else
1535+ preadd = prestrip = 0;
1536+ sufadd = hit->suffix ? hit->suffix->affl : 0;
1537+ }
1538+ /*
1539+ ** Search the variants for one that matches what we have. Note
1540+ ** that thiscap can't be ALLCAPS, since we already returned
1541+ ** for that case.
1542+ */
1543+ dent = hit->dictent;
1544+ while(True)
1545+ {
1546+ dentcap = captype (dent->flagfield);
1547+ if (dentcap != thiscap)
1548+ {
1549+ if (dentcap == ANYCASE && thiscap == CAPITALIZED
1550+ && entryhasaffixes (dent, hit))
1551+ return True;
1552+ }
1553+ else /* captypes match */
1554+ {
1555+ if (thiscap != FOLLOWCASE)
1556+ {
1557+ if (entryhasaffixes (dent, hit))
1558+ return True;
1559+ }
1560+ else
1561+ {
1562+ /*
1563+ ** Make sure followcase matches exactly.
1564+ ** Life is made more difficult by the
1565+ ** possibility of affixes. Start with
1566+ ** the prefix.
1567+ */
1568+ (void) strtoichar (dentword, dent->word, INPUTWORDLEN, 1);
1569+ dword = dentword;
1570+ limit = word + preadd;
1571+ if (myupper (dword[prestrip]))
1572+ {
1573+ for (w = word; w < limit; w++)
1574+ {
1575+ if (mylower (*w))
1576+ goto doublecontinue;
1577+ }
1578+ }
1579+ else
1580+ {
1581+ for (w = word; w < limit; w++)
1582+ {
1583+ if (myupper (*w))
1584+ goto doublecontinue;
1585+ }
1586+ }
1587+ dword += prestrip;
1588+ /* Do root part of word */
1589+ limit = dword + len - preadd - sufadd;
1590+ while (dword < limit)
1591+ {
1592+ if (*dword++ != *w++)
1593+ goto doublecontinue;
1594+ }
1595+ /* Do suffix */
1596+ dword = limit - 1;
1597+ if (myupper (*dword))
1598+ {
1599+ for ( ; *w; w++)
1600+ {
1601+ if (mylower (*w))
1602+ goto doublecontinue;
1603+ }
1604+ }
1605+ else
1606+ {
1607+ for ( ; *w; w++)
1608+ {
1609+ if (myupper (*w))
1610+ goto doublecontinue;
1611+ }
1612+ }
1613+ /*
1614+ ** All failure paths go to "doublecontinue,"
1615+ ** so if we get here it must match.
1616+ */
1617+ if (entryhasaffixes (dent, hit))
1618+ return True;
1619+doublecontinue: ;
1620+ }
1621+ }
1622+ if ((dent->flagfield & MOREVARIANTS) == 0)
1623+ break;
1624+ dent = dent->next;
1625+ }
1626+
1627+ /* No matches found */
1628+ return False;
1629+}
1630+
1631+/*
1632+** See if this particular capitalization (dent) is legal with these
1633+** particular affixes.
1634+*/
1635+Local Logical
1636+entryhasaffixes (register struct dent *dent, register struct success *hit)
1637+{
1638+
1639+ if (hit->prefix && !TSTMASKBIT (dent->mask, hit->prefix->flagbit))
1640+ return False;
1641+ if (hit->suffix && !TSTMASKBIT (dent->mask, hit->suffix->flagbit))
1642+ return False;
1643+ return True; /* Yes, these affixes are legal */
1644+}
1645+#endif
1646+
1647+/*
1648+ * Print a word and its flag, making sure the case of the output matches
1649+ * the case of the original found in "orig_word".
1650+ */
1651+Public void
1652+flagpr (register ichar_t *word, /* (Modified) word to print */
1653+ int preflag, /* Prefix flag (if any) */
1654+ int prestrip, /* Lth of pfx stripped off orig_word */
1655+ int preadd, /* Length of prefix added to w */
1656+ int sufflag, /* Suffix flag (if any) */
1657+ int sufadd) /* Length of suffix added to w */
1658+{
1659+ register ichar_t * origp; /* Pointer into orig_word */
1660+ int orig_len; /* Length of orig_word */
1661+
1662+ orig_len = icharlen (orig_word);
1663+ /*
1664+ * We refuse to print if the cases outside the modification
1665+ * points don't match those just inside. This prevents things
1666+ * like "OEM's" from being turned into "OEM/S" which expands
1667+ * only to "OEM'S".
1668+ */
1669+ if (preflag > 0)
1670+ {
1671+ origp = orig_word + preadd;
1672+ if (myupper (*origp))
1673+ {
1674+ for (origp = orig_word; origp < orig_word + preadd; origp++)
1675+ {
1676+ if (mylower (*origp))
1677+ return;
1678+ }
1679+ }
1680+ else
1681+ {
1682+ for (origp = orig_word; origp < orig_word + preadd; origp++)
1683+ {
1684+ if (myupper (*origp))
1685+ return;
1686+ }
1687+ }
1688+ }
1689+ if (sufflag > 0)
1690+ {
1691+ origp = orig_word + orig_len - sufadd;
1692+ if (myupper (origp[-1]))
1693+ {
1694+ for ( ; *origp != 0; origp++)
1695+ {
1696+ if (mylower (*origp))
1697+ return;
1698+ }
1699+ }
1700+ else
1701+ {
1702+ origp = orig_word + orig_len - sufadd;
1703+ for ( ; *origp != 0; origp++)
1704+ {
1705+ if (myupper (*origp))
1706+ return;
1707+ }
1708+ }
1709+ }
1710+ /*
1711+ * The cases are ok. Put out the word, being careful that the
1712+ * prefix/suffix cases match those in the original, and that the
1713+ * unchanged characters from the original actually match it.
1714+ */
1715+ (void) putchar (' ');
1716+ origp = orig_word + preadd;
1717+ if (myupper (*origp))
1718+ {
1719+ while (--prestrip >= 0)
1720+ (void) fputs (printichar ((int) *word++), stdout);
1721+ }
1722+ else
1723+ {
1724+ while (--prestrip >= 0)
1725+ (void) fputs (printichar ((int) mytolower (*word++)), stdout);
1726+ }
1727+ for (prestrip = orig_len - preadd - sufadd; --prestrip >= 0; word++)
1728+ (void) fputs (printichar ((int) *origp++), stdout);
1729+ if (origp > orig_word)
1730+ origp--;
1731+ if (myupper (*origp))
1732+ (void) fputs (ichartosstr (word, 0), stdout);
1733+ else
1734+ {
1735+ while (*word)
1736+ {
1737+ (void) fputs (printichar ((int) mytolower (*word++)), stdout);
1738+ }
1739+ }
1740+ /*
1741+ * Now put out the flags
1742+ */
1743+ (void) putchar (hashheader.flagmarker);
1744+ if (preflag > 0)
1745+ (void) putchar (preflag);
1746+ if (sufflag > 0)
1747+ (void) putchar (sufflag);
1748+}
0f1b3689
AG
1749diff -burN vim62.orig/src/spell/hash.c vim62/src/spell/hash.c
1750--- vim62.orig/src/spell/hash.c 1970-01-01 01:00:00.000000000 +0100
1751+++ vim62/src/spell/hash.c 2004-03-01 22:43:16.722882104 +0100
24ec98f0
JB
1752@@ -0,0 +1,91 @@
1753+/*
1754+ * hash.c - a simple hash function for ispell
1755+ *
1756+ * Pace Willisson, 1983
1757+ *
1758+ * Copyright 1992, 1993, Geoff Kuenning, Granada Hills, CA
1759+ * All rights reserved.
1760+ *
1761+ * Redistribution and use in source and binary forms, with or without
1762+ * modification, are permitted provided that the following conditions
1763+ * are met:
1764+ *
1765+ * 1. Redistributions of source code must retain the above copyright
1766+ * notice, this list of conditions and the following disclaimer.
1767+ * 2. Redistributions in binary form must reproduce the above copyright
1768+ * notice, this list of conditions and the following disclaimer in the
1769+ * documentation and/or other materials provided with the distribution.
1770+ * 3. All modifications to the source code must be clearly marked as
1771+ * such. Binary redistributions based on modified source code
1772+ * must be clearly marked as modified versions in the documentation
1773+ * and/or other materials provided with the distribution.
1774+ * 4. All advertising materials mentioning features or use of this software
1775+ * must display the following acknowledgment:
1776+ * This product includes software developed by Geoff Kuenning and
1777+ * other unpaid contributors.
1778+ * 5. The name of Geoff Kuenning may not be used to endorse or promote
1779+ * products derived from this software without specific prior
1780+ * written permission.
1781+ *
1782+ * THIS SOFTWARE IS PROVIDED BY GEOFF KUENNING AND CONTRIBUTORS ``AS IS'' AND
1783+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1784+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1785+ * ARE DISCLAIMED. IN NO EVENT SHALL GEOFF KUENNING OR CONTRIBUTORS BE LIABLE
1786+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1787+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1788+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1789+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1790+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1791+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1792+ * SUCH DAMAGE.
1793+ */
1794+
1795+/*
1796+ * $Log$
1797+ * Revision 1.20 1994/01/25 07:11:34 geoff
1798+ * Get rid of all old RCS log lines in preparation for the 3.1 release.
1799+ *
1800+ */
1801+
1802+#include "ispell.h"
1803+
1804+/*
1805+ * The following hash algorithm is due to Ian Dall, with slight modifications
1806+ * by Geoff Kuenning to reflect the results of testing with the English
1807+ * dictionaries actually distributed with ispell.
1808+ */
1809+#define HASHSHIFT 5
1810+
1811+#ifdef NO_CAPITALIZATION_SUPPORT
1812+#define HASHUPPER(c) c
1813+#else /* NO_CAPITALIZATION_SUPPORT */
1814+#define HASHUPPER(c) mytoupper(c)
1815+#endif /* NO_CAPITALIZATION_SUPPORT */
1816+
1817+Public int
1818+hash (
1819+ register ichar_t * s,
1820+ register int hashtblsize)
1821+{
1822+ register long h = 0;
1823+ register int i;
1824+
1825+#ifdef ICHAR_IS_CHAR
1826+ for (i = 4; i-- && *s != 0; )
1827+ h = (h << 8) | HASHUPPER (*s++);
1828+#else /* ICHAR_IS_CHAR */
1829+ for (i = 2; i-- && *s != 0; )
1830+ h = (h << 16) | HASHUPPER (*s++);
1831+#endif /* ICHAR_IS_CHAR */
1832+ while (*s != 0)
1833+ {
1834+ /*
1835+ * We have to do circular shifts the hard way, since C doesn't
1836+ * have them even though the hardware probably does. Oh, well.
1837+ */
1838+ h = (h << HASHSHIFT) |
1839+ ((h >> (32 - HASHSHIFT)) & ((1 << HASHSHIFT) - 1));
1840+ h ^= HASHUPPER (*s++);
1841+ }
1842+ return (unsigned long) h % hashtblsize;
1843+}
0f1b3689
AG
1844diff -burN vim62.orig/src/spell/i_proto.h vim62/src/spell/i_proto.h
1845--- vim62.orig/src/spell/i_proto.h 1970-01-01 01:00:00.000000000 +0100
1846+++ vim62/src/spell/i_proto.h 2004-03-01 22:43:16.724881800 +0100
24ec98f0
JB
1847@@ -0,0 +1,112 @@
1848+Global int addvheader (struct dent * ent);
1849+Global void askmode (void);
1850+Global void backup (void);
1851+#ifndef NO_CAPITALIZATION_SUPPORT
1852+Global Logical cap_ok (ichar_t * word, struct success * hit, int len);
1853+#endif /* NO_CAPITALIZATION_SUPPORT */
1854+Global void chupcase (char * s);
1855+Global void checkfile (void);
1856+Global void checkline (FILE * ofile);
1857+Global void chk_aff (ichar_t * word, ichar_t * ucword, int len,
1858+ int ignoreflagbits, int allhits, int pfxopts, int sfxopts);
1859+Global int combinecaps (struct dent * hdr, struct dent * newent);
1860+Global int compoundgood (ichar_t * word, int pfxopts);
1861+Global void copyout (char ** cc, int cnt);
1862+Global void correct (char * ctok, int ctokl, ichar_t * itok, int itokl,
1863+ char ** curchar);
1864+Global char * do_regex_lookup (char * expr, int whence);
1865+Global SIGNAL_TYPE done (int);
1866+Global void dumpmode (void);
1867+Global void erase (void);
1868+Global int expand_pre (char * croot, ichar_t * rootword,
1869+ MASKTYPE mask[], int option, char *extra);
1870+Global int expand_suf (char * croot, ichar_t * rootword,
1871+ MASKTYPE mask[], int crossonly, int option, char * extra);
1872+Global int findfiletype (char * name, int searchnames,
1873+ int * deformatter);
1874+Global void flagpr (ichar_t * word, int preflag, int prestrip,
1875+ int preadd, int sufflag, int sufadd);
1876+Global void givehelp (int interactive);
1877+Global int good (ichar_t * word, int ignoreflagbits, int allhits,
1878+ int pfxopts, int sfxopts);
1879+Global int hash (ichar_t * word, int hashtablesize);
1880+#ifndef ICHAR_IS_CHAR
1881+Global int icharcmp (ichar_t * s1, ichar_t * s2);
1882+Global ichar_t * icharcpy (ichar_t * out, ichar_t * in);
1883+Global int icharlen (ichar_t * str);
1884+Global int icharncmp (ichar_t * s1, ichar_t * s2, int n);
1885+#endif /* ICHAR_IS_CHAR */
1886+Global int ichartostr (char * out, ichar_t * in, int outlen,
1887+ int canonical);
1888+Global char * ichartosstr (ichar_t * in, int canonical);
1889+Global void inverse (void);
1890+Global struct dent * lookup (ichar_t * word, int dotree);
1891+Global void lowcase (ichar_t * string);
1892+Global int makedent (char * lbuf, int lbuflen, struct dent * d);
1893+Global void makepossibilities (ichar_t * word);
1894+Global void move (int row, int col);
1895+Global void normal (void);
1896+Global char * printichar (int in);
1897+#ifdef USESH
1898+Global int shellescape (char * buf);
1899+Global void shescape (char * buf);
1900+#else /* USESH */
1901+#ifndef REGEX_LOOKUP
1902+Global int shellescape (char * buf);
1903+#endif /* REGEX_LOOKUP */
1904+#endif /* USESH */
1905+Global char * skipoverword (char * bufp);
1906+Global void stop (void);
1907+Global int stringcharlen (char * bufp, int canonical);
1908+Global int strtoichar (ichar_t * out, char * in, int outlen,
1909+ int canonical);
1910+Global ichar_t * strtosichar (char * in, int canonical);
1911+Global void terminit (void);
1912+Global void toutent (FILE * outfile, struct dent * hent, int onlykeep);
1913+Global void treeinit (char * persdict, char * LibDict);
1914+Global void treeinsert (char * word, int wordlen, int keep);
1915+Global struct dent * treelookup (ichar_t * word);
1916+Global void treeoutput (void);
1917+Global void upcase (ichar_t * string);
1918+#ifndef NO_CAPITALIZATION_SUPPORT
1919+Global long whatcap (ichar_t * word);
1920+#endif
1921+Global char * xgets (char * string, int size, FILE * stream);
1922+Global void yyinit (void);
1923+Global Logical yyopen (char * file);
1924+Global int yyparse (void);
1925+
1926+#include <string.h>
1927+
1928+#ifdef REGEX_LOOKUP
1929+# ifdef USG
1930+Global char * regcmp (const char * expr, const char * terminator, ...);
1931+Global char * regex (const char * pat, const char * subject, ...);
1932+# else
1933+Global char * re_comp (const char * expr);
1934+Global int * re_exec (const char * pat);
1935+# endif
1936+#endif
1937+/* WM
1938+Global int tgetent (char * buf, const char * termname);
1939+Global int tgetnum (const char * id);
1940+Global char * tgetstr (const char * id, char ** area);
1941+Global char * tgoto (const char * cm, int col, int row);
1942+Global char * tputs (const char * str, int pad, int (*func) (int ch);
1943+*/
1944+
1945+Global char * mypath_rindex(char const *str, char c);
1946+Global void save_root_cap (ichar_t * word, ichar_t * pattern,
1947+ int prestrip, int preadd, int sufstrip, int sufadd,
1948+ struct dent * firstdent, struct flagent * pfxent,
1949+ struct flagent * sufent,
1950+ ichar_t savearea[MAX_CAPS][INPUTWORDLEN + MAXAFFIXLEN],
1951+ int * nsaved);
1952+Global int casecmp (char * a, char * b, int canonical);
1953+Global int ins_root_cap (ichar_t * word, ichar_t * pattern,
1954+ int prestrip, int preadd, int sufstrip, int sufadd,
1955+ struct dent * firstdent, struct flagent * pfxent,
1956+ struct flagent * sufent);
1957+Global int insert(register ichar_t * word);
1958+Global char * linit (char *);
1959+Global char * last_slash (char *file);
0f1b3689
AG
1960diff -burN vim62.orig/src/spell/ispell.h vim62/src/spell/ispell.h
1961--- vim62.orig/src/spell/ispell.h 1970-01-01 01:00:00.000000000 +0100
1962+++ vim62/src/spell/ispell.h 2004-03-01 22:43:16.728881192 +0100
35c7515f 1963@@ -0,0 +1,611 @@
24ec98f0
JB
1964+/*
1965+ * $Id$
1966+ */
1967+
1968+/*
1969+ * Copyright 1992, 1993, Geoff Kuenning, Granada Hills, CA
1970+ * All rights reserved.
1971+ *
1972+ * Redistribution and use in source and binary forms, with or without
1973+ * modification, are permitted provided that the following conditions
1974+ * are met:
1975+ *
1976+ * 1. Redistributions of source code must retain the above copyright
1977+ * notice, this list of conditions and the following disclaimer.
1978+ * 2. Redistributions in binary form must reproduce the above copyright
1979+ * notice, this list of conditions and the following disclaimer in the
1980+ * documentation and/or other materials provided with the distribution.
1981+ * 3. All modifications to the source code must be clearly marked as
1982+ * such. Binary redistributions based on modified source code
1983+ * must be clearly marked as modified versions in the documentation
1984+ * and/or other materials provided with the distribution.
1985+ * 4. All advertising materials mentioning features or use of this software
1986+ * must display the following acknowledgment:
1987+ * This product includes software developed by Geoff Kuenning and
1988+ * other unpaid contributors.
1989+ * 5. The name of Geoff Kuenning may not be used to endorse or promote
1990+ * products derived from this software without specific prior
1991+ * written permission.
1992+ *
1993+ * THIS SOFTWARE IS PROVIDED BY GEOFF KUENNING AND CONTRIBUTORS ``AS IS'' AND
1994+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1995+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1996+ * ARE DISCLAIMED. IN NO EVENT SHALL GEOFF KUENNING OR CONTRIBUTORS BE LIABLE
1997+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1998+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1999+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2000+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2001+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2002+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2003+ * SUCH DAMAGE.
2004+ */
2005+
2006+/*
2007+ * $Log$
2008+ * Revision 1.68 1995/03/06 02:42:41 geoff
2009+ * Be vastly more paranoid about parenthesizing macro arguments. This
2010+ * fixes a bug in defmt.c where a complex argument was passed to
2011+ * isstringch.
2012+ *
2013+ * Revision 1.67 1995/01/03 19:24:12 geoff
2014+ * Get rid of a non-global declaration.
2015+ *
2016+ * Revision 1.66 1994/12/27 23:08:49 geoff
2017+ * Fix a lot of subtly bad assumptions about the widths of ints and longs
2018+ * which only show up on 64-bit machines like the Cray and the DEC Alpha.
2019+ *
2020+ * Revision 1.65 1994/11/02 06:56:10 geoff
2021+ * Remove the anyword feature, which I've decided is a bad idea.
2022+ *
2023+ * Revision 1.64 1994/10/25 05:46:18 geoff
2024+ * Add the FF_ANYWORD flag for defining an affix that will apply to any
2025+ * word, even if not explicitly specified. (Good for French.)
2026+ *
2027+ * Revision 1.63 1994/09/16 04:48:28 geoff
2028+ * Make stringdups and laststringch unsigned ints, and dupnos a plain
2029+ * int, so that we can handle more than 128 stringchars and stringchar
2030+ * types.
2031+ *
2032+ * Revision 1.62 1994/09/01 06:06:39 geoff
2033+ * Change erasechar/killchar to uerasechar/ukillchar to avoid
2034+ * shared-library problems on HP systems.
2035+ *
2036+ * Revision 1.61 1994/08/31 05:58:35 geoff
2037+ * Add contextoffset, used in -a mode to handle extremely long lines.
2038+ *
2039+ * Revision 1.60 1994/05/17 06:44:15 geoff
2040+ * Add support for controlled compound formation and the COMPOUNDONLY
2041+ * option to affix flags.
2042+ *
2043+ * Revision 1.59 1994/03/15 06:25:16 geoff
2044+ * Change deftflag's initialization so we can tell if -t/-n appeared.
2045+ *
2046+ * Revision 1.58 1994/02/07 05:53:28 geoff
2047+ * Add typecasts to the the 7-bit versions of ichar* routines
2048+ *
2049+ * Revision 1.57 1994/01/25 07:11:48 geoff
2050+ * Get rid of all old RCS log lines in preparation for the 3.1 release.
2051+ *
2052+ */
2053+
2054+#include <stdio.h>
2055+#include "config.h"
2056+
2057+#ifdef NO8BIT
2058+#define SET_SIZE 128
2059+#else
2060+#define SET_SIZE 256
2061+#endif
2062+
2063+#define MASKSIZE (MASKBITS / MASKTYPE_WIDTH)
2064+
2065+/* The following is really testing for MASKSIZE <= 1, but cpp can't do that */
2066+#if MASKBITS <= MASKTYPE_WIDTH
2067+#define SETMASKBIT(mask, bit) ((mask)[0] |= (MASKTYPE) 1 << (bit))
2068+#define CLRMASKBIT(mask, bit) ((mask)[0] &= (MASKTYPE) ~(1 << (bit)))
2069+#define TSTMASKBIT(mask, bit) ((mask)[0] & ((MASKTYPE) 1 << (bit)))
2070+#else
2071+#define SETMASKBIT(mask, bit) \
2072+ ((mask)[(bit) / MASKTYPE_WIDTH] |= \
2073+ (MASKTYPE) 1 << ((bit) & (MASKTYPE_WIDTH - 1)))
2074+#define CLRMASKBIT(mask, bit) \
2075+ ((mask)[(bit) / MASKTYPE_WIDTH] &= \
2076+ ~((MASKTYPE) 1 << ((bit) & (MASKTYPE_WIDTH - 1))))
2077+#define TSTMASKBIT(mask, bit) \
2078+ ((mask)[(bit) / MASKTYPE_WIDTH] & \
2079+ ((MASKTYPE) 1 << ((bit) & (MASKTYPE_WIDTH - 1))))
2080+#endif
2081+
2082+#if MASKBITS > 64
2083+#define FULLMASKSET
2084+#endif
2085+
2086+#if MASKBITS <= 32
2087+# ifndef lint
2088+#define BITTOCHAR(bit) ((bit) + 'A')
2089+#define CHARTOBIT(ch) ((ch) - 'A')
2090+# endif /* lint */
2091+#define LARGESTFLAG 26 /* 5 are needed for flagfield below */
2092+#define FLAGBASE ((MASKTYPE_WIDTH) - 6)
2093+#else
2094+# if MASKBITS <= 64
2095+# ifndef lint
2096+#define BITTOCHAR(bit) ((bit) + 'A')
2097+#define CHARTOBIT(ch) ((ch) - 'A')
2098+# endif /* lint */
2099+#define LARGESTFLAG (64 - 6) /* 5 are needed for flagfield below */
2100+#define FLAGBASE ((MASKTYPE_WIDTH) - 6)
2101+# else
2102+# ifndef lint
2103+#define BITTOCHAR(bit) (bit)
2104+#define CHARTOBIT(ch) (ch)
2105+# endif /* lint */
2106+#define LARGESTFLAG MASKBITS /* flagfield is a separate field */
2107+#define FLAGBASE 0
2108+# endif
2109+#endif
2110+
2111+/*
2112+** Data type for internal word storage. If necessary, we use shorts rather
2113+** than chars so that string characters can be encoded as a single unit.
2114+*/
2115+#if (SET_SIZE + MAXSTRINGCHARS) <= 256
2116+#ifndef lint
2117+#define ICHAR_IS_CHAR
2118+#endif /* lint */
2119+#endif
2120+
2121+#ifdef ICHAR_IS_CHAR
2122+typedef unsigned char ichar_t; /* Internal character */
2123+#define icharlen(s) strlen ((char *) (s))
2124+#define icharcpy(a, b) strcpy ((char *) (a), (char *) (b))
2125+#define icharcmp(a, b) strcmp ((char *) (a), (char *) (b))
2126+#define icharncmp(a, b, n) strncmp ((char *) (a), (char *) (b), (n))
2127+#define chartoichar(x) ((ichar_t) (x))
2128+#else
2129+typedef unsigned short ichar_t; /* Internal character */
2130+#define chartoichar(x) ((ichar_t) (unsigned char) (x))
2131+#endif
2132+
2133+struct dent
2134+ {
2135+ struct dent * next;
2136+ char * word;
2137+ MASKTYPE mask[MASKSIZE];
2138+#ifdef FULLMASKSET
2139+ char flags;
2140+#endif
2141+ };
2142+
2143+/*
2144+** Flags in the directory entry. If FULLMASKSET is undefined, these are
2145+** stored in the highest bits of the last longword of the mask field. If
2146+** FULLMASKSET is defined, they are stored in the extra "flags" field.
2147+#ifndef NO_CAPITALIZATION_SUPPORT
2148+**
2149+** If a word has only one capitalization form, and that form is not
2150+** FOLLOWCASE, it will have exactly one entry in the dictionary. The
2151+** legal capitalizations will be indicated by the 2-bit capitalization
2152+** field, as follows:
2153+**
2154+** ALLCAPS The word must appear in all capitals.
2155+** CAPITALIZED The word must be capitalized (e.g., London).
2156+** It will also be accepted in all capitals.
2157+** ANYCASE The word may appear in lowercase, capitalized,
2158+** or all-capitals.
2159+**
2160+** Regardless of the capitalization flags, the "word" field of the entry
2161+** will point to an all-uppercase copy of the word. This is to simplify
2162+** the large portion of the code that doesn't care about capitalization.
2163+** Ispell will generate the correct version when needed.
2164+**
2165+** If a word has more than one capitalization, there will be multiple
2166+** entries for it, linked together by the "next" field. The initial
2167+** entry for such words will be a dummy entry, primarily for use by code
2168+** that ignores capitalization. The "word" field of this entry will
2169+** again point to an all-uppercase copy of the word. The "mask" field
2170+** will contain the logical OR of the mask fields of all variants.
2171+** A header entry is indicated by a capitalization type of ALLCAPS,
2172+** with the MOREVARIANTS bit set.
2173+**
2174+** The following entries will define the individual variants. Each
2175+** entry except the last has the MOREVARIANTS flag set, and each
2176+** contains one of the following capitalization options:
2177+**
2178+** ALLCAPS The word must appear in all capitals.
2179+** CAPITALIZED The word must be capitalized (e.g., London).
2180+** It will also be accepted in all capitals.
2181+** FOLLOWCASE The word must be capitalized exactly like the
2182+** sample in the entry. Prefix (suffix) characters
2183+** must be rendered in the case of the first (last)
2184+** "alphabetic" character. It will also be accepted
2185+** in all capitals. ("Alphabetic" means "mentioned
2186+** in a 'casechars' statement".)
2187+** ANYCASE The word may appear in lowercase, capitalized,
2188+** or all-capitals.
2189+**
2190+** The "mask" field for the entry contains only the affix flag bits that
2191+** are legal for that capitalization. The "word" field will be null
2192+** except for FOLLOWCASE entries, where it will point to the
2193+** correctly-capitalized spelling of the root word.
2194+**
2195+** It is worth discussing why the ALLCAPS option is used in
2196+** the header entry. The header entry accepts an all-capitals
2197+** version of the root plus every affix (this is always legal, since
2198+** words get capitalized in headers and so forth). Further, all of
2199+** the following variant entries will reject any all-capitals form
2200+** that is illegal due to an affix.
2201+**
2202+** Finally, note that variations in the KEEP flag can cause a multiple-variant
2203+** entry as well. For example, if the personal dictionary contains "ALPHA",
2204+** (KEEP flag set) and the user adds "alpha" with the KEEP flag clear, a
2205+** multiple-variant entry will be created so that "alpha" will be accepted
2206+** but only "ALPHA" will actually be kept.
2207+#endif
2208+*/
2209+#ifdef FULLMASKSET
2210+#define flagfield flags
2211+#else
2212+#define flagfield mask[MASKSIZE - 1]
2213+#endif
2214+#define USED ((MASKTYPE) 1 << (FLAGBASE + 0))
2215+#define KEEP ((MASKTYPE) 1 << (FLAGBASE + 1))
2216+#ifdef NO_CAPITALIZATION_SUPPORT
2217+#define ALLFLAGS (USED | KEEP)
2218+#else /* NO_CAPITALIZATION_SUPPORT */
2219+#define ANYCASE ((MASKTYPE) 0 << (FLAGBASE + 2))
2220+#define ALLCAPS ((MASKTYPE) 1 << (FLAGBASE + 2))
2221+#define CAPITALIZED ((MASKTYPE) 2 << (FLAGBASE + 2))
2222+#define FOLLOWCASE ((MASKTYPE) 3 << (FLAGBASE + 2))
2223+#define CAPTYPEMASK ((MASKTYPE) 3 << (FLAGBASE + 2))
2224+#define MOREVARIANTS ((MASKTYPE) 1 << (FLAGBASE + 4))
2225+#define ALLFLAGS (USED | KEEP | CAPTYPEMASK | MOREVARIANTS)
2226+#define captype(x) ((x) & CAPTYPEMASK)
2227+#endif /* NO_CAPITALIZATION_SUPPORT */
2228+
2229+/*
2230+ * Language tables used to encode prefix and suffix information.
2231+ */
2232+struct flagent
2233+ {
2234+ ichar_t * strip; /* String to strip off */
2235+ ichar_t * affix; /* Affix to append */
2236+ short flagbit; /* Flag bit this ent matches */
2237+ short stripl; /* Length of strip */
2238+ short affl; /* Length of affix */
2239+ short numconds; /* Number of char conditions */
2240+ short flagflags; /* Modifiers on this flag */
2241+ char conds[SET_SIZE + MAXSTRINGCHARS]; /* Adj. char conds */
2242+ };
2243+
2244+/*
2245+ * Bits in flagflags
2246+ */
2247+#define FF_CROSSPRODUCT (1 << 0) /* Affix does cross-products */
2248+#define FF_COMPOUNDONLY (1 << 1) /* Afx works in compounds */
2249+
2250+union ptr_union /* Aid for building flg ptrs */
2251+ {
2252+ struct flagptr * fp; /* Pointer to more indexing */
2253+ struct flagent * ent; /* First of a list of ents */
2254+ };
2255+
2256+struct flagptr
2257+ {
2258+ union ptr_union pu; /* Ent list or more indexes */
2259+ int numents; /* If zero, pu.fp is valid */
2260+ };
2261+
2262+/*
2263+ * Description of a single string character type.
2264+ */
2265+struct strchartype
2266+ {
2267+ char * name; /* Name of the type */
2268+ char * deformatter; /* Deformatter to use */
2269+ char * suffixes; /* File suffixes, null seps */
2270+ };
2271+
2272+/*
2273+ * Header placed at the beginning of the hash file.
2274+ */
2275+struct hashheader
2276+ {
2277+ unsigned short magic; /* Magic number for ID */
2278+ unsigned short compileoptions; /* How we were compiled */
2279+ short maxstringchars; /* Max # strchrs we support */
2280+ short maxstringcharlen; /* Max strchr len supported */
2281+ short compoundmin; /* Min lth of compound parts */
2282+ short compoundbit; /* Flag 4 compounding roots */
2283+ unsigned int stringsize; /* Size of string table */
2284+ int lstringsize; /* Size of lang. str tbl */
2285+ unsigned int tblsize; /* No. entries in hash tbl */
2286+ int stblsize; /* No. entries in sfx tbl */
2287+ int ptblsize; /* No. entries in pfx tbl */
2288+ int sortval; /* Largest sort ID assigned */
2289+ int nstrchars; /* No. strchars defined */
2290+ int nstrchartype; /* No. strchar types */
2291+ int strtypestart; /* Start of strtype table */
2292+ char nrchars[5]; /* Nroff special characters */
2293+ char texchars[13]; /* TeX special characters */
2294+#define TeXleftparen texchars[0]
2295+#define TeXrightparen texchars[1]
2296+#define TeXleftsquare texchars[2]
2297+#define TeXrightsquare texchars[3]
2298+#define TeXleftcurly texchars[4]
2299+#define TeXrightcurly texchars[5]
2300+#define TeXlefttangle texchars[6]
2301+#define TeXrighttangle texchars[7]
2302+#define TeXbackslash texchars[8]
2303+#define TeXdollar texchars[9]
2304+#define TeXstar texchars[10]
2305+#define TeXdot texchars[11]
2306+#define TeXpercent texchars[12]
2307+ char compoundflag; /* Compund-word handling */
2308+ char defhardflag; /* Default tryveryhard flag */
2309+ char flagmarker; /* "Start-of-flags" char */
2310+ unsigned short sortorder[SET_SIZE + MAXSTRINGCHARS]; /* Sort ordering */
2311+ ichar_t lowerconv[SET_SIZE + MAXSTRINGCHARS]; /* Lower-conversion table */
2312+ ichar_t upperconv[SET_SIZE + MAXSTRINGCHARS]; /* Upper-conversion table */
2313+ char wordchars[SET_SIZE + MAXSTRINGCHARS]; /* NZ for chars found in wrds */
2314+ char upperchars[SET_SIZE + MAXSTRINGCHARS]; /* NZ for uppercase chars */
2315+ char lowerchars[SET_SIZE + MAXSTRINGCHARS]; /* NZ for lowercase chars */
2316+ char boundarychars[SET_SIZE + MAXSTRINGCHARS]; /* NZ for boundary chars */
2317+ char stringstarts[SET_SIZE]; /* NZ if char can start str */
2318+ char stringchars[MAXSTRINGCHARS][MAXSTRINGCHARLEN + 1]; /* String chars */
2319+ unsigned int stringdups[MAXSTRINGCHARS]; /* No. of "base" char */
2320+ int dupnos[MAXSTRINGCHARS]; /* Dup char ID # */
2321+ unsigned short magic2; /* Second magic for dbl chk */
2322+ };
2323+
2324+/* hash table magic number */
2325+#define SPELL_MAGIC 0x9602
2326+
2327+/* compile options, put in the hash header for consistency checking */
35c7515f
JB
2328+# define MAGICNOTUSED1 0x01
2329+# define MAGICNOTUSED2 0x02
24ec98f0
JB
2330+#if MASKBITS <= 32
2331+# define MAGICMASKSET 0x00
2332+#else
2333+# if MASKBITS <= 64
2334+# define MAGICMASKSET 0x04
2335+# else
2336+# if MASKBITS <= 128
2337+# define MAGICMASKSET 0x08
2338+# else
2339+# define MAGICMASKSET 0x0C
2340+# endif
2341+# endif
2342+#endif
2343+
35c7515f 2344+#define COMPILEOPTIONS (MAGICNOTUSED1 | MAGICNOTUSED2 | MAGICMASKSET)
24ec98f0
JB
2345+
2346+/*
2347+ * Structure used to record data about successful lookups; these values
2348+ * are used in the ins_root_cap routine to produce correct capitalizations.
2349+ */
2350+struct success
2351+ {
2352+ struct dent * dictent; /* Header of dict entry chain for wd */
2353+ struct flagent * prefix; /* Prefix flag used, or NULL */
2354+ struct flagent * suffix; /* Suffix flag used, or NULL */
2355+ };
2356+
2357+/*
2358+** Offsets into the nroff special-character array
2359+*/
2360+#define NRLEFTPAREN hashheader.nrchars[0]
2361+#define NRRIGHTPAREN hashheader.nrchars[1]
2362+#define NRDOT hashheader.nrchars[2]
2363+#define NRBACKSLASH hashheader.nrchars[3]
2364+#define NRSTAR hashheader.nrchars[4]
2365+
2366+/*
2367+** Values for compoundflag
2368+*/
2369+#define COMPOUND_NEVER 0 /* Compound words are never good */
2370+#define COMPOUND_ANYTIME 1 /* Accept run-together words */
2371+#define COMPOUND_CONTROLLED 2 /* Compounds controlled by afx flags */
2372+
2373+/*
2374+** The isXXXX macros normally only check ASCII range, and don't support
2375+** the character sets of other languages. These private versions handle
2376+** whatever character sets have been defined in the affix files.
2377+*/
2378+#define myupper(X) (hashheader.upperchars[(X)])
2379+#define mylower(X) (hashheader.lowerchars[(X)])
2380+#define myspace(X) (((X) > 0) && ((X) < 0x80) \
2381+ && isspace((unsigned char) (X)))
2382+#define iswordch(X) (hashheader.wordchars[(X)])
2383+#define isboundarych(X) (hashheader.boundarychars[(X)])
2384+#define isstringstart(X) (hashheader.stringstarts[(unsigned char) (X)])
2385+#define mytolower(X) (hashheader.lowerconv[(X)])
2386+#define mytoupper(X) (hashheader.upperconv[(X)])
2387+
2388+/*
2389+** These macros are similar to the ones above, but they take into account
2390+** the possibility of string characters. Note well that they take a POINTER,
2391+** not a character.
2392+**
2393+** The "l_" versions set "len" to the length of the string character as a
2394+** handy side effect. (Note that the global "laststringch" is also set,
2395+** and sometimes used, by these macros.)
2396+**
2397+** The "l1_" versions go one step further and guarantee that the "len"
2398+** field is valid for *all* characters, being set to 1 even if the macro
2399+** returns false. This macro is a great example of how NOT to write
2400+** readable C.
2401+*/
2402+#define isstringch(ptr, canon) (isstringstart (*(ptr)) \
2403+ && stringcharlen ((ptr), (canon)) > 0)
2404+#define l_isstringch(ptr, len, canon) \
2405+ (isstringstart (*(ptr)) \
2406+ && (len = stringcharlen ((ptr), (canon))) \
2407+ > 0)
2408+#define l1_isstringch(ptr, len, canon) \
2409+ (len = 1, \
2410+ isstringstart (*(ptr)) \
2411+ && ((len = \
2412+ stringcharlen ((ptr), (canon))) \
2413+ > 0 \
2414+ ? 1 : (len = 1, 0)))
2415+
2416+/*
2417+ * Sizes of buffers returned by ichartosstr/strtosichar.
2418+ */
2419+#define ICHARTOSSTR_SIZE (INPUTWORDLEN + 4 * MAXAFFIXLEN + 4)
2420+#define STRTOSICHAR_SIZE ((INPUTWORDLEN + 4 * MAXAFFIXLEN + 4) \
2421+ * sizeof (ichar_t))
2422+
2423+/*
2424+ * termcap variables
2425+ */
2426+#ifdef MAIN
2427+# define S_EXTERN /* nothing */
2428+#define Global
2429+#else
2430+#define Global extern
2431+# define S_EXTERN extern
2432+#endif
2433+
2434+#include "wm.h"
2435+
2436+
2437+S_EXTERN char * BC; /* backspace if not ^H */
2438+S_EXTERN char * cd; /* clear to end of display */
2439+S_EXTERN char * cl; /* clear display */
2440+S_EXTERN char * cm; /* cursor movement */
2441+S_EXTERN char * ho; /* home */
2442+S_EXTERN char * nd; /* non-destructive space */
2443+S_EXTERN char * so; /* standout */
2444+S_EXTERN char * se; /* standout end */
2445+S_EXTERN int sg; /* space taken by so/se */
2446+S_EXTERN char * ti; /* terminal initialization sequence */
2447+S_EXTERN char * te; /* terminal termination sequence */
2448+S_EXTERN int li; /* lines */
2449+S_EXTERN int co; /* columns */
2450+
2451+S_EXTERN int contextsize; /* number of lines of context to show */
2452+S_EXTERN char contextbufs[MAXCONTEXT][BUFSIZ]; /* Context of current line */
2453+S_EXTERN int contextoffset; /* Offset of line start in contextbufs[0] */
2454+S_EXTERN char * currentchar; /* Location in contextbufs */
2455+S_EXTERN char ctoken[INPUTWORDLEN + MAXAFFIXLEN]; /* Current token as char */
2456+S_EXTERN ichar_t itoken[INPUTWORDLEN + MAXAFFIXLEN]; /* Ctoken as ichar_t str */
2457+
2458+S_EXTERN char termcap[2048]; /* termcap entry */
2459+S_EXTERN char termstr[2048]; /* for string values */
2460+S_EXTERN char * termptr; /* pointer into termcap, used by tgetstr */
2461+
2462+S_EXTERN int numhits; /* number of hits in dictionary lookups */
2463+S_EXTERN struct success
2464+ hits[MAX_HITS]; /* table of hits gotten in lookup */
2465+
2466+S_EXTERN char * hashstrings; /* Strings in hash table */
2467+S_EXTERN struct hashheader
2468+ hashheader; /* Header of hash table */
2469+S_EXTERN struct dent *
2470+ hashtbl; /* Main hash table, for dictionary */
2471+S_EXTERN int hashsize; /* Size of main hash table */
2472+
2473+
2474+S_EXTERN int aflag; /* NZ if -a or -A option specified */
2475+S_EXTERN int cflag; /* NZ if -c (crunch) option */
2476+S_EXTERN int lflag; /* NZ if -l (list) option */
2477+S_EXTERN int incfileflag; /* whether xgets() acts exactly like gets() */
2478+Global Logical nodictflag; /* NZ if dictionary not needed */
2479+
2480+S_EXTERN int uerasechar; /* User's erase character, from stty */
2481+S_EXTERN int ukillchar; /* User's kill character */
2482+
2483+S_EXTERN unsigned int laststringch; /* Number of last string character */
2484+S_EXTERN int defdupchar; /* Default duplicate string type */
2485+
2486+S_EXTERN unsigned int numpflags; /* Number of prefix flags in table */
2487+S_EXTERN unsigned int numsflags; /* Number of suffix flags in table */
2488+S_EXTERN struct flagptr *pflagindex;
2489+ /* Fast index to pflaglist */
2490+S_EXTERN struct flagent *pflaglist; /* Prefix flag control list */
2491+S_EXTERN struct flagptr *sflagindex;
2492+ /* Fast index to sflaglist */
2493+S_EXTERN struct flagent *sflaglist; /* Suffix flag control list */
2494+
2495+S_EXTERN struct strchartype * /* String character type collection */
2496+ chartypes;
2497+
2498+S_EXTERN FILE * infile; /* File being corrected */
2499+S_EXTERN FILE * outfile; /* Corrected copy of infile */
2500+
2501+S_EXTERN char * askfilename; /* File specified in -f option */
2502+
2503+S_EXTERN int changes; /* NZ if changes made to cur. file */
2504+S_EXTERN int readonly; /* NZ if current file is readonly */
2505+S_EXTERN int quit; /* NZ if we're done with this file */
2506+
2507+#define MAXPOSSIBLE 100 /* Max no. of possibilities to generate */
2508+
2509+S_EXTERN char possibilities[MAXPOSSIBLE][INPUTWORDLEN + MAXAFFIXLEN];
2510+ /* Table of possible corrections */
2511+S_EXTERN int pcount; /* Count of possibilities generated */
2512+S_EXTERN int maxposslen; /* Length of longest possibility */
2513+S_EXTERN int easypossibilities; /* Number of "easy" corrections found */
2514+ /* ..(defined as those using legal affixes) */
2515+
2516+Global Logical inited;
2517+/*
2518+ * The following array contains a list of characters that should be tried
2519+ * in "missingletter." Note that lowercase characters are omitted.
2520+ */
2521+S_EXTERN int Trynum; /* Size of "Try" array */
2522+S_EXTERN ichar_t Try[SET_SIZE + MAXSTRINGCHARS];
2523+
2524+/*
2525+ * Initialized variables. These are generated using macros so that they
2526+ * may be consistently declared in all programs. Numerous examples of
2527+ * usage are given below.
2528+ */
2529+#ifdef MAIN
2530+#define S_INIT(decl, init) decl = init
2531+#else
2532+#define S_INIT(decl, init) extern decl
2533+#endif
2534+
2535+#ifdef MINIMENU
2536+S_INIT (int minimenusize, 2); /* MUST be either 2 or zero */
2537+#else /* MINIMENU */
2538+S_INIT (int minimenusize, 0); /* MUST be either 2 or zero */
2539+#endif /* MINIMENU */
2540+
2541+S_INIT (int eflag, 0); /* NZ for expand mode */
2542+S_INIT (int dumpflag, 0); /* NZ to do dump mode */
2543+S_INIT (int fflag, 0); /* NZ if -f specified */
2544+#ifndef USG
2545+S_INIT (int sflag, 0); /* NZ to stop self after EOF */
2546+#endif
2547+S_INIT (int vflag, 0); /* NZ to display characters as M-xxx */
2548+S_INIT (int xflag, DEFNOBACKUPFLAG); /* NZ to suppress backups */
2549+S_INIT (int deftflag, -1); /* NZ for TeX mode by default */
2550+S_INIT (int tflag, DEFTEXFLAG); /* NZ for TeX mode in current file */
2551+S_INIT (int prefstringchar, -1); /* Preferred string character type */
2552+
2553+S_INIT (int terse, 0); /* NZ for "terse" mode */
2554+
2555+S_INIT (char tempfile[MAXPATHLEN], ""); /* Name of file we're spelling into */
2556+
2557+S_INIT (int minword, MINWORD); /* Longest always-legal word */
2558+S_INIT (int sortit, 1); /* Sort suggestions alphabetically */
2559+S_INIT (int compoundflag, -1); /* How to treat compounds: see above */
2560+S_INIT (int tryhardflag, -1); /* Always call tryveryhard */
2561+
2562+S_INIT (char * currentfile, NULL); /* Name of current input file */
2563+
2564+/* Odd numbers for math mode in LaTeX; even for LR or paragraph mode */
2565+S_INIT (int math_mode, 0);
2566+/* P -- paragraph or LR mode
2567+ * b -- parsing a \begin statement
2568+ * e -- parsing an \end statement
2569+ * r -- parsing a \ref type of argument.
2570+ * m -- looking for a \begin{minipage} argument.
2571+ */
2572+S_INIT (char LaTeX_Mode, 'P');
2573+
2574+#include "i_proto.h"
0f1b3689
AG
2575diff -burN vim62.orig/src/spell/local.h vim62/src/spell/local.h
2576--- vim62.orig/src/spell/local.h 1970-01-01 01:00:00.000000000 +0100
2577+++ vim62/src/spell/local.h 2004-03-01 22:43:16.731880736 +0100
24ec98f0
JB
2578@@ -0,0 +1,338 @@
2579+/*
2580+ * Written by Eli Zaretskii <eliz@is.elta.co.il>
2581+ *
2582+ * This is local.h file suitable for compiling Ispell on MS-DOS systems
2583+ * with version 2.x of DJGPP port of GNU C/C++ compiler.
2584+ *
2585+ * $Id$
2586+ *
2587+ * $Log$
2588+ */
2589+
2590+/*
2591+ * WARNING WARNING WARNING
2592+ *
2593+ * This file is *NOT* a normal C header file! Although it uses C
2594+ * syntax and is included in C programs, it is also processed by shell
2595+ * scripts that are very stupid about format.
2596+ *
2597+ * Do not try to use #if constructs to configure this file for more
2598+ * than one configuration. Do not place whitespace after the "#" in
2599+ * "#define". Do not attempt to disable lines by commenting them out.
2600+ * Do not use backslashes to reduce the length of long lines.
2601+ * None of these things will work the way you expect them to.
2602+ *
2603+ * WARNING WARNING WARNING
2604+ */
2605+
2606+/*
2607+** Things that normally go in a Makefile. Define these just like you
2608+** might in the Makefile, except you should use #define instead of
2609+** make's assignment syntax. Everything must be double-quoted, and
2610+** (unlike make) you can't use any sort of $-syntax to pick up the
2611+** values of other definitions.
2612+*/
2613+
2614+#define CC "gcc"
2615+#define CFLAGS "-O2 -g"
2616+#define YACC "bison -y"
2617+
2618+/*
2619+** TERMLIB - DJGPP doesn't have one, it uses direct screen writes.
2620+*/
2621+#define TERMLIB ""
2622+
2623+/*
2624+** Where to install various components of ispell. BINDIR contains
2625+** binaries. LIBDIR contains hash tables and affix files. ELISPDIR
2626+** contains emacs lisp files (if any) and TEXINFODIR contains emacs
2627+** TeXinfo files. MAN1DIR and MAN1EXT will hold the chapter-1 and
2628+** chapter-4 manual pages, respectively.
2629+**
2630+** If you intend to use multiple dictionary files, I would suggest
2631+** LIBDIR be a directory which will contain nothing else, so sensible
2632+** names can be constructed for the -d option without conflict.
2633+*/
2634+#define BINDIR "/usr/bin"
2635+#define LIBDIR "/usr/lib/ispell"
2636+#define ELISPDIR "/usr/lib/emacs/site-lisp"
2637+#define TEXINFODIR "/usr/share/info"
2638+#define MAN1DIR "/usr/share/man/man1"
2639+#define MAN4DIR "/usr/share/man/man4"
2640+
2641+/*
2642+** List of all hash files (languages) which will be supported by ispell.
2643+**
2644+** This variable has a complex format so that many options can be
2645+** specified. The format is as follows:
2646+**
2647+** <language>[,<make-options>...] [<language> [,<make-options> ...] ...]
2648+**
2649+** where
2650+**
2651+** language is the name of a subdirectory of the
2652+** "languages" directory
2653+** make-options are options that are to be passed to "make" in
2654+** the specified directory. The make-options
2655+** should not, in general, specify a target, as
2656+** this will be provided by the make process.
2657+**
2658+** For example, if LANGUAGES is:
2659+**
2660+** "{american,EXTRADICT=/usr/dict/words /usr/dict/web2} {deutsch}",
2661+**
2662+** then the American-English and Deutsch (German) languages will be supported,
2663+** and when the English dictionary is built, the variable
2664+** 'EXTRADICT=/usr/dict/words /usr/dict/web2' will be passed to the makefile.
2665+**
2666+** Notes on the syntax: The makefile is not very robust. If you have
2667+** make problems, or if make seems to in the language-subdirs
2668+** dependency, check your syntax. The makefile adds single quotes to
2669+** the individual variables in the LANGUAGES specification, so don't
2670+** use quotes of any kind.
2671+**
2672+** In the future, the first language listed in this variable will
2673+** become the default, and the DEFHASH, DEFLANG, and DEFPAFF,
2674+** variables will all become obsolete. So be sure to put your default
2675+** language first, to make later conversion easier!
2676+**
2677+** Notes on options for the various languages will be found in the
2678+** Makefiles for those languages. Some of those languages may require
2679+** you to also change various limits limits like MASKBITS or the
2680+** length parameters.
2681+**
2682+** A special note on the English language: because the British and
2683+** American dialects use different spelling, you should usually select
2684+** one or the other of these. If you select both, the setting of
2685+** MASTERHASH will determine which becomes the language linked to
2686+** DEFHASH (which will usually be named english.hash).
2687+**
2688+** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2689+** !!! Note the pathname for the `words' file: it might be different !!!
2690+** !!! If you don't have this file, make EXTRADICT empty !!!
2691+** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2692+*/
2693+#define LANGUAGES "{american,MASTERDICTS=americax.med,HASHFILES=amermedx.hash,EXTRADICT=/usr/lib/ispell/words}"
2694+
2695+/*
2696+** Master hash file for DEFHASH. This is the name of a hash file
2697+** built by a language Makefile. It should be the most-popular hash
2698+** file on your system, because it is the one that will be used by
2699+** default. It must be listed in LANGUAGES, above.
2700+*/
2701+#define MASTERHASH "polish.hash"
2702+
2703+/*
2704+** Default native-language hash file. This is the name given to the
2705+** hash table that will be used if no language is specified to
2706+** ispell. It is a link to MASTERHASH, above.
2707+*/
2708+#define DEFHASH "polish.hash"
2709+
2710+/*
2711+** If your sort command accepts the -T switch to set temp file
2712+** locations (try it out; on some systems it exists but is
2713+** undocumented), make the following variable the null string.
2714+** Otherwise leave it as the sed script.
2715+**
2716+** With DJGPP, you will probably use GNU Sort which accepts -T, so:
2717+*/
2718+#define SORTTMP ""
2719+
2720+/*
2721+** If your system has the rename(2) system call, define HAS_RENAME and
2722+** ispell will use that call to rename backup files. Otherwise, it
2723+** will use link/unlink. There is no harm in this except on MS-DOS,
2724+** which might not support link/unlink (DJGPP does, but also has rename).
2725+*/
2726+#define HAS_RENAME 1
2727+
2728+/* environment variable for user's word list */
2729+#ifndef PDICTVAR
2730+#define PDICTVAR "WORDLIST"
2731+#endif
2732+
2733+/*
2734+** Prefix part of default private dictionary. Under MS-DOS 8.3
2735+** filename limitation, we are in trouble...
2736+*/
310b65f3 2737+#define DEFPDICT ".ispell_"
24ec98f0
JB
2738+
2739+/* old place to look for default word list */
2740+#define OLDPDICT ".isp."
2741+
2742+/*
2743+** mktemp template for temporary file - MUST contain 6 consecutive X's.
2744+** On MSDOS the directory part of TEMPNAME is only used if neither $TMP
2745+** nor $TEMP nor $TMPDIR (in that order) are defined. If any of these
2746+** variables is defined, the filename part of TEMPNAME is appended to
2747+** their value.
2748+*/
2749+#define TEMPNAME "/tmp/isXXXXXX"
2750+
2751+/*
2752+** If REGEX_LOOKUP is NOT defined, the lookup command (L) will use the look(1)
2753+** command (if available) or the egrep command. If REGEX_LOOKUP is defined,
2754+** the lookup command will use the internal dictionary and the
2755+** regular-expression library (which you must supply separately.
2756+** DJGPP v2 has POSIX regexp functions.
2757+*/
2758+#ifndef FEAT_SPELL_HL
2759+#define REGEX_LOOKUP 1
2760+#endif
2761+
2762+/*
2763+** Choose the proper type of regular-expression routines here. BSD
2764+** and public-domain systems have routines called re_comp and re_exec;
2765+** System V uses regcmp and regex.
2766+*/
2767+#include <sys/types.h>
2768+#include <regex.h>
2769+#define REGCTYPE regex_t *
2770+#define REGCMP(re,str) (regcomp (re, str, 0), re)
2771+#define REGEX(re, str, dummy) \
2772+ (re != 0 && regexec (re, str, 0, 0, 0) == 0 ? (char *)1 : NULL)
2773+#define REGFREE(re) \
2774+ do { \
2775+ if (re == 0) \
2776+ re = (regex_t *)calloc (1, sizeof (regex_t)); \
2777+ else \
2778+ regfree(re); \
2779+ } while (0)
2780+
2781+/*
2782+**
2783+** The 2 following definitions are only meaningfull if you don't use
2784+** any regex library.
2785+*/
2786+/* path to egrep (use speeded up version if available);
2787+ defined without explicit path, since there are no
2788+ standard places for programs on MS-DOS. */
2789+#define EGREPCMD "egrep -i"
2790+
2791+/* path to wordlist for Lookup command (typically /usr/dict/{words|web2}) */
2792+/* note that /usr/dict/web2 is usually a bad idea due to obscure words */
2793+#undef WORDS
2794+
2795+/*
2796+** FIXME: The filename truncation below is not flexible enough for DJGPP
2797+** which can support long filenames on some platforms, since we
2798+** will only know if the support is available at runtime.
2799+*/
2800+
2801+/* max file name length (will truncate to fit BAKEXT) if not in sys/param.h */
2802+#ifdef NAME_MAX
2803+#define MAXNAMLEN NAME_MAX
2804+#else
2805+#define MAXNAMLEN 12
2806+#endif
2807+
2808+#define MAXEXTLEN 4 /* max. extension length including '.' */
2809+#define MAXBASENAMELEN 8 /* max. base filename length without ext */
2810+
2811+/* define if you want .bak file names truncated to MAXNAMLEN characters */
2812+/* On MS-DOS, we really have no choice... */
2813+#define TRUNCATEBAK 1
2814+
2815+/*
2816+** This is the extension that will be added to backup files.
2817+** On MS-DOS, it makes sense to use the shortest possible extension.
2818+*/
2819+#define BAKEXT "~"
2820+
2821+/*
2822+** Define the following to suppress the 8-bit character feature.
2823+** FIXME: does this defeat support of foreign languages?
2824+*/
2825+/*#define NO8BIT 1 */
2826+#ifdef NO8BIT
2827+#undef NO8BIT
2828+#endif
2829+
2830+/*
2831+** Define this if you want to use the shell for interpretation of commands
2832+** issued via the "L" command, "^Z" under System V, and "!". If this is
2833+** not defined then a direct spawnvp() will be used in place of the
2834+** normal system(). This may speed up these operations if the SHELL
2835+** environment variable points to a Unix-like shell (such as `sh' or `bash').
2836+**
2837+** However, if you undefine USESH, commands which use pipes, redirection
2838+** and shell wildcards won't work, and you will need support for the SIGTSTP
2839+** signal, for the above commands to work at all.
2840+*/
2841+
2842+#define USESH 1
2843+
2844+/*
2845+** Define this if you want to be able to type any command at a "type space
2846+** to continue" prompt.
2847+*/
2848+#define COMMANDFORSPACE 1
2849+
2850+/*
2851+** The next three variables are used to provide a variable-size context
2852+** display at the bottom of the screen. Normally, the user will see
2853+** a number of lines equal to CONTEXTPCT of his screen, rounded down
2854+** (thus, with CONTEXTPCT == 10, a 24-line screen will produce two lines
2855+** of context). The context will never be greater than MAXCONTEXT or
2856+** less than MINCONTEXT. To disable this feature entirely, set MAXCONTEXT
2857+** and MINCONTEXT to the same value. To round context percentages up,
2858+** define CONTEXTROUNDUP.
2859+**
2860+** Warning: don't set MAXCONTEXT ridiculously large. There is a
2861+** static buffer of size MAXCONTEXT*BUFSIZ; since BUFSIZ is frequently
2862+** 1K or larger, this can create a remarkably large executable.
2863+*/
2864+#define CONTEXTPCT 20 /* Use 20% of the screen for context */
2865+#define MINCONTEXT 2 /* Always show at least 2 lines of context */
2866+#define MAXCONTEXT 10 /* Never show more than 10 lines of context */
2867+#define CONTEXTROUNDUP 1 /* Round context up */
2868+
2869+/*
2870+** Define this if you want the "mini-menu," which gives the most important
2871+** options at the bottom of the screen, to be the default (in any case, it
2872+** can be controlled with the "-M" switch).
2873+*/
2874+#define MINIMENU
2875+
2876+/*
2877+** Redefine GETKEYSTROKE() to whatever appropriate on some MS-DOS systems
2878+** where getchar() doesn't operate properly in raw mode.
2879+*/
2880+#ifdef __DJGPP__
2881+#include <pc.h>
2882+#include <keys.h>
2883+#define GETKEYSTROKE() getxkey()
2884+#else
2885+#define GETKEYSTROKE() getchar()
2886+#endif
2887+
2888+/*
2889+** We include <fcntl.h> to have the definition of O_BINARY. The
2890+** configuration script will notice this and define MSDOS_BINARY_OPEN.
2891+*/
2892+#include <fcntl.h>
2893+
2894+/*
2895+** Environment variable to use to locate the home directory. On DOS
2896+** systems we set this to ISPELL_HOME to avoid conflicts with
8f3725c8 2897+** other programs that look for a HOME environment variable. We're not on DOS.
24ec98f0 2898+*/
8f3725c8 2899+#define HOME "HOME"
24ec98f0
JB
2900+#define PDICTHOME "."
2901+#define OPTIONVAR "ISPELL_OPTIONS"
2902+#define LIBRARYVAR "ISPELL_DICTDIR"
2903+
2904+/*
2905+** On MS-DOS systems, we define the following variables so that
2906+** ispell's files have legal suffixes. Note that these suffixes
2907+** must agree with the way you've defined dictionary files which
2908+** incorporate these suffixes.
2909+**
2910+** Actually, it is not recommended at all to change the suffixes,
2911+** since they are hardwired in the Makefile's under languages/
2912+** subdirectory, and MS-DOS will silently truncate excess letters anyway.
2913+*/
2914+#define HASHSUFFIX ".hash"
2915+#define STATSUFFIX ".sta"
2916+#define COUNTSUFFIX ".cnt"
0f1b3689
AG
2917diff -burN vim62.orig/src/spell/lookup.c vim62/src/spell/lookup.c
2918--- vim62.orig/src/spell/lookup.c 1970-01-01 01:00:00.000000000 +0100
2919+++ vim62/src/spell/lookup.c 2004-03-01 22:43:16.734880280 +0100
24ec98f0
JB
2920@@ -0,0 +1,534 @@
2921+#ifndef lint
2922+static char Rcs_Id[] =
2923+ "$Id$";
2924+#endif
2925+
2926+/*
2927+ * lookup.c - see if a word appears in the dictionary
2928+ *
2929+ * Pace Willisson, 1983
2930+ *
2931+ * Copyright 1987, 1988, 1989, 1992, 1993, Geoff Kuenning, Granada Hills, CA
2932+ * All rights reserved.
2933+ *
2934+ * Redistribution and use in source and binary forms, with or without
2935+ * modification, are permitted provided that the following conditions
2936+ * are met:
2937+ *
2938+ * 1. Redistributions of source code must retain the above copyright
2939+ * notice, this list of conditions and the following disclaimer.
2940+ * 2. Redistributions in binary form must reproduce the above copyright
2941+ * notice, this list of conditions and the following disclaimer in the
2942+ * documentation and/or other materials provided with the distribution.
2943+ * 3. All modifications to the source code must be clearly marked as
2944+ * such. Binary redistributions based on modified source code
2945+ * must be clearly marked as modified versions in the documentation
2946+ * and/or other materials provided with the distribution.
2947+ * 4. All advertising materials mentioning features or use of this software
2948+ * must display the following acknowledgment:
2949+ * This product includes software developed by Geoff Kuenning and
2950+ * other unpaid contributors.
2951+ * 5. The name of Geoff Kuenning may not be used to endorse or promote
2952+ * products derived from this software without specific prior
2953+ * written permission.
2954+ *
2955+ * THIS SOFTWARE IS PROVIDED BY GEOFF KUENNING AND CONTRIBUTORS ``AS IS'' AND
2956+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2957+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2958+ * ARE DISCLAIMED. IN NO EVENT SHALL GEOFF KUENNING OR CONTRIBUTORS BE LIABLE
2959+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2960+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2961+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2962+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2963+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2964+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2965+ * SUCH DAMAGE.
2966+ */
2967+
2968+/*
2969+ * $Log$
2970+ * Revision 1.42 1995/01/08 23:23:42 geoff
2971+ * Support MSDOS_BINARY_OPEN when opening the hash file to read it in.
2972+ *
2973+ * Revision 1.41 1994/01/25 07:11:51 geoff
2974+ * Get rid of all old RCS log lines in preparation for the 3.1 release.
2975+ *
2976+ */
2977+
2978+#include "ispell.h"
2979+#include "msgs.h"
2980+#include <stdlib.h>
2981+#include <fcntl.h>
2982+#ifdef WIN32
2983+#include <io.h>
2984+#endif
2985+
2986+#ifdef INDEXDUMP
2987+Local void dumpindex (struct flagptr * indexp, int depth);
2988+#endif /* INDEXDUMP */
2989+
2990+Public Logical inited = False;
2991+
2992+char err_buf[256];
2993+
2994+Public char *
2995+linit (char * hashname)
2996+{
2997+ int hashfd;
2998+ register int i;
2999+ register struct dent * dp;
3000+ struct flagent * entry;
3001+ struct flagptr * ind;
3002+ int nextchar;
3003+ int viazero;
3004+ register ichar_t * cp;
3005+
3006+ if (inited)
3007+ return(NULL);
3008+
3009+ if(hashtbl != NULL)
3010+ free(hashtbl);
3011+ numpflags = 0;
3012+ numsflags = 0;
3013+ if(pflagindex != NULL)
3014+ free(pflagindex);
3015+ pflagindex = NULL;
3016+ if(sflagindex != NULL)
3017+ free(sflagindex);
3018+ sflagindex = NULL;
3019+ if((pflagindex = (struct flagptr *)calloc(SET_SIZE + MAXSTRINGCHARS,
3020+ sizeof(struct flagptr))) == NULL)
3021+ {
3022+ (void) sprintf(err_buf, LOOKUP_C_NO_HASH_SPACE);
3023+ return(err_buf);
3024+ }
3025+ if((sflagindex = (struct flagptr *)calloc(SET_SIZE + MAXSTRINGCHARS,
3026+ sizeof(struct flagptr))) == NULL)
3027+ {
3028+ (void) sprintf(err_buf, LOOKUP_C_NO_HASH_SPACE);
3029+ return(err_buf);
3030+ }
3031+ hashtbl = NULL;
3032+ if ((hashfd = open (hashname, 0 | MSDOS_BINARY_OPEN)) < 0)
3033+ {
3034+ (void) sprintf(err_buf, CANT_OPEN, hashname);
3035+ return(err_buf);
3036+ }
3037+
3038+ hashsize = read (hashfd, (char *) &hashheader, sizeof hashheader);
3039+ if (hashsize < sizeof hashheader)
3040+ {
3041+ if (hashsize < 0)
3042+ (void) sprintf(err_buf, LOOKUP_C_CANT_READ, hashname);
3043+ else if (hashsize == 0)
3044+ (void) sprintf(err_buf, LOOKUP_C_NULL_HASH, hashname);
3045+ else
3046+ (void) sprintf(err_buf, LOOKUP_C_SHORT_HASH (hashname, hashsize,
3047+ (int) sizeof hashheader));
3048+ (void) close (hashfd);
3049+ return(err_buf);
3050+ }
3051+ else if (hashheader.magic != SPELL_MAGIC)
3052+ {
3053+ (void) sprintf(err_buf,
3054+ LOOKUP_C_BAD_MAGIC (hashname, (unsigned int) SPELL_MAGIC,
3055+ (unsigned int) hashheader.magic));
3056+ (void) close (hashfd);
3057+ return(err_buf);
3058+ }
3059+ else if (hashheader.magic2 != SPELL_MAGIC)
3060+ {
3061+ (void) sprintf(err_buf,
3062+ LOOKUP_C_BAD_MAGIC2 (hashname, (unsigned int) SPELL_MAGIC,
3063+ (unsigned int) hashheader.magic2));
3064+ (void) close (hashfd);
3065+ return(err_buf);
3066+ }
3067+ else if (hashheader.compileoptions != COMPILEOPTIONS
3068+ || hashheader.maxstringchars != MAXSTRINGCHARS
3069+ || hashheader.maxstringcharlen != MAXSTRINGCHARLEN)
3070+ {
3071+ (void) sprintf(err_buf,
3072+ LOOKUP_C_BAD_OPTIONS ((unsigned int) hashheader.compileoptions,
3073+ hashheader.maxstringchars, hashheader.maxstringcharlen,
3074+ (unsigned int) COMPILEOPTIONS, MAXSTRINGCHARS, MAXSTRINGCHARLEN));
3075+ (void) close (hashfd);
3076+ return(err_buf);
3077+ }
3078+ if (nodictflag)
3079+ {
3080+ /*
3081+ * Dictionary is not needed - create an empty dummy table. We
3082+ * actually have to have one entry since the hash
3083+ * algorithm involves a divide by the table size
3084+ * (actually modulo, but zero is still unacceptable).
3085+ * So we create an empty entry.
3086+ */
3087+ hashsize = 1; /* This prevents divides by zero */
3088+ hashtbl = (struct dent *) calloc (1, sizeof (struct dent));
3089+ if (hashtbl == NULL)
3090+ {
3091+ (void) sprintf(err_buf, LOOKUP_C_NO_HASH_SPACE);
3092+ (void) close (hashfd);
3093+ return(err_buf);
3094+ }
3095+ hashtbl[0].word = NULL;
3096+ hashtbl[0].next = NULL;
3097+ hashtbl[0].flagfield &= ~(USED | KEEP);
3098+ /* The flag bits don't matter, but calloc cleared them. */
3099+ if(hashstrings != NULL)
3100+ free(hashstrings);
3101+ if((hashstrings = (char *) calloc (1, (unsigned) hashheader.lstringsize))
3102+ == NULL)
3103+ {
3104+ (void) sprintf(err_buf, LOOKUP_C_NO_HASH_SPACE);
3105+ (void) close (hashfd);
3106+ return(err_buf);
3107+ }
3108+ }
3109+ else
3110+ {
3111+ if(hashtbl != NULL)
3112+ free(hashtbl);
3113+ if((hashtbl = (struct dent *)
3114+ malloc ((unsigned) hashheader.tblsize * sizeof (struct dent))) == NULL)
3115+ {
3116+ (void) sprintf(err_buf, LOOKUP_C_NO_HASH_SPACE);
3117+ (void) close (hashfd);
3118+ return(err_buf);
3119+ }
3120+ hashsize = hashheader.tblsize;
3121+ if(hashstrings != NULL)
3122+ free(hashstrings);
3123+ if((hashstrings = (char *) malloc ((unsigned) hashheader.stringsize)) == NULL)
3124+ {
3125+ (void) sprintf(err_buf, LOOKUP_C_NO_HASH_SPACE);
3126+ (void) close (hashfd);
3127+ return(err_buf);
3128+ }
3129+ }
3130+ numsflags = hashheader.stblsize;
3131+ numpflags = hashheader.ptblsize;
3132+ if(sflaglist != NULL)
3133+ free(sflaglist);
3134+ if((sflaglist = (struct flagent *)
3135+ malloc ((numsflags + numpflags) * sizeof (struct flagent))) == NULL)
3136+ {
3137+ (void) sprintf(err_buf, LOOKUP_C_NO_HASH_SPACE);
3138+ (void) close (hashfd);
3139+ return(err_buf);
3140+ }
3141+ pflaglist = sflaglist + numsflags;
3142+
3143+ if (nodictflag)
3144+ {
3145+ /*
3146+ * Read just the strings for the language table, and
3147+ * skip over the rest of the strings and all of the
3148+ * hash table.
3149+ */
3150+ if (read (hashfd, hashstrings, (unsigned) hashheader.lstringsize)
3151+ != hashheader.lstringsize)
3152+ {
3153+ (void) sprintf(err_buf, LOOKUP_C_BAD_FORMAT);
3154+ (void) close (hashfd);
3155+ return(err_buf);
3156+ }
3157+ (void) lseek (hashfd,
3158+ (long) hashheader.stringsize - (long) hashheader.lstringsize
3159+ + (long) hashheader.tblsize * (long) sizeof (struct dent), 1);
3160+ }
3161+ else
3162+ {
3163+ if ((unsigned int)read (hashfd, hashstrings,
3164+ (unsigned int) hashheader.stringsize) != hashheader.stringsize
3165+ || (unsigned int)read (hashfd, (char *) hashtbl, (unsigned)
3166+ hashheader.tblsize * sizeof (struct dent))
3167+ != (unsigned int) hashheader.tblsize * sizeof (struct dent))
3168+ {
3169+ (void) sprintf(err_buf, LOOKUP_C_BAD_FORMAT);
3170+ (void) close (hashfd);
3171+ return(err_buf);
3172+ }
3173+ }
3174+ if ((unsigned int)read (hashfd, (char *) sflaglist,
3175+ (unsigned int) (numsflags + numpflags) * sizeof (struct flagent))
3176+ != (unsigned int)(numsflags + numpflags) * sizeof (struct flagent))
3177+ {
3178+ (void) sprintf(err_buf, LOOKUP_C_BAD_FORMAT);
3179+ (void) close (hashfd);
3180+ return(err_buf);
3181+ }
3182+ (void) close (hashfd);
3183+
3184+ if (!nodictflag)
3185+ {
3186+ for (i = hashsize, dp = hashtbl; --i >= 0; dp++)
3187+ {
3188+ if (dp->word == (char *) -1)
3189+ dp->word = NULL;
3190+ else
3191+ dp->word = &hashstrings [ (int)(dp->word) ];
3192+ if (dp->next == (struct dent *) -1)
3193+ dp->next = NULL;
3194+ else
3195+ dp->next = &hashtbl [ (int)(dp->next) ];
3196+ }
3197+ }
3198+
3199+ for (i = numsflags + numpflags, entry = sflaglist; --i >= 0; entry++)
3200+ {
3201+ if (entry->stripl)
3202+ entry->strip = (ichar_t *) &hashstrings[(int) entry->strip];
3203+ else
3204+ entry->strip = NULL;
3205+ if (entry->affl)
3206+ entry->affix = (ichar_t *) &hashstrings[(int) entry->affix];
3207+ else
3208+ entry->affix = NULL;
3209+ }
3210+ /*
3211+ ** Warning - 'entry' and 'i' are reset in the body of the loop
3212+ ** below. Don't try to optimize it by (e.g.) moving the decrement
3213+ ** of i into the loop condition.
3214+ */
3215+ for (i = numsflags, entry = sflaglist; i > 0; i--, entry++)
3216+ {
3217+ if (entry->affl == 0)
3218+ {
3219+ cp = NULL;
3220+ ind = &sflagindex[0];
3221+ viazero = 1;
3222+ }
3223+ else
3224+ {
3225+ cp = entry->affix + entry->affl - 1;
3226+ ind = &sflagindex[*cp];
3227+ viazero = 0;
3228+ while (ind->numents == 0 && ind->pu.fp != NULL)
3229+ {
3230+ if (cp == entry->affix)
3231+ {
3232+ ind = &ind->pu.fp[0];
3233+ viazero = 1;
3234+ }
3235+ else
3236+ {
3237+ ind = &ind->pu.fp[*--cp];
3238+ viazero = 0;
3239+ }
3240+ }
3241+ }
3242+ if (ind->numents == 0)
3243+ ind->pu.ent = entry;
3244+ ind->numents++;
3245+ /*
3246+ ** If this index entry has more than MAXSEARCH flags in
3247+ ** it, we will split it into subentries to reduce the
3248+ ** searching. However, the split doesn't make sense in
3249+ ** two cases: (a) if we are already at the end of the
3250+ ** current affix, or (b) if all the entries in the list
3251+ ** have identical affixes. Since the list is sorted, (b)
3252+ ** is true if the first and last affixes in the list
3253+ ** are identical.
3254+ */
3255+ if (!viazero && ind->numents >= MAXSEARCH &&
3256+ icharcmp (entry->affix, ind->pu.ent->affix) != 0)
3257+ {
3258+ /* Sneaky trick: back up and reprocess */
3259+ entry = ind->pu.ent - 1; /* -1 is for entry++ in loop */
3260+ i = numsflags - (entry - sflaglist);
3261+ if((ind->pu.fp = (struct flagptr *)
3262+ calloc ((unsigned) (SET_SIZE + hashheader.nstrchars),
3263+ sizeof (struct flagptr))) == NULL)
3264+ {
3265+ (void) sprintf(err_buf, LOOKUP_C_NO_LANG_SPACE);
3266+ return(err_buf);
3267+ }
3268+ ind->numents = 0;
3269+ }
3270+ }
3271+ /*
3272+ ** Warning - 'entry' and 'i' are reset in the body of the loop
3273+ ** below. Don't try to optimize it by (e.g.) moving the decrement
3274+ ** of i into the loop condition.
3275+ */
3276+ for (i = numpflags, entry = pflaglist; i > 0; i--, entry++)
3277+ {
3278+ if (entry->affl == 0)
3279+ {
3280+ cp = NULL;
3281+ ind = &pflagindex[0];
3282+ viazero = 1;
3283+ }
3284+ else
3285+ {
3286+ cp = entry->affix;
3287+ ind = &pflagindex[*cp++];
3288+ viazero = 0;
3289+ while (ind->numents == 0 && ind->pu.fp != NULL)
3290+ {
3291+ if (*cp == 0)
3292+ {
3293+ ind = &ind->pu.fp[0];
3294+ viazero = 1;
3295+ }
3296+ else
3297+ {
3298+ ind = &ind->pu.fp[*cp++];
3299+ viazero = 0;
3300+ }
3301+ }
3302+ }
3303+ if (ind->numents == 0)
3304+ ind->pu.ent = entry;
3305+ ind->numents++;
3306+ /*
3307+ ** If this index entry has more than MAXSEARCH flags in
3308+ ** it, we will split it into subentries to reduce the
3309+ ** searching. However, the split doesn't make sense in
3310+ ** two cases: (a) if we are already at the end of the
3311+ ** current affix, or (b) if all the entries in the list
3312+ ** have identical affixes. Since the list is sorted, (b)
3313+ ** is true if the first and last affixes in the list
3314+ ** are identical.
3315+ */
3316+ if (!viazero && ind->numents >= MAXSEARCH
3317+ && icharcmp (entry->affix, ind->pu.ent->affix) != 0)
3318+ {
3319+ /* Sneaky trick: back up and reprocess */
3320+ entry = ind->pu.ent - 1; /* -1 is for entry++ in loop */
3321+ i = numpflags - (entry - pflaglist);
3322+ ind->pu.fp =
3323+ (struct flagptr *) calloc (SET_SIZE + hashheader.nstrchars,
3324+ sizeof (struct flagptr));
3325+ if (ind->pu.fp == NULL)
3326+ {
3327+ (void) sprintf(err_buf, LOOKUP_C_NO_LANG_SPACE);
3328+ return(err_buf);
3329+ }
3330+ ind->numents = 0;
3331+ }
3332+ }
3333+#ifdef INDEXDUMP
3334+ (void) sprintf(err_buf, "Prefix index table:");
3335+ dumpindex (pflagindex, 0);
3336+ (void) sprintf(err_buf, "Suffix index table:");
3337+ dumpindex (sflagindex, 0);
3338+#endif
3339+ if (hashheader.nstrchartype == 0)
3340+ chartypes = NULL;
3341+ else
3342+ {
3343+ chartypes = (struct strchartype *)
3344+ calloc (1, hashheader.nstrchartype * sizeof (struct strchartype));
3345+ if (chartypes == NULL)
3346+ {
3347+ (void) sprintf(err_buf, LOOKUP_C_NO_LANG_SPACE);
3348+ return(err_buf);
3349+ }
3350+ for (i = 0, nextchar = hashheader.strtypestart;
3351+ i < hashheader.nstrchartype; i++)
3352+ {
3353+ chartypes[i].name = &hashstrings[nextchar];
3354+ nextchar += strlen (chartypes[i].name) + 1;
3355+ chartypes[i].deformatter = &hashstrings[nextchar];
3356+ nextchar += strlen (chartypes[i].deformatter) + 1;
3357+ chartypes[i].suffixes = &hashstrings[nextchar];
3358+ while (hashstrings[nextchar] != '\0')
3359+ nextchar += strlen (&hashstrings[nextchar]) + 1;
3360+ nextchar++;
3361+ }
3362+ }
3363+ inited = True;
3364+ return (NULL);
3365+}
3366+
3367+#ifdef INDEXDUMP
3368+Local void
3369+dumpindex (
3370+ register struct flagptr * indexp,
3371+ register int depth)
3372+{
3373+ register int i;
3374+ int j;
3375+ int k;
3376+ char stripbuf[INPUTWORDLEN + 4 * MAXAFFIXLEN + 4];
3377+
3378+ for (i = 0; i < SET_SIZE + hashheader.nstrchars; i++, indexp++)
3379+ {
3380+ if (indexp->numents == 0 && indexp->pu.fp != NULL)
3381+ {
3382+ for (j = depth; --j >= 0; )
3383+ (void) putc (' ', stderr);
3384+ if (i >= ' ' && i <= '~')
3385+ (void) putc (i, stderr);
3386+ else
3387+ (void) fprintf (stderr, "0x%x", i);
3388+ (void) putc ('\n', stderr);
3389+ dumpindex (indexp->pu.fp, depth + 1);
3390+ }
3391+ else if (indexp->numents)
3392+ {
3393+ for (j = depth; --j >= 0; )
3394+ (void) putc (' ', stderr);
3395+ if (i >= ' ' && i <= '~')
3396+ (void) putc (i, stderr);
3397+ else
3398+ (void) fprintf (stderr, "0x%x", i);
3399+ (void) fprintf (stderr, " -> %d entries\n", indexp->numents);
3400+ for (k = 0; k < indexp->numents; k++)
3401+ {
3402+ for (j = depth; --j >= 0; )
3403+ (void) putc (' ', stderr);
3404+ if (indexp->pu.ent[k].stripl)
3405+ {
3406+ (void) ichartostr (stripbuf, indexp->pu.ent[k].strip,
3407+ sizeof stripbuf, 1);
3408+ (void) fprintf (stderr, " entry %d (-%s,%s)\n",
3409+ &indexp->pu.ent[k] - sflaglist,
3410+ stripbuf,
3411+ indexp->pu.ent[k].affl
3412+ ? ichartosstr (indexp->pu.ent[k].affix, 1) : "-");
3413+ }
3414+ else
3415+ (void) fprintf (stderr, " entry %d (%s)\n",
3416+ &indexp->pu.ent[k] - sflaglist,
3417+ ichartosstr (indexp->pu.ent[k].affix, 1));
3418+ }
3419+ }
3420+ }
3421+}
3422+#endif
3423+
3424+/* n is length of s */
3425+Public struct dent *
3426+lookup (register ichar_t *s, int dotree)
3427+
3428+{
3429+ register struct dent * dp;
3430+ register char * s1;
3431+ char schar[INPUTWORDLEN + MAXAFFIXLEN];
3432+
3433+ dp = &hashtbl[hash (s, hashsize)];
3434+ if (ichartostr (schar, s, sizeof schar, 1))
3435+ (void) fprintf (stderr, WORD_TOO_LONG (schar));
3436+ for ( ; dp != NULL; dp = dp->next)
3437+ {
3438+ /* quick strcmp, but only for equality */
3439+ s1 = dp->word;
3440+ if (s1 && s1[0] == schar[0] && strcmp (s1 + 1, schar + 1) == 0)
3441+ return dp;
3442+#ifndef NO_CAPITALIZATION_SUPPORT
3443+ while (dp->flagfield & MOREVARIANTS) /* Skip variations */
3444+ dp = dp->next;
3445+#endif
3446+ }
3447+ if (dotree)
3448+ {
3449+ dp = treelookup (s);
3450+ return dp;
3451+ }
3452+ else
3453+ return NULL;
3454+}
0f1b3689
AG
3455diff -burN vim62.orig/src/spell/makedent.c vim62/src/spell/makedent.c
3456--- vim62.orig/src/spell/makedent.c 1970-01-01 01:00:00.000000000 +0100
3457+++ vim62/src/spell/makedent.c 2004-03-01 22:43:16.755877088 +0100
24ec98f0
JB
3458@@ -0,0 +1,1107 @@
3459+/*
3460+ * Copyright 1988, 1989, 1992, 1993, Geoff Kuenning, Granada Hills, CA
3461+ * All rights reserved.
3462+ *
3463+ * Redistribution and use in source and binary forms, with or without
3464+ * modification, are permitted provided that the following conditions
3465+ * are met:
3466+ *
3467+ * 1. Redistributions of source code must retain the above copyright
3468+ * notice, this list of conditions and the following disclaimer.
3469+ * 2. Redistributions in binary form must reproduce the above copyright
3470+ * notice, this list of conditions and the following disclaimer in the
3471+ * documentation and/or other materials provided with the distribution.
3472+ * 3. All modifications to the source code must be clearly marked as
3473+ * such. Binary redistributions based on modified source code
3474+ * must be clearly marked as modified versions in the documentation
3475+ * and/or other materials provided with the distribution.
3476+ * 4. All advertising materials mentioning features or use of this software
3477+ * must display the following acknowledgment:
3478+ * This product includes software developed by Geoff Kuenning and
3479+ * other unpaid contributors.
3480+ * 5. The name of Geoff Kuenning may not be used to endorse or promote
3481+ * products derived from this software without specific prior
3482+ * written permission.
3483+ *
3484+ * THIS SOFTWARE IS PROVIDED BY GEOFF KUENNING AND CONTRIBUTORS ``AS IS'' AND
3485+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3486+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3487+ * ARE DISCLAIMED. IN NO EVENT SHALL GEOFF KUENNING OR CONTRIBUTORS BE LIABLE
3488+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3489+ * DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3490+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3491+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3492+ * LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3493+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3494+ * SUCH DAMAGE.
3495+ */
3496+
3497+/*
3498+ * $Log$
3499+ * Revision 1.45 1994/12/27 23:08:52 geoff
3500+ * Add code to makedent to reject words that contain non-word characters.
3501+ * This helps protect people who use ISO 8-bit characters when ispell
3502+ * isn't configured for that option.
3503+ *
3504+ * Revision 1.44 1994/10/25 05:46:20 geoff
3505+ * Fix some incorrect declarations in the lint versions of some routines.
3506+ *
3507+ * Revision 1.43 1994/09/16 03:32:34 geoff
3508+ * Issue an error message for bad affix flags
3509+ *
3510+ * Revision 1.42 1994/02/07 04:23:43 geoff
3511+ * Correctly identify the deformatter when changing file types
3512+ *
3513+ * Revision 1.41 1994/01/25 07:11:55 geoff
3514+ * Get rid of all old RCS log lines in preparation for the 3.1 release.
3515+ *
3516+ */
3517+
3518+#include "ispell.h"
3519+#include <stdlib.h>
3520+#include "msgs.h"
3521+
3522+Global int makedent(char * lbuf, int lbuflen, struct dent * ent);
3523+#ifndef NO_CAPITALIZATION_SUPPORT
3524+Global long whatcap(ichar_t * word);
3525+#endif
3526+Global int addvheader(struct dent * ent);
3527+Global int combinecaps(struct dent * hdr, struct dent * newent);
3528+#ifndef NO_CAPITALIZATION_SUPPORT
3529+Local void forcevheader(struct dent * hdrp, struct dent * oldp,
3530+ struct dent * newp);
3531+#endif /* NO_CAPITALIZATION_SUPPORT */
3532+Local int combine_two_entries(struct dent * hdrp,
3533+ struct dent * oldp, struct dent * newp);
3534+Local int acoversb(struct dent * enta, struct dent * entb);
3535+Global void upcase(ichar_t * string);
3536+Global void lowcase(ichar_t * string);
3537+Global void chupcase(char * s);
3538+Local int issubset(struct dent * ent1, struct dent * ent2);
3539+Local void combineaffixes(struct dent * ent1, struct dent * ent2);
3540+Global void toutent(FILE * outfile, struct dent * hent, int onlykeep);
3541+Local void toutword(FILE * outfile, char * word, struct dent * cent);
3542+Local void flagout(FILE * outfile, int flag);
3543+Global int stringcharlen(char * bufp, int canonical);
3544+Global int strtoichar(ichar_t * out, char * in, int outlen,
3545+ int canonical);
3546+Global int ichartostr(char * out, ichar_t * in, int outlen,
3547+ int canonical);
3548+Global ichar_t * strtosichar(char * in, int canonical);
3549+Global char * ichartosstr(ichar_t * in, int canonical);
3550+Global char * printichar(int in);
3551+#ifndef ICHAR_IS_CHAR
3552+Global ichar_t * icharcpy(ichar_t * out, ichar_t * in);
3553+Global int icharlen(ichar_t * str);
3554+Global int icharcmp(ichar_t * s1, ichar_t * s2);
3555+Global int icharncmp(ichar_t * s1, ichar_t * s2, int n);
3556+#endif /* ICHAR_IS_CHAR */
3557+Global int findfiletype(char * name, int searchnames,
3558+ int * deformatter);
3559+
3560+Local Logical has_marker;
3561+
3562+/*
3563+ * Fill in a directory entry, including setting the capitalization flags, and
3564+ * allocate and initialize memory for the d->word field. Returns -1
3565+ * if there was trouble. The input word must be in canonical form.
3566+ */
3567+
3568+Public int
3569+makedent(
3570+ char * lbuf,
3571+ int lbuflen,
3572+ struct dent * d)
3573+{
3574+ ichar_t ibuf[INPUTWORDLEN + MAXAFFIXLEN];
3575+ ichar_t * ip;
3576+ char * p;
3577+ int bit;
3578+ int len;
3579+
3580+ /* Strip off any trailing newline */
3581+ len = strlen(lbuf) - 1;
3582+ if(lbuf[len] == '\n')
3583+ lbuf[len] = '\0';
3584+
3585+ d->next = NULL;
3586+ /* WARNING: flagfield might be the same as mask! See ispell.h. */
3587+ d->flagfield = 0;
3588+ (void) bzero ((char *) d->mask, sizeof (d->mask));
3589+ d->flagfield |= USED;
3590+ d->flagfield &= ~KEEP;
3591+
3592+ p = index(lbuf, hashheader.flagmarker);
3593+ if(p != NULL)
3594+ *p = 0;
3595+
3596+ /*
3597+ ** Convert the word to an ichar_t and back; this makes sure that
3598+ ** it is in canonical form and thus that the length is correct.
3599+ */
3600+ if(strtoichar(ibuf, lbuf, INPUTWORDLEN * sizeof (ichar_t), 1)
3601+ || ichartostr(lbuf, ibuf, lbuflen, 1))
3602+ {
3603+ (void) fprintf(stderr, WORD_TOO_LONG (lbuf));
3604+ return(-1);
3605+ }
3606+ /*
3607+ ** Make sure the word is well-formed(contains only legal characters).
3608+ */
3609+ for(ip = ibuf; *ip != 0; ip++)
3610+ {
3611+ if(!iswordch(*ip))
3612+ {
3613+ /* Boundary characters are legal as long as they're not at edges */
3614+ if(!isboundarych(*ip) || ip == ibuf || ip[1] == 0)
3615+ {
3616+ (void) fprintf(stderr, MAKEDENT_C_BAD_WORD_CHAR, lbuf);
3617+ return -1;
3618+ }
3619+ }
3620+ }
3621+ len = strlen(lbuf);
3622+#ifndef NO_CAPITALIZATION_SUPPORT
3623+ /*
3624+ ** Figure out the capitalization rules from the capitalization of
3625+ ** the sample entry.
3626+ */
3627+ d->flagfield |= whatcap(ibuf);
3628+#endif
3629+
3630+ if(len > INPUTWORDLEN - 1)
3631+ {
3632+ (void) fprintf(stderr, WORD_TOO_LONG (lbuf));
3633+ return(-1);
3634+ }
3635+
3636+ d->word = malloc((unsigned) len + 1);
3637+ if(d->word == NULL)
3638+ {
3639+ (void) fprintf(stderr, MAKEDENT_C_NO_WORD_SPACE, lbuf);
3640+ return -1;
3641+ }
3642+
3643+ (void) strcpy (d->word, lbuf);
3644+#ifdef NO_CAPITALIZATION_SUPPORT
3645+ chupcase(d->word);
3646+#else /* NO_CAPITALIZATION_SUPPORT */
3647+ if(captype(d->flagfield) != FOLLOWCASE)
3648+ chupcase(d->word);
3649+#endif /* NO_CAPITALIZATION_SUPPORT */
3650+ if(p == NULL)
3651+ return(0);
3652+
3653+ p++;
3654+ while(*p != '\0' && *p != '\n')
3655+ {
3656+ bit = CHARTOBIT((unsigned char) *p);
3657+ if(bit >= 0 && bit <= LARGESTFLAG)
3658+ SETMASKBIT(d->mask, bit);
3659+ else
3660+ (void) fprintf (stderr, BAD_FLAG, (unsigned char) *p);
3661+ p++;
3662+ if(*p == hashheader.flagmarker)
3663+ p++; /* Handle old-format dictionaries too */
3664+ }
3665+ return(0);
3666+}
3667+
3668+#ifndef NO_CAPITALIZATION_SUPPORT
3669+/*
3670+** Classify the capitalization of a sample entry. Returns one of the
3671+** four capitalization codes ANYCASE, ALLCAPS, CAPITALIZED, or FOLLOWCASE.
3672+*/
3673+
3674+Public long
3675+whatcap(register ichar_t * word)
3676+{
3677+ register ichar_t * p;
3678+
3679+ for(p = word; *p; p++)
3680+ {
3681+ if(mylower(*p))
3682+ break;
3683+ }
3684+ if(*p == '\0')
3685+ return ALLCAPS;
3686+ else
3687+ {
3688+ for(; *p; p++)
3689+ if(myupper(*p))
3690+ break;
3691+ if(*p == '\0')
3692+ {
3693+ /*
3694+ ** No uppercase letters follow the lowercase ones.
3695+ ** If there is more than one uppercase letter, it's
3696+ ** "followcase". If only the first one is capitalized,
3697+ ** it's "capitalize". If there are no capitals
3698+ ** at all, it's ANYCASE.
3699+ */
3700+ if(myupper(word[0]))
3701+ {
3702+ for(p = word + 1; *p != '\0'; p++)
3703+ if(myupper(*p))
3704+ return FOLLOWCASE;
3705+ return CAPITALIZED;
3706+ }
3707+ else
3708+ return ANYCASE;
3709+ }
3710+ else
3711+ return FOLLOWCASE; /* .../lower/upper */
3712+ }
3713+}
3714+
3715+/*
3716+** Add a variant-capitalization header to a word. This routine may be
3717+** called even for a followcase word that doesn't yet have a header.
3718+**
3719+** Returns 0 if all was ok, -1 if allocation error.
3720+*/
3721+Public int
3722+addvheader(register struct dent *dp) /* Entry to update */
3723+{
3724+ register struct dent * tdent; /* Copy of entry */
3725+
3726+ /*
3727+ ** Add a second entry with the correct capitalization, and then make
3728+ ** dp into a special dummy entry.
3729+ */
3730+ tdent = (struct dent *) malloc (sizeof (struct dent));
3731+ if(tdent == NULL)
3732+ {
3733+ (void) fprintf(stderr, MAKEDENT_C_NO_WORD_SPACE, dp->word);
3734+ return -1;
3735+ }
3736+ *tdent = *dp;
3737+ if(captype(tdent->flagfield) != FOLLOWCASE)
3738+ tdent->word = NULL;
3739+ else
3740+ {
3741+ /* Followcase words need a copy of the capitalization */
3742+ tdent->word = malloc((unsigned int) strlen (tdent->word) + 1);
3743+ if(tdent->word == NULL)
3744+ {
3745+ (void) fprintf (stderr, MAKEDENT_C_NO_WORD_SPACE, dp->word);
3746+ free((char *) tdent);
3747+ return -1;
3748+ }
3749+ (void) strcpy(tdent->word, dp->word);
3750+ }
3751+ chupcase(dp->word);
3752+ dp->next = tdent;
3753+ dp->flagfield &= ~CAPTYPEMASK;
3754+ dp->flagfield |= (ALLCAPS | MOREVARIANTS);
3755+ return 0;
3756+}
3757+#endif /* NO_CAPITALIZATION_SUPPORT */
3758+
3759+/*
3760+** Combine and resolve the entries describing two capitalizations of the same
3761+** word. This may require allocating yet more entries.
3762+**
3763+** Hdrp is a pointer into a hash table. If the word covered by hdrp has
3764+** variations, hdrp must point to the header. Newp is a pointer to temporary
3765+** storage, and space is malloc'ed if newp is to be kept. The newp->word
3766+** field must have been allocated with mymalloc, so that this routine may free
3767+** the space if it keeps newp but not the word.
3768+**
3769+** Return value: 0 if the word was added, 1 if the word was combined
3770+** with an existing entry, and -1 if trouble occurred(e.g., malloc).
3771+** If 1 is returned, newp->word may have been be freed using myfree.
3772+**
3773+** Life is made much more difficult by the KEEP flag's possibilities. We
3774+** must ensure that a !KEEP word doesn't find its way into the personal
3775+** dictionary as a result of this routine's actions. However, a !KEEP
3776+** word that has affixes must have come from the main dictionary, so it
3777+** is acceptable to combine entries in that case(got that?).
3778+**
3779+** The net result of all this is a set of rules that is a bloody pain
3780+** to figure out. Basically, we want to choose one of the following actions:
3781+**
3782+** (1) Add newp's affixes and KEEP flag to oldp, and discard newp.
3783+** (2) Add oldp's affixes and KEEP flag to newp, replace oldp with
3784+** newp, and discard newp.
3785+#ifndef NO_CAPITALIZATION_SUPPORT
3786+** (3) Insert newp as a new entry in the variants list. If there is
3787+** currently no variant header, this requires adding one. Adding a
3788+** header splits into two sub-cases:
3789+**
3790+** (3a) If oldp is ALLCAPS and the KEEP flags match, just turn it
3791+** into the header.
3792+** (3b) Otherwise, add a new entry to serve as the header.
3793+** To ease list linking, this is done by copying oldp into
3794+** the new entry, and then performing(3a).
3795+**
3796+** After newp has been added as a variant, its affixes and KEEP
3797+** flag are OR-ed into the variant header.
3798+#endif
3799+**
3800+** So how to choose which? The default is always case(3), which adds newp
3801+** as a new entry in the variants list. Cases(1) and (2) are symmetrical
3802+** except for which entry is discarded. We can use case(1) or (2) whenever
3803+** one entry "covers" the other. "Covering" is defined as follows:
3804+**
3805+** (4) For entries with matching capitalization types, A covers B
3806+** if:
3807+**
3808+** (4a) B's affix flags are a subset of A's, or the KEEP flags
3809+** match, and
3810+** (4b) either the KEEP flags match, or A's KEEP flag is set.
3811+** (Since A has more suffixes, combining B with it won't
3812+** cause any extra suffixes to be added to the dictionary.)
3813+** (4c) If the words are FOLLOWCASE, the capitalizations match
3814+** exactly.
3815+**
3816+#ifndef NO_CAPITALIZATION_SUPPORT
3817+** (5) For entries with mismatched capitalization types, A covers B
3818+** if(4a) and(4b) are true, and:
3819+**
3820+** (5a) B is ALLCAPS, or
3821+** (5b) A is ANYCASE, and B is CAPITALIZED.
3822+#endif
3823+**
3824+** For any "hdrp" without variants, oldp is the same as hdrp. Otherwise,
3825+** the above tests are applied using each variant in turn for oldp.
3826+*/
3827+Public int
3828+combinecaps(
3829+ struct dent * hdrp, /* Header of entry currently in dictionary */
3830+ register struct dent * newp) /* Entry to add */
3831+{
3832+ register struct dent *
3833+ oldp; /* Current "oldp" entry */
3834+#ifndef NO_CAPITALIZATION_SUPPORT
3835+ register struct dent *
3836+ tdent; /* Entry we'll add to the dictionary */
3837+#endif /* NO_CAPITALIZATION_SUPPORT */
3838+ register int retval = 0; /* Return value from combine_two_entries */
3839+
3840+ /*
3841+ ** First, see if we can combine the two entries(cases 1 and 2). If
3842+ ** combine_two_entries does so, it will return 1. If it has trouble,
3843+ ** it will return zero.
3844+ */
3845+ oldp = hdrp;
3846+#ifdef NO_CAPITALIZATION_SUPPORT
3847+ retval = combine_two_entries(hdrp, oldp, newp);
3848+#else /* NO_CAPITALIZATION_SUPPORT */
3849+ if((oldp->flagfield &(CAPTYPEMASK | MOREVARIANTS))
3850+ == (ALLCAPS | MOREVARIANTS))
3851+ {
3852+ while(oldp->flagfield & MOREVARIANTS)
3853+ {
3854+ oldp = oldp->next;
3855+ retval = combine_two_entries(hdrp, oldp, newp);
3856+ if(retval != 0) /* Did we combine them? */
3857+ break;
3858+ }
3859+ }
3860+ else
3861+ retval = combine_two_entries(hdrp, oldp, newp);
3862+ if(retval == 0)
3863+ {
3864+ /*
3865+ ** Couldn't combine the two entries. Add a new variant. For
3866+ ** ease, we'll stick it right behind the header, rather than
3867+ ** at the end of the list.
3868+ */
3869+ forcevheader(hdrp, oldp, newp);
3870+ tdent = (struct dent *) malloc (sizeof (struct dent));
3871+ if(tdent == NULL)
3872+ {
3873+ (void) fprintf (stderr, MAKEDENT_C_NO_WORD_SPACE, newp->word);
3874+ return -1;
3875+ }
3876+ *tdent = *newp;
3877+ tdent->next = hdrp->next;
3878+ hdrp->next = tdent;
3879+ tdent->flagfield |= (hdrp->flagfield & MOREVARIANTS);
3880+ hdrp->flagfield |= MOREVARIANTS;
3881+ combineaffixes(hdrp, newp);
3882+ hdrp->flagfield |= (newp->flagfield & KEEP);
3883+ if(captype(newp->flagfield) == FOLLOWCASE)
3884+ tdent->word = newp->word;
3885+ else
3886+ {
3887+ tdent->word = NULL;
3888+ free(newp->word); /* newp->word isn't needed */
3889+ }
3890+ }
3891+#endif /* NO_CAPITALIZATION_SUPPORT */
3892+ return retval;
3893+}
3894+
3895+#ifndef NO_CAPITALIZATION_SUPPORT
3896+/*
3897+** The following routine implements steps 3a and 3b in the commentary
3898+** for "combinecaps".
3899+*/
3900+Local void
3901+forcevheader(
3902+ register struct dent * hdrp,
3903+ struct dent * oldp,
3904+ struct dent * newp)
3905+{
3906+
3907+ if((hdrp->flagfield &(CAPTYPEMASK | MOREVARIANTS)) == ALLCAPS
3908+ && ((oldp->flagfield ^ newp->flagfield) & KEEP) == 0)
3909+ return; /* Caller will set MOREVARIANTS */
3910+ else if((hdrp->flagfield &(CAPTYPEMASK | MOREVARIANTS))
3911+ != (ALLCAPS | MOREVARIANTS))
3912+ (void) addvheader(hdrp);
3913+}
3914+#endif /* NO_CAPITALIZATION_SUPPORT */
3915+
3916+/*
3917+** This routine implements steps 4 and 5 of the commentary for "combinecaps".
3918+**
3919+** Returns 1 if newp can be discarded, 0 if nothing done.
3920+*/
3921+Local int
3922+combine_two_entries(
3923+ struct dent *hdrp, /*(Possible) header of variant chain */
3924+ register struct dent *oldp, /* Pre-existing dictionary entry */
3925+ register struct dent *newp) /* Entry to possibly combine */
3926+{
3927+
3928+ if(acoversb(oldp, newp))
3929+ {
3930+ /* newp is superfluous. Drop it, preserving affixes and keep flag */
3931+ combineaffixes(oldp, newp);
3932+ oldp->flagfield |= (newp->flagfield & KEEP);
3933+ hdrp->flagfield |= (newp->flagfield & KEEP);
3934+ free(newp->word);
3935+ return 1;
3936+ }
3937+ else if(acoversb(newp, oldp))
3938+ {
3939+ /*
3940+ ** oldp is superfluous. Replace it with newp, preserving affixes and
3941+ ** the keep flag.
3942+ */
3943+ combineaffixes(newp, oldp);
3944+#ifdef NO_CAPITALIZATION_SUPPORT
3945+ newp->flagfield |= (oldp->flagfield & KEEP);
3946+#else /* NO_CAPITALIZATION_SUPPORT */
3947+ newp->flagfield |= (oldp->flagfield & (KEEP | MOREVARIANTS));
3948+#endif /* NO_CAPITALIZATION_SUPPORT */
3949+ hdrp->flagfield |= (newp->flagfield & KEEP);
3950+ newp->next = oldp->next;
3951+ /*
3952+ ** We really want to free oldp->word, but that might be part of
3953+ ** "hashstrings". So we'll futz around to arrange things so we can
3954+ ** free newp->word instead. This depends very much on the fact
3955+ ** that both words are the same length.
3956+ */
3957+ if(oldp->word != NULL)
3958+ (void) strcpy (oldp->word, newp->word);
3959+ free(newp->word); /* No longer needed */
3960+ newp->word = oldp->word;
3961+ *oldp = *newp;
3962+#ifndef NO_CAPITALIZATION_SUPPORT
3963+ /* We may need to add a header if newp is followcase */
3964+ if(captype(newp->flagfield) == FOLLOWCASE
3965+ && (hdrp->flagfield & (CAPTYPEMASK | MOREVARIANTS))
3966+ != (ALLCAPS | MOREVARIANTS))
3967+ (void) addvheader (hdrp);
3968+#endif /* NO_CAPITALIZATION_SUPPORT */
3969+ return 1;
3970+ }
3971+ else
3972+ return 0;
3973+}
3974+
3975+/*
3976+** Determine if enta covers entb, according to the rules in steps 4 and 5
3977+** of the commentary for "combinecaps".
3978+*/
3979+Local int
3980+acoversb(
3981+ register struct dent * enta, /* "A" in the rules */
3982+ register struct dent * entb) /* "B" in the rules */
3983+{
3984+ int subset; /* NZ if entb is a subset of enta */
3985+
3986+ if((subset = issubset(entb, enta)) != 0)
3987+ {
3988+ /* entb is a subset of enta; thus enta might cover entb */
3989+ if(((enta->flagfield ^ entb->flagfield) & KEEP) != 0
3990+ && (enta->flagfield & KEEP) == 0) /* Inverse of condition (4b) */
3991+ return 0;
3992+ }
3993+ else
3994+ {
3995+ /* not a subset; KEEP flags must match exactly(both (4a) and (4b)) */
3996+ if(((enta->flagfield ^ entb->flagfield) & KEEP) != 0)
3997+ return 0;
3998+ }
3999+
4000+ /* Rules(4a) and (4b) are satisfied; check for capitalization match */
4001+#ifdef NO_CAPITALIZATION_SUPPORT
4002+#ifdef lint
4003+ return subset; /* Just so it gets used */
4004+#else /* lint */
4005+ return 1; /* All words match */
4006+#endif /* lint */
4007+#else /* NO_CAPITALIZATION_SUPPORT */
4008+ if(((enta->flagfield ^ entb->flagfield) & CAPTYPEMASK) == 0)
4009+ {
4010+ if(captype(enta->flagfield) != FOLLOWCASE /* Condition (4c) */
4011+ || strcmp(enta->word, entb->word) == 0)
4012+ return 1; /* Perfect match */
4013+ else
4014+ return 0;
4015+ }
4016+ else if(subset == 0) /* No flag subset, refuse */
4017+ return 0; /* ..near matches */
4018+ else if(captype(entb->flagfield) == ALLCAPS)
4019+ return 1;
4020+ else if(captype(enta->flagfield) == ANYCASE
4021+ && captype(entb->flagfield) == CAPITALIZED)
4022+ return 1;
4023+ else
4024+ return 0;
4025+#endif /* NO_CAPITALIZATION_SUPPORT */
4026+}
4027+
4028+Public void
4029+upcase(register ichar_t * s)
4030+{
4031+
4032+ while(*s)
4033+ {
4034+ *s = mytoupper(*s);
4035+ s++;
4036+ }
4037+}
4038+
4039+Public void
4040+lowcase(register ichar_t * s)
4041+{
4042+
4043+ while(*s)
4044+ {
4045+ *s = mytolower(*s);
4046+ s++;
4047+ }
4048+}
4049+
4050+/*
4051+ * Upcase variant that works on normal strings. Note that it is a lot
4052+ * slower than the normal upcase. The input must be in canonical form.
4053+ */
4054+Public void
4055+chupcase(char * s)
4056+{
4057+ ichar_t * is;
4058+
4059+ is = strtosichar(s, 1);
4060+ upcase(is);
4061+ (void) ichartostr (s, is, strlen (s) + 1, 1);
4062+}
4063+
4064+/*
4065+** See if one affix field is a subset of another. Returns NZ if ent1
4066+** is a subset of ent2. The KEEP flag is not taken into consideration.
4067+*/
4068+Local int
4069+issubset(
4070+ register struct dent * ent1,
4071+ register struct dent * ent2)
4072+{
4073+/* The following is really testing for MASKSIZE > 1, but cpp can't do that */
4074+#if MASKBITS > 32
4075+ register int flagword;
4076+
4077+#ifdef FULLMASKSET
4078+#define MASKMAX MASKSIZE
4079+#else
4080+#define MASKMAX MASKSIZE - 1
4081+#endif /* FULLMASKSET */
4082+ for(flagword = MASKMAX; --flagword >= 0; )
4083+ {
4084+ if((ent1->mask[flagword] & ent2->mask[flagword])
4085+ != ent1->mask[flagword])
4086+ return 0;
4087+ }
4088+#endif /* MASKBITS > 32 */
4089+#ifdef FULLMASKSET
4090+ return((ent1->mask[MASKSIZE - 1] & ent2->mask[MASKSIZE - 1])
4091+ == ent1->mask[MASKSIZE - 1]);
4092+#else
4093+ if(((ent1->mask[MASKSIZE - 1] & ent2->mask[MASKSIZE - 1])
4094+ ^ ent1->mask[MASKSIZE - 1]) & ~ALLFLAGS)
4095+ return 0;
4096+ else
4097+ return 1;
4098+#endif /* FULLMASKSET */
4099+}
4100+
4101+/*
4102+** Add ent2's affix flags to ent1.
4103+*/
4104+Local void
4105+combineaffixes(
4106+ register struct dent * ent1,
4107+ register struct dent * ent2)
4108+{
4109+/* The following is really testing for MASKSIZE > 1, but cpp can't do that */
4110+#if MASKBITS > 32
4111+ register int flagword;
4112+
4113+ if(ent1 == ent2)
4114+ return;
4115+ /* MASKMAX is defined in issubset, just above */
4116+ for(flagword = MASKMAX; --flagword >= 0; )
4117+ ent1->mask[flagword] |= ent2->mask[flagword];
4118+#endif /* MASKBITS > 32 */
4119+#ifndef FULLMASKSET
4120+ ent1->mask[MASKSIZE - 1] |= ent2->mask[MASKSIZE - 1] & ~ALLFLAGS;
4121+#endif
4122+}
4123+
4124+/*
4125+** Write out a dictionary entry, including capitalization variants.
4126+** If onlykeep is true, only those variants with KEEP set will be
4127+** written.
4128+*/
4129+Public void
4130+toutent(
4131+ register FILE * toutfile,
4132+ struct dent * hent,
4133+ register int onlykeep)
4134+{
4135+#ifdef NO_CAPITALIZATION_SUPPORT
4136+ if(!onlykeep || (hent->flagfield & KEEP))
4137+ toutword(toutfile, hent->word, hent);
4138+#else
4139+ register struct dent * cent;
4140+ ichar_t wbuf[INPUTWORDLEN + MAXAFFIXLEN];
4141+
4142+ cent = hent;
4143+ if(strtoichar(wbuf, cent->word, INPUTWORDLEN, 1))
4144+ (void) fprintf(stderr, WORD_TOO_LONG (cent->word));
4145+ for( ; ; )
4146+ {
4147+ if(!onlykeep || (cent->flagfield & KEEP))
4148+ {
4149+ switch(captype (cent->flagfield))
4150+ {
4151+ case ANYCASE:
4152+ lowcase(wbuf);
4153+ toutword(toutfile, ichartosstr (wbuf, 1), cent);
4154+ break;
4155+ case ALLCAPS:
4156+ if((cent->flagfield & MOREVARIANTS) == 0 || cent != hent)
4157+ {
4158+ upcase(wbuf);
4159+ toutword(toutfile, ichartosstr (wbuf, 1), cent);
4160+ }
4161+ break;
4162+ case CAPITALIZED:
4163+ lowcase(wbuf);
4164+ wbuf[0] = mytoupper(wbuf[0]);
4165+ toutword(toutfile, ichartosstr (wbuf, 1), cent);
4166+ break;
4167+ case FOLLOWCASE:
4168+ toutword(toutfile, cent->word, cent);
4169+ break;
4170+ }
4171+ }
4172+ if(cent->flagfield & MOREVARIANTS)
4173+ cent = cent->next;
4174+ else
4175+ break;
4176+ }
4177+#endif
4178+}
4179+
4180+Local void
4181+toutword(
4182+ register FILE * toutfile,
4183+ char * word,
4184+ register struct dent * cent)
4185+{
4186+ register int bit;
4187+
4188+ has_marker = False;
4189+ (void) fprintf (toutfile, "%s", word);
4190+ for(bit = 0; bit < LARGESTFLAG; bit++)
4191+ {
4192+ if(TSTMASKBIT(cent->mask, bit))
4193+ flagout(toutfile, BITTOCHAR (bit));
4194+ }
4195+ (void) fprintf (toutfile, "\n");
4196+}
4197+
4198+Local void
4199+flagout(
4200+ register FILE * toutfile,
4201+ int flag)
4202+{
4203+ if(!has_marker)
4204+ (void) putc(hashheader.flagmarker, toutfile);
4205+ has_marker = True;
4206+ (void) putc (flag, toutfile);
4207+}
4208+
4209+/*
4210+ * If the string under the given pointer begins with a string character,
4211+ * return the length of that "character". If not, return 0.
4212+ * May be called any time, but it's best if "isstrstart" is first
4213+ * used to filter out unnecessary calls.
4214+ *
4215+ * As a side effect, "laststringch" is set to the number of the string
4216+ * found, or to -1 if none was found. This can be useful for such things
4217+ * as case conversion.
4218+ */
4219+Public int
4220+stringcharlen(
4221+ char * bufp,
4222+ int canonical) /* NZ if input is in canonical form */
4223+{
4224+#ifdef SLOWMULTIPLY
4225+ static char * sp[MAXSTRINGCHARS];
4226+ static int m_inited = 0;
4227+#endif /* SLOWMULTIPLY */
4228+ register char * bufcur;
4229+ register char * stringcur;
4230+ register int stringno;
4231+ register int lowstringno;
4232+ register int highstringno;
4233+ int dupwanted;
4234+
4235+#ifdef SLOWMULTIPLY
4236+ if(!m_inited)
4237+ {
4238+ m_inited = 1;
4239+ for(stringno = 0; stringno < MAXSTRINGCHARS; stringno++)
4240+ sp[stringno] = &hashheader.stringchars[stringno][0];
4241+ }
4242+#endif /* SLOWMULTIPLY */
4243+ lowstringno = 0;
4244+ highstringno = hashheader.nstrchars - 1;
4245+ dupwanted = canonical ? 0 : defdupchar;
4246+ while(lowstringno <= highstringno)
4247+ {
4248+ stringno = (lowstringno + highstringno) >> 1;
4249+#ifdef SLOWMULTIPLY
4250+ stringcur = sp[stringno];
4251+#else /* SLOWMULTIPLY */
4252+ stringcur = &hashheader.stringchars[stringno][0];
4253+#endif /* SLOWMULTIPLY */
4254+ bufcur = bufp;
4255+ while(*stringcur)
4256+ {
4257+#ifdef NO8BIT
4258+ if(((*bufcur++ ^ *stringcur) & 0x7F) != 0)
4259+#else /* NO8BIT */
4260+ if(*bufcur++ != *stringcur)
4261+#endif /* NO8BIT */
4262+ break;
4263+ /*
4264+ ** We can't use autoincrement above because of the
4265+ ** test below.
4266+ */
4267+ stringcur++;
4268+ }
4269+ if(*stringcur == '\0')
4270+ {
4271+ if(hashheader.dupnos[stringno] == dupwanted)
4272+ {
4273+ /* We have a match */
4274+ laststringch = hashheader.stringdups[stringno];
4275+#ifdef SLOWMULTIPLY
4276+ return stringcur - sp[stringno];
4277+#else /* SLOWMULTIPLY */
4278+ return stringcur - &hashheader.stringchars[stringno][0];
4279+#endif /* SLOWMULTIPLY */
4280+ }
4281+ else
4282+ --stringcur;
4283+ }
4284+ /* No match - choose which side to search on */
4285+#ifdef NO8BIT
4286+ if((*--bufcur & 0x7F) <(*stringcur & 0x7F))
4287+ highstringno = stringno - 1;
4288+ else if((*bufcur & 0x7F) >(*stringcur & 0x7F))
4289+ lowstringno = stringno + 1;
4290+#else /* NO8BIT */
4291+ if(*--bufcur < *stringcur)
4292+ highstringno = stringno - 1;
4293+ else if(*bufcur > *stringcur)
4294+ lowstringno = stringno + 1;
4295+#endif /* NO8BIT */
4296+ else if(dupwanted < hashheader.dupnos[stringno])
4297+ highstringno = stringno - 1;
4298+ else
4299+ lowstringno = stringno + 1;
4300+ }
4301+ laststringch = -1;
4302+ return 0; /* Not a string character */
4303+}
4304+
4305+/*
4306+ * Convert an external string to an ichar_t string. If necessary, the parity
4307+ * bit is stripped off as part of the process.
4308+ *
4309+ * Returns NZ if the output string overflowed.
4310+ */
4311+Public int
4312+strtoichar(
4313+ register ichar_t * out, /* Where to put result */
4314+ register char * in, /* String to convert */
4315+ int outlen, /* Size of output buffer, *BYTES* */
4316+ int canonical) /* NZ if input is in canonical form */
4317+{
4318+ register int len; /* Length of next character */
4319+
4320+ outlen /= sizeof(ichar_t); /* Convert to an ichar_t count */
4321+ for( ; --outlen > 0 && *in != '\0'; in += len)
4322+ {
4323+ if(l1_isstringch(in, len, canonical))
4324+ *out++ = SET_SIZE + laststringch;
4325+ else
4326+ *out++ = *in & S_NOPARITY;
4327+ }
4328+ *out = 0;
4329+ return outlen <= 0;
4330+}
4331+
4332+/*
4333+ * Convert an ichar_t string to an external string.
4334+ *
4335+ * WARNING: the resulting string may wind up being longer than the
4336+ * original. In fact, even the sequence strtoichar->ichartostr may
4337+ * produce a result longer than the original, because the output form
4338+ * may use a different string type set than the original input form.
4339+ *
4340+ * Returns NZ if the output string overflowed.
4341+ */
4342+Public int
4343+ichartostr(
4344+ register char * out, /* Where to put result */
4345+ register ichar_t * in, /* String to convert */
4346+ int outlen, /* Size of output buffer, bytes */
4347+ int canonical) /* NZ for canonical form */
4348+{
4349+ register unsigned int ch; /* Next character to store */
4350+ register unsigned int i; /* Index into duplicates list */
4351+ register char * scharp; /* Pointer into a string char */
4352+
4353+ while(--outlen > 0 && (ch = *in++) != 0)
4354+ {
4355+ if(ch < SET_SIZE)
4356+ *out++ = (char) ch;
4357+ else
4358+ {
4359+ ch -= SET_SIZE;
4360+ if(!canonical)
4361+ {
4362+ for(i = hashheader.nstrchars; --i >= 0; )
4363+ {
4364+ if(hashheader.dupnos[i] == defdupchar
4365+ && hashheader.stringdups[i] == ch)
4366+ {
4367+ ch = i;
4368+ break;
4369+ }
4370+ }
4371+ }
4372+ scharp = hashheader.stringchars[(unsigned) ch];
4373+ while((*out++ = *scharp++) != '\0')
4374+ ;
4375+ out--;
4376+ }
4377+ }
4378+ *out = '\0';
4379+ return outlen <= 0;
4380+}
4381+
4382+/*
4383+ * Convert a string to an ichar_t, storing the result in a static area.
4384+ */
4385+Public ichar_t *
4386+strtosichar(
4387+ char * in, /* String to convert */
4388+ int canonical) /* NZ if input is in canonical form */
4389+{
4390+ static ichar_t out[STRTOSICHAR_SIZE / sizeof(ichar_t)];
4391+
4392+ if(strtoichar(out, in, sizeof out, canonical))
4393+ (void) fprintf(stderr, WORD_TOO_LONG (in));
4394+ return out;
4395+}
4396+
4397+/*
4398+ * Convert an ichar_t to a string, storing the result in a static area.
4399+ */
4400+Public char *
4401+ichartosstr(
4402+ ichar_t * in, /* Internal string to convert */
4403+ int canonical) /* NZ for canonical conversion */
4404+{
4405+ static char out[ICHARTOSSTR_SIZE];
4406+
4407+ if(ichartostr(out, in, sizeof out, canonical))
4408+ (void) fprintf(stderr, WORD_TOO_LONG (out));
4409+ return out;
4410+}
4411+
4412+/*
4413+ * Convert a single ichar to a printable string, storing the result in
4414+ * a static area.
4415+ */
4416+Public char *
4417+printichar(int in)
4418+{
4419+ static char out[MAXSTRINGCHARLEN + 1];
4420+
4421+ if(in < SET_SIZE)
4422+ {
4423+ out[0] = (char) in;
4424+ out[1] = '\0';
4425+ }
4426+ else
4427+ (void) strcpy(out, hashheader.stringchars[(unsigned) in - SET_SIZE]);
4428+ return out;
4429+}
4430+
4431+#ifndef ICHAR_IS_CHAR
4432+/*
4433+ * Copy an ichar_t.
4434+ */
4435+Public ichar_t *
4436+icharcpy(
4437+ register ichar_t * out, /* Destination */
4438+ register ichar_t * in) /* Source */
4439+{
4440+ ichar_t * origout; /* Copy of destination for return */
4441+
4442+ origout = out;
4443+ while((*out++ = *in++) != 0)
4444+ ;
4445+ return origout;
4446+}
4447+
4448+/*
4449+ * Return the length of an ichar_t.
4450+ */
4451+Public int
4452+icharlen(register ichar_t * in) /* String to count */
4453+{
4454+ register int len; /* Length so far */
4455+
4456+ for(len = 0; *in++ != 0; len++)
4457+ ;
4458+ return len;
4459+}
4460+
4461+/*
4462+ * Compare two ichar_t's.
4463+ */
4464+Public int
4465+icharcmp(
4466+ register ichar_t * s1,
4467+ register ichar_t * s2)
4468+{
4469+
4470+ while(*s1 != 0)
4471+ {
4472+ if(*s1++ != *s2++)
4473+ return *--s1 - *--s2;
4474+ }
4475+ return *s1 - *s2;
4476+}
4477+
4478+/*
4479+ * Strncmp for two ichar_t's.
4480+ */
4481+Public int
4482+icharncmp(
4483+ register ichar_t * s1,
4484+ register ichar_t * s2,
4485+ register int n)
4486+{
4487+
4488+ while(--n >= 0 && *s1 != 0)
4489+ {
4490+ if(*s1++ != *s2++)
4491+ return *--s1 - *--s2;
4492+ }
4493+ if(n < 0)
4494+ return 0;
4495+ else
4496+ return *s1 - *s2;
4497+}
4498+
4499+#endif /* ICHAR_IS_CHAR */
4500+
4501+Public int
4502+findfiletype(
4503+ char * name, /* Name to look up in suffix table */
4504+ int searchnames, /* NZ to search name field of table */
4505+ int * deformatter) /* Where to set deformatter type */
4506+{
4507+ char * cp; /* Pointer into suffix list */
4508+ int cplen; /* Length of current suffix */
4509+ register int i; /* Index into type table */
4510+ int len; /* Length of the name */
4511+
4512+ /*
4513+ * Note: for now, the deformatter is set to 1 for tex, 0 for nroff.
4514+ * Further, we assume that it's one or the other, so that a test
4515+ * for tex is sufficient. This needs to be generalized.
4516+ */
4517+ len = strlen(name);
4518+ if(searchnames)
4519+ {
4520+ for(i = 0; i < hashheader.nstrchartype; i++)
4521+ {
4522+ if(strcmp(name, chartypes[i].name) == 0)
4523+ {
4524+ if(deformatter != NULL)
4525+ *deformatter =
4526+ (strcmp (chartypes[i].deformatter, "tex") == 0);
4527+ return i;
4528+ }
4529+ }
4530+ }
4531+ for(i = 0; i < hashheader.nstrchartype; i++)
4532+ {
4533+ for(cp = chartypes[i].suffixes; *cp != '\0'; cp += cplen + 1)
4534+ {
4535+ cplen = strlen(cp);
4536+ if(len >= cplen && strcmp(&name[len - cplen], cp) == 0)
4537+ {
4538+ if(deformatter != NULL)
4539+ *deformatter =
4540+ (strcmp (chartypes[i].deformatter, "tex") == 0);
4541+ return i;
4542+ }
4543+ }
4544+ }
4545+ return -1;
4546+}
4547+
4548+Public char *
4549+mypath_rindex(char const *str, char c)
4550+{
4551+ register char *x;
4552+
4553+ x = (char *)str + strlen(str);
4554+
4555+ while(x >= str)
4556+ {
4557+ if(*x == '\\' || *x == '/' || *x == ':')
4558+ return(NULL);
4559+ else if(*x == c)
4560+ return(x);
4561+ else
4562+ x--;
4563+ }
4564+ return(NULL);
4565+}
0f1b3689
AG
4566diff -burN vim62.orig/src/spell/msgs.h vim62/src/spell/msgs.h
4567--- vim62.orig/src/spell/msgs.h 1970-01-01 01:00:00.000000000 +0100
4568+++ vim62/src/spell/msgs.h 2004-03-01 22:43:16.758876632 +0100
24ec98f0
JB
4569@@ -0,0 +1,278 @@
4570+/*
4571+ * $Id$
4572+ *
4573+ * Copyright 1992, 1993, Geoff Kuenning, Granada Hills, CA
4574+ * All rights reserved.
4575+ *
4576+ * Redistribution and use in source and binary forms, with or without
4577+ * modification, are permitted provided that the following conditions
4578+ * are met:
4579+ *
4580+ * 1. Redistributions of source code must retain the above copyright
4581+ * notice, this list of conditions and the following disclaimer.
4582+ * 2. Redistributions in binary form must reproduce the above copyright
4583+ * notice, this list of conditions and the following disclaimer in the
4584+ * documentation and/or other materials provided with the distribution.
4585+ * 3. All modifications to the source code must be clearly marked as
4586+ * such. Binary redistributions based on modified source code
4587+ * must be clearly marked as modified versions in the documentation
4588+ * and/or other materials provided with the distribution.
4589+ * 4. All advertising materials mentioning features or use of this software
4590+ * must display the following acknowledgment:
4591+ * This product includes software developed by Geoff Kuenning and
4592+ * other unpaid contributors.
4593+ * 5. The name of Geoff Kuenning may not be used to endorse or promote
4594+ * products derived from this software without specific prior
4595+ * written permission.
4596+ *
4597+ * THIS SOFTWARE IS PROVIDED BY GEOFF KUENNING AND CONTRIBUTORS ``AS IS'' AND
4598+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4599+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4600+ * ARE DISCLAIMED. IN NO EVENT SHALL GEOFF KUENNING OR CONTRIBUTORS BE LIABLE
4601+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4602+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4603+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4604+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4605+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
4606+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
4607+ * SUCH DAMAGE.
4608+ *
4609+ */
4610+
4611+/*
4612+ * Messages header file.
4613+ *
4614+ * This file contains all text strings that are written by any of the
4615+ * C programs in the ispell package. The strings are collected here so that
4616+ * you can have the option of translating them into your local language for
4617+ * the benefit of your users.
4618+ *
4619+ * Anyone who goes to the effort of making a translation may wish to return
4620+ * the translated strings to me, geoff@ITcorp.com, so that I can include
4621+ * them in a later distribution under #ifdef control.
4622+ *
4623+ * Besides the strings in this header file, you may also want to translate
4624+ * the strings in version.h, which give the version and copyright information.
4625+ * However, any translation of these strings MUST accurately preserve the
4626+ * legal rights under international law; you may wish to consult a lawyer
4627+ * about this since you will be responsible for the results of any
4628+ * incorrect translation.
4629+ *
4630+ * Most of the strings below are simple printf format strings. If the printf
4631+ * takes more than one parameter, the string is given as a parameterized
4632+ * macro in case your local language needs a different word order.
4633+ */
4634+
4635+/*
4636+ * $Log$
4637+ * Revision 1.31 1994/12/27 23:08:57 geoff
4638+ * Add a message to be issued if a word contains illegal characters.
4639+ *
4640+ * Revision 1.30 1994/10/25 05:46:40 geoff
4641+ * Improve a couple of error messages relating to affix flags.
4642+ *
4643+ * Revision 1.29 1994/10/04 03:46:23 geoff
4644+ * Add a missing carriage return in the help message
4645+ *
4646+ * Revision 1.28 1994/09/16 05:07:00 geoff
4647+ * Add the BAD_FLAG message, and start a sentence in another message with
4648+ * an uppercase letter.
4649+ *
4650+ * Revision 1.27 1994/07/28 05:11:38 geoff
4651+ * Log message for previous revision: add BHASH_C_ZERO_COUNT.
4652+ *
4653+ * Revision 1.26 1994/07/28 04:53:49 geoff
4654+ *
4655+ * Revision 1.25 1994/05/24 04:54:36 geoff
4656+ * Add error messages for affix-flag checking.
4657+ *
4658+ * Revision 1.24 1994/01/25 07:12:42 geoff
4659+ * Get rid of all old RCS log lines in preparation for the 3.1 release.
4660+ *
4661+ */
4662+
4663+/*
4664+ * The following strings are used in numerous places:
4665+ */
4666+#define BAD_FLAG "\nIllegal affix flag character '%c'\n"
4667+#define CANT_OPEN "Can't open %s"
4668+#define CANT_CREATE "Can't create %s\n"
4669+#define WORD_TOO_LONG(w) "\nWord '%s' too long at line %d of %s, truncated\n", \
4670+ w, __LINE__, __FILE__
4671+
4672+/*
4673+ * The following strings are used in buildhash.c:
4674+ */
4675+#define BHASH_C_NO_DICT "No dictionary (%s)\n"
4676+#define BHASH_C_NO_COUNT "No count file\n"
4677+#define BHASH_C_BAD_COUNT "Bad count file\n"
4678+#define BHASH_C_ZERO_COUNT "No words in dictionary\n"
4679+ /* I think this message looks better when it's nearly 80 characters wide,
4680+ * thus the ugly formatting in the next two defines. GK 9-87 */
4681+#define BHASH_C_BAFF_1(max, excess) \
4682+ " Warning: this language table may exceed the maximum total affix length\nof %d by up to %d bytes. You should either increase MAXAFFIXLEN in config.X\nor shorten your largest affix/strip string difference. (This is the\n", \
4683+ max, excess
4684+#define BHASH_C_BAFF_2 \
4685+ "difference between the affix length and the strip length in a given\nreplacement rule, or the affix length if there is no strip string\nin that rule.)\n"
4686+#define BHASH_C_OVERFLOW "Hash table overflowed by %d words\n"
4687+#define BHASH_C_CANT_OPEN_DICT "Can't open dictionary\n"
4688+#define BHASH_C_NO_SPACE "Couldn't allocate hash table\n"
4689+#define BHASH_C_COLLISION_SPACE "\ncouldn't allocate space for collision\n"
4690+#define BHASH_C_COUNTING "Counting words in dictionary ...\n"
4691+#define BHASH_C_WORD_COUNT "\n%d words\n"
4692+#define BHASH_C_USAGE "Usage: buildhash [-s] dict-file aff-file hash-file\n\tbuildhash -c count aff-file\n"
4693+
4694+/*
4695+ * The following strings are used in correct.c:
4696+ */
4697+#define CORR_C_HELP_1 "Whenever a word is found that is not in the dictionary,\n"
4698+#define CORR_C_HELP_2 "it is printed on the first line of the screen. If the dictionary\n"
4699+#define CORR_C_HELP_3 "contains any similar words, they are listed with a number\n"
4700+#define CORR_C_HELP_4 "next to each one. You have the option of replacing the word\n"
4701+#define CORR_C_HELP_5 "completely, or choosing one of the suggested words.\n"
4702+ /* You may add HELP_6 through HELP_9 if your language needs more lines */
4703+#define CORR_C_HELP_6 ""
4704+#define CORR_C_HELP_7 ""
4705+#define CORR_C_HELP_8 ""
4706+#define CORR_C_HELP_9 ""
4707+#define CORR_C_HELP_COMMANDS "\nCommands are:\n\n"
4708+#define CORR_C_HELP_R_CMD "R Replace the misspelled word completely.\n"
4709+#define CORR_C_HELP_BLANK "Space Accept the word this time only.\n"
4710+#define CORR_C_HELP_A_CMD "A Accept the word for the rest of this session.\n"
4711+#define CORR_C_HELP_I_CMD "I Accept the word, and put it in your private dictionary.\n"
4712+#define CORR_C_HELP_U_CMD "U Accept and add lowercase version to private dictionary.\n"
4713+#define CORR_C_HELP_0_CMD "0-n Replace with one of the suggested words.\n"
4714+#define CORR_C_HELP_L_CMD "L Look up words in system dictionary.\n"
4715+#define CORR_C_HELP_X_CMD "X Write the rest of this file, ignoring misspellings,\n and start next file.\n"
4716+#define CORR_C_HELP_Q_CMD "Q Quit immediately. Asks for confirmation.\n Leaves file unchanged.\n"
4717+#define CORR_C_HELP_BANG "! Shell escape.\n"
4718+#define CORR_C_HELP_REDRAW "^L Redraw screen.\n"
4719+#define CORR_C_HELP_SUSPEND "^Z Suspend program.\n"
4720+#define CORR_C_HELP_HELP "? Show this help screen.\n"
4721+#define CORR_C_HELP_TYPE_SPACE "-- Type space to continue --"
4722+
4723+#define CORR_C_FILE_LABEL " File: %s"
4724+#define CORR_C_READONLY "[READONLY]"
4725+#define CORR_C_MINI_MENU "[SP] <number> R)epl A)ccept I)nsert L)ookup U)ncap Q)uit e(X)it or ? for help\n"
4726+#define CORR_C_CONFIRM_QUIT "Are you sure you want to throw away your changes? "
4727+#define CORR_C_REPLACE_WITH "Replace with: "
4728+#define CORR_C_LOOKUP_PROMPT "Lookup string ('*' is wildcard): "
4729+#define CORR_C_MORE_PROMPT "-- more --"
4730+#define CORR_C_BLANK_MORE " "
4731+#define CORR_C_END_LOOK "--end--"
4732+
4733+/*
4734+ * The following strings are used in defmt.c:
4735+ */
4736+#define DEFMT_C_TEX_MATH_ERROR "****ERROR in parsing TeX math mode!\n"
4737+#define DEFMT_C_LR_MATH_ERROR "***ERROR in LR to math-mode switch.\n"
4738+
4739+/*
4740+ * The following strings are used in icombine.c:
4741+ */
4742+#define ICOMBINE_C_BAD_TYPE "icombine: unrecognized formatter type '%s'\n"
4743+#define ICOMBINE_C_USAGE "Usage: icombine [-T suffix] [aff-file] < wordlist\n"
4744+
4745+/*
4746+ * The following strings are used in ispell.c:
4747+ */
4748+#define ISPELL_C_USAGE1 "Usage: %s [-dfile | -pfile | -wchars | -Wn | -t | -n | -x | -b | -S | -B | -C | -P | -m | -Lcontext | -M | -N | -Ttype | -V] file .....\n"
4749+#define ISPELL_C_USAGE2 " %s [-dfile | -pfile | -wchars | -Wn | -t | -n | -Ttype] -l\n"
4750+#ifndef USG
4751+#define ISPELL_C_USAGE3 " %s [-dfile | -pfile | -ffile | -Wn | -t | -n | -s | -B | -C | -P | -m | -Ttype] {-a | -A}\n"
4752+#else
4753+#define ISPELL_C_USAGE3 " %s [-dfile | -pfile | -ffile | -Wn | -t | -n | -B | -C | -P | -m | -Ttype] {-a | -A}\n"
4754+#endif
4755+#define ISPELL_C_USAGE4 " %s [-dfile] [-wchars | -Wn] -c\n"
4756+#define ISPELL_C_USAGE5 " %s [-dfile] [-wchars] -e[1-4]\n"
4757+#define ISPELL_C_USAGE6 " %s [-dfile] [-wchars] -D\n"
4758+#define ISPELL_C_USAGE7 " %s -v\n"
4759+#define ISPELL_C_TEMP_DISAPPEARED "temporary file disappeared (%s)\n"
4760+#define ISPELL_C_BAD_TYPE "ispell: unrecognized formatter type '%s'\n"
4761+#define ISPELL_C_NO_FILE "ispell: specified file does not exist\n"
4762+#define ISPELL_C_NO_FILES "ispell: specified files do not exist\n"
4763+#define ISPELL_C_CANT_WRITE "Warning: Can't write to %s\n"
4764+#define ISPELL_C_OPTIONS_ARE "Compiled-in options:\n"
4765+#ifdef MSDOS
4766+#define ISPELL_C_NO_OPTIONS_SPACE "ispell: no memory to read default options\n"
4767+#endif
4768+
4769+/*
4770+ * The following strings are used in lookup.c:
4771+ */
4772+#define LOOKUP_C_CANT_READ "Trouble reading hash table %s"
4773+#define LOOKUP_C_NULL_HASH "Null hash table %s"
4774+#define LOOKUP_C_SHORT_HASH(name, gotten, wanted) \
4775+ "Truncated hash table %s: got %d bytes, expected %d", \
4776+ name, gotten, wanted
4777+#define LOOKUP_C_BAD_MAGIC(name, wanted, gotten) \
4778+ "Illegal format hash table %s - expected magic 0x%x, got 0x%x", \
4779+ name, wanted, gotten
4780+#define LOOKUP_C_BAD_MAGIC2(name, wanted, gotten) \
4781+ "Illegal format hash table %s - \nexpected magic2 0x%x, got 0x%x", \
4782+ name, wanted, gotten
4783+#define LOOKUP_C_BAD_OPTIONS(gotopts, gotchars, gotlen, wantedopts, wantedchars, wantedlen) \
4784+ "Hash table options don't agree with buildhash - 0x%x/%d/%d vs. 0x%x/%d/%d", \
4785+ gotopts, gotchars, gotlen, \
4786+ wantedopts, wantedchars, wantedlen
4787+#define LOOKUP_C_NO_HASH_SPACE "Couldn't allocate space for hash table"
4788+#define LOOKUP_C_BAD_FORMAT "Illegal format hash table"
4789+#define LOOKUP_C_NO_LANG_SPACE "Couldn't allocate space for language tables"
4790+
4791+/*
4792+ * The following strings are used in makedent.c:
4793+ */
4794+#define MAKEDENT_C_NO_WORD_SPACE "\nCouldn't allocate space for word '%s'\n"
4795+#define MAKEDENT_C_BAD_WORD_CHAR "\nWord '%s' contains illegal characters\n"
4796+
4797+/*
4798+ * The following strings are used in parse.y:
4799+ */
4800+#define PARSE_Y_8_BIT "Eighth bit ignored (recompile ispell without NO8BIT)"
4801+#define PARSE_Y_NO_WORD_STRINGS "wordchars statement may not specify string characters"
4802+#define PARSE_Y_UNMATCHED "Unmatched charset lengths"
4803+#define PARSE_Y_NO_BOUNDARY_STRINGS "boundarychars statement may not specify string characters"
4804+#define PARSE_Y_LONG_STRING "String character is too long"
4805+#define PARSE_Y_NULL_STRING "String character must have nonzero length"
4806+#define PARSE_Y_MANY_STRINGS "Too many string characters"
4807+#define PARSE_Y_NO_SUCH_STRING "No such string character"
4808+#define PARSE_Y_MULTIPLE_STRINGS "Alternate string character was already defined"
4809+#define PARSE_Y_LENGTH_MISMATCH "Upper and lower versions of string character must be same length"
4810+#define PARSE_Y_WRONG_NROFF "Incorrect character count in nroffchars statement"
4811+#define PARSE_Y_WRONG_TEX "Incorrect character count in TeXchars statement"
4812+#define PARSE_Y_DOUBLE_COMPOUND "Compoundwords option may only appear once"
4813+#define PARSE_Y_LONG_FLAG "Flag must be single character"
4814+#define PARSE_Y_BAD_FLAG "Flag must be alphabetic"
4815+#define PARSE_Y_DUP_FLAG "Duplicate flag"
4816+#define PARSE_Y_NO_SPACE "Out of memory"
4817+#define PARSE_Y_NEED_BLANK "Single characters must be separated by a blank"
4818+#define PARSE_Y_MANY_CONDS "Too many conditions; 8 maximum"
4819+#define PARSE_Y_EOF "Unexpected EOF in quoted string"
4820+#define PARSE_Y_LONG_QUOTE "Quoted string too long, max 256 characters"
4821+#define PARSE_Y_ERROR_FORMAT(file, lineno, error) \
4822+ "%s line %d: %s\n", file, lineno, error
4823+#define PARSE_Y_MALLOC_TROUBLE "yyopen: trouble allocating memory\n"
4824+#define PARSE_Y_UNGRAB_PROBLEM "Internal error: ungrab buffer overflow"
4825+#define PARSE_Y_BAD_DEFORMATTER "Deformatter must be either 'nroff' or 'tex'"
4826+#define PARSE_Y_BAD_NUMBER "Illegal digit in number"
4827+
4828+/*
4829+ * The following strings are used in term.c:
4830+ */
4831+#define TERM_C_SMALL_SCREEN "Screen too small: need at least %d lines\n"
4832+#define TERM_C_NO_BATCH "Can't deal with non-interactive use yet.\n"
4833+#define TERM_C_CANT_FORK "Couldn't fork, try later.\n"
4834+#define TERM_C_TYPE_SPACE "\n-- Type space to continue --"
4835+
4836+/*
4837+ * The following strings are used in tree.c:
4838+ */
4839+#define TREE_C_CANT_UPDATE "Warning: Cannot update personal dictionary (%s)\n"
4840+#define TREE_C_NO_SPACE "Ran out of space for personal dictionary\n"
4841+#define TREE_C_TRY_ANYWAY "Continuing anyway (with reduced performance).\n"
4842+
4843+/*
4844+ * The following strings are used in unsq.c:
4845+ */
4846+#define UNSQ_C_BAD_COUNT "Illegal count character 0x%x\n"
4847+#define UNSQ_C_SURPRISE_EOF "Unexpected EOF\n"
0f1b3689
AG
4848diff -burN vim62.orig/src/spell/tgood.c vim62/src/spell/tgood.c
4849--- vim62.orig/src/spell/tgood.c 1970-01-01 01:00:00.000000000 +0100
4850+++ vim62/src/spell/tgood.c 2004-03-01 22:43:16.762876024 +0100
24ec98f0
JB
4851@@ -0,0 +1,654 @@
4852+/*
4853+ * Copyright 1987, 1988, 1989, 1992, 1993, Geoff Kuenning, Granada Hills, CA
4854+ * All rights reserved.
4855+ *
4856+ * Redistribution and use in source and binary forms, with or without
4857+ * modification, are permitted provided that the following conditions
4858+ * are met:
4859+ *
4860+ * 1. Redistributions of source code must retain the above copyright
4861+ * notice, this list of conditions and the following disclaimer.
4862+ * 2. Redistributions in binary form must reproduce the above copyright
4863+ * notice, this list of conditions and the following disclaimer in the
4864+ * documentation and/or other materials provided with the distribution.
4865+ * 3. All modifications to the source code must be clearly marked as
4866+ * such. Binary redistributions based on modified source code
4867+ * must be clearly marked as modified versions in the documentation
4868+ * and/or other materials provided with the distribution.
4869+ * 4. All advertising materials mentioning features or use of this software
4870+ * must display the following acknowledgment:
4871+ * This product includes software developed by Geoff Kuenning and
4872+ * other unpaid contributors.
4873+ * 5. The name of Geoff Kuenning may not be used to endorse or promote
4874+ * products derived from this software without specific prior
4875+ * written permission.
4876+ *
4877+ * THIS SOFTWARE IS PROVIDED BY GEOFF KUENNING AND CONTRIBUTORS ``AS IS'' AND
4878+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4879+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4880+ * ARE DISCLAIMED. IN NO EVENT SHALL GEOFF KUENNING OR CONTRIBUTORS BE LIABLE
4881+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4882+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4883+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4884+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4885+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
4886+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
4887+ * SUCH DAMAGE.
4888+ */
4889+
4890+/*
4891+ * Table-driven version of good.c.
4892+ *
4893+ * Geoff Kuenning, July 1987
4894+ */
4895+
4896+/*
4897+ * $Log$
4898+ * Revision 1.32 1994/11/02 06:56:16 geoff
4899+ * Remove the anyword feature, which I've decided is a bad idea.
4900+ *
4901+ * Revision 1.31 1994/10/25 05:46:25 geoff
4902+ * Add support for the FF_ANYWORD (affix applies to all words, even if
4903+ * flag bit isn't set) flag option.
4904+ *
4905+ * Revision 1.30 1994/05/24 06:23:08 geoff
4906+ * Don't create a hit if "allhits" is clear and capitalization
4907+ * mismatches. This cures a bug where a word could be in the dictionary
4908+ * and yet not found.
4909+ *
4910+ * Revision 1.29 1994/05/17 06:44:21 geoff
4911+ * Add support for controlled compound formation and the COMPOUNDONLY
4912+ * option to affix flags.
4913+ *
4914+ * Revision 1.28 1994/01/25 07:12:13 geoff
4915+ * Get rid of all old RCS log lines in preparation for the 3.1 release.
4916+ *
4917+ */
4918+
4919+#include <ctype.h>
4920+#include "ispell.h"
4921+
4922+Global void chk_aff (ichar_t * word, ichar_t * ucword, int len,
4923+ int ignoreflagbits, int allhits, int pfxopts, int sfxopts);
4924+Local void pfx_list_chk (ichar_t * word, ichar_t * ucword,
4925+ int len, int optflags, int sfxopts, struct flagptr * ind,
4926+ int ignoreflagbits, int allhits);
4927+Local void chk_suf (ichar_t * word, ichar_t * ucword, int len,
4928+ int optflags, struct flagent * pfxent, int ignoreflagbits,
4929+ int allhits);
4930+Local void suf_list_chk (ichar_t * word, ichar_t * ucword, int len,
4931+ struct flagptr * ind, int optflags, struct flagent * pfxent,
4932+ int ignoreflagbits, int allhits);
4933+Global int expand_pre (char * croot, ichar_t * rootword,
4934+ MASKTYPE mask[], int option, char * extra);
4935+Local int pr_pre_expansion (char * croot, ichar_t * rootword,
4936+ struct flagent * flent, MASKTYPE mask[], int option,
4937+ char * extra);
4938+Global int expand_suf (char * croot, ichar_t * rootword,
4939+ MASKTYPE mask[], int optflags, int option, char * extra);
4940+Local int pr_suf_expansion (char * croot, ichar_t * rootword,
4941+ struct flagent * flent, int option, char * extra);
4942+Local void forcelc (ichar_t * dst, int len);
4943+
4944+/* Check possible affixes */
4945+Public void
4946+chk_aff (
4947+ ichar_t * word, /* Word to be checked */
4948+ ichar_t * ucword, /* Upper-case-only copy of word */
4949+ int len, /* The length of word/ucword */
4950+ int ignoreflagbits, /* Ignore whether affix is legal */
4951+ int allhits, /* Keep going after first hit */
4952+ int pfxopts, /* Options to apply to prefixes */
4953+ int sfxopts) /* Options to apply to suffixes */
4954+ {
4955+ register ichar_t * cp; /* Pointer to char to index on */
4956+ struct flagptr * ind; /* Flag index table to test */
4957+
4958+ pfx_list_chk (word, ucword, len, pfxopts, sfxopts, &pflagindex[0],
4959+ ignoreflagbits, allhits);
4960+ cp = ucword;
4961+ ind = &pflagindex[*cp++];
4962+ while (ind->numents == 0 && ind->pu.fp != NULL)
4963+ {
4964+ if (*cp == 0)
4965+ return;
4966+ if (ind->pu.fp[0].numents)
4967+ {
4968+ pfx_list_chk (word, ucword, len, pfxopts, sfxopts, &ind->pu.fp[0],
4969+ ignoreflagbits, allhits);
4970+ if (numhits && !allhits && !cflag && !ignoreflagbits)
4971+ return;
4972+ }
4973+ ind = &ind->pu.fp[*cp++];
4974+ }
4975+ pfx_list_chk (word, ucword, len, pfxopts, sfxopts, ind, ignoreflagbits,
4976+ allhits);
4977+ if (numhits && !allhits && !cflag && !ignoreflagbits)
4978+ return;
4979+ chk_suf (word, ucword, len, sfxopts, (struct flagent *) NULL,
4980+ ignoreflagbits, allhits);
4981+ }
4982+
4983+/* Check some prefix flags */
4984+Local void
4985+pfx_list_chk(
4986+ ichar_t * word, /* Word to be checked */
4987+ ichar_t * ucword, /* Upper-case-only word */
4988+ int len, /* The length of ucword */
4989+ int optflags, /* Options to apply */
4990+ int sfxopts, /* Options to apply to suffixes */
4991+ struct flagptr * ind, /* Flag index table */
4992+ int ignoreflagbits, /* Ignore whether affix is legal */
4993+ int allhits) /* Keep going after first hit */
4994+ {
4995+ int cond; /* Condition number */
4996+ register ichar_t * cp; /* Pointer into end of ucword */
4997+ struct dent * dent; /* Dictionary entry we found */
4998+ int entcount; /* Number of entries to process */
4999+ register struct flagent *
5000+ flent; /* Current table entry */
5001+ int preadd; /* Length added to tword2 as prefix */
5002+ register int tlen; /* Length of tword */
5003+ ichar_t tword[INPUTWORDLEN + 4 * MAXAFFIXLEN + 4]; /* Tmp cpy */
5004+ ichar_t tword2[sizeof tword]; /* 2nd copy for ins_root_cap */
5005+
5006+ for (flent = ind->pu.ent, entcount = ind->numents;
5007+ entcount > 0; flent++, entcount--)
5008+ {
5009+ /*
5010+ * If this is a compound-only affix, ignore it unless we're
5011+ * looking for that specific thing.
5012+ */
5013+ if ((flent->flagflags & FF_COMPOUNDONLY) != 0
5014+ && (optflags & FF_COMPOUNDONLY) == 0)
5015+ continue;
5016+ /*
5017+ * In COMPOUND_CONTROLLED mode, the FF_COMPOUNDONLY bit must
5018+ * match exactly.
5019+ */
5020+ if (compoundflag == COMPOUND_CONTROLLED
5021+ && ((flent->flagflags ^ optflags) & FF_COMPOUNDONLY) != 0)
5022+ continue;
5023+ /*
5024+ * See if the prefix matches.
5025+ */
5026+ tlen = len - flent->affl;
5027+ if (tlen > 0 && (flent->affl == 0 ||
5028+ icharncmp (flent->affix, ucword, flent->affl) == 0) &&
5029+ tlen + flent->stripl >= flent->numconds)
5030+ {
5031+ /*
5032+ * The prefix matches. Remove it, replace it by the "strip"
5033+ * string (if any), and check the original conditions.
5034+ */
5035+ if (flent->stripl)
5036+ (void) icharcpy (tword, flent->strip);
5037+ (void) icharcpy (tword + flent->stripl, ucword + flent->affl);
5038+ cp = tword;
5039+ for (cond = 0; cond < flent->numconds; cond++)
5040+ {
5041+ if ((flent->conds[*cp++] & (1 << cond)) == 0)
5042+ break;
5043+ }
5044+ if (cond >= flent->numconds)
5045+ {
5046+ /*
5047+ * The conditions match. See if the word is in the
5048+ * dictionary.
5049+ */
5050+ tlen += flent->stripl;
5051+ if (cflag)
5052+ flagpr (tword, BITTOCHAR (flent->flagbit), flent->stripl,
5053+ flent->affl, -1, 0);
5054+ else if (ignoreflagbits)
5055+ {
5056+ if ((dent = lookup (tword, 1)) != NULL)
5057+ {
5058+ cp = tword2;
5059+ if (flent->affl)
5060+ {
5061+ (void) icharcpy (cp, flent->affix);
5062+ cp += flent->affl;
5063+ *cp++ = '+';
5064+ }
5065+ preadd = cp - tword2;
5066+ (void) icharcpy (cp, tword);
5067+ cp += tlen;
5068+ if (flent->stripl)
5069+ {
5070+ *cp++ = '-';
5071+ (void) icharcpy (cp, flent->strip);
5072+ }
5073+ (void) ins_root_cap (tword2, word,
5074+ flent->stripl, preadd,
5075+ 0, (cp - tword2) - tlen - preadd,
5076+ dent, flent, (struct flagent *) NULL);
5077+ }
5078+ }
5079+ else if ((dent = lookup (tword, 1)) != NULL
5080+ && TSTMASKBIT (dent->mask, flent->flagbit))
5081+ {
5082+ if (numhits < MAX_HITS)
5083+ {
5084+ hits[numhits].dictent = dent;
5085+ hits[numhits].prefix = flent;
5086+ hits[numhits].suffix = NULL;
5087+ numhits++;
5088+ }
5089+ if (!allhits)
5090+ {
5091+#ifndef NO_CAPITALIZATION_SUPPORT
5092+ if (cap_ok (word, &hits[0], len))
5093+ return;
5094+ numhits = 0;
5095+#else /* NO_CAPITALIZATION_SUPPORT */
5096+ return;
5097+#endif /* NO_CAPITALIZATION_SUPPORT */
5098+ }
5099+ }
5100+ /*
5101+ * Handle cross-products.
5102+ */
5103+ if (flent->flagflags & FF_CROSSPRODUCT)
5104+ chk_suf (word, tword, tlen, sfxopts | FF_CROSSPRODUCT,
5105+ flent, ignoreflagbits, allhits);
5106+ }
5107+ }
5108+ }
5109+ }
5110+
5111+/* Check possible suffixes */
5112+Local void
5113+chk_suf(
5114+ ichar_t * word, /* Word to be checked */
5115+ ichar_t * ucword, /* Upper-case-only word */
5116+ int len, /* The length of ucword */
5117+ int optflags, /* Affix option flags */
5118+ struct flagent * pfxent, /* Prefix flag entry if cross-prod */
5119+ int ignoreflagbits, /* Ignore whether affix is legal */
5120+ int allhits) /* Keep going after first hit */
5121+ {
5122+ register ichar_t * cp; /* Pointer to char to index on */
5123+ struct flagptr * ind; /* Flag index table to test */
5124+
5125+ suf_list_chk (word, ucword, len, &sflagindex[0], optflags, pfxent,
5126+ ignoreflagbits, allhits);
5127+ cp = ucword + len - 1;
5128+ ind = &sflagindex[*cp];
5129+ while (ind->numents == 0 && ind->pu.fp != NULL)
5130+ {
5131+ if (cp == ucword)
5132+ return;
5133+ if (ind->pu.fp[0].numents)
5134+ {
5135+ suf_list_chk (word, ucword, len, &ind->pu.fp[0],
5136+ optflags, pfxent, ignoreflagbits, allhits);
5137+ if (numhits != 0 && !allhits && !cflag && !ignoreflagbits)
5138+ return;
5139+ }
5140+ ind = &ind->pu.fp[*--cp];
5141+ }
5142+ suf_list_chk (word, ucword, len, ind, optflags, pfxent,
5143+ ignoreflagbits, allhits);
5144+ }
5145+
5146+Local void
5147+suf_list_chk (
5148+ ichar_t * word, /* Word to be checked */
5149+ ichar_t * ucword, /* Upper-case-only word */
5150+ int len, /* The length of ucword */
5151+ struct flagptr * ind, /* Flag index table */
5152+ int optflags, /* Affix option flags */
5153+ struct flagent * pfxent, /* Prefix flag entry if crossonly */
5154+ int ignoreflagbits, /* Ignore whether affix is legal */
5155+ int allhits) /* Keep going after first hit */
5156+{
5157+ register ichar_t * cp; /* Pointer into end of ucword */
5158+ int cond; /* Condition number */
5159+ struct dent * dent; /* Dictionary entry we found */
5160+ int entcount; /* Number of entries to process */
5161+ register struct flagent *
5162+ flent; /* Current table entry */
5163+ int preadd; /* Length added to tword2 as prefix */
5164+ register int tlen; /* Length of tword */
5165+ ichar_t tword[INPUTWORDLEN + 4 * MAXAFFIXLEN + 4]; /* Tmp cpy */
5166+ ichar_t tword2[sizeof tword]; /* 2nd copy for ins_root_cap */
5167+
5168+ (void) icharcpy (tword, ucword);
5169+ for (flent = ind->pu.ent, entcount = ind->numents;
5170+ entcount > 0;
5171+ flent++, entcount--)
5172+ {
5173+ if ((optflags & FF_CROSSPRODUCT) != 0
5174+ && (flent->flagflags & FF_CROSSPRODUCT) == 0)
5175+ continue;
5176+ /*
5177+ * If this is a compound-only affix, ignore it unless we're
5178+ * looking for that specific thing.
5179+ */
5180+ if ((flent->flagflags & FF_COMPOUNDONLY) != 0
5181+ && (optflags & FF_COMPOUNDONLY) == 0)
5182+ continue;
5183+ /*
5184+ * In COMPOUND_CONTROLLED mode, the FF_COMPOUNDONLY bit must
5185+ * match exactly.
5186+ */
5187+ if (compoundflag == COMPOUND_CONTROLLED
5188+ && ((flent->flagflags ^ optflags) & FF_COMPOUNDONLY) != 0)
5189+ continue;
5190+ /*
5191+ * See if the suffix matches.
5192+ */
5193+ tlen = len - flent->affl;
5194+ if (tlen > 0
5195+ && (flent->affl == 0
5196+ || icharcmp (flent->affix, ucword + tlen) == 0)
5197+ && tlen + flent->stripl >= flent->numconds)
5198+ {
5199+ /*
5200+ * The suffix matches. Remove it, replace it by the "strip"
5201+ * string (if any), and check the original conditions.
5202+ */
5203+ (void) icharcpy (tword, ucword);
5204+ cp = tword + tlen;
5205+ if (flent->stripl)
5206+ {
5207+ (void) icharcpy (cp, flent->strip);
5208+ tlen += flent->stripl;
5209+ cp = tword + tlen;
5210+ }
5211+ else
5212+ *cp = '\0';
5213+ for (cond = flent->numconds; --cond >= 0; )
5214+ {
5215+ if ((flent->conds[*--cp] & (1 << cond)) == 0)
5216+ break;
5217+ }
5218+ if (cond < 0)
5219+ {
5220+ /*
5221+ * The conditions match. See if the word is in the
5222+ * dictionary.
5223+ */
5224+ if (cflag)
5225+ {
5226+ if (optflags & FF_CROSSPRODUCT)
5227+ flagpr (tword, BITTOCHAR (pfxent->flagbit),
5228+ pfxent->stripl, pfxent->affl,
5229+ BITTOCHAR (flent->flagbit), flent->affl);
5230+ else
5231+ flagpr (tword, -1, 0, 0,
5232+ BITTOCHAR (flent->flagbit), flent->affl);
5233+ }
5234+ else if (ignoreflagbits)
5235+ {
5236+ if ((dent = lookup (tword, 1)) != NULL)
5237+ {
5238+ cp = tword2;
5239+ if ((optflags & FF_CROSSPRODUCT)
5240+ && pfxent->affl != 0)
5241+ {
5242+ (void) icharcpy (cp, pfxent->affix);
5243+ cp += pfxent->affl;
5244+ *cp++ = '+';
5245+ }
5246+ preadd = cp - tword2;
5247+ (void) icharcpy (cp, tword);
5248+ cp += tlen;
5249+ if ((optflags & FF_CROSSPRODUCT)
5250+ && pfxent->stripl != 0)
5251+ {
5252+ *cp++ = '-';
5253+ (void) icharcpy (cp, pfxent->strip);
5254+ cp += pfxent->stripl;
5255+ }
5256+ if (flent->stripl)
5257+ {
5258+ *cp++ = '-';
5259+ (void) icharcpy (cp, flent->strip);
5260+ cp += flent->stripl;
5261+ }
5262+ if (flent->affl)
5263+ {
5264+ *cp++ = '+';
5265+ (void) icharcpy (cp, flent->affix);
5266+ cp += flent->affl;
5267+ }
5268+ (void) ins_root_cap (tword2, word,
5269+ (optflags & FF_CROSSPRODUCT) ? pfxent->stripl : 0,
5270+ preadd,
5271+ flent->stripl, (cp - tword2) - tlen - preadd,
5272+ dent, pfxent, flent);
5273+ }
5274+ }
5275+ else if ((dent = lookup (tword, 1)) != NULL
5276+ && TSTMASKBIT (dent->mask, flent->flagbit)
5277+ && ((optflags & FF_CROSSPRODUCT) == 0
5278+ || TSTMASKBIT (dent->mask, pfxent->flagbit)))
5279+ {
5280+ if (numhits < MAX_HITS)
5281+ {
5282+ hits[numhits].dictent = dent;
5283+ hits[numhits].prefix = pfxent;
5284+ hits[numhits].suffix = flent;
5285+ numhits++;
5286+ }
5287+ if (!allhits)
5288+ {
5289+#ifndef NO_CAPITALIZATION_SUPPORT
5290+ if (cap_ok (word, &hits[0], len))
5291+ return;
5292+ numhits = 0;
5293+#else /* NO_CAPITALIZATION_SUPPORT */
5294+ return;
5295+#endif /* NO_CAPITALIZATION_SUPPORT */
5296+ }
5297+ }
5298+ }
5299+ }
5300+ }
5301+}
5302+
5303+/*
5304+ * Expand a dictionary prefix entry
5305+ */
5306+Public int
5307+expand_pre(
5308+ char * croot, /* Char version of rootword */
5309+ ichar_t * rootword, /* Root word to expand */
5310+ register MASKTYPE mask[], /* Mask bits to expand on */
5311+ int option, /* Option, see expandmode */
5312+ char * extra) /* Extra info to add to line */
5313+{
5314+ int entcount; /* No. of entries to process */
5315+ int explength; /* Length of expansions */
5316+ register struct flagent *
5317+ flent; /* Current table entry */
5318+
5319+ for (flent = pflaglist, entcount = numpflags, explength = 0;
5320+ entcount > 0; flent++, entcount--)
5321+ {
5322+ if (TSTMASKBIT (mask, flent->flagbit))
5323+ explength +=
5324+ pr_pre_expansion (croot, rootword, flent, mask, option, extra);
5325+ }
5326+ return explength;
5327+}
5328+
5329+/* Print a prefix expansion */
5330+Local int
5331+pr_pre_expansion(
5332+ char * croot, /* Char version of rootword */
5333+ register ichar_t * rootword, /* Root word to expand */
5334+ register struct flagent * flent, /* Current table entry */
5335+ MASKTYPE mask[], /* Mask bits to expand on */
5336+ int option, /* Option, see expandmode */
5337+ char * extra) /* Extra info to add to line */
5338+{
5339+ int cond; /* Current condition number */
5340+ register ichar_t * nextc; /* Next case choice */
5341+ int tlen; /* Length of tword */
5342+ ichar_t tword[INPUTWORDLEN + MAXAFFIXLEN]; /* Temp */
5343+
5344+ tlen = icharlen (rootword);
5345+ if (flent->numconds > tlen)
5346+ return 0;
5347+ tlen -= flent->stripl;
5348+ if (tlen <= 0)
5349+ return 0;
5350+ tlen += flent->affl;
5351+ for (cond = 0, nextc = rootword; cond < flent->numconds; cond++)
5352+ {
5353+ if ((flent->conds[mytoupper (*nextc++)] & (1 << cond)) == 0)
5354+ return 0;
5355+ }
5356+ /*
5357+ * The conditions are satisfied. Copy the word, add the prefix,
5358+ * and make it the proper case. This code is carefully written
5359+ * to match that ins_cap and cap_ok. Note that the affix, as
5360+ * inserted, is uppercase.
5361+ *
5362+ * There is a tricky bit here: if the root is capitalized, we
5363+ * want a capitalized result. If the root is followcase, however,
5364+ * we want to duplicate the case of the first remaining letter
5365+ * of the root. In other words, "Loved/U" should generate "Unloved",
5366+ * but "LOved/U" should generate "UNLOved" and "lOved/U" should
5367+ * produce "unlOved".
5368+ */
5369+ if (flent->affl)
5370+ {
5371+ (void) icharcpy (tword, flent->affix);
5372+ nextc = tword + flent->affl;
5373+ }
5374+ (void) icharcpy (nextc, rootword + flent->stripl);
5375+ if (myupper (rootword[0]))
5376+ {
5377+ /* We must distinguish followcase from capitalized and all-upper */
5378+ for (nextc = rootword + 1; *nextc; nextc++)
5379+ {
5380+ if (!myupper (*nextc))
5381+ break;
5382+ }
5383+ if (*nextc)
5384+ {
5385+ /* It's a followcase or capitalized word. Figure out which. */
5386+ for ( ; *nextc; nextc++)
5387+ {
5388+ if (myupper (*nextc))
5389+ break;
5390+ }
5391+ if (*nextc)
5392+ {
5393+ /* It's followcase. */
5394+ if (!myupper (tword[flent->affl]))
5395+ forcelc (tword, flent->affl);
5396+ }
5397+ else
5398+ {
5399+ /* It's capitalized */
5400+ forcelc (tword + 1, tlen - 1);
5401+ }
5402+ }
5403+ }
5404+ else
5405+ {
5406+ /* Followcase or all-lower, we don't care which */
5407+ if (!myupper (*nextc))
5408+ forcelc (tword, flent->affl);
5409+ }
5410+ if (option == 3)
5411+ (void) printf ("\n%s", croot);
5412+ if (option != 4)
5413+ (void) printf (" %s%s", ichartosstr (tword, 1), extra);
5414+ if (flent->flagflags & FF_CROSSPRODUCT)
5415+ return tlen
5416+ + expand_suf (croot, tword, mask, FF_CROSSPRODUCT, option, extra);
5417+ else
5418+ return tlen;
5419+}
5420+
5421+/*
5422+ * Expand a dictionary suffix entry
5423+ */
5424+int expand_suf (croot, rootword, mask, optflags, option, extra)
5425+ char * croot; /* Char version of rootword */
5426+ ichar_t * rootword; /* Root word to expand */
5427+ register MASKTYPE mask[]; /* Mask bits to expand on */
5428+ int optflags; /* Affix option flags */
5429+ int option; /* Option, see expandmode */
5430+ char * extra; /* Extra info to add to line */
5431+ {
5432+ int entcount; /* No. of entries to process */
5433+ int explength; /* Length of expansions */
5434+ register struct flagent *
5435+ flent; /* Current table entry */
5436+
5437+ for (flent = sflaglist, entcount = numsflags, explength = 0;
5438+ entcount > 0;
5439+ flent++, entcount--)
5440+ {
5441+ if (TSTMASKBIT (mask, flent->flagbit))
5442+ {
5443+ if ((optflags & FF_CROSSPRODUCT) == 0
5444+ || (flent->flagflags & FF_CROSSPRODUCT))
5445+ explength +=
5446+ pr_suf_expansion (croot, rootword, flent, option, extra);
5447+ }
5448+ }
5449+ return explength;
5450+ }
5451+
5452+/* Print a suffix expansion */
5453+static int pr_suf_expansion (croot, rootword, flent, option, extra)
5454+ char * croot; /* Char version of rootword */
5455+ register ichar_t * rootword; /* Root word to expand */
5456+ register struct flagent * flent; /* Current table entry */
5457+ int option; /* Option, see expandmode */
5458+ char * extra; /* Extra info to add to line */
5459+ {
5460+ int cond; /* Current condition number */
5461+ register ichar_t * nextc; /* Next case choice */
5462+ int tlen; /* Length of tword */
5463+ ichar_t tword[INPUTWORDLEN + MAXAFFIXLEN]; /* Temp */
5464+
5465+ tlen = icharlen (rootword);
5466+ cond = flent->numconds;
5467+ if (cond > tlen)
5468+ return 0;
5469+ if (tlen - flent->stripl <= 0)
5470+ return 0;
5471+ for (nextc = rootword + tlen; --cond >= 0; )
5472+ {
5473+ if ((flent->conds[mytoupper (*--nextc)] & (1 << cond)) == 0)
5474+ return 0;
5475+ }
5476+ /*
5477+ * The conditions are satisfied. Copy the word, add the suffix,
5478+ * and make it match the case of the last remaining character of the
5479+ * root. Again, this code carefully matches ins_cap and cap_ok.
5480+ */
5481+ (void) icharcpy (tword, rootword);
5482+ nextc = tword + tlen - flent->stripl;
5483+ if (flent->affl)
5484+ {
5485+ (void) icharcpy (nextc, flent->affix);
5486+ if (!myupper (nextc[-1]))
5487+ forcelc (nextc, flent->affl);
5488+ }
5489+ else
5490+ *nextc = 0;
5491+ if (option == 3)
5492+ (void) printf ("\n%s", croot);
5493+ if (option != 4)
5494+ (void) printf (" %s%s", ichartosstr (tword, 1), extra);
5495+ return tlen + flent->affl - flent->stripl;
5496+ }
5497+
5498+static void forcelc (dst, len) /* Force to lowercase */
5499+ register ichar_t * dst; /* Destination to modify */
5500+ register int len; /* Length to copy */
5501+ {
5502+
5503+ for ( ; --len >= 0; dst++)
5504+ *dst = mytolower (*dst);
5505+ }
0f1b3689
AG
5506diff -burN vim62.orig/src/spell/tree.c vim62/src/spell/tree.c
5507--- vim62.orig/src/spell/tree.c 1970-01-01 01:00:00.000000000 +0100
5508+++ vim62/src/spell/tree.c 2004-03-01 22:43:16.766875416 +0100
24ec98f0
JB
5509@@ -0,0 +1,748 @@
5510+/*
5511+ * tree.c - a hash style dictionary for user's personal words
5512+ *
5513+ * Pace Willisson, 1983
5514+ * Hash support added by Geoff Kuenning, 1987
5515+ *
5516+ * Copyright 1987, 1988, 1989, 1992, 1993, Geoff Kuenning, Granada Hills, CA
5517+ * All rights reserved.
5518+ *
5519+ * Redistribution and use in source and binary forms, with or without
5520+ * modification, are permitted provided that the following conditions
5521+ * are met:
5522+ *
5523+ * 1. Redistributions of source code must retain the above copyright
5524+ * notice, this list of conditions and the following disclaimer.
5525+ * 2. Redistributions in binary form must reproduce the above copyright
5526+ * notice, this list of conditions and the following disclaimer in the
5527+ * documentation and/or other materials provided with the distribution.
5528+ * 3. All modifications to the source code must be clearly marked as
5529+ * such. Binary redistributions based on modified source code
5530+ * must be clearly marked as modified versions in the documentation
5531+ * and/or other materials provided with the distribution.
5532+ * 4. All advertising materials mentioning features or use of this software
5533+ * must display the following acknowledgment:
5534+ * This product includes software developed by Geoff Kuenning and
5535+ * other unpaid contributors.
5536+ * 5. The name of Geoff Kuenning may not be used to endorse or promote
5537+ * products derived from this software without specific prior
5538+ * written permission.
5539+ *
5540+ * THIS SOFTWARE IS PROVIDED BY GEOFF KUENNING AND CONTRIBUTORS ``AS IS'' AND
5541+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5542+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5543+ * ARE DISCLAIMED. IN NO EVENT SHALL GEOFF KUENNING OR CONTRIBUTORS BE LIABLE
5544+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5545+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
5546+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
5547+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
5548+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5549+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5550+ * SUCH DAMAGE.
5551+ */
5552+
5553+/*
5554+ * $Log$
5555+ * Revision 1.56 1995/01/08 23:23:49 geoff
5556+ * Support PDICTHOME for DOS purposes.
5557+ *
5558+ * Revision 1.55 1994/10/25 05:46:27 geoff
5559+ * Fix a comment that looked to some compilers like it might be nested.
5560+ *
5561+ * Revision 1.54 1994/01/25 07:12:15 geoff
5562+ * Get rid of all old RCS log lines in preparation for the 3.1 release.
5563+ *
5564+ */
5565+
5566+#include <ctype.h>
5567+#include <stdlib.h>
5568+#include <errno.h>
5569+#include "ispell.h"
5570+#include "msgs.h"
5571+
5572+Local FILE * trydict (char * dictname, char * home,
5573+ char * prefix, char * suffix);
5574+Local void treeload (FILE * dictf);
5575+Local struct dent * tinsert (struct dent * proto);
5576+#if SORTPERSONAL != 0
5577+Local int pdictcmp (struct dent ** enta, struct dent **entb);
5578+#endif /* SORTPERSONAL != 0 */
5579+#ifdef REGEX_LOOKUP
5580+#endif /* REGEX_LOOKUP */
5581+
5582+Local int cantexpand = 0; /* NZ if an expansion fails */
5583+Local struct dent * pershtab; /* Aux hash table for personal dict */
5584+Local int pershsize = 0; /* Space available in aux hash table */
5585+Local int hcount = 0; /* Number of items in hash table */
5586+
5587+/*
5588+ * Hash table sizes. Prime is probably a good idea, though in truth I
5589+ * whipped the algorithm up on the spot rather than looking it up, so
5590+ * who knows what's really best? If we overflow the table, we just
5591+ * use a double-and-add-1 algorithm.
5592+ */
5593+static int goodsizes[] =
5594+ {
5595+ 53, 223, 907, 3631
5596+ };
5597+
5598+Local char personaldict[MAXPATHLEN];
5599+Local FILE * dictf;
5600+Local newwords = 0;
5601+
5602+Public void
5603+treeinit (
5604+ char * p, /* Value specified in -p switch */
5605+ char * LibDict) /* Root of default dict name */
5606+{
5607+ int abspath; /* NZ if p is abs path name */
5608+ char * h; /* Home directory name */
5609+ char seconddict[MAXPATHLEN]; /* Name of secondary dict */
5610+ FILE * secondf; /* Access to second dict file */
5611+
5612+ /*
5613+ ** If -p was not specified, try to get a default name from the
5614+ ** environment. After this point, if p is null, the the value in
5615+ ** personaldict is the only possible name for the personal dictionary.
5616+ ** If p is non-null, then there is a possibility that we should
5617+ ** prepend HOME to get the correct dictionary name.
5618+ */
5619+ if (p == NULL)
5620+ p = getenv (PDICTVAR);
5621+ /*
5622+ ** if p exists and begins with '/' we don't really need HOME,
5623+ ** but it's not very likely that HOME isn't set anyway (on non-DOS
5624+ ** systems).
5625+ */
5626+ {
5627+ int i;
5628+ struct dent *x;
5629+
5630+ for(i = 0; i < pershsize; i++)
5631+ {
5632+ x = &pershtab[i];
5633+ if(x->word != NULL)
5634+ free(x->word);
5635+ for(x = x->next; x != NULL;)
5636+ {
5637+ struct dent *y;
5638+
5639+ if(x->word != NULL)
5640+ free(x->word);
5641+ y = x;
5642+ x = x->next;
5643+ free(y);
5644+ }
5645+ }
5646+ if(pershtab != NULL)
5647+ free(pershtab);
5648+ pershtab = NULL;
5649+ pershsize = 0;
5650+ hcount = 0;
5651+ }
5652+ if ((h = getenv (HOME)) == NULL)
5653+ {
5654+#ifdef PDICTHOME
5655+ h = PDICTHOME;
5656+#else /* PDICTHOME */
5657+ return;
5658+#endif /* PDICTHOME */
5659+ }
5660+
5661+ if (p == NULL)
5662+ {
5663+ /*
5664+ * No -p and no PDICTVAR. We will use LibDict and DEFPAFF to
5665+ * figure out the name of the personal dictionary and where it
5666+ * is. The rules are as follows:
5667+ *
5668+ * (1) If there is a local dictionary and a HOME dictionary,
5669+ * both are loaded, but changes are saved in the local one.
5670+ * The dictionary to save changes in is named "personaldict".
5671+ * (2) Dictionaries named after the affix file take precedence
5672+ * over dictionaries with the default suffix (DEFPAFF).
5673+ * (3) Dictionaries named with the new default names
5674+ * (DEFPDICT/DEFPAFF) take precedence over the old ones
5675+ * (OLDPDICT/OLDPAFF).
5676+ * (4) Dictionaries aren't combined unless they follow the same
5677+ * naming scheme.
5678+ * (5) If no dictionary can be found, a new one is created in
5679+ * the home directory, named after DEFPDICT and the affix
5680+ * file.
5681+ */
5682+ dictf = trydict (personaldict, (char *) NULL, DEFPDICT, LibDict);
5683+ secondf = trydict (seconddict, h, DEFPDICT, LibDict);
5684+ if (dictf == NULL && secondf == NULL)
5685+ {
5686+ dictf = trydict (personaldict, (char *) NULL, DEFPDICT, DEFPAFF);
5687+ secondf = trydict (seconddict, h, DEFPDICT, DEFPAFF);
5688+ }
5689+ if (dictf == NULL && secondf == NULL)
5690+ {
5691+ dictf = trydict (personaldict, (char *) NULL, OLDPDICT, LibDict);
5692+ secondf = trydict (seconddict, h, OLDPDICT, LibDict);
5693+ }
5694+ if (dictf == NULL && secondf == NULL)
5695+ {
5696+ dictf = trydict (personaldict, (char *) NULL, OLDPDICT, OLDPAFF);
5697+ secondf = trydict (seconddict, h, OLDPDICT, OLDPAFF);
5698+ }
5699+ if (personaldict[0] == '\0')
5700+ {
5701+ if (seconddict[0] != '\0')
5702+ (void) strcpy (personaldict, seconddict);
5703+ else
5704+ (void) sprintf (personaldict, "%s/%s%s", h, DEFPDICT, LibDict);
5705+ }
5706+ if (dictf != NULL)
5707+ {
5708+ treeload (dictf);
5709+ (void) fclose (dictf);
5710+ }
5711+ if (secondf != NULL)
5712+ {
5713+ treeload (secondf);
5714+ (void) fclose (secondf);
5715+ }
5716+ }
5717+ else
5718+ {
5719+ /*
5720+ ** Figure out if p is an absolute path name. Note that beginning
5721+ ** with "./" and "../" is considered an absolute path, since this
5722+ ** still means we can't prepend HOME.
5723+ */
5724+ abspath = (*p == '/' || strncmp (p, "./", 2) == 0
5725+ || strncmp (p, "../", 3) == 0);
5726+#ifdef MSDOS
5727+ if (!abspath)
5728+ abspath = (*p == '\\' || strncmp (p, ".\\", 2) == 0
5729+ || strncmp (p, "..\\", 3) == 0
5730+ || (p[0] && p[1] == ':'));
5731+#endif
5732+ if (abspath)
5733+ {
5734+ (void) strcpy (personaldict, p);
5735+ if ((dictf = fopen (personaldict, "r")) != NULL)
5736+ {
5737+ treeload (dictf);
5738+ (void) fclose (dictf);
5739+ }
5740+ }
5741+ else
5742+ {
5743+ /*
5744+ ** The user gave us a relative pathname. We will try it
5745+ ** locally, and if that doesn't work, we'll try the home
5746+ ** directory. If neither exists, it will be created in
5747+ ** the home directory if words are added.
5748+ */
5749+ (void) strcpy (personaldict, p);
5750+ if ((dictf = fopen (personaldict, "r")) != NULL)
5751+ {
5752+ treeload (dictf);
5753+ (void) fclose (dictf);
5754+ }
5755+ else if (!abspath)
5756+ {
5757+ /* Try the home */
5758+ (void) sprintf (personaldict, "%s/%s", h, p);
5759+ if ((dictf = fopen (personaldict, "r")) != NULL)
5760+ {
5761+ treeload (dictf);
5762+ (void) fclose (dictf);
5763+ }
5764+ }
5765+ /*
5766+ * If dictf is null, we couldn't open the dictionary
5767+ * specified in the -p switch. Complain.
5768+ */
5769+ if (dictf == NULL)
5770+ {
5771+ (void) fprintf (stderr, CANT_OPEN, p);
5772+ perror ("");
5773+ return;
5774+ }
5775+ }
5776+ }
5777+
5778+#ifndef FEAT_SPELL_HL
5779+ if (!lflag && !aflag
5780+ && access (personaldict, 2) < 0 && errno != ENOENT)
5781+ {
5782+ (void) fprintf (stderr, TREE_C_CANT_UPDATE, personaldict);
5783+ (void) sleep ((unsigned) 2);
5784+ }
5785+#endif
5786+}
5787+
5788+/*
5789+ * Try to open a dictionary. As a side effect, leaves the dictionary
5790+ * name in "filename" if one is found, and leaves a null string there
5791+ * otherwise.
5792+ */
5793+Local FILE *
5794+trydict (
5795+ char * filename, /* Where to store the file name */
5796+ char * home, /* Home directory */
5797+ char * prefix, /* Prefix for dictionary */
5798+ char * suffix) /* Suffix for dictionary */
5799+{
5800+ FILE * dictf; /* Access to dictionary file */
5801+
5802+ if (home == NULL)
5803+ (void) sprintf (filename, "%s%s", prefix, suffix);
5804+ else
5805+ (void) sprintf (filename, "%s/%s%s", home, prefix, suffix);
5806+ dictf = fopen (filename, "r");
5807+ if (dictf == NULL)
5808+ filename[0] = '\0';
5809+ return dictf;
5810+}
5811+
5812+Local void
5813+treeload (
5814+ register FILE * loadfile) /* File to load words from */
5815+{
5816+ char buf[BUFSIZ]; /* Buffer for reading pers dict */
5817+
5818+ while (fgets (buf, sizeof buf, loadfile) != NULL)
5819+ treeinsert (buf, sizeof(buf), 1);
5820+ newwords = 0;
5821+}
5822+
5823+Public void
5824+treeinsert (
5825+ char * word, /* Word to insert - must be canonical */
5826+ int wordlen, /* Length of the word buffer */
5827+ int keep)
5828+{
5829+ register int i, len;
5830+ struct dent wordent;
5831+ register struct dent * dp;
5832+ struct dent * olddp;
5833+#ifndef NO_CAPITALIZATION_SUPPORT
5834+ struct dent * newdp;
5835+#endif
5836+ struct dent * oldhtab;
5837+ int oldhsize;
5838+ ichar_t nword[INPUTWORDLEN + MAXAFFIXLEN];
5839+#ifndef NO_CAPITALIZATION_SUPPORT
5840+ int isvariant;
5841+#endif
5842+
5843+ len = strlen(word);
5844+ if((word[len - 1] == '\n') || (word[len - 1] == '\r'))
5845+ word[len - 1] = '\0', len--;
5846+ if((word[len - 1] == '\n') || (word[len - 1] == '\r'))
5847+ word[len - 1] = '\0';
5848+ /*
5849+ * Expand hash table when it is MAXPCT % full.
5850+ */
5851+ if (!cantexpand && (hcount * 100) / MAXPCT >= pershsize)
5852+ {
5853+ oldhsize = pershsize;
5854+ oldhtab = pershtab;
5855+ for (i = 0; i < sizeof goodsizes / sizeof (goodsizes[0]); i++)
5856+ if (goodsizes[i] > pershsize)
5857+ break;
5858+ if (i >= sizeof goodsizes / sizeof goodsizes[0])
5859+ pershsize += pershsize + 1;
5860+ else
5861+ pershsize = goodsizes[i];
5862+ pershtab =
5863+ (struct dent *) calloc ((unsigned) pershsize, sizeof (struct dent));
5864+ if (pershtab == NULL)
5865+ {
5866+ (void) fprintf (stderr, TREE_C_NO_SPACE);
5867+ /*
5868+ * Try to continue anyway, since our overflow
5869+ * algorithm can handle an overfull (100%+) table,
5870+ * and the malloc very likely failed because we
5871+ * already have such a huge table, so small mallocs
5872+ * for overflow entries will still work.
5873+ */
5874+ if (oldhtab == NULL)
5875+ exit (1); /* No old table, can't go on */
5876+ (void) fprintf (stderr, TREE_C_TRY_ANYWAY);
5877+ cantexpand = 1; /* Suppress further messages */
5878+ pershsize = oldhsize; /* Put things back */
5879+ pershtab = oldhtab; /* ... */
5880+ newwords = 1; /* And pretend it worked */
5881+ }
5882+ else
5883+ {
5884+ /*
5885+ * Re-insert old entries into new table
5886+ */
5887+ for (i = 0; i < oldhsize; i++)
5888+ {
5889+ dp = &oldhtab[i];
5890+ if (dp->flagfield & USED)
5891+ {
5892+#ifdef NO_CAPITALIZATION_SUPPORT
5893+ (void) tinsert (dp);
5894+#else
5895+ newdp = tinsert (dp);
5896+ isvariant = (dp->flagfield & MOREVARIANTS);
5897+#endif
5898+ dp = dp->next;
5899+#ifdef NO_CAPITALIZATION_SUPPORT
5900+ while (dp != NULL)
5901+ {
5902+ (void) tinsert (dp);
5903+ olddp = dp;
5904+ dp = dp->next;
5905+ free ((char *) olddp);
5906+ }
5907+#else
5908+ while (dp != NULL)
5909+ {
5910+ if (isvariant)
5911+ {
5912+ isvariant = dp->flagfield & MOREVARIANTS;
5913+ olddp = newdp->next;
5914+ newdp->next = dp;
5915+ newdp = dp;
5916+ dp = dp->next;
5917+ newdp->next = olddp;
5918+ }
5919+ else
5920+ {
5921+ isvariant = dp->flagfield & MOREVARIANTS;
5922+ newdp = tinsert (dp);
5923+ olddp = dp;
5924+ dp = dp->next;
5925+ free ((char *) olddp);
5926+ }
5927+ }
5928+#endif
5929+ }
5930+ }
5931+ if (oldhtab != NULL)
5932+ free ((char *) oldhtab);
5933+ }
5934+ }
5935+
5936+ /*
5937+ ** We're ready to do the insertion. Start by creating a sample
5938+ ** entry for the word.
5939+ */
5940+ if (makedent (word, wordlen, &wordent) < 0)
5941+ return; /* Word must be too big or something */
5942+ if (keep)
5943+ wordent.flagfield |= KEEP;
5944+ /*
5945+ ** Now see if word or a variant is already in the table. We use the
5946+ ** capitalized version so we'll find the header, if any.
5947+ **/
5948+ (void) strtoichar (nword, word, sizeof nword, 1);
5949+ upcase (nword);
5950+ if ((dp = lookup (nword, 1)) != NULL)
5951+ {
5952+ /* It exists. Combine caps and set the keep flag. */
5953+ if (combinecaps (dp, &wordent) < 0)
5954+ {
5955+ free (wordent.word);
5956+ return;
5957+ }
5958+ }
5959+ else
5960+ {
5961+ /* It's new. Insert the word. */
5962+ dp = tinsert (&wordent);
5963+#ifndef NO_CAPITALIZATION_SUPPORT
5964+ if (captype (dp->flagfield) == FOLLOWCASE)
5965+ (void) addvheader (dp);
5966+#endif
5967+ }
5968+ newwords |= keep;
5969+ hcount++;
5970+}
5971+
5972+Local struct dent *
5973+tinsert (
5974+ struct dent * proto) /* Prototype entry to copy */
5975+{
5976+ ichar_t iword[INPUTWORDLEN + MAXAFFIXLEN];
5977+ register int hcode;
5978+ register struct dent * hp; /* Next trial entry in hash table */
5979+ register struct dent * php; /* Prev. value of hp, for chaining */
5980+
5981+ if (strtoichar (iword, proto->word, sizeof iword, 1))
5982+ (void) fprintf (stderr, WORD_TOO_LONG (proto->word));
5983+#ifdef NO_CAPITALIZATION_SUPPORT
5984+ upcase (iword);
5985+#endif
5986+ hcode = hash (iword, pershsize);
5987+ php = NULL;
5988+ hp = &pershtab[hcode];
5989+ if (hp->flagfield & USED)
5990+ {
5991+ while (hp != NULL)
5992+ {
5993+ php = hp;
5994+ hp = hp->next;
5995+ }
5996+ hp = (struct dent *) calloc (1, sizeof (struct dent));
5997+ if (hp == NULL)
5998+ {
5999+ (void) fprintf (stderr, TREE_C_NO_SPACE);
6000+ exit (1);
6001+ }
6002+ }
6003+ *hp = *proto;
6004+ if (php != NULL)
6005+ php->next = hp;
6006+ hp->next = NULL;
6007+ return hp;
6008+}
6009+
6010+Public struct dent *
6011+treelookup (register ichar_t * word)
6012+
6013+{
6014+ register int hcode;
6015+ register struct dent * hp;
6016+ char chword[INPUTWORDLEN + MAXAFFIXLEN];
6017+
6018+ if (pershsize <= 0)
6019+ return NULL;
6020+ (void) ichartostr (chword, word, sizeof chword, 1);
6021+ hcode = hash (word, pershsize);
6022+ hp = &pershtab[hcode];
6023+ while (hp != NULL && (hp->flagfield & USED))
6024+ {
6025+ if (strcmp (chword, hp->word) == 0)
6026+ break;
6027+#ifndef NO_CAPITALIZATION_SUPPORT
6028+ while (hp->flagfield & MOREVARIANTS)
6029+ hp = hp->next;
6030+#endif
6031+ hp = hp->next;
6032+ }
6033+ if (hp != NULL && (hp->flagfield & USED))
6034+ return hp;
6035+ else
6036+ return NULL;
6037+}
6038+
6039+#if SORTPERSONAL != 0
6040+/* Comparison routine for sorting the personal dictionary with qsort */
6041+Local int
6042+pdictcmp (
6043+ struct dent ** enta,
6044+ struct dent ** entb)
6045+{
6046+
6047+ /* The parentheses around *enta and *entb below are NECESSARY!
6048+ ** Otherwise the compiler reads it as *(enta->word), or
6049+ ** enta->word[0], which is illegal (but pcc takes it and
6050+ ** produces wrong code).
6051+ **/
6052+ return casecmp ((*enta)->word, (*entb)->word, 1);
6053+}
6054+#endif
6055+
6056+Public void
6057+treeoutput ()
6058+
6059+{
6060+ register struct dent * cent; /* Current entry */
6061+ register struct dent * lent; /* Linked entry */
6062+#if SORTPERSONAL != 0
6063+ int pdictsize; /* Number of entries to write */
6064+ struct dent ** sortlist; /* List of entries to be sorted */
6065+ register struct dent ** sortptr; /* Handy pointer into sortlist */
6066+#endif
6067+ register struct dent * ehtab; /* End of pershtab, for fast looping */
6068+
6069+ if (newwords == 0)
6070+ return;
6071+
6072+ if ((dictf = fopen (personaldict, "w")) == NULL)
6073+ {
6074+ (void) fprintf (stderr, CANT_CREATE, personaldict);
6075+ return;
6076+ }
6077+
6078+#if SORTPERSONAL != 0
6079+ /*
6080+ ** If we are going to sort the personal dictionary, we must know
6081+ ** how many items are going to be sorted.
6082+ */
6083+ pdictsize = 0;
6084+ if (hcount >= SORTPERSONAL)
6085+ sortlist = NULL;
6086+ else
6087+ {
6088+ for (cent = pershtab, ehtab = pershtab + pershsize; cent < ehtab;
6089+ cent++)
6090+ {
6091+ for (lent = cent; lent != NULL; lent = lent->next)
6092+ {
6093+ if ((lent->flagfield & (USED | KEEP)) == (USED | KEEP))
6094+ pdictsize++;
6095+#ifndef NO_CAPITALIZATION_SUPPORT
6096+ while (lent->flagfield & MOREVARIANTS)
6097+ lent = lent->next;
6098+#endif
6099+ }
6100+ }
6101+ for (cent = hashtbl, ehtab = hashtbl + hashsize; cent < ehtab; cent++)
6102+ {
6103+ if ((cent->flagfield & (USED | KEEP)) == (USED | KEEP))
6104+ {
6105+ /*
6106+ ** We only want to count variant headers
6107+ ** and standalone entries. These happen
6108+ ** to share the characteristics in the
6109+ ** test below. This test will appear
6110+ ** several more times in this routine.
6111+ */
6112+#ifndef NO_CAPITALIZATION_SUPPORT
6113+ if (captype (cent->flagfield) != FOLLOWCASE
6114+ && cent->word != NULL)
6115+#endif
6116+ pdictsize++;
6117+ }
6118+ }
6119+ sortlist = (struct dent **) malloc (pdictsize * sizeof (struct dent));
6120+ }
6121+ if (sortlist == NULL)
6122+ {
6123+#endif
6124+ for (cent = pershtab, ehtab = pershtab + pershsize; cent < ehtab;
6125+ cent++)
6126+ {
6127+ for (lent = cent; lent != NULL; lent = lent->next)
6128+ {
6129+ if ((lent->flagfield & (USED | KEEP)) == (USED | KEEP))
6130+ {
6131+ toutent (dictf, lent, 1);
6132+#ifndef NO_CAPITALIZATION_SUPPORT
6133+ while (lent->flagfield & MOREVARIANTS)
6134+ lent = lent->next;
6135+#endif
6136+ }
6137+ }
6138+ }
6139+ for (cent = hashtbl, ehtab = hashtbl + hashsize; cent < ehtab; cent++)
6140+ {
6141+ if ((cent->flagfield & (USED | KEEP)) == (USED | KEEP))
6142+ {
6143+#ifndef NO_CAPITALIZATION_SUPPORT
6144+ if (captype (cent->flagfield) != FOLLOWCASE
6145+ && cent->word != NULL)
6146+#endif
6147+ toutent (dictf, cent, 1);
6148+ }
6149+ }
6150+#if SORTPERSONAL != 0
6151+ return;
6152+ }
6153+ /*
6154+ ** Produce dictionary in sorted order. We used to do this
6155+ ** destructively, but that turns out to fail because in some modes
6156+ ** the dictionary is written more than once. So we build an
6157+ ** auxiliary pointer table (in sortlist) and sort that. This
6158+ ** is faster anyway, though it uses more memory.
6159+ */
6160+ sortptr = sortlist;
6161+ for (cent = pershtab, ehtab = pershtab + pershsize; cent < ehtab; cent++)
6162+ {
6163+ for (lent = cent; lent != NULL; lent = lent->next)
6164+ {
6165+ if ((lent->flagfield & (USED | KEEP)) == (USED | KEEP))
6166+ {
6167+ *sortptr++ = lent;
6168+#ifndef NO_CAPITALIZATION_SUPPORT
6169+ while (lent->flagfield & MOREVARIANTS)
6170+ lent = lent->next;
6171+#endif
6172+ }
6173+ }
6174+ }
6175+ for (cent = hashtbl, ehtab = hashtbl + hashsize; cent < ehtab; cent++)
6176+ {
6177+ if ((cent->flagfield & (USED | KEEP)) == (USED | KEEP))
6178+ {
6179+#ifndef NO_CAPITALIZATION_SUPPORT
6180+ if (captype (cent->flagfield) != FOLLOWCASE
6181+ && cent->word != NULL)
6182+#endif
6183+ *sortptr++ = cent;
6184+ }
6185+ }
6186+ /* Sort the list */
6187+ qsort ((char *) sortlist, (unsigned) pdictsize,
6188+ sizeof (sortlist[0]),
6189+ (int (*) (const void *, const void *)) pdictcmp);
6190+ /* Write it out */
6191+ for (sortptr = sortlist; --pdictsize >= 0; )
6192+ toutent (dictf, *sortptr++, 1);
6193+ free ((char *) sortlist);
6194+#endif
6195+
6196+ newwords = 0;
6197+
6198+ (void) fclose (dictf);
6199+}
6200+
6201+#ifdef REGEX_LOOKUP
6202+
6203+/* check the hashed dictionary for words matching the regex. return the */
6204+/* a matching string if found else return NULL */
6205+char *
6206+do_regex_lookup (
6207+ char * expr, /* regular expression to use in the match */
6208+ int whence) /* 0 = start at the beg with new regx, else */
6209+ /* continue from cur point w/ old regex */
6210+{
6211+ static struct dent * curent;
6212+ static int curindex;
6213+ static struct dent * curpersent;
6214+ static int curpersindex;
6215+ static REGCTYPE cmp_expr = (REGCTYPE)0;
6216+ char dummy[INPUTWORDLEN + MAXAFFIXLEN];
6217+ ichar_t * is;
6218+
6219+ if (whence == 0)
6220+ {
6221+ is = strtosichar (expr, 0);
6222+ upcase (is);
6223+ expr = ichartosstr (is, 1);
6224+ REGFREE (cmp_expr); /* free previous compiled pattern, if any */
6225+ cmp_expr = REGCMP (cmp_expr, expr);
6226+ curent = hashtbl;
6227+ curindex = 0;
6228+ curpersent = pershtab;
6229+ curpersindex = 0;
6230+ }
6231+
6232+ /* search the dictionary until the word is found or the words run out */
6233+ for ( ; curindex < hashsize; curent++, curindex++)
6234+ {
6235+ if (curent->word != NULL
6236+ && REGEX (cmp_expr, curent->word, dummy) != NULL)
6237+ {
6238+ curindex++;
6239+ /* Everybody's gotta write a wierd expression once in a while! */
6240+ return curent++->word;
6241+ }
6242+ }
6243+ /* Try the personal dictionary too */
6244+ for ( ; curpersindex < pershsize; curpersent++, curpersindex++)
6245+ {
6246+ if ((curpersent->flagfield & USED) != 0
6247+ && curpersent->word != NULL
6248+ && REGEX (cmp_expr, curpersent->word, dummy) != NULL)
6249+ {
6250+ curpersindex++;
6251+ /* Everybody's gotta write a wierd expression once in a while! */
6252+ return curpersent++->word;
6253+ }
6254+ }
6255+ return NULL;
6256+}
6257+#endif /* REGEX_LOOKUP */
0f1b3689
AG
6258diff -burN vim62.orig/src/spell/util.c vim62/src/spell/util.c
6259--- vim62.orig/src/spell/util.c 1970-01-01 01:00:00.000000000 +0100
6260+++ vim62/src/spell/util.c 2004-03-01 22:43:16.768875112 +0100
24ec98f0
JB
6261@@ -0,0 +1,351 @@
6262+#include <ctype.h>
6263+#include "ispell.h"
6264+
6265+Local char *myrindex(char *s, char c);
6266+
6267+Public int
6268+casecmp (
6269+ char * a,
6270+ char * b,
6271+ int canonical) /* NZ for canonical string chars */
6272+{
6273+ register ichar_t * ap;
6274+ register ichar_t * bp;
6275+ ichar_t inta[INPUTWORDLEN + 4 * MAXAFFIXLEN + 4];
6276+ ichar_t intb[INPUTWORDLEN + 4 * MAXAFFIXLEN + 4];
6277+
6278+ (void) strtoichar (inta, a, sizeof inta, canonical);
6279+ (void) strtoichar (intb, b, sizeof intb, canonical);
6280+ for (ap = inta, bp = intb; *ap != 0; ap++, bp++)
6281+ {
6282+ if (*ap != *bp)
6283+ {
6284+ if (*bp == '\0')
6285+ return hashheader.sortorder[*ap];
6286+ else if (mylower (*ap))
6287+ {
6288+ if (mylower (*bp) || mytoupper (*ap) != *bp)
6289+ return (int) hashheader.sortorder[*ap] -
6290+ (int) hashheader.sortorder[*bp];
6291+ }
6292+ else
6293+ {
6294+ if (myupper (*bp) || mytolower (*ap) != *bp)
6295+ return (int) hashheader.sortorder[*ap] -
6296+ (int) hashheader.sortorder[*bp];
6297+ }
6298+ }
6299+ }
6300+ if (*bp != '\0')
6301+ return -(int) hashheader.sortorder[*bp];
6302+ for (ap = inta, bp = intb; *ap; ap++, bp++)
6303+ {
6304+ if (*ap != *bp)
6305+ {
6306+ return (int) hashheader.sortorder[*ap] -
6307+ (int) hashheader.sortorder[*bp];
6308+ }
6309+ }
6310+ return 0;
6311+}
6312+
6313+Public int
6314+ins_root_cap (
6315+ register ichar_t * word,
6316+ register ichar_t * pattern,
6317+ int prestrip,
6318+ int preadd,
6319+ int sufstrip,
6320+ int sufadd,
6321+ struct dent * firstdent,
6322+ struct flagent * pfxent,
6323+ struct flagent * sufent)
6324+{
6325+ int i; /* Index into savearea */
6326+ ichar_t savearea[MAX_CAPS][INPUTWORDLEN + MAXAFFIXLEN];
6327+ int nsaved; /* Number of words saved */
6328+
6329+ nsaved = 0;
6330+ save_root_cap (word, pattern, prestrip, preadd, sufstrip, sufadd,
6331+ firstdent, pfxent, sufent, savearea, &nsaved);
6332+ for (i = 0; i < nsaved; i++)
6333+ {
6334+ if (insert (savearea[i]) < 0)
6335+ return -1;
6336+ }
6337+ return 0;
6338+}
6339+
6340+Public void
6341+save_root_cap(
6342+ register ichar_t * word, /* Word to be saved */
6343+ register ichar_t * pattern, /* Capitalization pattern */
6344+ int prestrip, /* No. chars stripped from front */
6345+ int preadd, /* No. chars added to front of root */
6346+ int sufstrip, /* No. chars stripped from back */
6347+ int sufadd, /* No. chars added to back of root */
6348+ struct dent * firstdent, /* First dent for root */
6349+ struct flagent * pfxent, /* Pfx-flag entry for word */
6350+ struct flagent * sufent, /* Sfx-flag entry for word */
6351+ ichar_t savearea[MAX_CAPS][INPUTWORDLEN + MAXAFFIXLEN],
6352+ /* Room to save words */
6353+ int * nsaved) /* Number saved so far (updated) */
6354+{
6355+#ifndef NO_CAPITALIZATION_SUPPORT
6356+ register struct dent * dent;
6357+#endif /* NO_CAPITALIZATION_SUPPORT */
6358+ int firstisupper;
6359+ ichar_t newword[INPUTWORDLEN + 4 * MAXAFFIXLEN + 4];
6360+#ifndef NO_CAPITALIZATION_SUPPORT
6361+ register ichar_t * p;
6362+ int len;
6363+ int i;
6364+ int limit;
6365+#endif /* NO_CAPITALIZATION_SUPPORT */
6366+
6367+ if (*nsaved >= MAX_CAPS)
6368+ return;
6369+ (void) icharcpy (newword, word);
6370+ firstisupper = myupper (pattern[0]);
6371+#ifdef NO_CAPITALIZATION_SUPPORT
6372+ /*
6373+ ** Apply the old, simple-minded capitalization rules.
6374+ */
6375+ if (firstisupper)
6376+ {
6377+ if (myupper (pattern[1]))
6378+ upcase (newword);
6379+ else
6380+ {
6381+ lowcase (newword);
6382+ newword[0] = mytoupper (newword[0]);
6383+ }
6384+ }
6385+ else
6386+ lowcase (newword);
6387+ (void) icharcpy (savearea[*nsaved], newword);
6388+ (*nsaved)++;
6389+ return;
6390+#else /* NO_CAPITALIZATION_SUPPORT */
6391+#define flagsareok(dent) \
6392+ ((pfxent == NULL \
6393+ || TSTMASKBIT (dent->mask, pfxent->flagbit)) \
6394+ && (sufent == NULL \
6395+ || TSTMASKBIT (dent->mask, sufent->flagbit)))
6396+
6397+ dent = firstdent;
6398+ if ((dent->flagfield & (CAPTYPEMASK | MOREVARIANTS)) == ALLCAPS)
6399+ {
6400+ upcase (newword); /* Uppercase required */
6401+ (void) icharcpy (savearea[*nsaved], newword);
6402+ (*nsaved)++;
6403+ return;
6404+ }
6405+ for (p = pattern; *p; p++)
6406+ {
6407+ if (mylower (*p))
6408+ break;
6409+ }
6410+ if (*p == 0)
6411+ {
6412+ upcase (newword); /* Pattern was all caps */
6413+ (void) icharcpy (savearea[*nsaved], newword);
6414+ (*nsaved)++;
6415+ return;
6416+ }
6417+ for (p = pattern + 1; *p; p++)
6418+ {
6419+ if (myupper (*p))
6420+ break;
6421+ }
6422+ if (*p == 0)
6423+ {
6424+ /*
6425+ ** The pattern was all-lower or capitalized. If that's
6426+ ** legal, insert only that version.
6427+ */
6428+ if (firstisupper)
6429+ {
6430+ if (captype (dent->flagfield) == CAPITALIZED
6431+ || captype (dent->flagfield) == ANYCASE)
6432+ {
6433+ lowcase (newword);
6434+ newword[0] = mytoupper (newword[0]);
6435+ (void) icharcpy (savearea[*nsaved], newword);
6436+ (*nsaved)++;
6437+ return;
6438+ }
6439+ }
6440+ else
6441+ {
6442+ if (captype (dent->flagfield) == ANYCASE)
6443+ {
6444+ lowcase (newword);
6445+ (void) icharcpy (savearea[*nsaved], newword);
6446+ (*nsaved)++;
6447+ return;
6448+ }
6449+ }
6450+ while (dent->flagfield & MOREVARIANTS)
6451+ {
6452+ dent = dent->next;
6453+ if (captype (dent->flagfield) == FOLLOWCASE
6454+ || !flagsareok (dent))
6455+ continue;
6456+ if (firstisupper)
6457+ {
6458+ if (captype (dent->flagfield) == CAPITALIZED)
6459+ {
6460+ lowcase (newword);
6461+ newword[0] = mytoupper (newword[0]);
6462+ (void) icharcpy (savearea[*nsaved], newword);
6463+ (*nsaved)++;
6464+ return;
6465+ }
6466+ }
6467+ else
6468+ {
6469+ if (captype (dent->flagfield) == ANYCASE)
6470+ {
6471+ lowcase (newword);
6472+ (void) icharcpy (savearea[*nsaved], newword);
6473+ (*nsaved)++;
6474+ return;
6475+ }
6476+ }
6477+ }
6478+ }
6479+ /*
6480+ ** Either the sample had complex capitalization, or the simple
6481+ ** capitalizations (all-lower or capitalized) are illegal.
6482+ ** Insert all legal capitalizations, including those that are
6483+ ** all-lower or capitalized. If the prototype is capitalized,
6484+ ** capitalized all-lower samples. Watch out for affixes.
6485+ */
6486+ dent = firstdent;
6487+ p = strtosichar (dent->word, 1);
6488+ len = icharlen (p);
6489+ if (dent->flagfield & MOREVARIANTS)
6490+ dent = dent->next; /* Skip place-holder entry */
6491+ for ( ; ; )
6492+ {
6493+ if (flagsareok (dent))
6494+ {
6495+ if (captype (dent->flagfield) != FOLLOWCASE)
6496+ {
6497+ lowcase (newword);
6498+ if (firstisupper || captype (dent->flagfield) == CAPITALIZED)
6499+ newword[0] = mytoupper (newword[0]);
6500+ (void) icharcpy (savearea[*nsaved], newword);
6501+ (*nsaved)++;
6502+ if (*nsaved >= MAX_CAPS)
6503+ return;
6504+ }
6505+ else
6506+ {
6507+ /* Followcase is the tough one. */
6508+ p = strtosichar (dent->word, 1);
6509+ (void) bcopy ((char *) (p + prestrip),
6510+ (char *) (newword + preadd),
6511+ (len - prestrip - sufstrip) * sizeof (ichar_t));
6512+ if (myupper (p[prestrip]))
6513+ {
6514+ for (i = 0; i < preadd; i++)
6515+ newword[i] = mytoupper (newword[i]);
6516+ }
6517+ else
6518+ {
6519+ for (i = 0; i < preadd; i++)
6520+ newword[i] = mytolower (newword[i]);
6521+ }
6522+ limit = len + preadd + sufadd - prestrip - sufstrip;
6523+ i = len + preadd - prestrip - sufstrip;
6524+ p += len - sufstrip - 1;
6525+ if (myupper (*p))
6526+ {
6527+ for (p = newword + i; i < limit; i++, p++)
6528+ *p = mytoupper (*p);
6529+ }
6530+ else
6531+ {
6532+ for (p = newword + i; i < limit; i++, p++)
6533+ *p = mytolower (*p);
6534+ }
6535+ (void) icharcpy (savearea[*nsaved], newword);
6536+ (*nsaved)++;
6537+ if (*nsaved >= MAX_CAPS)
6538+ return;
6539+ }
6540+ }
6541+ if ((dent->flagfield & MOREVARIANTS) == 0)
6542+ break; /* End of the line */
6543+ dent = dent->next;
6544+ }
6545+ return;
6546+#endif /* NO_CAPITALIZATION_SUPPORT */
6547+}
6548+Public int
6549+insert(register ichar_t * word)
6550+{
6551+ register int i;
6552+ register char * realword;
6553+
6554+ realword = ichartosstr (word, 0);
6555+ for (i = 0; i < pcount; i++)
6556+ if (strcmp (possibilities[i], realword) == 0)
6557+ return (0);
6558+
6559+ (void) strcpy (possibilities[pcount++], realword);
6560+ i = strlen (realword);
6561+ if (i > maxposslen)
6562+ maxposslen = i;
6563+ if (pcount >= MAXPOSSIBLE)
6564+ return (-1);
6565+ else
6566+ return (0);
6567+}
6568+/*
6569+** A trivial wrapper for rindex (file '/') on Unix, but
6570+** saves a lot of ifdef-ing on MS-DOS.
6571+*/
6572+
6573+Public char *
6574+last_slash (char *file)
6575+
6576+{
6577+ char *slash = myrindex (file, '/');
6578+#ifdef MSDOS
6579+ /*
6580+ ** Can have a backslash or a colon; both mean the basename
6581+ ** begins right after them.
6582+ */
6583+ char *bs = myrindex (file, '\\');
6584+
6585+ /*
6586+ ** We can have both forward- and backslashes; return the
6587+ ** place of rightmost one of either gender.
6588+ */
6589+ if (slash == NULL || (bs != NULL && bs > slash))
6590+ slash = bs;
6591+ if (slash == NULL && file[0] != '\0' && file[1] == ':')
6592+ slash = file + 1;
6593+#endif
6594+ return slash;
6595+}
6596+
6597+Local char *
6598+myrindex(char *s, register char c)
6599+
6600+{
6601+ register char *x;
6602+
6603+ x = s + strlen(s) - 1;
6604+
6605+ while(x >= s)
6606+ {
6607+ if(*x == c)
6608+ return(x);
6609+ x--;
6610+ }
6611+ return(NULL);
6612+}
0f1b3689
AG
6613diff -burN vim62.orig/src/spell/version.h vim62/src/spell/version.h
6614--- vim62.orig/src/spell/version.h 1970-01-01 01:00:00.000000000 +0100
6615+++ vim62/src/spell/version.h 2004-03-01 22:43:16.770874808 +0100
24ec98f0
JB
6616@@ -0,0 +1,124 @@
6617+/*
6618+ * Since the strings in this file are printed out when the "-v" switch is
6619+ * given to ispell, you may want to translate them into your native language.
6620+ * However, any translation of these strings MUST accurately preserve the
6621+ * legal rights under international law; you may wish to consult a lawyer
6622+ * about this since you will be responsible for the results of any
6623+ * incorrect translation.
6624+ */
6625+
6626+Local char *Version_ID[] = {
6627+ "@(#) International Ispell Version 3.1.20 10/10/95",
6628+ "@(#) Copyright (c), 1983, by Pace Willisson",
6629+ "@(#) International version Copyright (c) 1987, 1988, 1990-1995,",
6630+ "@(#) by Geoff Kuenning, Granada Hills, CA. All rights reserved.",
6631+ "@(#)",
6632+ "@(#) Redistribution and use in source and binary forms, with or without",
6633+ "@(#) modification, are permitted provided that the following conditions",
6634+ "@(#) are met:",
6635+ "@(#)",
6636+ "@(#) 1. Redistributions of source code must retain the above copyright",
6637+ "@(#) notice, this list of conditions and the following disclaimer.",
6638+ "@(#) 2. Redistributions in binary form must reproduce the above",
6639+ "@(#) copyright notice, this list of conditions and the following",
6640+ "@(#) disclaimer in the documentation and/or other materials provided",
6641+ "@(#) with the distribution.",
6642+ "@(#) 3. All modifications to the source code must be clearly marked as",
6643+ "@(#) such. Binary redistributions based on modified source code",
6644+ "@(#) must be clearly marked as modified versions in the documentation",
6645+ "@(#) and/or other materials provided with the distribution.",
6646+ "@(#) 4. All advertising materials mentioning features or use of this",
6647+ "@(#) software must display the following acknowledgment:",
6648+ "@(#) This product includes software developed by Geoff Kuenning and",
6649+ "@(#) other unpaid contributors.",
6650+ "@(#) 5. The name of Geoff Kuenning may not be used to endorse or promote",
6651+ "@(#) products derived from this software without specific prior",
6652+ "@(#) written permission.",
6653+ "@(#)",
6654+ "@(#) THIS SOFTWARE IS PROVIDED BY GEOFF KUENNING AND CONTRIBUTORS ``AS",
6655+ "@(#) IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT",
6656+ "@(#) LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS",
6657+ "@(#) FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GEOFF",
6658+ "@(#) KUENNING OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,",
6659+ "@(#) INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES",
6660+ "@(#) (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR",
6661+ "@(#) SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)",
6662+ "@(#) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,",
6663+ "@(#) STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)",
6664+ "@(#) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED",
6665+ "@(#) OF THE POSSIBILITY OF SUCH DAMAGE.",
6666+ NULL
6667+};
6668+
6669+static char RCS_Version_ID[] =
6670+ "$Id$";
6671+
6672+/*
6673+ * $Log$
6674+ * Revision 1.44 1995/10/11 05:03:28 geoff
6675+ * Upgrade to patch level 20
6676+ *
6677+ * Revision 1.43 1995/10/11 04:58:26 geoff
6678+ * Upgrade to patch 19
6679+ *
6680+ * Revision 1.42 1995/01/15 01:23:26 geoff
6681+ * Upgrade to patch level 18
6682+ *
6683+ * Revision 1.41 1995/01/15 01:14:30 geoff
6684+ * Upgrade to patch level 17
6685+ *
6686+ * Revision 1.40 1995/01/15 01:03:55 geoff
6687+ * Upgrade to patch level 16
6688+ *
6689+ * Revision 1.39 1995/01/15 01:01:01 geoff
6690+ * Upgrade to patch level 15
6691+ *
6692+ * Revision 1.38 1995/01/15 00:54:19 geoff
6693+ * Upgrade to patch level 14
6694+ *
6695+ * Revision 1.37 1994/11/21 07:03:01 geoff
6696+ * Update to patch level 13.
6697+ *
6698+ * Revision 1.36 1994/11/01 06:28:31 geoff
6699+ * Update to patch level 12
6700+ *
6701+ * Revision 1.35 1994/11/01 06:12:42 geoff
6702+ * Update to patch level 11
6703+ *
6704+ * Revision 1.34 1994/11/01 06:01:15 geoff
6705+ * Update to patch level 10
6706+ *
6707+ * Revision 1.33 1994/11/01 05:36:43 geoff
6708+ * Update to patch level 9
6709+ *
6710+ * Revision 1.32 1994/05/25 04:38:59 geoff
6711+ * Update to patch level 8
6712+ *
6713+ * Revision 1.31 1994/05/18 03:07:26 geoff
6714+ * Update to patch level 7
6715+ *
6716+ * Revision 1.30 1994/05/17 06:21:05 geoff
6717+ * Version update for ispell.el release
6718+ *
6719+ * Revision 1.29 1994/04/27 04:14:18 geoff
6720+ * Update to patch level 5
6721+ *
6722+ * Revision 1.28 1994/03/21 02:00:50 geoff
6723+ * Update to patch level 4
6724+ *
6725+ * Revision 1.27 1994/02/23 04:52:31 geoff
6726+ * Update to latest version.
6727+ *
6728+ * Revision 1.26 1994/02/08 05:59:20 geoff
6729+ * Update version
6730+ *
6731+ * Revision 1.25 1994/02/07 08:58:28 geoff
6732+ * Get rid of a comma that confuses patch
6733+ *
6734+ * Revision 1.24 1994/02/07 08:24:23 geoff
6735+ * Upate patch level
6736+ *
6737+ * Revision 1.23 1994/01/25 07:12:21 geoff
6738+ * Get rid of all old RCS log lines in preparation for the 3.1 release.
6739+ *
6740+ */
0f1b3689
AG
6741diff -burN vim62.orig/src/spell/wm.h vim62/src/spell/wm.h
6742--- vim62.orig/src/spell/wm.h 1970-01-01 01:00:00.000000000 +0100
6743+++ vim62/src/spell/wm.h 2004-03-01 22:43:16.770874808 +0100
24ec98f0
JB
6744@@ -0,0 +1,12 @@
6745+#ifndef Public
6746+enum _logical {False,True};
6747+typedef enum _logical Logical;
6748+
6749+#define EOS '\0'
6750+
6751+typedef unsigned int Word;
6752+typedef unsigned char Byte;
6753+
6754+#define Public
6755+#define Local static
6756+#endif
0f1b3689
AG
6757diff -burN vim62.orig/src/spell.c vim62/src/spell.c
6758--- vim62.orig/src/spell.c 1970-01-01 01:00:00.000000000 +0100
6759+++ vim62/src/spell.c 2004-03-01 22:43:16.772874504 +0100
24ec98f0
JB
6760@@ -0,0 +1,183 @@
6761+#include "spell/wm.h"
6762+#include "vim.h"
6763+#define MAIN 1
6764+#include "ispell.h"
6765+#define MAXWORDLEN 80
6766+
6767+#ifdef FEAT_SPELL_HL
6768+
6769+int spell_flag = 0;
6770+Local char *err;
6771+void
6772+ex_spell(exarg_T *eap)
6773+
6774+{
6775+ if(strcmp(eap->arg, "on") == 0)
6776+ {
6777+ spell_flag = 1;
6778+ if(!inited)
6779+ {
6780+ if(!reload_dict())
6781+ return;
6782+ }
6783+ }
6784+ else if(STRCMP(eap->arg, "off") == 0)
6785+ spell_flag = 0;
6786+ else
6787+ EMSG2("Invalid :spell %s", eap->arg);
6788+ redraw_all_later(NOT_VALID);
6789+ return;
6790+}
6791+
6792+int
6793+reload_dict()
6794+
6795+{
6796+ if(spell_flag == 0)
6797+ return(TRUE);
6798+ spell_save_private_dict();
6799+ inited = 0;
6800+ if(STRCMP(p_spell_lang, "") == 0)
6801+ {
6802+ EMSG("dictionary not defined");
6803+ do_cmdline((char_u *)"spell off", NULL, NULL, DOCMD_VERBOSE);
6804+ spell_flag = 0;
6805+ return(FALSE);
6806+ }
6807+ if ((err = linit(hashname)) != NULL)
6808+ {
6809+ EMSG(err);
6810+ do_cmdline((char_u *)"spell off", NULL, NULL, DOCMD_VERBOSE);
6811+ spell_flag = 0;
6812+ return(FALSE);
6813+ }
6814+ treeinit (NULL, p_spell_lang);
6815+ return(TRUE);
6816+}
6817+
6818+static colnr_T last_col;
6819+static ichar_t curr_word[MAXWORDLEN + 1]; /* assume max. keyword len is 80 */
6820+static char word_to_spell[MAXWORDLEN + 1];
6821+ int last_attr;
6822+static Logical in_word;
6823+
6824+int my_is_char(char_u ccc);
6825+
6826+int
6827+get_spell_attr(spell_col, col, line)
6828+ colnr_T spell_col;
6829+ colnr_T col;
6830+ char_u *line;
6831+{
6832+ char_u *line_ptr;
6833+ colnr_T curr_col;
6834+ unsigned int i;
6835+
6836+ if(spell_col == 0)
6837+ last_col = 0, in_word = False, last_attr = 0;
6838+
6839+ if((spell_col < last_col) && in_word)
6840+ return(last_attr);
6841+ else if(spell_col >= last_col)
6842+ {
6843+ last_attr = 0;
6844+ in_word = False;
6845+ line_ptr = &line[spell_col];
6846+ curr_col = spell_col;
6847+ if(iswordch((ichar_t)(*line_ptr)) && *line_ptr)
6848+ {
6849+ while((spell_col > 0) && my_is_char(*(line_ptr - 1)))
6850+ spell_col--, line_ptr--;
6851+ while(isboundarych((ichar_t)(*(line_ptr))))
6852+ spell_col++, line_ptr++;
6853+
6854+ line_ptr = &line[spell_col];
6855+ curr_col = spell_col;
6856+ while(my_is_char(*line_ptr) && *line_ptr &&
6857+ ((curr_col - spell_col) < MAXWORDLEN))
6858+ curr_col++, line_ptr++;
6859+ while(isboundarych((ichar_t)(*(line_ptr - 1))))
6860+ curr_col--, line_ptr--;
6861+ }
6862+ if(curr_col - spell_col > 1)
6863+ {
6864+ /*for(i = 0; i < curr_col - spell_col; i++)
6865+ curr_word[i] = line[spell_col + i];
6866+ curr_word[curr_col - spell_col] = NUL;*/
6867+ strtoichar(curr_word,line+spell_col,(curr_col-spell_col+1)*sizeof(ichar_t),0);
6868+ in_word = True;
6869+
6870+/* for(i = 0; curr_word[i]; i++)
6871+ fprintf(stderr, "%c", curr_word[i]);
6872+ fprintf(stderr, "-%d\n", good((ichar_t *)curr_word, 0, 0, 0, 0)); wm */
6873+ if(good((ichar_t *)curr_word, 0, 0, 0, 0) == 0)
6874+ last_attr = hl_attr(HLF_SPELL);
6875+ last_col = curr_col;
6876+ }
6877+ }
6878+ return(last_attr);
6879+}
6880+
6881+int
6882+my_is_char(ccc)
6883+ char_u ccc;
6884+{
6885+ if(iswordch((ichar_t)ccc) || isboundarych((ichar_t)ccc))
6886+ return(TRUE);
6887+ else
6888+ return(FALSE);
6889+
6890+}
6891+
6892+static ichar_t *itok;
6893+
6894+int
6895+set_to_private_dict(char *line, int cursor_col, int convert_to_lower)
6896+
6897+{
6898+ int i;
6899+ char_u *b,
6900+ *e;
6901+
6902+ b = line + cursor_col;
6903+ e = b;
6904+ if(inited == 0)
6905+ return(TRUE);
6906+ if(iswordch((ichar_t)(*b)) || isboundarych((ichar_t)(*b)))
6907+ {
6908+ while((iswordch((ichar_t)(*(b - 1))) ||
6909+ isboundarych((ichar_t)(*(b - 1)))) &&
6910+ cursor_col > 0)
6911+ b--, cursor_col--;
6912+ while(isboundarych((ichar_t)(*b)))
6913+ b++;
6914+ while((iswordch((ichar_t)(*(e))) || isboundarych((ichar_t)(*(e)))) &&
6915+ *e)
6916+ e++;
6917+ while(isboundarych((ichar_t)(*(e - 1))))
6918+ e--;
6919+ for(i = 0; b < e;)
6920+ word_to_spell[i++] = *b++;
6921+ word_to_spell[i] = '\0';
6922+ if(!convert_to_lower)
6923+ treeinsert (ichartosstr (strtosichar (word_to_spell, 0), 1),
6924+ ICHARTOSSTR_SIZE, 1);
6925+ else
6926+ {
6927+ itok = strtosichar (word_to_spell, 0);
6928+ lowcase (itok);
6929+ treeinsert (ichartosstr (itok, 1), ICHARTOSSTR_SIZE, 1);
6930+ }
6931+ redraw_all_later(NOT_VALID);
6932+ }
6933+ return(FALSE);
6934+}
6935+
6936+void
6937+spell_save_private_dict(void)
6938+
6939+{
6940+ if(inited)
6941+ treeoutput ();
6942+}
6943+#endif
0f1b3689
AG
6944diff -burN vim62.orig/src/syntax.c vim62/src/syntax.c
6945--- vim62.orig/src/syntax.c 2004-03-01 22:36:43.675634368 +0100
6946+++ vim62/src/syntax.c 2004-03-01 22:43:16.806869336 +0100
6947@@ -5921,6 +5921,9 @@
24ec98f0
JB
6948 "VertSplit term=reverse cterm=reverse gui=reverse",
6949 "Visual term=reverse cterm=reverse gui=reverse guifg=Grey guibg=fg",
6950 "VisualNOS term=underline,bold cterm=underline,bold gui=underline,bold",
6951+#ifdef FEAT_SPELL_HL
6952+ "Spell term=reverse ctermbg=NONE ctermfg=White guibg=NONE guifg=Red",
6953+#endif
6954 "DiffText term=reverse cterm=bold ctermbg=Red gui=bold guibg=Red",
6955 NULL
6956 };
0f1b3689 6957@@ -5940,6 +5943,9 @@
24ec98f0
JB
6958 "Folded term=standout ctermbg=Grey ctermfg=DarkBlue guibg=LightGrey guifg=DarkBlue",
6959 "FoldColumn term=standout ctermbg=Grey ctermfg=DarkBlue guibg=Grey guifg=DarkBlue",
6960 "DiffAdd term=bold ctermbg=LightBlue guibg=LightBlue",
6961+#ifdef FEAT_SPELL_HL
6962+ "Spell term=reverse ctermbg=NONE ctermfg=White guibg=NONE guifg=Red",
6963+#endif
6964 "DiffChange term=bold ctermbg=LightMagenta guibg=LightMagenta",
6965 "DiffDelete term=bold ctermfg=Blue ctermbg=LightCyan gui=bold guifg=Blue guibg=LightCyan",
6966 NULL
0f1b3689 6967@@ -5960,6 +5966,9 @@
24ec98f0
JB
6968 "Folded term=standout ctermbg=DarkGrey ctermfg=Cyan guibg=DarkGrey guifg=Cyan",
6969 "FoldColumn term=standout ctermbg=DarkGrey ctermfg=Cyan guibg=Grey guifg=Cyan",
6970 "DiffAdd term=bold ctermbg=DarkBlue guibg=DarkBlue",
6971+#ifdef FEAT_SPELL_HL
6972+ "Spell term=reverse ctermbg=NONE ctermfg=White guibg=NONE guifg=Red",
6973+#endif
6974 "DiffChange term=bold ctermbg=DarkMagenta guibg=DarkMagenta",
6975 "DiffDelete term=bold ctermfg=Blue ctermbg=DarkCyan gui=bold guifg=Blue guibg=DarkCyan",
6976 NULL
0f1b3689
AG
6977diff -burN vim62.orig/src/version.c vim62/src/version.c
6978--- vim62.orig/src/version.c 2004-03-01 22:36:43.728626312 +0100
6979+++ vim62/src/version.c 2004-03-01 22:43:16.810868728 +0100
41e3656f 6980@@ -470,6 +470,11 @@
24ec98f0
JB
6981 #else
6982 "-syntax",
6983 #endif
6984+#ifdef FEAT_SPELL_HL
6985+ "+spell",
6986+#else
6987+ "-spell",
6988+#endif
6989 /* only interesting on Unix systems */
6990 #if defined(USE_SYSTEM) && (defined(UNIX) || defined(__EMX__))
6991 "+system()",
0f1b3689 6992@@ -1729,7 +1734,7 @@
24ec98f0
JB
6993 int add_version;
6994 int attr;
6995 {
6996- char_u vers[20];
6997+ char_u vers[80];
6998 int col;
6999 char_u *p;
7000 int l;
0f1b3689
AG
7001diff -burN vim62.orig/src/version.h vim62/src/version.h
7002--- vim62.orig/src/version.h 2004-03-01 22:36:43.728626312 +0100
7003+++ vim62/src/version.h 2004-03-01 22:43:16.812868424 +0100
98f80704 7004@@ -35,6 +35,10 @@
24ec98f0 7005 */
41e3656f 7006 #define VIM_VERSION_NODOT "vim62"
7007 #define VIM_VERSION_SHORT "6.2"
24ec98f0 7008+#ifdef FEAT_SPELL_HL
41e3656f 7009+#define VIM_VERSION_MEDIUM "6.2 + ispell 3.1.20 WM-3"
24ec98f0 7010+#else
41e3656f 7011 #define VIM_VERSION_MEDIUM "6.2"
7012+#endif
7013 #define VIM_VERSION_LONG "VIM - Vi IMproved 6.2 (2003 Jun 1)"
7014 #define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 6.2 (2003 Jun 1, compiled "
0f1b3689
AG
7015diff -burN vim62.orig/src/vim.h vim62/src/vim.h
7016--- vim62.orig/src/vim.h 2004-03-01 22:36:43.367681184 +0100
7017+++ vim62/src/vim.h 2004-03-01 22:43:16.815867968 +0100
7018@@ -1068,13 +1068,14 @@
24ec98f0
JB
7019 , HLF_CHD /* Changed diff line */
7020 , HLF_DED /* Deleted diff line */
7021 , HLF_TXD /* Text Changed in diff line */
7022+ , HLF_SPELL /* spell - string not in dictionary WM */
7023 , HLF_COUNT /* MUST be the last one */
7024 };
7025
7026 /* the HL_FLAGS must be in the same order as the HLF_ enums! */
7027 #define HL_FLAGS {'8', '@', 'd', 'e', 'h', 'i', 'l', 'm', 'M', \
7028 'n', 'r', 's', 'S', 'c', 't', 'v', 'V', 'w', 'W', \
7029- 'f', 'F', 'A', 'C', 'D', 'T'}
7030+ 'f', 'F', 'A', 'C', 'D', 'T', 'Z'}
7031
7032 /*
7033 * Boolean constants
This page took 0.857231 seconds and 4 git commands to generate.