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