Use tr instead of substitute in a few places

db4
Slava Pestov 2008-07-09 19:43:46 -05:00
parent 1386297022
commit 34c0cf6111
7 changed files with 20 additions and 19 deletions

View File

@ -4,7 +4,7 @@ io.windows.nt.backend windows windows.kernel32
kernel libc math threads system kernel libc math threads system
alien.c-types alien.arrays alien.strings sequences combinators alien.c-types alien.arrays alien.strings sequences combinators
combinators.short-circuit ascii splitting alien strings combinators.short-circuit ascii splitting alien strings
assocs namespaces io.files.private accessors ; assocs namespaces io.files.private accessors tr ;
IN: io.windows.nt.files IN: io.windows.nt.files
M: winnt cwd M: winnt cwd
@ -40,9 +40,11 @@ ERROR: not-absolute-path ;
unicode-prefix prepend unicode-prefix prepend
] unless ; ] unless ;
TR: normalize-separators "/" "\\" ;
M: winnt normalize-path ( string -- string' ) M: winnt normalize-path ( string -- string' )
(normalize-path) (normalize-path)
{ { CHAR: / CHAR: \\ } } substitute normalize-separators
prepend-prefix ; prepend-prefix ;
M: winnt CreateFile-flags ( DWORD -- DWORD ) M: winnt CreateFile-flags ( DWORD -- DWORD )

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: kernel io.streams.string io strings splitting sequences math USING: kernel io.streams.string io strings splitting sequences math
math.parser assocs classes words namespaces prettyprint math.parser assocs classes words namespaces prettyprint
hashtables mirrors ; hashtables mirrors tr ;
IN: json.writer IN: json.writer
#! Writes the object out to a stream in JSON format #! Writes the object out to a stream in JSON format
@ -24,10 +24,7 @@ M: number json-print ( num -- )
M: sequence json-print ( array -- ) M: sequence json-print ( array -- )
CHAR: [ write1 [ >json ] map "," join write CHAR: ] write1 ; CHAR: [ write1 [ >json ] map "," join write CHAR: ] write1 ;
: jsvar-encode ( string -- string ) TR: jsvar-encode "-" "_" ;
#! Convert the string so that it contains characters usable within
#! javascript variable names.
{ { CHAR: - CHAR: _ } } substitute ;
: tuple>fields ( object -- seq ) : tuple>fields ( object -- seq )
<mirror> [ <mirror> [

View File

@ -210,9 +210,6 @@ PRIVATE>
: nths ( seq indices -- seq' ) : nths ( seq indices -- seq' )
swap [ nth ] curry map ; swap [ nth ] curry map ;
: replace ( str oldseq newseq -- str' )
zip >hashtable substitute ;
: remove-nth ( seq n -- seq' ) : remove-nth ( seq n -- seq' )
cut-slice rest-slice append ; cut-slice rest-slice append ;

View File

@ -3,7 +3,7 @@
USING: io.files io words alien kernel math.parser alien.syntax USING: io.files io words alien kernel math.parser alien.syntax
io.launcher system assocs arrays sequences namespaces qualified io.launcher system assocs arrays sequences namespaces qualified
system math generator.fixup io.encodings.ascii accessors system math generator.fixup io.encodings.ascii accessors
generic ; generic tr ;
IN: tools.disassembler IN: tools.disassembler
: in-file ( -- path ) "gdb-in.txt" temp-file ; : in-file ( -- path ) "gdb-in.txt" temp-file ;
@ -36,8 +36,7 @@ M: method-spec make-disassemble-cmd
try-process try-process
out-file ascii file-lines ; out-file ascii file-lines ;
: tabs>spaces ( str -- str' ) TR: tabs>spaces "\t" "\s" ;
{ { CHAR: \t CHAR: \s } } substitute ;
: disassemble ( obj -- ) : disassemble ( obj -- )
make-disassemble-cmd run-gdb make-disassemble-cmd run-gdb

View File

@ -2,12 +2,16 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: threads io.files io.monitors init kernel USING: threads io.files io.monitors init kernel
vocabs vocabs.loader tools.vocabs namespaces continuations vocabs vocabs.loader tools.vocabs namespaces continuations
sequences splitting assocs command-line concurrency.messaging io.backend sets ; sequences splitting assocs command-line concurrency.messaging
io.backend sets tr ;
IN: tools.vocabs.monitor IN: tools.vocabs.monitor
TR: convert-separators "/\\" ".." ;
: vocab-dir>vocab-name ( path -- vocab ) : vocab-dir>vocab-name ( path -- vocab )
left-trim-separators right-trim-separators left-trim-separators
{ { CHAR: / CHAR: . } { CHAR: \\ CHAR: . } } substitute ; right-trim-separators
convert-separators ;
: path>vocab-name ( path -- vocab ) : path>vocab-name ( path -- vocab )
dup ".factor" tail? [ parent-directory ] when ; dup ".factor" tail? [ parent-directory ] when ;

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays definitions kernel sequences strings USING: accessors arrays definitions kernel sequences strings
math assocs words generic namespaces assocs quotations splitting math assocs words generic namespaces assocs quotations splitting
ui.gestures unicode.case unicode.categories ; ui.gestures unicode.case unicode.categories tr ;
IN: ui.commands IN: ui.commands
SYMBOL: +nullary+ SYMBOL: +nullary+
@ -50,8 +50,10 @@ GENERIC: command-word ( command -- word )
swap pick commands set-at swap pick commands set-at
update-gestures ; update-gestures ;
TR: convert-command-name "-" " " ;
: (command-name) ( string -- newstring ) : (command-name) ( string -- newstring )
{ { CHAR: - CHAR: \s } } substitute >title ; convert-command-name >title ;
M: word command-name ( word -- str ) M: word command-name ( word -- str )
name>> name>>

View File

@ -125,7 +125,7 @@ VALUE: properties
: process-names ( data -- names-hash ) : process-names ( data -- names-hash )
1 swap (process-data) [ 1 swap (process-data) [
ascii-lower { { CHAR: \s CHAR: - } } substitute swap ascii-lower { { CHAR: \s CHAR: - } } substitute swap
] assoc-map >hashtable ; ] H{ } assoc-map-as ;
: multihex ( hexstring -- string ) : multihex ( hexstring -- string )
" " split [ hex> ] map sift ; " " split [ hex> ] map sift ;