7 {"oed", "Oxford English Dictionary, 2nd Ed.",
8 "#9/dict/oed2", "#9/dict/oed2index",
9 oednextoff, oedprintentry, oedprintkey},
10 {"ahd", "American Heritage Dictionary, 2nd College Ed.",
11 "ahd/DICT.DB", "ahd/index",
12 ahdnextoff, ahdprintentry, ahdprintkey},
13 {"pgw", "Project Gutenberg Webster Dictionary",
14 "#9/dict/pgw", "#9/dict/pgwindex",
15 pgwnextoff, pgwprintentry, pgwprintkey},
16 {"thesaurus", "Collins Thesaurus",
17 "#9/dict/thesaurus", "#9/dict/thesindex",
18 thesnextoff, thesprintentry, thesprintkey},
20 {"ce", "Gendai Chinese->English",
21 "#9/dict/world/sansdata/sandic24.dat",
22 "#9/dict/world/sansdata/ceindex",
23 worldnextoff, worldprintentry, worldprintkey},
24 {"ceh", "Gendai Chinese->English (Hanzi index)",
25 "#9/dict/world/sansdata/sandic24.dat",
26 "#9/dict/world/sansdata/cehindex",
27 worldnextoff, worldprintentry, worldprintkey},
28 {"ec", "Gendai English->Chinese",
29 "#9/dict/world/sansdata/sandic24.dat",
30 "#9/dict/world/sansdata/ecindex",
31 worldnextoff, worldprintentry, worldprintkey},
33 {"dae", "Gyldendal Danish->English",
34 "#9/dict/world/gylddata/sandic30.dat",
35 "#9/dict/world/gylddata/daeindex",
36 worldnextoff, worldprintentry, worldprintkey},
37 {"eda", "Gyldendal English->Danish",
38 "#9/dict/world/gylddata/sandic29.dat",
39 "#9/dict/world/gylddata/edaindex",
40 worldnextoff, worldprintentry, worldprintkey},
42 {"due", "Wolters-Noordhoff Dutch->English",
43 "#9/dict/world/woltdata/sandic07.dat",
44 "#9/dict/world/woltdata/deindex",
45 worldnextoff, worldprintentry, worldprintkey},
46 {"edu", "Wolters-Noordhoff English->Dutch",
47 "#9/dict/world/woltdata/sandic06.dat",
48 "#9/dict/world/woltdata/edindex",
49 worldnextoff, worldprintentry, worldprintkey},
51 {"fie", "WSOY Finnish->English",
52 "#9/dict/world/werndata/sandic32.dat",
53 "#9/dict/world/werndata/fieindex",
54 worldnextoff, worldprintentry, worldprintkey},
55 {"efi", "WSOY English->Finnish",
56 "#9/dict/world/werndata/sandic31.dat",
57 "#9/dict/world/werndata/efiindex",
58 worldnextoff, worldprintentry, worldprintkey},
60 {"fe", "Collins French->English",
61 "#9/dict/fe", "#9/dict/feindex",
62 pcollnextoff, pcollprintentry, pcollprintkey},
63 {"ef", "Collins English->French",
64 "#9/dict/ef", "#9/dict/efindex",
65 pcollnextoff, pcollprintentry, pcollprintkey},
67 {"ge", "Collins German->English",
68 "#9/dict/ge", "#9/dict/geindex",
69 pcollgnextoff, pcollgprintentry, pcollgprintkey},
70 {"eg", "Collins English->German",
71 "#9/dict/eg", "#9/dict/egindex",
72 pcollgnextoff, pcollgprintentry, pcollgprintkey},
74 {"ie", "Collins Italian->English",
75 "#9/dict/ie", "#9/dict/ieindex",
76 pcollnextoff, pcollprintentry, pcollprintkey},
77 {"ei", "Collins English->Italian",
78 "#9/dict/ei", "#9/dict/eiindex",
79 pcollnextoff, pcollprintentry, pcollprintkey},
81 {"je", "Sanshusha Japanese->English",
82 "#9/dict/world/sansdata/sandic18.dat",
83 "#9/dict/world/sansdata/jeindex",
84 worldnextoff, worldprintentry, worldprintkey},
85 {"jek", "Sanshusha Japanese->English (Kanji index)",
86 "#9/dict/world/sansdata/sandic18.dat",
87 "#9/dict/world/sansdata/jekindex",
88 worldnextoff, worldprintentry, worldprintkey},
89 {"ej", "Sanshusha English->Japanese",
90 "#9/dict/world/sansdata/sandic18.dat",
91 "#9/dict/world/sansdata/ejindex",
92 worldnextoff, worldprintentry, worldprintkey},
94 {"tjeg", "Sanshusha technical Japanese->English,German",
95 "#9/dict/world/sansdata/sandic16.dat",
96 "#9/dict/world/sansdata/tjegindex",
97 worldnextoff, worldprintentry, worldprintkey},
98 {"tjegk", "Sanshusha technical Japanese->English,German (Kanji index)",
99 "#9/dict/world/sansdata/sandic16.dat",
100 "#9/dict/world/sansdata/tjegkindex",
101 worldnextoff, worldprintentry, worldprintkey},
102 {"tegj", "Sanshusha technical English->German,Japanese",
103 "#9/dict/world/sansdata/sandic16.dat",
104 "#9/dict/world/sansdata/tegjindex",
105 worldnextoff, worldprintentry, worldprintkey},
106 {"tgje", "Sanshusha technical German->Japanese,English",
107 "#9/dict/world/sansdata/sandic16.dat",
108 "#9/dict/world/sansdata/tgjeindex",
109 worldnextoff, worldprintentry, worldprintkey},
111 {"ne", "Kunnskapforlaget Norwegian->English",
112 "#9/dict/world/kunndata/sandic28.dat",
113 "#9/dict/world/kunndata/neindex",
114 worldnextoff, worldprintentry, worldprintkey},
115 {"en", "Kunnskapforlaget English->Norwegian",
116 "#9/dict/world/kunndata/sandic27.dat",
117 "#9/dict/world/kunndata/enindex",
118 worldnextoff, worldprintentry, worldprintkey},
120 {"re", "Leon Ungier Russian->English",
121 "#9/dict/re", "#9/dict/reindex",
122 simplenextoff, simpleprintentry, simpleprintkey},
123 {"er", "Leon Ungier English->Russian",
124 "#9/dict/re", "#9/dict/erindex",
125 simplenextoff, simpleprintentry, simpleprintkey},
127 {"se", "Collins Spanish->English",
128 "#9/dict/se", "#9/dict/seindex",
129 pcollnextoff, pcollprintentry, pcollprintkey},
130 {"es", "Collins English->Spanish",
131 "#9/dict/es", "#9/dict/esindex",
132 pcollnextoff, pcollprintentry, pcollprintkey},
134 {"swe", "Esselte Studium Swedish->English",
135 "#9/dict/world/essedata/sandic34.dat",
136 "#9/dict/world/essedata/sweindex",
137 worldnextoff, worldprintentry, worldprintkey},
138 {"esw", "Esselte Studium English->Swedish",
139 "#9/dict/world/essedata/sandic33.dat",
140 "#9/dict/world/essedata/eswindex",
141 worldnextoff, worldprintentry, worldprintkey},
143 {"movie", "Movies -- by title",
144 "movie/data", "#9/dict/movtindex",
145 movienextoff, movieprintentry, movieprintkey},
146 {"moviea", "Movies -- by actor",
147 "movie/data", "#9/dict/movaindex",
148 movienextoff, movieprintentry, movieprintkey},
149 {"movied", "Movies -- by director",
150 "movie/data", "#9/dict/movdindex",
151 movienextoff, movieprintentry, movieprintkey},
153 {"slang", "English Slang",
154 "#9/dict/slang", "#9/dict/slangindex",
155 slangnextoff, slangprintentry, slangprintkey},
157 {"robert", "Robert Électronique",
158 "#9/dict/robert/_pointers", "#9/dict/robert/_index",
159 robertnextoff, robertindexentry, robertprintkey},
160 {"robertv", "Robert Électronique - formes des verbes",
161 "#9/dict/robert/flex.rob", "#9/dict/robert/_flexindex",
162 robertnextflex, robertflexentry, robertprintkey},
167 typedef struct Lig Lig;
169 Rune start; /* accent rune */
170 Rune pairs[100]; /* <char,accented version> pairs */
173 /* keep in sync with dict.h */
174 static Lig ligtab[Nligs] = {
175 {0xb4, {0x41, 0xc1, 0x61, 0xe1, 0x43, 0x106, 0x63, 0x107, 0x45, 0xc9, 0x65, 0xe9, 0x67, 0x123, 0x49, 0xcd, 0x69, 0xed, 0x131, 0xed, 0x4c, 0x139, 0x6c, 0x13a, 0x4e, 0x143, 0x6e, 0x144, 0x4f, 0xd3, 0x6f, 0xf3, 0x52, 0x154, 0x72, 0x155, 0x53, 0x15a, 0x73, 0x15b, 0x55, 0xda, 0x75, 0xfa, 0x59, 0xdd, 0x79, 0xfd, 0x5a, 0x179, 0x7a, 0x17a, 0}},
176 {0x2cb, {0x41, 0xc0, 0x61, 0xe0, 0x45, 0xc8, 0x65, 0xe8, 0x49, 0xcc, 0x69, 0xec, 0x131, 0xec, 0x4f, 0xd2, 0x6f, 0xf2, 0x55, 0xd9, 0x75, 0xf9, 0}},
177 {0xa8, {0x41, 0xc4, 0x61, 0xe4, 0x45, 0xcb, 0x65, 0xeb, 0x49, 0xcf, 0x69, 0xef, 0x4f, 0xd6, 0x6f, 0xf6, 0x55, 0xdc, 0x75, 0xfc, 0x59, 0x178, 0x79, 0xff, 0}},
178 {0xb8, {0x43, 0xc7, 0x63, 0xe7, 0x47, 0x122, 0x4b, 0x136, 0x6b, 0x137, 0x4c, 0x13b, 0x6c, 0x13c, 0x4e, 0x145, 0x6e, 0x146, 0x52, 0x156, 0x72, 0x157, 0x53, 0x15e, 0x73, 0x15f, 0x54, 0x162, 0x74, 0x163, 0}},
179 {0x2dc, {0x41, 0xc3, 0x61, 0xe3, 0x49, 0x128, 0x69, 0x129, 0x131, 0x129, 0x4e, 0xd1, 0x6e, 0xf1, 0x4f, 0xd5, 0x6f, 0xf5, 0x55, 0x168, 0x75, 0x169, 0}},
180 {0x2d8, {0x41, 0x102, 0x61, 0x103, 0x45, 0x114, 0x65, 0x115, 0x47, 0x11e, 0x67, 0x11f, 0x49, 0x12c, 0x69, 0x12d, 0x131, 0x12d, 0x4f, 0x14e, 0x6f, 0x14f, 0x55, 0x16c, 0x75, 0x16d, 0}},
181 {0x2da, {0x41, 0xc5, 0x61, 0xe5, 0x55, 0x16e, 0x75, 0x16f, 0}},
182 {0x2d9, {0x43, 0x10a, 0x63, 0x10b, 0x45, 0x116, 0x65, 0x117, 0x47, 0x120, 0x67, 0x121, 0x49, 0x130, 0x4c, 0x13f, 0x6c, 0x140, 0x5a, 0x17b, 0x7a, 0x17c, 0}},
184 {0x2322, {0x41, 0xc2, 0x61, 0xe2, 0x43, 0x108, 0x63, 0x109, 0x45, 0xca, 0x65, 0xea, 0x47, 0x11c, 0x67, 0x11d, 0x48, 0x124, 0x68, 0x125, 0x49, 0xce, 0x69, 0xee, 0x131, 0xee, 0x4a, 0x134, 0x6a, 0x135, 0x4f, 0xd4, 0x6f, 0xf4, 0x53, 0x15c, 0x73, 0x15d, 0x55, 0xdb, 0x75, 0xfb, 0x57, 0x174, 0x77, 0x175, 0x59, 0x176, 0x79, 0x177, 0}},
186 {0x2db, {0x41, 0x104, 0x61, 0x105, 0x45, 0x118, 0x65, 0x119, 0x49, 0x12e, 0x69, 0x12f, 0x131, 0x12f, 0x55, 0x172, 0x75, 0x173, 0}},
187 {0xaf, {0x41, 0x100, 0x61, 0x101, 0x45, 0x112, 0x65, 0x113, 0x49, 0x12a, 0x69, 0x12b, 0x131, 0x12b, 0x4f, 0x14c, 0x6f, 0x14d, 0x55, 0x16a, 0x75, 0x16b, 0}},
188 {0x2c7, {0x43, 0x10c, 0x63, 0x10d, 0x44, 0x10e, 0x64, 0x10f, 0x45, 0x11a, 0x65, 0x11b, 0x4c, 0x13d, 0x6c, 0x13e, 0x4e, 0x147, 0x6e, 0x148, 0x52, 0x158, 0x72, 0x159, 0x53, 0x160, 0x73, 0x161, 0x54, 0x164, 0x74, 0x165, 0x5a, 0x17d, 0x7a, 0x17e, 0}},
194 Rune multitab[Nmulti][5] = {
197 {0x61, 0x6e, 0x64, 0},
198 {0x61, 0x2f, 0x71, 0},
201 {0x2e, 0x2e, 0x2e, 0},
211 {0x66, 0x66, 0x69, 0},
212 {0x66, 0x66, 0x6c, 0},
231 #define risupper(r) (0x41 <= (r) && (r) <= 0x5a)
232 #define rislatin1(r) (0xC0 <= (r) && (r) <= 0xFF)
233 #define rtolower(r) ((r)-'A'+'a')
235 static Rune latin_fold_tab[] =
237 /* Table to fold latin 1 characters to ASCII equivalents
238 based at Rune value 0xc0
249 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'c',
250 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i',
251 'd', 'n', 'o', 'o', 'o', 'o', 'o', 0 ,
252 'o', 'u', 'u', 'u', 'u', 'y', 0 , 0 ,
253 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'c',
254 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i',
255 'd', 'n', 'o', 'o', 'o', 'o', 'o', 0 ,
256 'o', 'u', 'u', 'u', 'u', 'y', 0 , 'y',
259 static Rune *ttabstack[20];
263 * tab is an array of n Assoc's, sorted by key.
264 * Look for key in tab, and return corresponding val
268 lookassoc(Assoc *tab, int n, char *key)
274 for(low = -1, high = n; high > low+1; ){
277 if((r=strcmp(key, q->key))<0)
288 looknassoc(Nassoc *tab, int n, long key)
293 for(low = -1, high = n; high > low+1; ){
298 else if(key == q->key)
313 vsnprint(buf, sizeof(buf), fmt, v);
315 fprint(2, "%s: %s\n", argv0, buf);
319 * Write the rune r to bout, keeping track of line length
320 * and breaking the lines (at blanks) when they get too long
327 if(++linelen > breaklen && r == 0x20) {
339 while((r = *rp++) != 0)
343 /* like outrune, but when arg is know to be a char */
349 if(++linelen > breaklen && c == ' ') {
361 while((c = *s++) != 0)
366 outprint(char *fmt, ...)
372 vsnprint(buf, sizeof(buf), fmt, v);
378 outpiece(char *b, char *e)
387 if(!(c == ' ' && lastc == ' '))
394 * Go to new line if not already there; indent if ind != 0.
395 * If ind > 1, leave a blank line too.
396 * Slight hack: assume if current line is only one or two
397 * characters long, then they were spaces.
409 } else if(linelen == 0)
411 else if(linelen == 1)
413 else if(linelen != 2)
425 * Fold the runes in null-terminated rp.
426 * Use the sort(1) definition of folding (uppercase to lowercase,
427 * latin1-accented characters to corresponding unaccented chars)
434 while((r = *rp) != 0) {
435 if (rislatin1(r) && latin_fold_tab[r-0xc0])
436 r = latin_fold_tab[r-0xc0];
444 * Like fold, but put folded result into new
445 * (assumed to have enough space).
446 * old is a regular expression, but we know that
447 * metacharacters aren't affected
450 foldre(char *new, char *old)
455 old += chartorune(&r, old);
456 if (rislatin1(r) && latin_fold_tab[r-0xc0])
457 r = latin_fold_tab[r-0xc0];
460 new += runetochar(new, &r);
466 * acomp(s, t) returns:
467 * -2 if s strictly precedes t
468 * -1 if s is a prefix of t
469 * 0 if s is the same as t
470 * 1 if t is a prefix of s
471 * 2 if t strictly precedes s
475 acomp(Rune *s, Rune *t)
499 * Copy null terminated Runes from 'from' to 'to'.
502 runescpy(Rune *to, Rune *from)
504 while((*to++ = *from++) != 0)
509 * Conversion of unsigned number to long, no overflow detection
520 if(0x30<=c && c<=0x39)
530 * See if there is a rune corresponding to the accented
531 * version of r with accent acc (acc in [LIGS..LIGE-1]),
532 * and return it if so, else return NONE.
535 liglookup(Rune acc, Rune r)
539 if(acc < LIGS || acc >= LIGE)
541 for(p = ligtab[acc-LIGS].pairs; *p; p += 2)
548 * Maintain a translation table stack (a translation table
549 * is an array of Runes indexed by bytes or 7-bit bytes).
550 * If starting is true, push the curtab onto the stack
551 * and return newtab; else pop the top of the stack and
553 * If curtab is 0, initialize the stack and return.
556 changett(Rune *curtab, Rune *newtab, int starting)
563 if(ntt >= asize(ttabstack)) {
565 err("translation stack overflow");
568 ttabstack[ntt++] = curtab;
573 err("translation stack underflow");
576 return ttabstack[--ntt];