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