Annotation of gforth/compat/strcomp.fs, revision 1.3
1.1 anton 1: \ string comparisons
2:
3: \ This file is in the public domain. NO WARRANTY.
4:
5: \ Uses of COMPARE can be replaced with STR=, STRING-PREFIX?, and STR<
6: \ (and these can be implemented more efficiently and used more easily
7: \ than COMPARE). See <news:2002Aug12.110229@a0.complang.tuwien.ac.at>
8: \ and following.
9:
10: s" gforth" environment? [if]
1.2 anton 11: 2drop defined str=
1.1 anton 12: [else]
1.3 ! anton 13: \ : \G postpone \ ; immediate
1.1 anton 14: 0
15: [then]
16: 0= [if]
17:
1.3 ! anton 18: : str= ( c-addr1 u1 c-addr2 u2 -- f ) \ gforth
1.1 anton 19: compare 0= ;
20:
1.3 ! anton 21: : string-prefix? ( c-addr1 u1 c-addr2 u2 -- f ) \ gforth
1.1 anton 22: \G Is @var{c-addr2 u2} a prefix of @var{c-addr1 u1}?
23: tuck 2>r min 2r> str= ;
24:
1.3 ! anton 25: : str< ( c-addr1 u1 c-addr2 u2 -- f ) \ gforth
1.1 anton 26: compare 0< ;
27:
28: [then]
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>