left-trim -> trim-left

db4
Doug Coleman 2008-09-05 18:56:35 -05:00
parent dd3dbf1b14
commit 9af12d96cf
9 changed files with 12 additions and 19 deletions

View File

@ -114,7 +114,7 @@ M: sha1 checksum-stream ( stream -- sha1 )
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 ;

View File

@ -151,7 +151,7 @@ M: #branch normalize*
: 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 ;

View File

@ -113,7 +113,7 @@ SYMBOL: redirects
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 ( -- )

View File

@ -45,9 +45,9 @@ TUPLE: file-responder root hook special allow-listings ;
[ file-responder get hook>> call ] [ 2drop <304> ] if ;
: serving-path ( filename -- filename )
file-responder get root>> right-trim-separators
file-responder get root>> trim-right-separators
"/"
rot "" or left-trim-separators 3append ;
rot "" or trim-left-separators 3append ;
: serve-file ( filename -- response )
dup mime-type

View File

@ -54,7 +54,7 @@ os { winnt linux macosx } member? [
"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
@ -63,7 +63,7 @@ os { winnt linux macosx } member? [
"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

View File

@ -21,8 +21,8 @@ IN: io.windows.nt.files.tests
[ 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

View File

@ -22,7 +22,7 @@ M: winnt root-directory? ( path -- ? )
{
{ [ 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 ;

View File

@ -513,18 +513,11 @@ TUPLE: action-parser p1 quot ;
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 ;

View File

@ -136,7 +136,7 @@ PRIVATE>
: insensitive= ( str1 str2 levels-removed -- ? )
[
swap collation-key swap
[ [ 0 = not ] right-trim but-last ] times
[ [ 0 = not ] trim-right but-last ] times
] curry bi@ = ;
PRIVATE>