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_INET6 = ] [ T{ inet6 } ] }
{ [ dup AF_UNIX = ] [ T{ local } ] }
{ [ t ] [ f ] }
[ f ]
} cond nip ;
M: f parse-sockaddr nip ;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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