17.6.1.0170 -TRAILING dash-trailing STRING

( c-addr u1 -- c-addr u2 )

If u1 is greater than zero, u2 is equal to u1 less the number of spaces at the end of the character string specified by c-addr u1. If u1 is zero or the entire string consists of spaces, u2 is zero.

Testing:

T{ :  s8 S" abc  " ; -> }T
T{ :  s9 S"      " ; -> }T
T{ : s10 S"    a " ; -> }T

T{  s1 -TRAILING -> s1 }T    \ "abcdefghijklmnopqrstuvwxyz"
T{  s8 -TRAILING -> s8 2 - }T       \ "abc "
T{  s7 -TRAILING -> s7 }T             \ " "
T{  s9 -TRAILING -> s9 DROP 0 }T    \ " "
T{ s10 -TRAILING -> s10 1- }T        \ " a "

ContributeContributions