Skip to content

Commit

Permalink
Fix -trailing
Browse files Browse the repository at this point in the history
  • Loading branch information
davazp committed Apr 13, 2012
1 parent 3b9979c commit 9bce136
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 28 deletions.
14 changes: 1 addition & 13 deletions string.fs
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,11 @@ variable read-string-index


\ Count the number of spaces from ADDR backward.
: <count-spaces ( addr )
0 swap
begin
dup c@ 32 = while
1-
swap 1+ swap
repeat
drop
;


: /string ( caddr1 u1 n - caddr2 u2 )
tuck - >r + r> ;

: -trailing ( caddr u1 - caddr u2 )
2dup 1- + <count-spaces - ;

begin 2dup 1- + c@ 32 = over 0<> and while 1- repeat ;

: compare-integer ( m n -- p )
2dup < if
Expand Down
30 changes: 15 additions & 15 deletions user.fs
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,21 @@ variable error-message-size
FORTH{
! ' ( ) * + +! +loop , - -rot -trailing . ." .( .s / /mod /string 0!
0< 0<> 0= 0> 1+ 1- 2* 2+ 2- 2>r 2drop 2dup 2nip 2over 2r> 2r@ 2rot
2swap 2tuck : :noname ; < <= <> <count-spaces = > >= >in >order >r ?
?do ?dup @ Forth Only Root [ ['] [char] [compile] [defined] [else]
[endif] [if] [ifdef] [ifundef] [then] \ ] ]L abort abort" abs accept
again alias align aligned allocate allot also and at-xy base beep
begin blank c! c, c@ case catch cell cell+ cells char char+ chars
clearstack cmove cmove> compare compile, compile-only constant context
count cr create current dec. decimal defer definitions depth do does>
drop dump dup edit-line else emit end-struct endcase endif endof eulex
evaluate execute exit false field fill free gcd get-current get-order
here hex hex. i id. if immediate invert is j k key latest latestxt lcm
leave literal loop lshift max marker min mod move ms negate nextname
nip noname noop not oct. octal of off on or order over pad page
parse-name pick postpone previous query r> r@ reboot recurse recursive
refill repeat restore-input resize roll room rot rshift s" save-input
see set-current set-order sign source source-id space spaces state
2swap 2tuck : :noname ; < <= <> = > >= >in >order >r ? ?do ?dup @
Forth Only Root [ ['] [char] [compile] [defined] [else] [endif] [if]
[ifdef] [ifundef] [then] \ ] ]L abort abort" abs accept again alias
align aligned allocate allot also and at-xy base beep begin blank c!
c, c@ case catch cell cell+ cells char char+ chars clearstack cmove
cmove> compare compile, compile-only constant context count cr create
current dec. decimal defer definitions depth do does> drop dump dup
edit-line else emit end-struct endcase endif endof eulex evaluate
execute exit false field fill free gcd get-current get-order here hex
hex. i id. if immediate invert is j k key latest latestxt lcm leave
literal loop lshift max marker min mod move ms negate nextname nip
noname noop not oct. octal of off on or order over pad page parse-name
pick postpone previous query r> r@ reboot recurse recursive refill
repeat restore-input resize roll room rot rshift s" save-input see
set-current set-order sign source source-id space spaces state
string-prefix? string<> string= struct swap then throw tib to true
tuck type typewhite u< unloop until value variable vocabulary vocs w!
w@ while wordlist words xor
Expand Down

0 comments on commit 9bce136

Please sign in to comment.