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
alien.c-types alien.arrays alien.strings sequences combinators
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
M: winnt cwd
@ -40,9 +40,11 @@ ERROR: not-absolute-path ;
unicode-prefix prepend
] unless ;
TR: normalize-separators "/" "\\" ;
M: winnt normalize-path ( string -- string' )
(normalize-path)
{ { CHAR: / CHAR: \\ } } substitute
normalize-separators
prepend-prefix ;
M: winnt CreateFile-flags ( DWORD -- DWORD )

View File

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

View File

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

View File

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

View File

@ -2,12 +2,16 @@
! See http://factorcode.org/license.txt for BSD license.
USING: threads io.files io.monitors init kernel
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
TR: convert-separators "/\\" ".." ;
: vocab-dir>vocab-name ( path -- vocab )
left-trim-separators right-trim-separators
{ { CHAR: / CHAR: . } { CHAR: \\ CHAR: . } } substitute ;
left-trim-separators
right-trim-separators
convert-separators ;
: path>vocab-name ( path -- vocab )
dup ".factor" tail? [ parent-directory ] when ;

View File

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

View File

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