File:  [gforth] / gforth / compat / strcomp.fs
Revision 1.2: download - view: text, annotated - select for diffs
Sat Sep 14 08:34:03 2002 UTC (21 years, 7 months ago) by anton
Branches: MAIN
CVS tags: HEAD
fixed bugs in compat/strcomp.fs and its usage

    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]
   11:     2drop defined str=
   12: [else]
   13:     0
   14: [then]
   15: 0= [if]
   16: 
   17: : str= ( c-addr1 u1 c-addr2 u2 -- f )
   18:     compare 0= ;
   19: 
   20: : string-prefix? ( c-addr1 u1 c-addr2 u2 -- f )
   21:     \G Is @var{c-addr2 u2} a prefix of @var{c-addr1 u1}?
   22:     tuck 2>r min 2r> str= ;
   23: 
   24: : str< ( c-addr1 u1 c-addr2 u2 -- f )
   25:     compare 0< ;
   26: 
   27: [then]

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>