xref: /freebsd/stand/ficl/search.c (revision 2a63c3be158216222d89a073dcbd6a72ee4aab5a)
1*ca987d46SWarner Losh /*******************************************************************
2*ca987d46SWarner Losh ** s e a r c h . c
3*ca987d46SWarner Losh ** Forth Inspired Command Language
4*ca987d46SWarner Losh ** ANS Forth SEARCH and SEARCH-EXT word-set written in C
5*ca987d46SWarner Losh ** Author: John Sadler (john_sadler@alum.mit.edu)
6*ca987d46SWarner Losh ** Created: 6 June 2000
7*ca987d46SWarner Losh ** $Id: search.c,v 1.9 2001/12/05 07:21:34 jsadler Exp $
8*ca987d46SWarner Losh *******************************************************************/
9*ca987d46SWarner Losh /*
10*ca987d46SWarner Losh ** Copyright (c) 1997-2001 John Sadler (john_sadler@alum.mit.edu)
11*ca987d46SWarner Losh ** All rights reserved.
12*ca987d46SWarner Losh **
13*ca987d46SWarner Losh ** Get the latest Ficl release at http://ficl.sourceforge.net
14*ca987d46SWarner Losh **
15*ca987d46SWarner Losh ** I am interested in hearing from anyone who uses ficl. If you have
16*ca987d46SWarner Losh ** a problem, a success story, a defect, an enhancement request, or
17*ca987d46SWarner Losh ** if you would like to contribute to the ficl release, please
18*ca987d46SWarner Losh ** contact me by email at the address above.
19*ca987d46SWarner Losh **
20*ca987d46SWarner Losh ** L I C E N S E  and  D I S C L A I M E R
21*ca987d46SWarner Losh **
22*ca987d46SWarner Losh ** Redistribution and use in source and binary forms, with or without
23*ca987d46SWarner Losh ** modification, are permitted provided that the following conditions
24*ca987d46SWarner Losh ** are met:
25*ca987d46SWarner Losh ** 1. Redistributions of source code must retain the above copyright
26*ca987d46SWarner Losh **    notice, this list of conditions and the following disclaimer.
27*ca987d46SWarner Losh ** 2. Redistributions in binary form must reproduce the above copyright
28*ca987d46SWarner Losh **    notice, this list of conditions and the following disclaimer in the
29*ca987d46SWarner Losh **    documentation and/or other materials provided with the distribution.
30*ca987d46SWarner Losh **
31*ca987d46SWarner Losh ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
32*ca987d46SWarner Losh ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
33*ca987d46SWarner Losh ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
34*ca987d46SWarner Losh ** ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
35*ca987d46SWarner Losh ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36*ca987d46SWarner Losh ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37*ca987d46SWarner Losh ** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38*ca987d46SWarner Losh ** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
39*ca987d46SWarner Losh ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
40*ca987d46SWarner Losh ** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41*ca987d46SWarner Losh ** SUCH DAMAGE.
42*ca987d46SWarner Losh */
43*ca987d46SWarner Losh 
44*ca987d46SWarner Losh 
45*ca987d46SWarner Losh #include <string.h>
46*ca987d46SWarner Losh #include "ficl.h"
47*ca987d46SWarner Losh #include "math64.h"
48*ca987d46SWarner Losh 
49*ca987d46SWarner Losh /**************************************************************************
50*ca987d46SWarner Losh                         d e f i n i t i o n s
51*ca987d46SWarner Losh ** SEARCH ( -- )
52*ca987d46SWarner Losh ** Make the compilation word list the same as the first word list in the
53*ca987d46SWarner Losh ** search order. Specifies that the names of subsequent definitions will
54*ca987d46SWarner Losh ** be placed in the compilation word list. Subsequent changes in the search
55*ca987d46SWarner Losh ** order will not affect the compilation word list.
56*ca987d46SWarner Losh **************************************************************************/
definitions(FICL_VM * pVM)57*ca987d46SWarner Losh static void definitions(FICL_VM *pVM)
58*ca987d46SWarner Losh {
59*ca987d46SWarner Losh     FICL_DICT *pDict = vmGetDict(pVM);
60*ca987d46SWarner Losh 
61*ca987d46SWarner Losh     assert(pDict);
62*ca987d46SWarner Losh     if (pDict->nLists < 1)
63*ca987d46SWarner Losh     {
64*ca987d46SWarner Losh         vmThrowErr(pVM, "DEFINITIONS error - empty search order");
65*ca987d46SWarner Losh     }
66*ca987d46SWarner Losh 
67*ca987d46SWarner Losh     pDict->pCompile = pDict->pSearch[pDict->nLists-1];
68*ca987d46SWarner Losh     return;
69*ca987d46SWarner Losh }
70*ca987d46SWarner Losh 
71*ca987d46SWarner Losh 
72*ca987d46SWarner Losh /**************************************************************************
73*ca987d46SWarner Losh                         f o r t h - w o r d l i s t
74*ca987d46SWarner Losh ** SEARCH ( -- wid )
75*ca987d46SWarner Losh ** Return wid, the identifier of the word list that includes all standard
76*ca987d46SWarner Losh ** words provided by the implementation. This word list is initially the
77*ca987d46SWarner Losh ** compilation word list and is part of the initial search order.
78*ca987d46SWarner Losh **************************************************************************/
forthWordlist(FICL_VM * pVM)79*ca987d46SWarner Losh static void forthWordlist(FICL_VM *pVM)
80*ca987d46SWarner Losh {
81*ca987d46SWarner Losh     FICL_HASH *pHash = vmGetDict(pVM)->pForthWords;
82*ca987d46SWarner Losh     stackPushPtr(pVM->pStack, pHash);
83*ca987d46SWarner Losh     return;
84*ca987d46SWarner Losh }
85*ca987d46SWarner Losh 
86*ca987d46SWarner Losh 
87*ca987d46SWarner Losh /**************************************************************************
88*ca987d46SWarner Losh                         g e t - c u r r e n t
89*ca987d46SWarner Losh ** SEARCH ( -- wid )
90*ca987d46SWarner Losh ** Return wid, the identifier of the compilation word list.
91*ca987d46SWarner Losh **************************************************************************/
getCurrent(FICL_VM * pVM)92*ca987d46SWarner Losh static void getCurrent(FICL_VM *pVM)
93*ca987d46SWarner Losh {
94*ca987d46SWarner Losh     ficlLockDictionary(TRUE);
95*ca987d46SWarner Losh     stackPushPtr(pVM->pStack, vmGetDict(pVM)->pCompile);
96*ca987d46SWarner Losh     ficlLockDictionary(FALSE);
97*ca987d46SWarner Losh     return;
98*ca987d46SWarner Losh }
99*ca987d46SWarner Losh 
100*ca987d46SWarner Losh 
101*ca987d46SWarner Losh /**************************************************************************
102*ca987d46SWarner Losh                         g e t - o r d e r
103*ca987d46SWarner Losh ** SEARCH ( -- widn ... wid1 n )
104*ca987d46SWarner Losh ** Returns the number of word lists n in the search order and the word list
105*ca987d46SWarner Losh ** identifiers widn ... wid1 identifying these word lists. wid1 identifies
106*ca987d46SWarner Losh ** the word list that is searched first, and widn the word list that is
107*ca987d46SWarner Losh ** searched last. The search order is unaffected.
108*ca987d46SWarner Losh **************************************************************************/
getOrder(FICL_VM * pVM)109*ca987d46SWarner Losh static void getOrder(FICL_VM *pVM)
110*ca987d46SWarner Losh {
111*ca987d46SWarner Losh     FICL_DICT *pDict = vmGetDict(pVM);
112*ca987d46SWarner Losh     int nLists = pDict->nLists;
113*ca987d46SWarner Losh     int i;
114*ca987d46SWarner Losh 
115*ca987d46SWarner Losh     ficlLockDictionary(TRUE);
116*ca987d46SWarner Losh     for (i = 0; i < nLists; i++)
117*ca987d46SWarner Losh     {
118*ca987d46SWarner Losh         stackPushPtr(pVM->pStack, pDict->pSearch[i]);
119*ca987d46SWarner Losh     }
120*ca987d46SWarner Losh 
121*ca987d46SWarner Losh     stackPushUNS(pVM->pStack, nLists);
122*ca987d46SWarner Losh     ficlLockDictionary(FALSE);
123*ca987d46SWarner Losh     return;
124*ca987d46SWarner Losh }
125*ca987d46SWarner Losh 
126*ca987d46SWarner Losh 
127*ca987d46SWarner Losh /**************************************************************************
128*ca987d46SWarner Losh                         s e a r c h - w o r d l i s t
129*ca987d46SWarner Losh ** SEARCH ( c-addr u wid -- 0 | xt 1 | xt -1 )
130*ca987d46SWarner Losh ** Find the definition identified by the string c-addr u in the word list
131*ca987d46SWarner Losh ** identified by wid. If the definition is not found, return zero. If the
132*ca987d46SWarner Losh ** definition is found, return its execution token xt and one (1) if the
133*ca987d46SWarner Losh ** definition is immediate, minus-one (-1) otherwise.
134*ca987d46SWarner Losh **************************************************************************/
searchWordlist(FICL_VM * pVM)135*ca987d46SWarner Losh static void searchWordlist(FICL_VM *pVM)
136*ca987d46SWarner Losh {
137*ca987d46SWarner Losh     STRINGINFO si;
138*ca987d46SWarner Losh     UNS16 hashCode;
139*ca987d46SWarner Losh     FICL_WORD *pFW;
140*ca987d46SWarner Losh     FICL_HASH *pHash = stackPopPtr(pVM->pStack);
141*ca987d46SWarner Losh 
142*ca987d46SWarner Losh     si.count         = (FICL_COUNT)stackPopUNS(pVM->pStack);
143*ca987d46SWarner Losh     si.cp            = stackPopPtr(pVM->pStack);
144*ca987d46SWarner Losh     hashCode         = hashHashCode(si);
145*ca987d46SWarner Losh 
146*ca987d46SWarner Losh     ficlLockDictionary(TRUE);
147*ca987d46SWarner Losh     pFW = hashLookup(pHash, si, hashCode);
148*ca987d46SWarner Losh     ficlLockDictionary(FALSE);
149*ca987d46SWarner Losh 
150*ca987d46SWarner Losh     if (pFW)
151*ca987d46SWarner Losh     {
152*ca987d46SWarner Losh         stackPushPtr(pVM->pStack, pFW);
153*ca987d46SWarner Losh         stackPushINT(pVM->pStack, (wordIsImmediate(pFW) ? 1 : -1));
154*ca987d46SWarner Losh     }
155*ca987d46SWarner Losh     else
156*ca987d46SWarner Losh     {
157*ca987d46SWarner Losh         stackPushUNS(pVM->pStack, 0);
158*ca987d46SWarner Losh     }
159*ca987d46SWarner Losh 
160*ca987d46SWarner Losh     return;
161*ca987d46SWarner Losh }
162*ca987d46SWarner Losh 
163*ca987d46SWarner Losh 
164*ca987d46SWarner Losh /**************************************************************************
165*ca987d46SWarner Losh                         s e t - c u r r e n t
166*ca987d46SWarner Losh ** SEARCH ( wid -- )
167*ca987d46SWarner Losh ** Set the compilation word list to the word list identified by wid.
168*ca987d46SWarner Losh **************************************************************************/
setCurrent(FICL_VM * pVM)169*ca987d46SWarner Losh static void setCurrent(FICL_VM *pVM)
170*ca987d46SWarner Losh {
171*ca987d46SWarner Losh     FICL_HASH *pHash = stackPopPtr(pVM->pStack);
172*ca987d46SWarner Losh     FICL_DICT *pDict = vmGetDict(pVM);
173*ca987d46SWarner Losh     ficlLockDictionary(TRUE);
174*ca987d46SWarner Losh     pDict->pCompile = pHash;
175*ca987d46SWarner Losh     ficlLockDictionary(FALSE);
176*ca987d46SWarner Losh     return;
177*ca987d46SWarner Losh }
178*ca987d46SWarner Losh 
179*ca987d46SWarner Losh 
180*ca987d46SWarner Losh /**************************************************************************
181*ca987d46SWarner Losh                         s e t - o r d e r
182*ca987d46SWarner Losh ** SEARCH ( widn ... wid1 n -- )
183*ca987d46SWarner Losh ** Set the search order to the word lists identified by widn ... wid1.
184*ca987d46SWarner Losh ** Subsequently, word list wid1 will be searched first, and word list
185*ca987d46SWarner Losh ** widn searched last. If n is zero, empty the search order. If n is minus
186*ca987d46SWarner Losh ** one, set the search order to the implementation-defined minimum
187*ca987d46SWarner Losh ** search order. The minimum search order shall include the words
188*ca987d46SWarner Losh ** FORTH-WORDLIST and SET-ORDER. A system shall allow n to
189*ca987d46SWarner Losh ** be at least eight.
190*ca987d46SWarner Losh **************************************************************************/
setOrder(FICL_VM * pVM)191*ca987d46SWarner Losh static void setOrder(FICL_VM *pVM)
192*ca987d46SWarner Losh {
193*ca987d46SWarner Losh     int i;
194*ca987d46SWarner Losh     int nLists = stackPopINT(pVM->pStack);
195*ca987d46SWarner Losh     FICL_DICT *dp = vmGetDict(pVM);
196*ca987d46SWarner Losh 
197*ca987d46SWarner Losh     if (nLists > FICL_DEFAULT_VOCS)
198*ca987d46SWarner Losh     {
199*ca987d46SWarner Losh         vmThrowErr(pVM, "set-order error: list would be too large");
200*ca987d46SWarner Losh     }
201*ca987d46SWarner Losh 
202*ca987d46SWarner Losh     ficlLockDictionary(TRUE);
203*ca987d46SWarner Losh 
204*ca987d46SWarner Losh     if (nLists >= 0)
205*ca987d46SWarner Losh     {
206*ca987d46SWarner Losh         dp->nLists = nLists;
207*ca987d46SWarner Losh         for (i = nLists-1; i >= 0; --i)
208*ca987d46SWarner Losh         {
209*ca987d46SWarner Losh             dp->pSearch[i] = stackPopPtr(pVM->pStack);
210*ca987d46SWarner Losh         }
211*ca987d46SWarner Losh     }
212*ca987d46SWarner Losh     else
213*ca987d46SWarner Losh     {
214*ca987d46SWarner Losh         dictResetSearchOrder(dp);
215*ca987d46SWarner Losh     }
216*ca987d46SWarner Losh 
217*ca987d46SWarner Losh     ficlLockDictionary(FALSE);
218*ca987d46SWarner Losh     return;
219*ca987d46SWarner Losh }
220*ca987d46SWarner Losh 
221*ca987d46SWarner Losh 
222*ca987d46SWarner Losh /**************************************************************************
223*ca987d46SWarner Losh                         f i c l - w o r d l i s t
224*ca987d46SWarner Losh ** SEARCH ( -- wid )
225*ca987d46SWarner Losh ** Create a new empty word list, returning its word list identifier wid.
226*ca987d46SWarner Losh ** The new word list may be returned from a pool of preallocated word
227*ca987d46SWarner Losh ** lists or may be dynamically allocated in data space. A system shall
228*ca987d46SWarner Losh ** allow the creation of at least 8 new word lists in addition to any
229*ca987d46SWarner Losh ** provided as part of the system.
230*ca987d46SWarner Losh ** Notes:
231*ca987d46SWarner Losh ** 1. ficl creates a new single-list hash in the dictionary and returns
232*ca987d46SWarner Losh **    its address.
233*ca987d46SWarner Losh ** 2. ficl-wordlist takes an arg off the stack indicating the number of
234*ca987d46SWarner Losh **    hash entries in the wordlist. Ficl 2.02 and later define WORDLIST as
235*ca987d46SWarner Losh **    : wordlist 1 ficl-wordlist ;
236*ca987d46SWarner Losh **************************************************************************/
ficlWordlist(FICL_VM * pVM)237*ca987d46SWarner Losh static void ficlWordlist(FICL_VM *pVM)
238*ca987d46SWarner Losh {
239*ca987d46SWarner Losh     FICL_DICT *dp = vmGetDict(pVM);
240*ca987d46SWarner Losh     FICL_HASH *pHash;
241*ca987d46SWarner Losh     FICL_UNS nBuckets;
242*ca987d46SWarner Losh 
243*ca987d46SWarner Losh #if FICL_ROBUST > 1
244*ca987d46SWarner Losh     vmCheckStack(pVM, 1, 1);
245*ca987d46SWarner Losh #endif
246*ca987d46SWarner Losh     nBuckets = stackPopUNS(pVM->pStack);
247*ca987d46SWarner Losh     pHash = dictCreateWordlist(dp, nBuckets);
248*ca987d46SWarner Losh     stackPushPtr(pVM->pStack, pHash);
249*ca987d46SWarner Losh     return;
250*ca987d46SWarner Losh }
251*ca987d46SWarner Losh 
252*ca987d46SWarner Losh 
253*ca987d46SWarner Losh /**************************************************************************
254*ca987d46SWarner Losh                         S E A R C H >
255*ca987d46SWarner Losh ** ficl  ( -- wid )
256*ca987d46SWarner Losh ** Pop wid off the search order. Error if the search order is empty
257*ca987d46SWarner Losh **************************************************************************/
searchPop(FICL_VM * pVM)258*ca987d46SWarner Losh static void searchPop(FICL_VM *pVM)
259*ca987d46SWarner Losh {
260*ca987d46SWarner Losh     FICL_DICT *dp = vmGetDict(pVM);
261*ca987d46SWarner Losh     int nLists;
262*ca987d46SWarner Losh 
263*ca987d46SWarner Losh     ficlLockDictionary(TRUE);
264*ca987d46SWarner Losh     nLists = dp->nLists;
265*ca987d46SWarner Losh     if (nLists == 0)
266*ca987d46SWarner Losh     {
267*ca987d46SWarner Losh         vmThrowErr(pVM, "search> error: empty search order");
268*ca987d46SWarner Losh     }
269*ca987d46SWarner Losh     stackPushPtr(pVM->pStack, dp->pSearch[--dp->nLists]);
270*ca987d46SWarner Losh     ficlLockDictionary(FALSE);
271*ca987d46SWarner Losh     return;
272*ca987d46SWarner Losh }
273*ca987d46SWarner Losh 
274*ca987d46SWarner Losh 
275*ca987d46SWarner Losh /**************************************************************************
276*ca987d46SWarner Losh                         > S E A R C H
277*ca987d46SWarner Losh ** ficl  ( wid -- )
278*ca987d46SWarner Losh ** Push wid onto the search order. Error if the search order is full.
279*ca987d46SWarner Losh **************************************************************************/
searchPush(FICL_VM * pVM)280*ca987d46SWarner Losh static void searchPush(FICL_VM *pVM)
281*ca987d46SWarner Losh {
282*ca987d46SWarner Losh     FICL_DICT *dp = vmGetDict(pVM);
283*ca987d46SWarner Losh 
284*ca987d46SWarner Losh     ficlLockDictionary(TRUE);
285*ca987d46SWarner Losh     if (dp->nLists > FICL_DEFAULT_VOCS)
286*ca987d46SWarner Losh     {
287*ca987d46SWarner Losh         vmThrowErr(pVM, ">search error: search order overflow");
288*ca987d46SWarner Losh     }
289*ca987d46SWarner Losh     dp->pSearch[dp->nLists++] = stackPopPtr(pVM->pStack);
290*ca987d46SWarner Losh     ficlLockDictionary(FALSE);
291*ca987d46SWarner Losh     return;
292*ca987d46SWarner Losh }
293*ca987d46SWarner Losh 
294*ca987d46SWarner Losh 
295*ca987d46SWarner Losh /**************************************************************************
296*ca987d46SWarner Losh                         W I D - G E T - N A M E
297*ca987d46SWarner Losh ** ficl  ( wid -- c-addr u )
298*ca987d46SWarner Losh ** Get wid's (optional) name and push onto stack as a counted string
299*ca987d46SWarner Losh **************************************************************************/
widGetName(FICL_VM * pVM)300*ca987d46SWarner Losh static void widGetName(FICL_VM *pVM)
301*ca987d46SWarner Losh {
302*ca987d46SWarner Losh     FICL_HASH *pHash = vmPop(pVM).p;
303*ca987d46SWarner Losh     char *cp = pHash->name;
304*ca987d46SWarner Losh     FICL_INT len = 0;
305*ca987d46SWarner Losh 
306*ca987d46SWarner Losh     if (cp)
307*ca987d46SWarner Losh         len = strlen(cp);
308*ca987d46SWarner Losh 
309*ca987d46SWarner Losh     vmPush(pVM, LVALUEtoCELL(cp));
310*ca987d46SWarner Losh     vmPush(pVM, LVALUEtoCELL(len));
311*ca987d46SWarner Losh     return;
312*ca987d46SWarner Losh }
313*ca987d46SWarner Losh 
314*ca987d46SWarner Losh /**************************************************************************
315*ca987d46SWarner Losh                         W I D - S E T - N A M E
316*ca987d46SWarner Losh ** ficl  ( wid c-addr -- )
317*ca987d46SWarner Losh ** Set wid's name pointer to the \0 terminated string address supplied
318*ca987d46SWarner Losh **************************************************************************/
widSetName(FICL_VM * pVM)319*ca987d46SWarner Losh static void widSetName(FICL_VM *pVM)
320*ca987d46SWarner Losh {
321*ca987d46SWarner Losh     char *cp = (char *)vmPop(pVM).p;
322*ca987d46SWarner Losh     FICL_HASH *pHash = vmPop(pVM).p;
323*ca987d46SWarner Losh     pHash->name = cp;
324*ca987d46SWarner Losh     return;
325*ca987d46SWarner Losh }
326*ca987d46SWarner Losh 
327*ca987d46SWarner Losh 
328*ca987d46SWarner Losh /**************************************************************************
329*ca987d46SWarner Losh                         setParentWid
330*ca987d46SWarner Losh ** FICL
331*ca987d46SWarner Losh ** setparentwid   ( parent-wid wid -- )
332*ca987d46SWarner Losh ** Set WID's link field to the parent-wid. search-wordlist will
333*ca987d46SWarner Losh ** iterate through all the links when finding words in the child wid.
334*ca987d46SWarner Losh **************************************************************************/
setParentWid(FICL_VM * pVM)335*ca987d46SWarner Losh static void setParentWid(FICL_VM *pVM)
336*ca987d46SWarner Losh {
337*ca987d46SWarner Losh     FICL_HASH *parent, *child;
338*ca987d46SWarner Losh #if FICL_ROBUST > 1
339*ca987d46SWarner Losh     vmCheckStack(pVM, 2, 0);
340*ca987d46SWarner Losh #endif
341*ca987d46SWarner Losh     child  = (FICL_HASH *)stackPopPtr(pVM->pStack);
342*ca987d46SWarner Losh     parent = (FICL_HASH *)stackPopPtr(pVM->pStack);
343*ca987d46SWarner Losh 
344*ca987d46SWarner Losh     child->link = parent;
345*ca987d46SWarner Losh     return;
346*ca987d46SWarner Losh }
347*ca987d46SWarner Losh 
348*ca987d46SWarner Losh 
349*ca987d46SWarner Losh /**************************************************************************
350*ca987d46SWarner Losh                         f i c l C o m p i l e S e a r c h
351*ca987d46SWarner Losh ** Builds the primitive wordset and the environment-query namespace.
352*ca987d46SWarner Losh **************************************************************************/
353*ca987d46SWarner Losh 
ficlCompileSearch(FICL_SYSTEM * pSys)354*ca987d46SWarner Losh void ficlCompileSearch(FICL_SYSTEM *pSys)
355*ca987d46SWarner Losh {
356*ca987d46SWarner Losh     FICL_DICT *dp = pSys->dp;
357*ca987d46SWarner Losh     assert (dp);
358*ca987d46SWarner Losh 
359*ca987d46SWarner Losh     /*
360*ca987d46SWarner Losh     ** optional SEARCH-ORDER word set
361*ca987d46SWarner Losh     */
362*ca987d46SWarner Losh     dictAppendWord(dp, ">search",   searchPush,     FW_DEFAULT);
363*ca987d46SWarner Losh     dictAppendWord(dp, "search>",   searchPop,      FW_DEFAULT);
364*ca987d46SWarner Losh     dictAppendWord(dp, "definitions",
365*ca987d46SWarner Losh                                     definitions,    FW_DEFAULT);
366*ca987d46SWarner Losh     dictAppendWord(dp, "forth-wordlist",
367*ca987d46SWarner Losh                                     forthWordlist,  FW_DEFAULT);
368*ca987d46SWarner Losh     dictAppendWord(dp, "get-current",
369*ca987d46SWarner Losh                                     getCurrent,     FW_DEFAULT);
370*ca987d46SWarner Losh     dictAppendWord(dp, "get-order", getOrder,       FW_DEFAULT);
371*ca987d46SWarner Losh     dictAppendWord(dp, "search-wordlist",
372*ca987d46SWarner Losh                                     searchWordlist, FW_DEFAULT);
373*ca987d46SWarner Losh     dictAppendWord(dp, "set-current",
374*ca987d46SWarner Losh                                     setCurrent,     FW_DEFAULT);
375*ca987d46SWarner Losh     dictAppendWord(dp, "set-order", setOrder,       FW_DEFAULT);
376*ca987d46SWarner Losh     dictAppendWord(dp, "ficl-wordlist",
377*ca987d46SWarner Losh                                     ficlWordlist,   FW_DEFAULT);
378*ca987d46SWarner Losh 
379*ca987d46SWarner Losh     /*
380*ca987d46SWarner Losh     ** Set SEARCH environment query values
381*ca987d46SWarner Losh     */
382*ca987d46SWarner Losh     ficlSetEnv(pSys, "search-order",      FICL_TRUE);
383*ca987d46SWarner Losh     ficlSetEnv(pSys, "search-order-ext",  FICL_TRUE);
384*ca987d46SWarner Losh     ficlSetEnv(pSys, "wordlists",         FICL_DEFAULT_VOCS);
385*ca987d46SWarner Losh 
386*ca987d46SWarner Losh     dictAppendWord(dp, "wid-get-name", widGetName,  FW_DEFAULT);
387*ca987d46SWarner Losh     dictAppendWord(dp, "wid-set-name", widSetName,  FW_DEFAULT);
388*ca987d46SWarner Losh     dictAppendWord(dp, "wid-set-super",
389*ca987d46SWarner Losh                                     setParentWid,   FW_DEFAULT);
390*ca987d46SWarner Losh     return;
391*ca987d46SWarner Losh }
392*ca987d46SWarner Losh 
393