moontalk/server/eventloop-server-experiment/libs/xstring/xstring.4th

23 lines
640 B
Plaintext
Raw Permalink Normal View History

2024-02-17 13:26:14 -05:00
\ An extended string is essentially the same
\ as a counted string, with the only difference that
\ instead of storing max 1 char length of a string,
\ we can store up to cell sized strings.
\ Copy an extended string to
: xplace ( c-addr u a-addr -- )
swap dup >r over ! ( c-addr a-addr )
cell + r> move ;
: xcount ( a-addr -- c-addr u )
dup cell + swap @ ;
: +xplace ( c-addr u a-addr -- )
2dup >r >r xcount ( c-addr u c-addr u )
+ swap ( c-addr a-addr u )
move ( -- )
r> r> +! ;
\ single char
create somechar 1 chars allot align
: +xplace-char ( n a-addr -- )
swap somechar c! somechar 1 rot +xplace ;