1*67ab13dcSToomas Soome\
2*67ab13dcSToomas Soome\ This file and its contents are supplied under the terms of the
3*67ab13dcSToomas Soome\ Common Development and Distribution License ("CDDL"), version 1.0.
4*67ab13dcSToomas Soome\ You may only use this file in accordance with the terms of version
5*67ab13dcSToomas Soome\ 1.0 of the CDDL.
6*67ab13dcSToomas Soome\
7*67ab13dcSToomas Soome\ A full copy of the text of the CDDL should have accompanied this
8*67ab13dcSToomas Soome\ source.  A copy of the CDDL is also available via the Internet at
9*67ab13dcSToomas Soome\ http://www.illumos.org/license/CDDL.
10*67ab13dcSToomas Soome
11*67ab13dcSToomas Soome\ Copyright 2016 Toomas Soome <tsoome@me.com>
12*67ab13dcSToomas Soome
13*67ab13dcSToomas Soome\ This file is part of the softcore, implementing [partial] word sets.
14*67ab13dcSToomas Soome
15*67ab13dcSToomas Soome\ Optional String word set.
16*67ab13dcSToomas Soome\ compare is implemented in ficl core.
17*67ab13dcSToomas Soome
18*67ab13dcSToomas Soome\ search ( c-addr1 u1 c-addr2 u2 -- c-addr3 u3 flag )
19*67ab13dcSToomas Soome\ Search the string specified by c-addr1 u1 for the string specified by
20*67ab13dcSToomas Soome\ c-addr2 u2. If flag is true, a match was found at c-addr3 with u3 characters
21*67ab13dcSToomas Soome\ remaining. If flag is false there was no match and c-addr3 is c-addr1 and u3
22*67ab13dcSToomas Soome\ is u1.
23*67ab13dcSToomas Soome: search { c-addr1 u1 c-addr2 u2 | saved-addr1 saved-u1 -- c-addr3 u3 flag }
24*67ab13dcSToomas Soome	c-addr1 to saved-addr1	\ save original c-addr1
25*67ab13dcSToomas Soome	u1 to saved-u1		\ save original u1
26*67ab13dcSToomas Soome	begin
27*67ab13dcSToomas Soome		c-addr1 u1 u2 < if u1 else u2 then
28*67ab13dcSToomas Soome		c-addr2 u2 compare
29*67ab13dcSToomas Soome	while
30*67ab13dcSToomas Soome		c-addr1 1+ to c-addr1
31*67ab13dcSToomas Soome		u1 1- to u1
32*67ab13dcSToomas Soome		u1 0= if
33*67ab13dcSToomas Soome			saved-addr1 saved-u1 0 exit	\ not found
34*67ab13dcSToomas Soome		then
35*67ab13dcSToomas Soome	repeat
36*67ab13dcSToomas Soome	c-addr1 u1 -1
37*67ab13dcSToomas Soome;
38