Diff for /gforth/string.fs between versions 1.18 and 1.20

version 1.18, 2012/09/17 18:46:46 version 1.20, 2012/12/31 15:25:18
Line 1 Line 1
 \ dynamic string handling                              10aug99py  \ dynamic string handling                              10aug99py
   
 \ Copyright (C) 2000,2005,2007,2010,2011 Free Software Foundation, Inc.  \ Copyright (C) 2000,2005,2007,2010,2011,2012 Free Software Foundation, Inc.
   
 \ This file is part of Gforth.  \ This file is part of Gforth.
   
Line 83 Line 83
     $@ BEGIN  dup  WHILE  r@ $split i' -rot >r >r execute r> r>      $@ BEGIN  dup  WHILE  r@ $split i' -rot >r >r execute r> r>
     REPEAT  2drop rdrop rdrop ;      REPEAT  2drop rdrop rdrop ;
   
   : $over ( addr u $addr off -- )
       \G overwrite string at offset off with addr u
       swap >r
       r@ @ 0= IF  s" " r@ $!  THEN
       2dup + r@ $@len > IF
           2dup + r@ $@len tuck max r@ $!len
           r@ $@ rot /string bl fill
       THEN
       r> $@ rot /string rot umin move ;
   
 \ string array words  \ string array words
   
 : $[] ( n addr -- addr' ) >r  : $[] ( n addr -- addr' ) >r
       \G index into the string array and return the address at index n
     r@ @ 0= IF  s" " r@ $!  THEN      r@ @ 0= IF  s" " r@ $!  THEN
     r@ $@ 2 pick cells /string      r@ $@ 2 pick cells /string
     dup cell < IF      dup cell < IF
Line 95 Line 106
         r@ $@ 2 pick cells /string          r@ $@ 2 pick cells /string
     THEN  drop nip rdrop ;      THEN  drop nip rdrop ;
   
 : $[]! ( addr u n $addr -- )  $[] $! ;  : $[]! ( addr u n $[]addr -- )  $[] $! ;
 : $[]+! ( addr u n $addr -- )  $[] $+! ;  \G store a string into an array at index n
 : $[]@ ( n $addr -- addr u )  $[] dup @ IF $@ ELSE drop s" " THEN ;  : $[]+! ( addr u n $[]addr -- )  $[] $+! ;
   \G add a string to the string at addr n
 : $over ( addr u $addr off -- )  : $[]@ ( n $[]addr -- addr u )  $[] dup @ IF $@ ELSE drop s" " THEN ;
     \G overwrite string at offset off with addr u  \G fetch a string from array index n -- return the zero string if empty
     swap >r  
     r@ @ 0= IF  s" " r@ $!  THEN  
     2dup + r@ $@len > IF  
         2dup + r@ $@len tuck max r@ $!len  
         r@ $@ rot /string bl fill  
     THEN  
     r> $@ rot /string rot umin move ;  
 [THEN]  [THEN]
   

Removed from v.1.18  
changed lines
  Added in v.1.20


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