Plan 9 from Bell Labs’s /usr/web/sources/contrib/fgb/root/sys/src/cmd/4th/lib/stsstack.4th

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


\ 4tH library - STRING STACK - Copyright 2004 J.L. Bezemer
\ You can redistribute this file and/or modify it under
\ the terms of the GNU General Public License

\ N.B. Items taken from a stack by s> will remain
\ unclobbered UNTIL the next >s to that stack is performed.

[UNDEFINED] N! [IF]
INCLUDE lib/ncoding.4th
[THEN]

[UNDEFINED] STRING-STACK [IF]
nell 1 [+] constant tail
                                       ( stack --)
: string-stack dup nell+ tuck tail erase n! ;
: s@ n@ count ;                        ( stack -- a n)
: s> dup s@ rot dup n@ dup nell- n@ tail + chars - swap n! ;
                                       ( stack -- a n)
: >s                                   ( a n stack --)
  >r tuck r@ s@ tail + chars + >r r@   \ calculate new string address
  place r@ over 1+ chars + n! r> r> n! \ save count and stack pointer
;

[DEFINED] 4TH# [IF]
hide tail
[THEN]
[THEN]


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.