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