From: Doug Coleman Date: Tue, 21 Dec 2021 00:01:12 +0000 (-0600) Subject: factor: use more split/join words X-Git-Tag: 0.99~2169 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=eb239127d73291adf3c9c1e9ffb2b5721884964f factor: use more split/join words --- diff --git a/basis/compiler/tree/builder/builder-docs.factor b/basis/compiler/tree/builder/builder-docs.factor index 5f761be681..f2dbbd406f 100644 --- a/basis/compiler/tree/builder/builder-docs.factor +++ b/basis/compiler/tree/builder/builder-docs.factor @@ -1,5 +1,5 @@ -USING: compiler.tree help.markup help.syntax literals quotations sequences -stack-checker.errors words ; +USING: compiler.tree help.markup help.syntax literals quotations +sequences splitting stack-checker.errors words ; IN: compiler.tree.builder HELP: build-tree @@ -23,7 +23,7 @@ HELP: build-sub-tree " T{ #call { word * } { in-d V{ \"x\" 1 } } { out-d { 2 } } }" " T{ #copy { in-d V{ 2 } } { out-d { \"y\" } } }" "}" - } "\n" join + } join-lines ] } } ; diff --git a/basis/db/postgresql/lib/lib.factor b/basis/db/postgresql/lib/lib.factor index ebbc85dec3..ad75d100b5 100644 --- a/basis/db/postgresql/lib/lib.factor +++ b/basis/db/postgresql/lib/lib.factor @@ -21,7 +21,7 @@ IN: db.postgresql.lib : (postgresql-error-message) ( handle -- str ) PQerrorMessage - "\n" split [ [ ascii:blank? ] trim ] map join-lines ; + split-lines [ [ ascii:blank? ] trim ] map join-lines ; : postgresql-error-message ( -- str ) db-connection get handle>> (postgresql-error-message) ; diff --git a/basis/db/postgresql/postgresql.factor b/basis/db/postgresql/postgresql.factor index 34baeba51c..ebd1328900 100644 --- a/basis/db/postgresql/postgresql.factor +++ b/basis/db/postgresql/postgresql.factor @@ -280,7 +280,7 @@ M: postgresql-db-connection compound } case ; M: postgresql-db-connection parse-db-error - "\n" split dup length { + split-lines dup length { { 1 [ first parse-postgresql-sql-error ] } { 2 [ concat parse-postgresql-sql-error ] } { 3 [ diff --git a/basis/db/types/types.factor b/basis/db/types/types.factor index 5932f4531e..eea4d1dcaa 100644 --- a/basis/db/types/types.factor +++ b/basis/db/types/types.factor @@ -1,10 +1,8 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: arrays assocs db kernel math math.parser -sequences continuations sequences.deep prettyprint -words namespaces slots slots.private classes mirrors -classes.tuple combinators calendar.format classes.singleton -accessors quotations random db.private ; +USING: accessors arrays assocs classes classes.tuple combinators +db kernel math math.parser mirrors sequences sequences.deep +splitting words ; IN: db.types HOOK: persistent-table db-connection ( -- hash ) @@ -139,7 +137,7 @@ ERROR: no-sql-type type ; ] if ; : modifiers ( spec -- string ) - modifiers>> [ lookup-modifier ] map " " join + modifiers>> [ lookup-modifier ] map join-words [ "" ] [ " " prepend ] if-empty ; HOOK: bind% db-connection ( spec -- ) diff --git a/basis/farkup/farkup.factor b/basis/farkup/farkup.factor index 897f454e18..494da659b4 100644 --- a/basis/farkup/farkup.factor +++ b/basis/farkup/farkup.factor @@ -113,7 +113,7 @@ DEFER: (parse-paragraph) first delimiter split1 :> ( before after ) before accum push after [ - accum "\n" join + accum join-lines rest after prefix ] [ rest delimiter accum (take-until) diff --git a/basis/help/lint/checks/checks.factor b/basis/help/lint/checks/checks.factor index 2be0093a1e..6c73369f36 100644 --- a/basis/help/lint/checks/checks.factor +++ b/basis/help/lint/checks/checks.factor @@ -51,7 +51,7 @@ SYMBOL: vocab-articles [ '[ _ rest [ - but-last "\n" join + but-last join-lines eval-with-stack "\n" ?tail drop ] keep diff --git a/basis/help/topics/topics-tests.factor b/basis/help/topics/topics-tests.factor index a62b43fb6e..a524ca6be5 100644 --- a/basis/help/topics/topics-tests.factor +++ b/basis/help/topics/topics-tests.factor @@ -1,6 +1,5 @@ -USING: accessors definitions help help.topics help.crossref -help.markup help.syntax kernel sequences tools.test words parser -namespaces assocs source-files eval ; +USING: accessors assocs eval help help.markup help.topics +namespaces source-files splitting tools.test ; IN: help.topics.tests ! Test help cross-referencing @@ -21,7 +20,7 @@ SYMBOL: foo "ARTICLE: { \"test\" 1 } \"Hello\"" "\"abc\"" "\"def\" ;" - } "\n" join + } join-lines [ "testfile" path>source-file current-source-file set eval( -- ) diff --git a/basis/http/http-tests.factor b/basis/http/http-tests.factor index b1b2508989..ca9db152d4 100644 --- a/basis/http/http-tests.factor +++ b/basis/http/http-tests.factor @@ -66,7 +66,7 @@ ${ read-request-test-1' } [ [ read-request ] with-string-reader [ write-request ] with-string-writer ! normalize crlf - split-lines "\n" join + split-lines join-lines ] unit-test STRING: read-request-test-2 @@ -165,7 +165,7 @@ ${ read-response-test-1' } [ [ read-response ] with-string-reader [ write-response ] with-string-writer ! normalize crlf - split-lines "\n" join + split-lines join-lines ] unit-test { t } [ diff --git a/basis/io/crlf/crlf.factor b/basis/io/crlf/crlf.factor index 9ab6f7dff9..43f6ae0cd6 100644 --- a/basis/io/crlf/crlf.factor +++ b/basis/io/crlf/crlf.factor @@ -27,7 +27,7 @@ IN: io.crlf CHAR: \r swap remove ; : lf>crlf ( str -- str' ) - "\n" split "\r\n" join ; + split-lines "\r\n" join ; :: stream-read1-ignoring-crlf ( stream -- ch ) stream stream-read1 dup "\r\n" member? diff --git a/basis/io/launcher/launcher-docs.factor b/basis/io/launcher/launcher-docs.factor index 60628b71bc..d8b64ef4f9 100644 --- a/basis/io/launcher/launcher-docs.factor +++ b/basis/io/launcher/launcher-docs.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2007, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: assocs calendar help.markup help.syntax io io.files -io.launcher.private kernel literals quotations sequences ; +io.launcher.private kernel literals quotations splitting ; IN: io.launcher ARTICLE: "io.launcher.command" "Specifying a command" @@ -163,7 +163,7 @@ HELP: try-process " }" " }" "}" - } "\n" join + } join-lines ] } } ; diff --git a/basis/prettyprint/prettyprint-tests.factor b/basis/prettyprint/prettyprint-tests.factor index 8f4c977135..3b550071b6 100644 --- a/basis/prettyprint/prettyprint-tests.factor +++ b/basis/prettyprint/prettyprint-tests.factor @@ -115,7 +115,7 @@ unit-test [ parse-fresh drop ] with-compilation-unit [ "prettyprint.tests" lookup-word see - ] with-string-writer "\n" split but-last + ] with-string-writer split-lines but-last ] keep = ] with-interactive-vocabs ; @@ -151,7 +151,7 @@ M: object method-layout ; "" } } [ - [ \ method-layout see-methods ] with-string-writer "\n" split + [ \ method-layout see-methods ] with-string-writer split-lines ] unit-test : soft-break-test ( -- str ) @@ -253,7 +253,7 @@ M: class-see-layout class-see-layout ; "" } } [ - [ \ class-see-layout see ] with-string-writer "\n" split + [ \ class-see-layout see ] with-string-writer split-lines ] unit-test { @@ -263,7 +263,7 @@ M: class-see-layout class-see-layout ; "" } } [ - [ \ class-see-layout see-methods ] with-string-writer "\n" split + [ \ class-see-layout see-methods ] with-string-writer split-lines ] unit-test { } [ \ in>> synopsis drop ] unit-test @@ -333,7 +333,7 @@ TUPLE: tuple-with-declared-slot { x integer } ; "" } } [ - [ \ tuple-with-declared-slot see ] with-string-writer "\n" split + [ \ tuple-with-declared-slot see ] with-string-writer split-lines ] unit-test TUPLE: tuple-with-read-only-slot { x read-only } ; @@ -345,7 +345,7 @@ TUPLE: tuple-with-read-only-slot { x read-only } ; "" } } [ - [ \ tuple-with-read-only-slot see ] with-string-writer "\n" split + [ \ tuple-with-read-only-slot see ] with-string-writer split-lines ] unit-test TUPLE: tuple-with-initial-slot { x initial: 123 } ; @@ -357,7 +357,7 @@ TUPLE: tuple-with-initial-slot { x initial: 123 } ; "" } } [ - [ \ tuple-with-initial-slot see ] with-string-writer "\n" split + [ \ tuple-with-initial-slot see ] with-string-writer split-lines ] unit-test TUPLE: tuple-with-initial-declared-slot { x integer initial: 123 } ; @@ -371,7 +371,7 @@ TUPLE: tuple-with-initial-declared-slot { x integer initial: 123 } ; "" } } [ - [ \ tuple-with-initial-declared-slot see ] with-string-writer "\n" split + [ \ tuple-with-initial-declared-slot see ] with-string-writer split-lines ] unit-test TUPLE: final-tuple ; final @@ -383,7 +383,7 @@ TUPLE: final-tuple ; final "" } } [ - [ \ final-tuple see ] with-string-writer "\n" split + [ \ final-tuple see ] with-string-writer split-lines ] unit-test { "H{ { 1 2 } }\n" } [ [ H{ { 1 2 } } short. ] with-string-writer ] unit-test diff --git a/basis/resolv-conf/resolv-conf.factor b/basis/resolv-conf/resolv-conf.factor index bbcbc623b3..efd548d681 100644 --- a/basis/resolv-conf/resolv-conf.factor +++ b/basis/resolv-conf/resolv-conf.factor @@ -35,7 +35,7 @@ CONSTRUCTOR: resolv.conf ( -- resolv.conf ) : trim-blanks ( string -- string' ) [ blank? ] trim ; : split-line ( resolv.conf string -- resolv.conf seq resolv.conf ) - trim-blanks " " split + trim-blanks split-words [ trim-blanks ] map harvest over ; : parse-nameserver ( resolv.conf string -- resolv.conf ) @@ -51,7 +51,7 @@ CONSTRUCTOR: resolv.conf ( -- resolv.conf ) split-line search>> push-all ; : parse-sortlist ( resolv.conf string -- resolv.conf ) - trim-blanks " " split + trim-blanks split-words [ trim-blanks "/" split1 ] map >>sortlist ; ERROR: unsupported-resolv.conf-option string ; diff --git a/basis/tools/ps/linux/linux.factor b/basis/tools/ps/linux/linux.factor index 56cc146379..d8dab2534d 100644 --- a/basis/tools/ps/linux/linux.factor +++ b/basis/tools/ps/linux/linux.factor @@ -11,7 +11,7 @@ IN: tools.ps.linux [ "()" member? ] trim "[" "]" surround ] [ - nip "\0" split harvest " " join + nip "\0" split harvest join-words ] if-empty ; : safe-ps-cmdline ( path -- string/f ) diff --git a/basis/ui/gadgets/editors/editors.factor b/basis/ui/gadgets/editors/editors.factor index a5c4b26524..29e7bbb025 100644 --- a/basis/ui/gadgets/editors/editors.factor +++ b/basis/ui/gadgets/editors/editors.factor @@ -636,7 +636,7 @@ PRIVATE> cpu ( string -- cpu ) - " " split + split-words unclip-slice [ [ [ CHAR: \s = ] trim string>number ] map ] dip prefix [ proc-cpu-stat boa ] input " } [ - "one two three" " " split + "one two three" split-Words [ [XML <-> XML] ] map <-> XML> pprint-xml>string ] unit-test diff --git a/extra/benchmark/wrap/wrap.factor b/extra/benchmark/wrap/wrap.factor index ca8f1b215f..0aa6d46a8a 100644 --- a/extra/benchmark/wrap/wrap.factor +++ b/extra/benchmark/wrap/wrap.factor @@ -4,7 +4,7 @@ USING: kernel math math.parser sequences wrap wrap.strings ; IN: benchmark.wrap : wrap-benchmark ( -- ) - 1,000 [ number>string ] map " " join + 1,000 [ number>string ] map join-words 100 [ dup 80 wrap-string drop ] times drop ; MAIN: wrap-benchmark diff --git a/extra/broadcast-server/broadcast-server.factor b/extra/broadcast-server/broadcast-server.factor index a5cf648256..c5c80a6b0e 100644 --- a/extra/broadcast-server/broadcast-server.factor +++ b/extra/broadcast-server/broadcast-server.factor @@ -64,7 +64,7 @@ SINGLETONS: command data ; ] [ [ receive-socket>> receive - [ utf8 decode "\n" split parse-lines ] dip + [ utf8 decode split-lines parse-lines ] dip ] keep handle-data t ] if ] loop diff --git a/extra/git/git.factor b/extra/git/git.factor index 3c976bc1c1..81a2f3637e 100644 --- a/extra/git/git.factor +++ b/extra/git/git.factor @@ -137,7 +137,7 @@ CONSTRUCTOR: tree ( -- obj ) ; [ hash>> "commit " prepend print ] [ author>> "Author: " prepend split-words 2 head* join-words print ] [ author>> split-words git-date>string "Date: " prepend print ] - [ message>> "\n" split [ " " prepend ] map join-lines nl print nl ] + [ message>> split-lines [ " " prepend ] map join-lines nl print nl ] } cleave ; ERROR: unknown-field name parameter ; diff --git a/extra/gpu/shaders/shaders.factor b/extra/gpu/shaders/shaders.factor index 444b243eb1..fb48ed0897 100644 --- a/extra/gpu/shaders/shaders.factor +++ b/extra/gpu/shaders/shaders.factor @@ -330,7 +330,7 @@ SYMBOL: padding-no ] [ nip ] if ":" join ; : replace-log-line-numbers ( object log -- log' ) - "\n" split harvest + split-lines harvest [ replace-log-line-number ] with map join-lines ; diff --git a/extra/graphviz/graphviz-tests.factor b/extra/graphviz/graphviz-tests.factor index 03f4710f6f..97be3991b5 100644 --- a/extra/graphviz/graphviz-tests.factor +++ b/extra/graphviz/graphviz-tests.factor @@ -17,7 +17,7 @@ IN: graphviz.tests ] [ nip output>> "Use one of: " split1 nip "\n" ?tail drop - " " split + split-words ] recover ; ! http://www.graphviz.org/Download_macos.php#comment-474 diff --git a/extra/math/text/english/english.factor b/extra/math/text/english/english.factor index 4137447412..9a886c926a 100644 --- a/extra/math/text/english/english.factor +++ b/extra/math/text/english/english.factor @@ -104,7 +104,7 @@ M: float number>text [ string>number number>text ] [ [ "negative " prepend ] when ] bi* ] [ - [ CHAR: 0 - small-numbers ] { } map-as " " join + [ CHAR: 0 - small-numbers ] { } map-as join-words ] bi* " point " glue ; M: complex number>text diff --git a/extra/metar/metar.factor b/extra/metar/metar.factor index 427c3d689b..6227986dc7 100644 --- a/extra/metar/metar.factor +++ b/extra/metar/metar.factor @@ -151,7 +151,7 @@ MEMO: glossary ( -- assoc ) dup number? [ number>string ] [ glossary ?at drop ] if - ] map " " join + ] map join-words ] map "/" join ; : parse-timestamp ( str -- str' ) @@ -701,7 +701,7 @@ sky-condition raw ; [ re-visibility matches? ] find-one [ parse-visibility pick visibility<< ] when* - [ re-rvr matches? ] find-all " " join + [ re-rvr matches? ] find-all join-words [ parse-rvr ] map ", " join pick rvr<< [ re-weather matches? ] find-all @@ -727,7 +727,7 @@ sky-condition raw ; [ re-visibility matches? ] find-one [ parse-visibility pick visibility<< ] when* - [ re-rvr matches? ] find-all " " join + [ re-rvr matches? ] find-all join-words [ parse-rvr ] map ", " join pick rvr<< [ re-weather matches? ] find-all diff --git a/extra/path-finding/path-finding-tests.factor b/extra/path-finding/path-finding-tests.factor index 38d46f2b50..3bdf77ca28 100644 --- a/extra/path-finding/path-finding-tests.factor +++ b/extra/path-finding/path-finding-tests.factor @@ -28,7 +28,7 @@ TUPLE: maze < astar ; 6 X X X X X X e X 7 X g X X 8 X X X X X X X X X X" - "\n" split ] nth nth CHAR: X = not ; + split-lines ] nth nth CHAR: X = not ; M: maze neighbours drop diff --git a/extra/rosetta-code/align-columns/align-columns.factor b/extra/rosetta-code/align-columns/align-columns.factor index 7c9817c2f6..84c70190ff 100644 --- a/extra/rosetta-code/align-columns/align-columns.factor +++ b/extra/rosetta-code/align-columns/align-columns.factor @@ -44,7 +44,7 @@ Further,$allow$for$each$word$in$a$column$to$be$either$left$ justified,$right$justified,$or$center$justified$within$its$column." : split-and-pad ( text -- lines ) - "\n" split [ "$" split harvest ] map + split-lines [ "$" split harvest ] map dup longest length '[ _ "" pad-tail ] map ; diff --git a/extra/visionect/visionect.factor b/extra/visionect/visionect.factor index 5ae0a01357..917f3661c0 100644 --- a/extra/visionect/visionect.factor +++ b/extra/visionect/visionect.factor @@ -2,9 +2,9 @@ ! See http://factorcode.org/license.txt for BSD license USING: accessors assocs base64 calendar calendar.format -checksums.hmac checksums.sha combinators combinators.smart -formatting fry http http.client json.reader json.writer kernel -locals make math.parser namespaces random sequences ; +checksums.hmac checksums.sha combinators.smart formatting http +http.client json.reader json.writer kernel make math.parser +namespaces random sequences splitting ; IN: visionect @@ -24,7 +24,7 @@ SYMBOL: visionect-api-secret [ "content-type" header ] [ "date" header ] [ url>> path>> ] - } cleave>array "\n" join + } cleave>array join-lines visionect-api-secret get sha-256 hmac-bytes >base64 visionect-api-key get ":" rot 3append ;