From 897a8ed8aabd15ba2fe411bb6f523ad74dcdefb4 Mon Sep 17 00:00:00 2001 From: Aaron Schaefer Date: Mon, 31 Dec 2007 14:47:24 -0500 Subject: [PATCH] Replace ' contents' with 'file-contents' in all vocabs --- core/io/crc32/crc32.factor | 2 +- core/io/files/files-tests.factor | 4 +- core/source-files/source-files.factor | 2 +- extra/cryptlib/cryptlib-tests.factor | 60 +++++++++---------- extra/html/parser/analyzer/analyzer.factor | 6 +- .../server/templating/templating-tests.factor | 10 +--- .../http/server/templating/templating.factor | 2 +- extra/icfp/2006/2006.factor | 14 ++--- extra/io/mmap/mmap-tests.factor | 6 +- extra/project-euler/022/022.factor | 2 +- extra/project-euler/067/067.factor | 6 +- extra/project-euler/common/common.factor | 9 +++ extra/xmode/code2html/code2html.factor | 7 +-- 13 files changed, 65 insertions(+), 65 deletions(-) diff --git a/core/io/crc32/crc32.factor b/core/io/crc32/crc32.factor index 2b101945e7..1c0c2e9f5c 100644 --- a/core/io/crc32/crc32.factor +++ b/core/io/crc32/crc32.factor @@ -27,4 +27,4 @@ DEFER: crc32-table inline : crc32 ( seq -- n ) >r HEX: ffffffff dup r> [ (crc32) ] each bitxor ; -: file-crc32 ( path -- n ) contents crc32 ; +: file-crc32 ( path -- n ) file-contents crc32 ; diff --git a/core/io/files/files-tests.factor b/core/io/files/files-tests.factor index 4f071e03b7..3559a3487b 100644 --- a/core/io/files/files-tests.factor +++ b/core/io/files/files-tests.factor @@ -23,11 +23,11 @@ USING: tools.test io.files io threads kernel ; ] unit-test [ "Hello world.\nHello appender.\n" ] [ - "test-foo.txt" resource-path contents + "test-foo.txt" resource-path file-contents ] unit-test [ "Hello appender.\n" ] [ - "test-bar.txt" resource-path contents + "test-bar.txt" resource-path file-contents ] unit-test [ ] [ "test-foo.txt" resource-path delete-file ] unit-test diff --git a/core/source-files/source-files.factor b/core/source-files/source-files.factor index 57ae7d7a53..4df59e5dd9 100644 --- a/core/source-files/source-files.factor +++ b/core/source-files/source-files.factor @@ -63,7 +63,7 @@ uses definitions ; : reset-checksums ( -- ) source-files get [ swap ?resource-path dup exists? - [ contents record-checksum ] [ 2drop ] if + [ file-contents record-checksum ] [ 2drop ] if ] assoc-each ; M: pathname where pathname-string 1 2array ; diff --git a/extra/cryptlib/cryptlib-tests.factor b/extra/cryptlib/cryptlib-tests.factor index 8cce40778e..c404114716 100644 --- a/extra/cryptlib/cryptlib-tests.factor +++ b/extra/cryptlib/cryptlib-tests.factor @@ -1,4 +1,4 @@ -USING: cryptlib.libcl cryptlib prettyprint kernel alien sequences libc math +USING: cryptlib.libcl cryptlib prettyprint kernel alien sequences libc math tools.test io io.files continuations alien.c-types splitting generic.math ; "=========================================================" print @@ -53,12 +53,12 @@ tools.test io io.files continuations alien.c-types splitting generic.math ; ! de-envelope CRYPT_FORMAT_AUTO [ [ envelope-handle get-pop-buffer get-bytes-copied push-data ] [ - dup CRYPT_ENVELOPE_RESOURCE = [ + dup CRYPT_ENVELOPE_RESOURCE = [ envelope-handle CRYPT_ENVINFO_PASSWORD - "password" set-attribute-string - ] [ + "password" set-attribute-string + ] [ rethrow - ] if + ] if ] recover drop get-bytes-copied . envelope-handle flush-data @@ -124,17 +124,17 @@ tools.test io io.files continuations alien.c-types splitting generic.math ; ! de-envelope CRYPT_FORMAT_AUTO [ [ envelope-handle get-pop-buffer get-bytes-copied push-data ] [ - dup CRYPT_ENVELOPE_RESOURCE = [ + dup CRYPT_ENVELOPE_RESOURCE = [ CRYPT_ALGO_IDEA create-context context-handle CRYPT_CTXINFO_KEY "0123456789ABCDEF" set-attribute-string - envelope-handle CRYPT_ENVINFO_SESSIONKEY context-handle *int + envelope-handle CRYPT_ENVINFO_SESSIONKEY context-handle *int set-attribute - ] [ - rethrow - ] if + ] [ + rethrow + ] if ] recover drop - + get-bytes-copied . destroy-context envelope-handle flush-data @@ -151,8 +151,8 @@ tools.test io io.files continuations alien.c-types splitting generic.math ; [ ! envelope CRYPT_FORMAT_CRYPTLIB [ - "extra/cryptlib/test/large_data.txt" resource-path - contents set-pop-buffer + "extra/cryptlib/test/large_data.txt" resource-path + file-contents set-pop-buffer envelope-handle CRYPT_ATTRIBUTE_BUFFERSIZE get-pop-buffer alien>char-string length 10000 + set-attribute envelope-handle CRYPT_ENVINFO_DATASIZE @@ -175,9 +175,9 @@ tools.test io io.files continuations alien.c-types splitting generic.math ; envelope-handle get-bytes-copied pop-data get-bytes-copied . ! pop-buffer-string . - [ "/opt/local/lib/libcl.dylib(dylib1.o):" ] + [ "/opt/local/lib/libcl.dylib(dylib1.o):" ] [ pop-buffer-string "\n" split first ] unit-test - [ "00000000 t __mh_dylib_header" ] + [ "00000000 t __mh_dylib_header" ] [ pop-buffer-string "\n" split last/first first ] unit-test ] with-envelope ] with-cryptlib @@ -192,7 +192,7 @@ tools.test io io.files continuations alien.c-types splitting generic.math ; CRYPT_FORMAT_CRYPTLIB [ envelope-handle CRYPT_ENVINFO_PASSWORD "password" set-attribute-string "extra/cryptlib/test/large_data.txt" resource-path - contents set-pop-buffer + file-contents set-pop-buffer envelope-handle CRYPT_ATTRIBUTE_BUFFERSIZE get-pop-buffer alien>char-string length 10000 + set-attribute envelope-handle CRYPT_ENVINFO_DATASIZE @@ -204,17 +204,17 @@ tools.test io io.files continuations alien.c-types splitting generic.math ; get-bytes-copied . pop-buffer-string . ] with-envelope - + ! de-envelope CRYPT_FORMAT_AUTO [ envelope-handle CRYPT_ATTRIBUTE_BUFFERSIZE 130000 set-attribute [ envelope-handle get-pop-buffer get-bytes-copied push-data ] [ - dup CRYPT_ENVELOPE_RESOURCE = [ + dup CRYPT_ENVELOPE_RESOURCE = [ envelope-handle CRYPT_ENVINFO_PASSWORD "password" set-attribute-string - ] [ - rethrow - ] if + ] [ + rethrow + ] if ] recover drop get-bytes-copied . @@ -226,7 +226,7 @@ tools.test io io.files continuations alien.c-types splitting generic.math ; [ "/opt/local/lib/libcl.dylib(dylib1.o):" ] [ pop-buffer-string "\n" split first ] unit-test - [ "00000000 t __mh_dylib_header" ] + [ "00000000 t __mh_dylib_header" ] [ pop-buffer-string "\n" split last/first first ] unit-test ] with-envelope ] with-cryptlib @@ -274,7 +274,7 @@ tools.test io io.files continuations alien.c-types splitting generic.math ; check-certificate add-public-key f 0 CRYPT_CERTFORMAT_TEXT_CERTIFICATE export-certificate - get-cert-length *int dup malloc swap + get-cert-length *int dup malloc swap CRYPT_CERTFORMAT_TEXT_CERTIFICATE export-certificate get-cert-buffer alien>char-string print ] with-certificate @@ -295,15 +295,15 @@ tools.test io io.files continuations alien.c-types splitting generic.math ; ! ... ! localhost's password: (any password will be accepted) - ! If you want to run the test again you should clean the [localhost]:3000 - ! ssh-rsa entry in the known_hosts file, in your home directory under the .ssh + ! If you want to run the test again you should clean the [localhost]:3000 + ! ssh-rsa entry in the known_hosts file, in your home directory under the .ssh ! folder, since the test generates a new RSA certificate on every run. [ CRYPT_KEYSET_FILE "extra/cryptlib/test/keys.p15" resource-path CRYPT_KEYOPT_READONLY [ CRYPT_KEYID_NAME "private key" "password" get-private-key - + CRYPT_SESSION_SSH_SERVER [ session-handle CRYPT_SESSINFO_SERVER_NAME "localhost" @@ -312,7 +312,7 @@ tools.test io io.files continuations alien.c-types splitting generic.math ; session-handle CRYPT_SESSINFO_SERVER_PORT 3000 set-attribute session-handle CRYPT_SESSINFO_PRIVATEKEY - + context-handle *int set-attribute [ session-handle CRYPT_SESSINFO_ACTIVE 1 set-attribute ] [ @@ -328,9 +328,9 @@ tools.test io io.files continuations alien.c-types splitting generic.math ; length push-data session-handle flush-data - ] [ - rethrow - ] if + ] [ + rethrow + ] if ] recover drop ] with-session ] with-keyset diff --git a/extra/html/parser/analyzer/analyzer.factor b/extra/html/parser/analyzer/analyzer.factor index 9303b81055..168c2002a8 100755 --- a/extra/html/parser/analyzer/analyzer.factor +++ b/extra/html/parser/analyzer/analyzer.factor @@ -81,11 +81,11 @@ IN: html.parser.analyzer ! ] if ; -! clear "/Users/erg/web/fark.html" contents parse-html find-links [ "go.pl" swap start ] subset [ "=" split peek ] map +! clear "/Users/erg/web/fark.html" file-contents parse-html find-links [ "go.pl" swap start ] subset [ "=" split peek ] map ! clear "http://fark.com" http-get parse-html find-links [ "go.pl" swap start ] subset [ "=" split peek ] map -! clear "/Users/erg/web/hostels.html" contents parse-html "Currency" "name" pick find-first-attribute-key-value +! clear "/Users/erg/web/hostels.html" file-contents parse-html "Currency" "name" pick find-first-attribute-key-value -! clear "/Users/erg/web/hostels.html" contents parse-html +! clear "/Users/erg/web/hostels.html" file-contents parse-html ! "Currency" "name" pick find-first-attribute-key-value ! pick find-between remove-blank-text diff --git a/extra/http/server/templating/templating-tests.factor b/extra/http/server/templating/templating-tests.factor index 6ccf3ed154..d979a071f2 100644 --- a/extra/http/server/templating/templating-tests.factor +++ b/extra/http/server/templating/templating-tests.factor @@ -1,18 +1,14 @@ -USING: io io.files io.streams.string http.server.templating -kernel tools.test sequences ; +USING: io io.files io.streams.string http.server.templating kernel tools.test + sequences ; IN: temporary : test-template ( path -- ? ) "extra/http/server/templating/test/" swap append - [ ".fhtml" append resource-path [ run-template-file ] string-out ] keep - - ".html" append resource-path - contents - = ; + ".html" append resource-path file-contents = ; [ t ] [ "example" test-template ] unit-test [ t ] [ "bug" test-template ] unit-test diff --git a/extra/http/server/templating/templating.factor b/extra/http/server/templating/templating.factor index cd587799c2..680f7b73d5 100755 --- a/extra/http/server/templating/templating.factor +++ b/extra/http/server/templating/templating.factor @@ -82,7 +82,7 @@ DEFER: <% delimiter templating-vocab use+ dup source-file file set ! so that reload works properly [ - ?resource-path contents + ?resource-path file-contents [ eval-template ] [ html-error. drop ] recover ] keep ] with-scope diff --git a/extra/icfp/2006/2006.factor b/extra/icfp/2006/2006.factor index 90ac9dc03e..53c7fd5a9b 100644 --- a/extra/icfp/2006/2006.factor +++ b/extra/icfp/2006/2006.factor @@ -1,9 +1,7 @@ ! Copyright (C) 2007 Gavin Harrison ! See http://factorcode.org/license.txt for BSD license. - -USING: kernel math sequences kernel.private namespaces arrays -io io.files splitting io.binary math.functions vectors -quotations combinators.private ; +USING: kernel math sequences kernel.private namespaces arrays io io.files + splitting io.binary math.functions vectors quotations combinators.private ; IN: icfp.2006 SYMBOL: regs @@ -58,7 +56,7 @@ SYMBOL: open-arrays >r get-cba r> swap >r >r [ reg-val ] 2apply swap r> call r> set-reg f ; inline - + : op1 ( opcode -- ? ) [ swap arr-val ] binary-op ; @@ -89,7 +87,7 @@ SYMBOL: open-arrays : op8 ( opcode -- ? ) ?grow-storage - get-cb >r reg-val open-arrays get pop [ new-array ] keep r> + get-cb >r reg-val open-arrays get pop [ new-array ] keep r> set-reg f ; : op9 ( opcode -- ? ) @@ -111,7 +109,7 @@ SYMBOL: open-arrays : op13 ( opcode -- ? ) [ get-value ] keep get-special set-reg f ; - + : advance ( -- val opcode ) finger get arrays get first nth finger inc dup get-op ; @@ -129,7 +127,7 @@ SYMBOL: open-arrays [ run-op exec-loop ] unless ; : load-platters ( path -- ) - contents 4 group [ be> ] map + file-contents 4 group [ be> ] map 0 arrays get set-nth ; : init ( path -- ) diff --git a/extra/io/mmap/mmap-tests.factor b/extra/io/mmap/mmap-tests.factor index 729882deeb..a01481ecdc 100644 --- a/extra/io/mmap/mmap-tests.factor +++ b/extra/io/mmap/mmap-tests.factor @@ -1,11 +1,9 @@ -USING: io io.mmap io.files kernel tools.test continuations -sequences ; +USING: io io.mmap io.files kernel tools.test continuations sequences ; IN: temporary [ "mmap-test-file.txt" resource-path delete-file ] catch drop [ ] [ "mmap-test-file.txt" resource-path [ "12345" write ] with-stream ] unit-test [ ] [ "mmap-test-file.txt" resource-path dup file-length [ CHAR: 2 0 pick set-nth drop ] with-mapped-file ] unit-test [ 5 ] [ "mmap-test-file.txt" resource-path dup file-length [ length ] with-mapped-file ] unit-test -[ "22345" ] [ "mmap-test-file.txt" resource-path contents ] unit-test +[ "22345" ] [ "mmap-test-file.txt" resource-path file-contents ] unit-test [ "mmap-test-file.txt" resource-path delete-file ] catch drop - diff --git a/extra/project-euler/022/022.factor b/extra/project-euler/022/022.factor index 1c8c8743f9..f523f586c5 100644 --- a/extra/project-euler/022/022.factor +++ b/extra/project-euler/022/022.factor @@ -38,7 +38,7 @@ IN: project-euler.022 ] "" make ; : source-022 ( -- seq ) - (source-022) contents [ quotable? ] subset "," split ; + (source-022) file-contents [ quotable? ] subset "," split ; : alpha-value ( str -- n ) string>digits [ 9 - ] sigma ; diff --git a/extra/project-euler/067/067.factor b/extra/project-euler/067/067.factor index c97ad90128..a675a5635e 100644 --- a/extra/project-euler/067/067.factor +++ b/extra/project-euler/067/067.factor @@ -38,12 +38,12 @@ IN: project-euler.067 - lines [ " " split [ string>number ] map ] map ; + "resource:extra/project-euler/067/triangle.txt" ?resource-path + lines [ " " split [ string>number ] map ] map ; PRIVATE> -: euler067 ( -- best ) +: euler067 ( -- answer ) pyramid propagate-all first first ; ! [ euler067 ] 100 ave-time diff --git a/extra/project-euler/common/common.factor b/extra/project-euler/common/common.factor index 4c7987371d..2e18d744fc 100644 --- a/extra/project-euler/common/common.factor +++ b/extra/project-euler/common/common.factor @@ -74,6 +74,15 @@ PRIVATE> : sum-proper-divisors ( n -- sum ) dup sum-divisors swap - ; +: abundant? ( n -- ? ) + dup sum-proper-divisors < ; + +: deficient? ( n -- ? ) + dup sum-proper-divisors > ; + +: perfect? ( n -- ? ) + dup sum-proper-divisors = ; + ! The divisor function, counts the number of divisors : tau ( n -- n ) prime-factorization* flip second 1 [ 1+ * ] reduce ; diff --git a/extra/xmode/code2html/code2html.factor b/extra/xmode/code2html/code2html.factor index dfc50988a3..3db70cf2e9 100755 --- a/extra/xmode/code2html/code2html.factor +++ b/extra/xmode/code2html/code2html.factor @@ -1,6 +1,5 @@ -USING: xmode.tokens xmode.marker -xmode.catalog kernel html html.elements io io.files -sequences words ; +USING: xmode.tokens xmode.marker xmode.catalog kernel html html.elements io + io.files sequences words ; IN: xmode.code2html : htmlize-tokens ( tokens -- ) @@ -21,7 +20,7 @@ IN: xmode.code2html : default-stylesheet ( -- ) ; : htmlize-stream ( path stream -- )