drop [ initialize-sha1 stream>sha1 get-sha1 ] with-input-stream ;
: sha1-interleave ( string -- seq )
- [ zero? ] left-trim
+ [ zero? ] trim-left
dup length odd? [ rest ] when
seq>2seq [ sha1 checksum-bytes ] bi@
2seq>seq ;
: eliminate-phi-introductions ( introductions seq terminated -- seq' )
[
[ nip ] [
- dup [ +bottom+ eq? ] left-trim
+ dup [ +bottom+ eq? ] trim-left
[ [ length ] bi@ - tail* ] keep append
] if
] 3map ;
PRIVATE>
: read-chunk-size ( -- n )
- read-crlf ";" split1 drop [ blank? ] right-trim
+ read-crlf ";" split1 drop [ blank? ] trim-right
hex> [ "Bad chunk size" throw ] unless* ;
: read-chunks ( -- )
[ file-responder get hook>> call ] [ 2drop <304> ] if ;\r
\r
: serving-path ( filename -- filename )\r
- file-responder get root>> right-trim-separators\r
+ file-responder get root>> trim-right-separators\r
"/"\r
- rot "" or left-trim-separators 3append ;\r
+ rot "" or trim-left-separators 3append ;\r
\r
: serve-file ( filename -- response )\r
dup mime-type\r
"m" get next-change drop
dup print flush
dup parent-directory
- [ right-trim-separators "xyz" tail? ] either? not
+ [ trim-right-separators "xyz" tail? ] either? not
] loop
"c1" get count-down
"m" get next-change drop
dup print flush
dup parent-directory
- [ right-trim-separators "yxy" tail? ] either? not
+ [ trim-right-separators "yxy" tail? ] either? not
] loop
"c2" get count-down
[ t ] [ "\\\\" root-directory? ] unit-test
[ t ] [ "/" root-directory? ] unit-test
[ t ] [ "//" root-directory? ] unit-test
-[ t ] [ "c:\\" right-trim-separators root-directory? ] unit-test
-[ t ] [ "Z:\\" right-trim-separators root-directory? ] unit-test
+[ t ] [ "c:\\" trim-right-separators root-directory? ] unit-test
+[ t ] [ "Z:\\" trim-right-separators root-directory? ] unit-test
[ f ] [ "c:\\foo" root-directory? ] unit-test
[ f ] [ "." root-directory? ] unit-test
[ f ] [ ".." root-directory? ] unit-test
{
{ [ dup empty? ] [ f ] }
{ [ dup [ path-separator? ] all? ] [ t ] }
- { [ dup right-trim-separators { [ length 2 = ] [ second CHAR: : = ] } 1&& ] [ t ] }
+ { [ dup trim-right-separators { [ length 2 = ] [ second CHAR: : = ] } 1&& ] [ t ] }
[ f ]
} cond nip ;
M: action-parser (compile) ( peg -- quot )
[ p1>> compile-parser 1quotation ] [ quot>> ] bi '[ @ , check-action ] ;
-: left-trim-slice ( string -- string )
- #! Return a new string without any leading whitespace
- #! from the original string.
- dup empty? [
- dup first blank? [ rest-slice left-trim-slice ] when
- ] unless ;
-
TUPLE: sp-parser p1 ;
M: sp-parser (compile) ( peg -- quot )
p1>> compile-parser 1quotation '[
- input-slice left-trim-slice input-from pos set @
+ input-slice trim-left-slice input-from pos set @
] ;
TUPLE: delay-parser quot ;
: insensitive= ( str1 str2 levels-removed -- ? )\r
[\r
swap collation-key swap\r
- [ [ 0 = not ] right-trim but-last ] times\r
+ [ [ 0 = not ] trim-right but-last ] times\r
] curry bi@ = ;\r
PRIVATE>\r
\r