cond/case

db4
Doug Coleman 2008-04-11 12:56:11 -05:00
parent 5fa3bd8c74
commit 2b78870033
7 changed files with 22 additions and 22 deletions

View File

@ -90,7 +90,7 @@ M: inet6 parse-sockaddr
{ [ dup AF_INET = ] [ T{ inet4 } ] } { [ dup AF_INET = ] [ T{ inet4 } ] }
{ [ dup AF_INET6 = ] [ T{ inet6 } ] } { [ dup AF_INET6 = ] [ T{ inet6 } ] }
{ [ dup AF_UNIX = ] [ T{ local } ] } { [ dup AF_UNIX = ] [ T{ local } ] }
{ [ t ] [ f ] } [ f ]
} cond nip ; } cond nip ;
M: f parse-sockaddr nip ; M: f parse-sockaddr nip ;

View File

@ -76,16 +76,16 @@ M: unix copy-file ( from to -- )
2bi ; 2bi ;
: stat>type ( stat -- type ) : stat>type ( stat -- type )
stat-st_mode { stat-st_mode S_IFMT bitand {
{ [ dup S_ISREG ] [ +regular-file+ ] } { S_IFREG [ +regular-file+ ] }
{ [ dup S_ISDIR ] [ +directory+ ] } { S_IFDIR [ +directory+ ] }
{ [ dup S_ISCHR ] [ +character-device+ ] } { S_IFCHR [ +character-device+ ] }
{ [ dup S_ISBLK ] [ +block-device+ ] } { S_IFBLK [ +block-device+ ] }
{ [ dup S_ISFIFO ] [ +fifo+ ] } { S_IFIFO [ +fifo+ ] }
{ [ dup S_ISLNK ] [ +symbolic-link+ ] } { S_IFLNK [ +symbolic-link+ ] }
{ [ dup S_ISSOCK ] [ +socket+ ] } { S_IFSOCK [ +socket+ ] }
{ [ t ] [ +unknown+ ] } [ drop +unknown+ ]
} cond nip ; } case ;
: stat>file-info ( stat -- info ) : stat>file-info ( stat -- info )
{ {

View File

@ -55,7 +55,7 @@ USE: unix
{ [ pick string? ] [ redirect-file ] } { [ pick string? ] [ redirect-file ] }
{ [ pick +closed+ eq? ] [ redirect-closed ] } { [ pick +closed+ eq? ] [ redirect-closed ] }
{ [ pick +inherit+ eq? ] [ redirect-closed ] } { [ pick +inherit+ eq? ] [ redirect-closed ] }
{ [ t ] [ redirect-stream ] } [ redirect-stream ]
} cond ; } cond ;
: ?closed dup +closed+ eq? [ drop "/dev/null" ] when ; : ?closed dup +closed+ eq? [ drop "/dev/null" ] when ;

View File

@ -39,7 +39,7 @@ M: winnt add-completion ( handle -- )
GetLastError { GetLastError {
{ [ dup expected-io-error? ] [ 2drop t ] } { [ dup expected-io-error? ] [ 2drop t ] }
{ [ dup eof? ] [ drop t swap set-port-eof? f ] } { [ dup eof? ] [ drop t swap set-port-eof? f ] }
{ [ t ] [ (win32-error-string) throw ] } [ (win32-error-string) throw ]
} cond } cond
] [ ] [
drop t drop t

View File

@ -25,7 +25,7 @@ M: winnt root-directory? ( path -- ? )
{ [ dup length 2 = ] [ dup second CHAR: : = ] } && nip ] [ { [ dup length 2 = ] [ dup second CHAR: : = ] } && nip ] [
t t
] } ] }
{ [ t ] [ f ] } [ f ]
} cond nip ; } cond nip ;
ERROR: not-absolute-path ; ERROR: not-absolute-path ;

View File

@ -55,7 +55,7 @@ IN: io.windows.nt.launcher
{ [ pick +inherit+ eq? ] [ redirect-inherit ] } { [ pick +inherit+ eq? ] [ redirect-inherit ] }
{ [ pick +closed+ eq? ] [ redirect-closed ] } { [ pick +closed+ eq? ] [ redirect-closed ] }
{ [ pick string? ] [ redirect-file ] } { [ pick string? ] [ redirect-file ] }
{ [ t ] [ redirect-stream ] } [ redirect-stream ]
} cond ; } cond ;
: default-stdout ( args -- handle ) : default-stdout ( args -- handle )

View File

@ -58,13 +58,13 @@ M: winnt <monitor> ( path recursive? -- monitor )
: parse-action ( action -- changed ) : parse-action ( action -- changed )
{ {
{ [ dup FILE_ACTION_ADDED = ] [ +add-file+ ] } { \ FILE_ACTION_ADDED [ +add-file+ ] }
{ [ dup FILE_ACTION_REMOVED = ] [ +remove-file+ ] } { \ FILE_ACTION_REMOVED [ +remove-file+ ] }
{ [ dup FILE_ACTION_MODIFIED = ] [ +modify-file+ ] } { \ FILE_ACTION_MODIFIED [ +modify-file+ ] }
{ [ dup FILE_ACTION_RENAMED_OLD_NAME = ] [ +rename-file+ ] } { \ FILE_ACTION_RENAMED_OLD_NAME [ +rename-file+ ] }
{ [ dup FILE_ACTION_RENAMED_NEW_NAME = ] [ +rename-file+ ] } { \ FILE_ACTION_RENAMED_NEW_NAME [ +rename-file+ ] }
{ [ t ] [ +modify-file+ ] } [ drop +modify-file+ ]
} cond nip ; } case ;
: memory>u16-string ( alien len -- string ) : memory>u16-string ( alien len -- string )
[ memory>byte-array ] keep 2/ c-ushort-array> >string ; [ memory>byte-array ] keep 2/ c-ushort-array> >string ;