]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' of git://factorcode.org/git/factor into experimental
authorAlex Chapman <chapman.alex@gmail.com>
Wed, 7 May 2008 15:10:04 +0000 (01:10 +1000)
committerAlex Chapman <chapman.alex@gmail.com>
Wed, 7 May 2008 15:10:04 +0000 (01:10 +1000)
302 files changed:
Factor.app/Contents/Info.plist
core/alien/alien-docs.factor
core/bootstrap/image/image.factor
core/bootstrap/stage2.factor
core/checksums/checksums-tests.factor [new file with mode: 0644]
core/classes/algebra/algebra-docs.factor
core/classes/algebra/algebra-tests.factor
core/classes/algebra/algebra.factor
core/classes/classes.factor
core/classes/tuple/tuple-tests.factor
core/classes/tuple/tuple.factor
core/compiler/compiler.factor
core/compiler/errors/errors-docs.factor
core/continuations/continuations-docs.factor
core/continuations/continuations-tests.factor
core/continuations/continuations.factor
core/debugger/debugger-docs.factor
core/debugger/debugger.factor
core/generic/standard/engines/tuple/tuple.factor
core/inference/inference-docs.factor
core/inference/state/state-tests.factor
core/inference/state/state.factor
core/inference/transforms/transforms.factor
core/inspector/inspector-docs.factor
core/io/backend/backend-docs.factor
core/io/backend/backend.factor
core/io/encodings/encodings-docs.factor
core/io/encodings/encodings-tests.factor
core/io/encodings/encodings.factor
core/io/files/files-docs.factor
core/io/files/files.factor
core/io/io-docs.factor
core/io/io-tests.factor
core/io/io.factor
core/io/streams/byte-array/byte-array-docs.factor
core/io/streams/byte-array/byte-array.factor
core/io/streams/c/c.factor
core/io/streams/duplex/authors.txt [deleted file]
core/io/streams/duplex/duplex-docs.factor [deleted file]
core/io/streams/duplex/duplex-tests.factor [deleted file]
core/io/streams/duplex/duplex.factor [deleted file]
core/io/streams/duplex/summary.txt [deleted file]
core/io/streams/string/string-docs.factor
core/io/streams/string/string-tests.factor
core/io/streams/string/string.factor
core/listener/listener-docs.factor
core/listener/listener-tests.factor
core/listener/listener.factor
core/math/order/order-docs.factor
core/math/parser/parser-tests.factor
core/math/parser/parser.factor
core/optimizer/def-use/def-use-tests.factor
core/parser/parser-docs.factor
core/prettyprint/prettyprint-docs.factor
core/prettyprint/prettyprint-tests.factor
core/prettyprint/sections/sections-docs.factor
core/prettyprint/sections/sections.factor
core/sequences/sequences-docs.factor
core/sequences/sequences.factor
core/splitting/splitting.factor
core/threads/threads-docs.factor
core/threads/threads-tests.factor
core/threads/threads.factor
extra/asn1/asn1-tests.factor
extra/asn1/asn1.factor
extra/bank/bank.factor
extra/benchmark/fasta/fasta.factor
extra/benchmark/knucleotide/knucleotide.factor
extra/benchmark/reverse-complement/reverse-complement.factor
extra/benchmark/sockets/sockets.factor
extra/builder/util/util.factor
extra/cairo/png/png.factor
extra/checksums/md5/md5.factor
extra/checksums/null/null.factor
extra/checksums/sha1/sha1.factor
extra/combinators/lib/lib.factor
extra/concurrency/combinators/combinators-docs.factor
extra/concurrency/combinators/combinators-tests.factor
extra/concurrency/combinators/combinators.factor
extra/concurrency/count-downs/count-downs.factor
extra/concurrency/distributed/distributed.factor
extra/concurrency/flags/flags-tests.factor
extra/concurrency/flags/flags.factor
extra/concurrency/mailboxes/mailboxes.factor
extra/contributors/contributors-tests.factor [new file with mode: 0644]
extra/contributors/contributors.factor
extra/cpu/8080/test/test.factor
extra/crypto/hmac/hmac.factor
extra/csv/csv.factor
extra/delegate/protocols/protocols.factor
extra/destructors/destructors.factor
extra/editors/jedit/jedit.factor
extra/fry/fry-docs.factor
extra/fry/fry-tests.factor
extra/fry/fry.factor
extra/gap-buffer/tags.txt
extra/geo-ip/authors.txt [new file with mode: 0644]
extra/geo-ip/geo-ip.factor [new file with mode: 0644]
extra/geo-ip/summary.txt [new file with mode: 0644]
extra/geo-ip/tags.txt [new file with mode: 0644]
extra/gesture-logger/gesture-logger.factor
extra/help/cookbook/cookbook.factor
extra/help/handbook/handbook.factor
extra/help/help-docs.factor
extra/help/lint/lint.factor
extra/help/tutorial/tutorial.factor
extra/html/html-tests.factor
extra/html/html.factor
extra/html/parser/analyzer/analyzer.factor
extra/html/parser/utils/utils.factor
extra/http/client/client.factor
extra/http/http-tests.factor
extra/http/http.factor
extra/http/server/actions/actions.factor
extra/http/server/auth/admin/admin.factor
extra/http/server/auth/admin/admin.xml
extra/http/server/auth/admin/edit-user.xml
extra/http/server/auth/admin/new-user.xml
extra/http/server/auth/login/edit-profile.xml
extra/http/server/auth/login/login.factor
extra/http/server/auth/login/login.xml
extra/http/server/auth/login/recover-3.xml
extra/http/server/auth/login/register.xml
extra/http/server/cgi/cgi.factor
extra/http/server/components/code/code.factor
extra/http/server/components/components.factor
extra/http/server/server.factor
extra/http/server/static/static.factor
extra/http/server/templating/chloe/chloe.factor
extra/icfp/2006/2006.factor
extra/interval-maps/authors.txt [new file with mode: 0755]
extra/interval-maps/interval-maps-docs.factor [new file with mode: 0755]
extra/interval-maps/interval-maps-tests.factor [new file with mode: 0755]
extra/interval-maps/interval-maps.factor [new file with mode: 0755]
extra/interval-maps/summary.txt [new file with mode: 0755]
extra/interval-maps/tags.txt [new file with mode: 0755]
extra/inverse/inverse.factor
extra/io/encodings/8-bit/8-bit.factor
extra/io/launcher/launcher-docs.factor
extra/io/launcher/launcher-tests.factor
extra/io/launcher/launcher.factor
extra/io/nonblocking/nonblocking.factor
extra/io/pipes/pipes-docs.factor [new file with mode: 0644]
extra/io/pipes/pipes-tests.factor [new file with mode: 0755]
extra/io/pipes/pipes.factor [new file with mode: 0644]
extra/io/server/server-docs.factor
extra/io/server/server.factor
extra/io/sockets/sockets-docs.factor
extra/io/sockets/sockets.factor
extra/io/streams/duplex/authors.txt [new file with mode: 0644]
extra/io/streams/duplex/duplex-docs.factor [new file with mode: 0755]
extra/io/streams/duplex/duplex-tests.factor [new file with mode: 0755]
extra/io/streams/duplex/duplex.factor [new file with mode: 0755]
extra/io/streams/duplex/summary.txt [new file with mode: 0644]
extra/io/streams/null/null.factor
extra/io/timeouts/timeouts.factor
extra/io/unix/backend/backend.factor
extra/io/unix/launcher/launcher-tests.factor
extra/io/unix/launcher/launcher.factor
extra/io/unix/macosx/macosx.factor
extra/io/unix/pipes/pipes-tests.factor [new file with mode: 0644]
extra/io/unix/pipes/pipes.factor [new file with mode: 0644]
extra/io/unix/unix-tests.factor
extra/io/unix/unix.factor
extra/io/windows/launcher/launcher.factor
extra/io/windows/nt/files/files.factor
extra/io/windows/nt/launcher/launcher-tests.factor
extra/io/windows/nt/launcher/launcher.factor
extra/io/windows/nt/launcher/test/append.factor [new file with mode: 0755]
extra/io/windows/nt/launcher/test/stderr.factor
extra/io/windows/nt/monitors/monitors.factor
extra/io/windows/nt/pipes/pipes.factor
extra/io/windows/windows.factor
extra/koszul/koszul.factor
extra/lcs/authors.txt [new file with mode: 0755]
extra/lcs/lcs-docs.factor [new file with mode: 0755]
extra/lcs/lcs-tests.factor [new file with mode: 0755]
extra/lcs/lcs.factor [new file with mode: 0755]
extra/lcs/summary.txt [new file with mode: 0755]
extra/lcs/tags.txt [new file with mode: 0755]
extra/levenshtein/authors.txt [deleted file]
extra/levenshtein/levenshtein-tests.factor [deleted file]
extra/levenshtein/levenshtein.factor [deleted file]
extra/levenshtein/summary.txt [deleted file]
extra/locals/locals-docs.factor
extra/locals/locals-tests.factor
extra/locals/locals.factor
extra/logging/server/server.factor
extra/monads/authors.txt [new file with mode: 0644]
extra/monads/monads-tests.factor [new file with mode: 0644]
extra/monads/monads.factor [new file with mode: 0644]
extra/monads/summary.txt [new file with mode: 0644]
extra/monads/tags.txt [new file with mode: 0644]
extra/morse/morse-docs.factor
extra/morse/morse-tests.factor
extra/mortar/mortar.factor
extra/multiline/multiline.factor
extra/opengl/opengl-docs.factor
extra/openssl/authors.txt [deleted file]
extra/openssl/libcrypto/libcrypto.factor [deleted file]
extra/openssl/libssl/libssl.factor [deleted file]
extra/openssl/openssl-docs.factor [deleted file]
extra/openssl/openssl-tests.factor [deleted file]
extra/openssl/openssl.factor [deleted file]
extra/openssl/summary.txt [deleted file]
extra/openssl/tags.txt [deleted file]
extra/openssl/test/dh1024.pem [deleted file]
extra/openssl/test/errors.txt [deleted file]
extra/openssl/test/root.pem [deleted file]
extra/openssl/test/server.pem [deleted file]
extra/pack/pack-tests.factor
extra/pack/pack.factor
extra/peg/ebnf/ebnf.factor
extra/porter-stemmer/porter-stemmer-tests.factor
extra/porter-stemmer/porter-stemmer.factor
extra/project-euler/002/002.factor
extra/project-euler/022/022.factor
extra/project-euler/042/042.factor
extra/project-euler/059/059.factor
extra/project-euler/067/067.factor
extra/project-euler/079/079.factor
extra/random/unix/unix.factor
extra/rss/rss-tests.factor
extra/shuffle/shuffle.factor
extra/size-of/size-of.factor
extra/smtp/server/server.factor
extra/smtp/smtp.factor
extra/space-invaders/space-invaders.factor
extra/state-parser/state-parser-docs.factor
extra/state-parser/state-parser.factor
extra/tangle/tangle.factor
extra/tar/tar.factor
extra/taxes/taxes-tests.factor
extra/tools/deploy/backend/backend.factor
extra/tools/deploy/shaker/shaker.factor
extra/tools/profiler/profiler-docs.factor
extra/tools/test/test-docs.factor
extra/tools/test/ui/ui.factor
extra/tools/vocabs/monitor/monitor.factor
extra/trees/avl/avl-tests.factor [changed mode: 0644->0755]
extra/trees/avl/avl.factor
extra/trees/splay/splay.factor [changed mode: 0644->0755]
extra/trees/trees.factor
extra/tuple-syntax/tuple-syntax.factor
extra/ui/gadgets/gadgets-tests.factor
extra/ui/gadgets/panes/panes-docs.factor
extra/ui/gadgets/panes/panes-tests.factor
extra/ui/gadgets/panes/panes.factor
extra/ui/gestures/gestures.factor
extra/ui/tools/interactor/interactor-tests.factor
extra/ui/tools/interactor/interactor.factor
extra/ui/tools/listener/listener-tests.factor
extra/ui/tools/listener/listener.factor
extra/unicode/breaks/breaks.factor
extra/unicode/data/data.factor
extra/unicode/script/Scripts.txt [new file with mode: 0755]
extra/unicode/script/authors.txt [new file with mode: 0755]
extra/unicode/script/script-docs.factor [new file with mode: 0755]
extra/unicode/script/script-tests.factor [new file with mode: 0755]
extra/unicode/script/script.factor [new file with mode: 0755]
extra/unicode/script/summary.txt [new file with mode: 0755]
extra/unix/bsd/bsd.factor
extra/unix/linux/linux.factor
extra/update/backup/backup.factor [new file with mode: 0644]
extra/update/latest/latest.factor [new file with mode: 0644]
extra/webapps/factor-website/page.css
extra/webapps/pastebin/annotation.xml
extra/webapps/pastebin/new-annotation.xml
extra/webapps/pastebin/paste-summary.xml
extra/webapps/pastebin/paste.xml
extra/webapps/pastebin/pastebin.factor
extra/webapps/pastebin/pastebin.xml
extra/webapps/planet/edit-blog.xml
extra/webapps/planet/planet.xml
extra/webapps/todo/edit-todo.xml
extra/webapps/todo/todo.xml
extra/webapps/todo/view-todo.xml
extra/xml/backend/backend.factor [new file with mode: 0644]
extra/xml/errors/errors-tests.factor [new file with mode: 0755]
extra/xml/errors/errors.factor
extra/xml/tests/errors.factor [deleted file]
extra/xml/tests/soap.factor
extra/xml/tests/test.factor
extra/xml/xml-docs.factor
extra/xml/xml.factor
extra/xmode/catalog/catalog.factor
extra/xmode/code2html/code2html.factor
extra/xmode/utilities/utilities-tests.factor
extra/yahoo/yahoo-tests.factor
misc/Factor.tmbundle/Syntaxes/HTML (Factor).tmLanguage
unmaintained/openssl/authors.txt [new file with mode: 0644]
unmaintained/openssl/libcrypto/libcrypto.factor [new file with mode: 0755]
unmaintained/openssl/libssl/libssl.factor [new file with mode: 0755]
unmaintained/openssl/openssl-docs.factor [new file with mode: 0644]
unmaintained/openssl/openssl-tests.factor [new file with mode: 0755]
unmaintained/openssl/openssl.factor [new file with mode: 0755]
unmaintained/openssl/summary.txt [new file with mode: 0755]
unmaintained/openssl/tags.txt [new file with mode: 0644]
unmaintained/openssl/test/dh1024.pem [new file with mode: 0644]
unmaintained/openssl/test/errors.txt [new file with mode: 0644]
unmaintained/openssl/test/root.pem [new file with mode: 0644]
unmaintained/openssl/test/server.pem [new file with mode: 0644]

index ca0e6d5f8adc3e5804d714ae090dcab1d601c57e..a8943d0d32f507a804ad341bef02ea8aaefef533 100644 (file)
@@ -32,7 +32,7 @@
        <key>CFBundlePackageType</key>
        <string>APPL</string>
        <key>NSHumanReadableCopyright</key>
-       <string>Copyright Â© 2003-2007, Slava Pestov and friends</string>
+       <string>Copyright Â© 2003-2008, Slava Pestov and friends</string>
        <key>NSServices</key>
        <array>
                <dict>
index 7d13080e3c046deb72ae93a5af04eeecd0b3c05d..0caf0e9a9fb9b1c18339fef32cefcd80e9eacf53 100755 (executable)
@@ -265,7 +265,7 @@ ARTICLE: "embedding-restrictions" "Embedding API restrictions"
 ARTICLE: "embedding-factor" "What embedding looks like from Factor"
 "Factor code will run inside an embedded instance in the same way it would run in a stand-alone instance."
 $nl
-"One exception is the global " { $link stdio } " stream, which is by default not bound to the terminal where the process is running, to avoid conflicting with any I/O the host process might perform. To initialize the terminal stream, " { $link init-stdio } " must be called explicitly."
+"One exception is that the global " { $link input-stream } " and " { $link output-stream } " streams are not bound by default, to avoid conflicting with any I/O the host process might perform. The " { $link init-stdio } " words must be called explicitly to initialize terminal streams."
 $nl
 "There is a word which can detect when Factor is embedded:"
 { $subsection embedded? }
index cb73dc387efbbbafef6f199b39792b2498c8ea35..1ff04bacc2993dfe4ebc0316c79d158945ca9c40 100755 (executable)
@@ -404,7 +404,7 @@ M: quotation '
     [
         {
             dictionary source-files builtins
-            update-map class<=-cache class<=>-cache
+            update-map class<=-cache
             class-not-cache classes-intersect-cache class-and-cache
             class-or-cache
         } [ dup get swap bootstrap-word set ] each
@@ -475,7 +475,7 @@ M: quotation '
     "Writing image to " write
     architecture get boot-image-name resource-path
     [ write "..." print flush ]
-    [ binary <file-writer> [ (write-image) ] with-stream ] bi ;
+    [ binary [ (write-image) ] with-file-writer ] bi ;
 
 PRIVATE>
 
index 3247832d52566b769ba943596bbb4d06fb0578fa..2e087ff5bd3569d8d745e0aee54b37577440fc16 100755 (executable)
@@ -87,7 +87,7 @@ f error-continuation set-global
             parse-command-line
             run-user-init
             "run" get run
-            stdio get [ stream-flush ] when*
+            output-stream get [ stream-flush ] when*
         ] [ print-error 1 exit ] recover
     ] set-boot-quot
 
diff --git a/core/checksums/checksums-tests.factor b/core/checksums/checksums-tests.factor
new file mode 100644 (file)
index 0000000..1ec675b
--- /dev/null
@@ -0,0 +1,7 @@
+IN: checksums.tests
+USING: checksums tools.test ;
+
+\ checksum-bytes must-infer
+\ checksum-stream must-infer
+\ checksum-lines must-infer
+\ checksum-file must-infer
index 3903da1ebcef94d5e5b938165319e36d1e4f9232..810bdbe10fc23ae0c4eb26e0b5880182403e188f 100755 (executable)
@@ -23,30 +23,19 @@ ARTICLE: "class-linearization" "Class linearization"
     "If a generic word defines a method on a mixin class A and another class B, and B is the only instance of A, there is an ambiguity because A and B are equal as sets; any object that is an instance of one is an instance of both."\r
     { "If a generic word defines methods on two union classes which are incomparable but not disjoint, for example " { $link sequence } " and " { $link number } ", there is an ambiguity because the generic word may be called on an object that is an instance of both unions." }\r
 }\r
-"These difficulties are resolved by imposing a linear order on classes, computed as follows for two classes A and B:"\r
+"The first ambiguity is resolved with a tie-breaker that compares metaclasses. The intrinsic meta-class order, from most-specific to least-specific:"\r
 { $list\r
-    "If A and B are the same class (not just equal as sets), then comparison stops."\r
-    "If A is a proper subset of B, or B is a proper subset of A, then comparison stops."\r
-    { "Next, the metaclasses of A and B are compared, with intrinsic meta-class order, from most-specific to least-specific:"\r
-        { $list\r
-            "Built-in classes and tuple classes"\r
-            "Predicate classes"\r
-            "Union classes"\r
-            "Mixin classes"\r
-        }\r
-    "If this yields an unambiguous answer, comparison stops."\r
-    }\r
-    "If the metaclasses of A and B occupy the same position in the order, then the vocabularies of A and B are compared lexicographically. If this yields an unambiguous answer, comparison stops."\r
-    "If A and B belong to the same vocabulary, their names are compared lexicographically. This must yield an unambiguous result, since if the names equal they must be the same class and this case was already handled in the first step."\r
-}\r
-"Some examples:"\r
-{ $list\r
-    { { $link integer } " precedes " { $link number } " because it is a strict subset" }\r
-    { { $link number } " precedes " { $link sequence } " because the " { $vocab-link "math" } " vocabulary precedes the " { $vocab-link "sequences" } " vocabulary" }\r
-    { { $link crc32 } " precedes " { $link checksum } ", even if it were the only instance, because " { $link crc32 } " is a singleton class which is more specific than a mixin class" }\r
+    "Built-in classes and tuple classes"\r
+    "Predicate classes"\r
+    "Union classes"\r
+    "Mixin classes"\r
 }\r
+"This means that in the above example, the generic word with methods on a mixin and its sole instance will always call the method for the sole instance, since it is more specific than a mixin class."\r
+$nl\r
+"The second problem is resolved with another tie-breaker. When performing the topological sort of classes, if there are multiple candidates at any given step of the sort, lexicographical order on the class name is used."\r
+$nl\r
 "Operations:"\r
-{ $subsection class<=> }\r
+{ $subsection class< }\r
 { $subsection sort-classes }\r
 "Metaclass order:"\r
 { $subsection rank-class } ;\r
@@ -72,8 +61,6 @@ HELP: sort-classes
 { $values { "seq" "a sequence of class" } { "newseq" "a new seqence of classes" } }\r
 { $description "Outputs a linear sort of a sequence of classes. Larger classes come before their subclasses." } ;\r
 \r
-{ sort-classes class<=> } related-words\r
-\r
 HELP: class-or\r
 { $values { "first" class } { "second" class } { "class" class } }\r
 { $description "Outputs the smallest anonymous class containing both " { $snippet "class1" } " and " { $snippet "class2" } "." } ;\r
@@ -89,7 +76,3 @@ HELP: classes-intersect?
 HELP: min-class\r
 { $values { "class" class } { "seq" "a sequence of class words" } { "class/f" "a class word or " { $link f } } }\r
 { $description "If all classes in " { $snippet "seq" } " that intersect " { $snippet "class" } " are subtypes of " { $snippet "class" } ", outputs the last such element of " { $snippet "seq" } ". If any conditions fail to hold, outputs " { $link f } "." } ;\r
-\r
-HELP: class<=>\r
-{ $values { "first" class } { "second" class } { "n" symbol } }\r
-{ $description "Compares two classes with the class linearization order." } ;\r
index 7387b8ae3a6cd06ffc0b704b0ece9a791a0ae509..dfe4a0fbc9753c70f5e0b15b47e2f714462347c5 100755 (executable)
@@ -248,7 +248,16 @@ UNION: yyy xxx ;
 [ { yyy xxx } ] [ { xxx yyy } sort-classes ] unit-test\r
 [ { yyy xxx } ] [ { yyy xxx } sort-classes ] unit-test\r
 \r
-[ { number integer ratio } ] [ { ratio number integer } sort-classes ] unit-test\r
+[ { number ratio integer } ] [ { ratio number integer } sort-classes ] unit-test\r
 [ { sequence number ratio } ] [ { ratio number sequence } sort-classes ] unit-test\r
 \r
-[ +lt+ ] [ \ real sequence class<=> ] unit-test\r
+TUPLE: xa ;\r
+TUPLE: xb ;\r
+TUPLE: xc < xa ;\r
+TUPLE: xd < xb ;\r
+TUPLE: xe ;\r
+TUPLE: xf < xb ;\r
+TUPLE: xg < xb ;\r
+TUPLE: xh < xb ;\r
+\r
+[ t ] [ { xa xb xc xd xe xf xg xh } sort-classes dup sort-classes = ] unit-test\r
index 8c910a1f8c29ddb630f38b2a6a72373ba2bbeec2..4160f4e9d2f0ac232c14c640723fcf8bc952a1a2 100755 (executable)
@@ -187,31 +187,15 @@ C: <anonymous-complement> anonymous-complement
         [ [ rank-class ] bi@ < ]\r
     } cond ;\r
 \r
-: class-tie-breaker ( first second -- n )\r
-    2dup [ rank-class ] compare {\r
-        { +lt+ [ 2drop +lt+ ] }\r
-        { +gt+ [ 2drop +gt+ ] }\r
-        { +eq+ [ <=> ] }\r
-    } case ;\r
-\r
-: (class<=>) ( first second -- n )\r
-    {\r
-        { [ 2dup class<= ] [\r
-            2dup swap class<=\r
-            [ class-tie-breaker ] [ 2drop +lt+ ] if\r
-        ] }\r
-        { [ 2dup swap class<= ] [\r
-            2dup class<=\r
-            [ class-tie-breaker ] [ 2drop +gt+ ] if\r
-        ] }\r
-        [ class-tie-breaker ]\r
-    } cond ;\r
-\r
-: class<=> ( first second -- n )\r
-    class<=>-cache get [ (class<=>) ] 2cache ;\r
+: largest-class ( seq -- n elt )\r
+    dup [ [ class< ] with contains? not ] curry find-last\r
+    [ "Topological sort failed" throw ] unless* ;\r
 \r
 : sort-classes ( seq -- newseq )\r
-    [ class<=> invert-comparison ] sort ;\r
+    [ [ word-name ] compare ] sort >vector\r
+    [ dup empty? not ]\r
+    [ dup largest-class >r over delete-nth r> ]\r
+    [ ] unfold nip ;\r
 \r
 : min-class ( class seq -- class/f )\r
     over [ classes-intersect? ] curry filter\r
index 53840c002725387ee5e99bdf87e3e73d49e002a3..594b2005b8a332cea7d73d5650b6050ceebe204a 100755 (executable)
@@ -6,7 +6,6 @@ quotations combinators sorting effects graphs vocabs ;
 IN: classes
 
 SYMBOL: class<=-cache
-SYMBOL: class<=>-cache
 SYMBOL: class-not-cache
 SYMBOL: classes-intersect-cache
 SYMBOL: class-and-cache
@@ -14,7 +13,6 @@ SYMBOL: class-or-cache
 
 : init-caches ( -- )
     H{ } clone class<=-cache set
-    H{ } clone class<=>-cache set
     H{ } clone class-not-cache set
     H{ } clone classes-intersect-cache set
     H{ } clone class-and-cache set
@@ -22,7 +20,6 @@ SYMBOL: class-or-cache
 
 : reset-caches ( -- )
     class<=-cache get clear-assoc
-    class<=>-cache get clear-assoc
     class-not-cache get clear-assoc
     classes-intersect-cache get clear-assoc
     class-and-cache get clear-assoc
index 0cde687f160a99499f56576fd0c2d4b5c60c46d8..fb9530b1c541ffc639e4044092efc0e2aae10e83 100755 (executable)
@@ -542,3 +542,15 @@ TUPLE: another-forget-accessors-test ;
 
 ! Missing error check
 [ "IN: tuples.test USE: words TUPLE: wrong-superclass < word ;" eval ] must-fail
+
+TUPLE: subclass-forget-test ;
+
+TUPLE: subclass-forget-test-1 < subclass-forget-test ;
+TUPLE: subclass-forget-test-2 < subclass-forget-test ;
+TUPLE: subclass-forget-test-3 < subclass-forget-test-2 ;
+
+[ ] [ "IN: classes.tuple.tests FORGET: subclass-forget-test" eval ] unit-test
+
+[ f ] [ subclass-forget-test-1 tuple-class? ] unit-test
+[ f ] [ subclass-forget-test-2 tuple-class? ] unit-test
+[ subclass-forget-test-3 new ] must-fail
index ee7ff8c6084f26fc6196bfbc7201dd503bb260f5..5ebcc7a2862b5c93855a765fd7ee550501a7e192 100755 (executable)
@@ -102,7 +102,7 @@ ERROR: bad-superclass class ;
     dup tuple-predicate-quot define-predicate ;
 
 : superclass-size ( class -- n )
-    superclasses 1 head-slice*
+    superclasses but-last-slice
     [ slot-names length ] map sum ;
 
 : generate-tuple-slots ( class slots -- slot-specs )
index 806ea914bb7dc4eb1b923f3cb42b7d98abfe3e85..ef00e94dd52070d052bb3bb2618844f2b15238a1 100755 (executable)
@@ -4,38 +4,55 @@ USING: kernel namespaces arrays sequences io inference.backend
 inference.state generator debugger words compiler.units
 continuations vocabs assocs alien.compiler dlists optimizer
 definitions math compiler.errors threads graphs generic
-inference ;
+inference combinators ;
 IN: compiler
 
 : ripple-up ( word -- )
     compiled-usage [ drop queue-compile ] assoc-each ;
 
 : save-effect ( word effect -- )
-    over "compiled-uses" word-prop [
-        2dup swap "compiled-effect" word-prop =
-        [ over ripple-up ] unless
-    ] when
-    "compiled-effect" set-word-prop ;
+    [
+        over "compiled-effect" word-prop = [
+            dup "compiled-uses" word-prop
+            [ dup ripple-up ] when
+        ] unless drop
+    ]
+    [ "compiled-effect" set-word-prop ] 2bi ;
 
-: finish-compile ( word effect dependencies -- )
-    >r dupd save-effect r>
-    over compiled-unxref
-    over compiled-crossref? [ compiled-xref ] [ 2drop ] if ;
+: compile-begins ( word -- )
+    f swap compiler-error ;
 
-: compile-succeeded ( word -- effect dependencies )
+: compile-failed ( word error -- )
+    [ swap compiler-error ]
     [
-        [ word-dataflow optimize ] keep dup generate
-    ] computing-dependencies ;
+        drop
+        [ f swap compiled get set-at ]
+        [ f save-effect ]
+        bi
+    ] 2bi ;
 
-: compile-failed ( word error -- )
-    f pick compiled get set-at
-    swap compiler-error ;
+: compile-succeeded ( effect word -- )
+    [ swap save-effect ]
+    [ compiled-unxref ]
+    [
+        dup compiled-crossref?
+        [ dependencies get compiled-xref ] [ drop ] if
+    ] tri ;
 
 : (compile) ( word -- )
-    f over compiler-error
-    [ dup compile-succeeded finish-compile ]
-    [ dupd compile-failed f save-effect ]
-    recover ;
+    [
+        H{ } clone dependencies set
+
+        {
+            [ compile-begins ]
+            [
+                [ word-dataflow ] [ compile-failed return ] recover
+                optimize
+            ]
+            [ dup generate ]
+            [ compile-succeeded ]
+        } cleave
+    ] curry with-return ;
 
 : compile-loop ( assoc -- )
     dup assoc-empty? [ drop ] [
index dd71eb704f49cb2e08760efe853e41365ed8961f..d86587662bd6732f4b0b6798ba3ab41619874955 100755 (executable)
@@ -21,19 +21,19 @@ HELP: compiler-error
 
 HELP: compiler-error.
 { $values { "error" "an error" } { "word" word } }
-{ $description "Prints a compiler error to the " { $link stdio } " stream." } ;
+{ $description "Prints a compiler error to " { $link output-stream } "." } ;
 
 HELP: compiler-errors.
 { $values { "type" symbol } }
-{ $description "Prints compiler errors to the " { $link stdio } " stream. The type parameter is one of " { $link +error+ } ", " { $link +warning+ } ", or " { $link +linkage+ } "." } ;
+{ $description "Prints compiler errors to " { $link output-stream } ". The type parameter is one of " { $link +error+ } ", " { $link +warning+ } ", or " { $link +linkage+ } "." } ;
 HELP: :errors
-{ $description "Prints all serious compiler errors from the most recent compile to the " { $link stdio } " stream." } ;
+{ $description "Prints all serious compiler errors from the most recent compile to " { $link output-stream } "." } ;
 
 HELP: :warnings
-{ $description "Prints all ignorable compiler warnings from the most recent compile to the " { $link stdio } " stream." } ;
+{ $description "Prints all ignorable compiler warnings from the most recent compile to " { $link output-stream } "." } ;
 
 HELP: :linkage
-{ $description "Prints all C library interface linkage errors from the most recent compile to the " { $link stdio } " stream." } ;
+{ $description "Prints all C library interface linkage errors from the most recent compile to " { $link output-stream } "." } ;
 
 { :errors :warnings } related-words
 
index b1db09b6bcf28e4059c8a9112468383b9ae29f9c..472136da8ecff0e90bdf2a569ac4914dc527a4d1 100755 (executable)
@@ -34,7 +34,7 @@ $nl
 { $code
     "<external-resource> ... do stuff ... dispose"
 }
-"The reason being that if " { $snippet "do stuff" } " throws an error, the resource will not be disposed of. The most important case where this can occur is with I/O streams, and the correct solution is to always use " { $link with-stream } "; see " { $link "stdio" } " for details." ;
+"The reason being that if " { $snippet "do stuff" } " throws an error, the resource will not be disposed of. The most important case where this can occur is with I/O streams, and the correct solution is to always use " { $link with-input-stream } " and " { $link with-output-stream } "; see " { $link "stdio" } " for details." ;
 
 ARTICLE: "errors" "Error handling"
 "Support for handling exceptional situations such as bad user input, implementation bugs, and input/output errors is provided by a set of words built using continuations."
index b0c216e82f91fa7a77b3f1ec42dbb97589230f2f..28581820fd4666e3554ea97cf951d1409e347898 100755 (executable)
@@ -39,7 +39,7 @@ IN: continuations.tests
 
 "!!! The following error is part of the test" print
 
-[ ] [ [ [ "2 car" ] eval ] [ print-error ] recover ] unit-test
+[ ] [ [ [ "2 car" ] eval ] try ] unit-test
 
 [ f throw ] must-fail
 
@@ -117,3 +117,5 @@ T{ dispose-dummy } "b" set
 [ { "a" "b" } [ get ] map dispose-each ] [ 3 = ] must-fail-with
 
 [ t ] [ "b" get disposed?>> ] unit-test
+
+[ ] [ [ return ] with-return ] unit-test
index 3e675b1f0f90f5180d31d4d2b2b8c26dc9eb8a91..78effb043afbd280ce4b07b19070ff3d0f2ba44f 100755 (executable)
@@ -101,6 +101,14 @@ PRIVATE>
 : continue ( continuation -- )
     f swap continue-with ;
 
+SYMBOL: return-continuation
+
+: with-return ( quot -- )
+    [ [ return-continuation set ] prepose callcc0 ] with-scope ; inline
+
+: return ( -- )
+    return-continuation get continue ;
+
 GENERIC: compute-restarts ( error -- seq )
 
 <PRIVATE
index ca6aa59cc4d58d81caa70eb9d151da09755df82b..9dd23c6011964364f18ee96a056fce15a2cd8a8e 100755 (executable)
@@ -1,7 +1,7 @@
 USING: alien arrays generic generic.math help.markup help.syntax
 kernel math memory strings sbufs vectors io io.files classes
 help generic.standard continuations system debugger.private
-io.files.private ;
+io.files.private listener ;
 IN: debugger
 
 ARTICLE: "errors-assert" "Assertions"
@@ -64,7 +64,7 @@ HELP: :3
 
 HELP: error.
 { $values { "error" "an error" } }
-{ $contract "Print an error to the " { $link stdio } " stream.  You can define methods on this generic word to print human-readable messages for custom errors." }
+{ $contract "Print an error to " { $link output-stream } ". You can define methods on this generic word to print human-readable messages for custom errors." }
 { $notes "Code should call " { $link print-error } " instead, which handles the case where the printing of the error itself throws an error." } ;
 
 HELP: error-help
@@ -75,19 +75,15 @@ HELP: error-help
 
 HELP: print-error
 { $values { "error" "an error" } }
-{ $description "Print an error to the " { $link stdio } " stream." }
+{ $description "Print an error to " { $link output-stream } "." }
 { $notes "This word is called by the listener and other tools which report caught errors to the user." } ;
 
 HELP: restarts.
-{ $description "Print a list of restarts for the most recently thrown error to the " { $link stdio } " stream." } ;
-
-HELP: error-hook
-{ $var-description "A quotation with stack effect " { $snippet "( error -- )" } " which is used by " { $link try } " to report the error to the user." }
-{ $examples "The default value prints the error with " { $link print-error } ", followed by a list of restarts and a help message. The graphical listener sets this variable to display a popup instead." } ;
+{ $description "Print a list of restarts for the most recently thrown error to " { $link output-stream } "." } ;
 
 HELP: try
 { $values { "quot" "a quotation" } }
-{ $description "Attempts to call a quotation; if it throws an error, the " { $link error-hook } " gets called, stacks are restored, and execution continues after the call to " { $link try } "." }
+{ $description "Attempts to call a quotation; if it throws an error, the error is printed to " { $link output-stream } ", stacks are restored, and execution continues after the call to " { $link try } "." }
 { $examples
     "The following example prints an error and keeps going:"
     { $code
index 34fcf8e6bc6d70ff77e2f3f48090443a34263307..df7d33f41c7d3f229ed54fbe12a3e97dd3b250d1 100755 (executable)
@@ -1,13 +1,13 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays definitions generic hashtables inspector io kernel
-math namespaces prettyprint sequences assocs sequences.private
-strings io.styles vectors words system splitting math.parser
-classes.tuple continuations continuations.private combinators
-generic.math io.streams.duplex classes.builtin classes
-compiler.units generic.standard vocabs threads threads.private
-init kernel.private libc io.encodings mirrors accessors
-math.order ;
+math namespaces prettyprint prettyprint.config sequences assocs
+sequences.private strings io.styles vectors words system
+splitting math.parser classes.tuple continuations
+continuations.private combinators generic.math
+classes.builtin classes compiler.units generic.standard vocabs
+threads threads.private init kernel.private libc io.encodings
+mirrors accessors math.order ;
 IN: debugger
 
 GENERIC: error. ( error -- )
@@ -64,17 +64,14 @@ M: string error. print ;
     [ global [ "Error in print-error!" print drop ] bind ]
     recover ;
 
-SYMBOL: error-hook
-
-[
+: print-error-and-restarts ( error -- )
     print-error
     restarts.
     nl
-    "Type :help for debugging help." print flush
-] error-hook set-global
+    "Type :help for debugging help." print flush ;
 
 : try ( quot -- )
-    [ error-hook get call ] recover ;
+    [ print-error-and-restarts ] recover ;
 
 ERROR: assert got expect ;
 
@@ -209,9 +206,6 @@ M: no-next-method summary
 M: inconsistent-next-method summary
     drop "Executing call-next-method with inconsistent parameters" ;
 
-M: stream-closed-twice summary
-    drop "Attempt to perform I/O on closed stream" ;
-
 M: check-method summary
     drop "Invalid parameters for create-method" ;
 
@@ -241,6 +235,15 @@ M: condition error-help error>> error-help ;
 
 M: assert summary drop "Assertion failed" ;
 
+M: assert error.
+    "Assertion failed" print
+    standard-table-style [
+        15 length-limit set
+        5 line-limit set
+        [ expect>> [ [ "Expect:" write ] with-cell pprint-cell ] with-row ]
+        [ got>> [ [ "Got:" write ] with-cell pprint-cell ] with-row ] bi
+    ] tabular-output ;
+
 M: immutable summary drop "Sequence is immutable" ;
 
 M: redefine-error error.
@@ -267,8 +270,7 @@ M: double-free summary
 M: realloc-error summary
     drop "Memory reallocation failed" ;
 
-: error-in-thread. ( -- )
-    error-thread get-global
+: error-in-thread. ( thread -- )
     "Error in thread " write
     [
         dup thread-id #
@@ -282,7 +284,7 @@ M: thread error-in-thread ( error thread -- )
         die drop
     ] [
         global [
-            error-in-thread. print-error flush
+            error-thread get-global error-in-thread. print-error flush
         ] bind
     ] if ;
 
index 7639d1d49912f9f25ccb37db6d3207df41d08845..51ea4f8225cec8c64eb22f1294bfbf6659a728a8 100644 (file)
@@ -127,8 +127,6 @@ M: echelon-dispatch-engine engine>quot
     1 slot { tuple-layout } declare
     5 slot ; inline
 
-: unclip-last [ 1 head* ] [ peek ] bi ;
-
 M: tuple-dispatch-engine engine>quot
     [
         picker %
index e32c94ed371263df9655a1a95b0293cd5205ce35..d79c82ed6518699cc1f7bed44ed931f787d24d66 100755 (executable)
@@ -135,7 +135,7 @@ HELP: infer
 
 HELP: infer.
 { $values { "quot" "a quotation" } }
-{ $description "Attempts to infer the quotation's stack effect, and prints this data to the " { $link stdio } " stream." }
+{ $description "Attempts to infer the quotation's stack effect, and prints this data to " { $link output-stream } "." }
 { $errors "Throws an " { $link inference-error } " if stack effect inference fails." } ;
 
 { infer infer. } related-words
index 84d72bdd9b25f55de88569d466dc550a33ee5c63..fe1f51a5e7a998f3705b6b3274bcbeece821bf41 100644 (file)
@@ -1,6 +1,10 @@
 IN: inference.state.tests
 USING: tools.test inference.state words ;
 
+: computing-dependencies ( quot -- dependencies )
+    H{ } clone [ dependencies rot with-variable ] keep ;
+    inline
+
 SYMBOL: a
 SYMBOL: b
 
index a426f410e27720165cb81bbedd24ab1d0e530825..6f0eecf2d9617419863fdfb55c6e3ebdec4ae454 100755 (executable)
@@ -36,10 +36,6 @@ SYMBOL: dependencies
         2dup at +inlined+ eq? [ 3drop ] [ set-at ] if
     ] [ 3drop ] if ;
 
-: computing-dependencies ( quot -- dependencies )
-    H{ } clone [ dependencies rot with-variable ] keep ;
-    inline
-
 ! Did the current control-flow path throw an error?
 SYMBOL: terminated?
 
index 624dcbbf980ae8d0a6284dda7d4b05d7b4856d7f..0040629edd444786c06184f78f5b03d064c70025 100755 (executable)
@@ -32,7 +32,7 @@ IN: inference.transforms
         drop [ no-case ]
     ] [
         dup peek quotation? [
-            dup peek swap 1 head*
+            dup peek swap but-last
         ] [
             [ no-case ] swap
         ] if case>quot
index 84ae34480d540424e2e09ffd6b02a7fea2e190b6..ab1c38b0b736facf41c7fbff11928a0499384bf5 100644 (file)
@@ -108,4 +108,4 @@ HELP: me
 HELP: inspector-hook
 { $var-description "A quotation with stack effect " { $snippet "( obj -- )" } ", called by the inspector to display an overview of an object."
 $nl
-"The default implementation calls " { $link describe } " which outputs on the " { $link stdio } " stream, but the graphical listener sets this variable so that calling " { $link inspect } " in the UI opens the graphical inspector." } ;
+"The default implementation calls " { $link describe } " which outputs on " { $link output-stream } ", but the graphical listener sets this variable so that calling " { $link inspect } " in the UI opens the graphical inspector." } ;
index 8bf761e2a691b28fa395562f34ff28707b266233..48b49ed32b66fedc5fea449161db80c253f3479b 100644 (file)
@@ -9,4 +9,4 @@ HELP: init-io
 { $contract "Initializes the I/O system. Called on startup." } ;
 
 HELP: init-stdio
-{ $contract "Initializes the global " { $link stdio } " stream.  Called on startup." } ;
+{ $contract "Initializes the global " { $link input-stream } " and " { $link output-stream } ".  Called on startup." } ;
index 44b1eea349e1a0fe910b6fb13a516fdd079606d5..0760063f0df9ff7c7394c833d8e502a55851e486 100755 (executable)
@@ -11,8 +11,10 @@ HOOK: init-io io-backend ( -- )
 HOOK: (init-stdio) io-backend ( -- stdin stdout stderr )
 
 : init-stdio ( -- )
-    (init-stdio) utf8 <encoder> stderr set-global
-    utf8 <encoder-duplex> stdio set-global ;
+    (init-stdio)
+    [ utf8 <decoder> input-stream set-global ]
+    [ utf8 <encoder> output-stream set-global ]
+    [ utf8 <encoder> error-stream set-global ] tri* ;
 
 HOOK: io-multiplex io-backend ( ms -- )
 
index 8a176ce4ec7db6b7a30df6d3b6ce5146e96c2074..92471acb5d0b680088b8d8d93679a11eadb7e3db 100644 (file)
@@ -12,8 +12,7 @@ ARTICLE: "io.encodings" "I/O encodings"
 ARTICLE: "encodings-constructors" "Manually constructing an encoded stream"
 "The following words can be used to construct encoded streams. Note that they are usually not used directly, but rather by the stream constructors themselves. Most stream constructors take an encoding descriptor as a parameter and internally call these constructors."
 { $subsection <encoder> }
-{ $subsection <decoder> }
-{ $subsection <encoder-duplex> } ;
+{ $subsection <decoder> } ;
 
 HELP: <encoder>
 { $values { "stream" "an output stream" }
@@ -29,16 +28,6 @@ HELP: <decoder>
 { $description "Wraps the given stream in a new stream using the given encoding for all input. The encoding descriptor can either be a class or an instance of something conforming to the " { $link "encodings-protocol" } "." }
 $low-level-note ;
 
-HELP: <encoder-duplex>
-{ $values { "stream-in" "an input stream" }
-    { "stream-out" "an output stream" }
-    { "encoding" "an encoding descriptor" }
-    { "duplex" "an encoded duplex stream" } }
-{ $description "Wraps the given streams in an encoder or decoder stream, and puts them together in a duplex stream for input and output. If either input stream is already encoded, that encoding is stripped off before it is reencoded. The encoding descriptor must conform to the " { $link "encodings-protocol" } "." }
-$low-level-note ;
-
-{ <encoder> <decoder> <encoder-duplex> } related-words
-
 ARTICLE: "encodings-descriptors" "Encoding descriptors"
 "An encoding descriptor is something which can be used for input or output streams to encode or decode files. It must conform to the " { $link "encodings-protocol" } ". Encodings which you can use are defined in the following vocabularies:"
 { $subsection "io.encodings.binary" }
index 397d1ea89c3b40b40dd4784debfc1f2755cc4014..e6b180fde2f249e566fce453a66753d6150b4989 100755 (executable)
@@ -2,35 +2,35 @@ USING: io.files io.streams.string io
 tools.test kernel io.encodings.ascii ;
 IN: io.streams.encodings.tests
 
-: <resource-reader> ( resource -- stream )
-    resource-path ascii <file-reader> ;
-    
 [ { } ]
-[ "core/io/test/empty-file.txt" <resource-reader> lines ]
+[ "resource:core/io/test/empty-file.txt" ascii <file-reader> lines ]
 unit-test
 
 : lines-test ( stream -- line1 line2 )
-    [ readln readln ] with-stream ;
+    [ readln readln ] with-input-stream ;
 
 [
     "This is a line."
     "This is another line."
 ] [
-    "core/io/test/windows-eol.txt" <resource-reader> lines-test
+    "resource:core/io/test/windows-eol.txt"
+    ascii <file-reader> lines-test
 ] unit-test
 
 [
     "This is a line."
     "This is another line."
 ] [
-    "core/io/test/mac-os-eol.txt" <resource-reader> lines-test
+    "resource:core/io/test/mac-os-eol.txt"
+    ascii <file-reader> lines-test
 ] unit-test
 
 [
     "This is a line."
     "This is another line."
 ] [
-    "core/io/test/unix-eol.txt" <resource-reader> lines-test
+    "resource:core/io/test/unix-eol.txt"
+    ascii <file-reader> lines-test
 ] unit-test
 
 [
index 4559cec666c5a1ed166447fa13ee0d20b3aac1c0..0f6e58bdc9186262c16644d5fbb13becd89dfb2b 100755 (executable)
@@ -2,8 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: math kernel sequences sbufs vectors namespaces growable
 strings io classes continuations combinators io.styles
-io.streams.plain splitting io.streams.duplex byte-arrays
-sequences.private accessors ;
+io.streams.plain splitting byte-arrays sequences.private
+accessors ;
 IN: io.encodings
 
 ! The encoding descriptor protocol
@@ -131,6 +131,3 @@ INSTANCE: encoder plain-writer
     over decoder? [ >r decoder-stream r> ] when <decoder> ;
 
 PRIVATE>
-
-: <encoder-duplex> ( stream-in stream-out encoding -- duplex )
-    tuck reencode >r redecode r> <duplex-stream> ;
index ba17223a2937eec75a98eb6d5926e8e5a500084b..d18babf31ba15061334dd0c312b8651de2ee018b 100755 (executable)
@@ -184,8 +184,12 @@ HELP: +unknown+
 { $description "A unknown file type." } ;
 
 HELP: <file-reader>
-{ $values { "path" "a pathname string" } { "encoding" "an encoding descriptor" { "stream" "an input stream" } }
-    { "stream" "an input stream" } }
+{
+  $values
+  { "path" "a pathname string" }
+  { "encoding" "an encoding descriptor" }
+  { "stream" "an input stream" }
+}
 { $description "Outputs an input stream for reading from the specified pathname using the given encoding." }
 { $errors "Throws an error if the file is unreadable." } ;
 
@@ -201,17 +205,17 @@ HELP: <file-appender>
 
 HELP: with-file-reader
 { $values { "path" "a pathname string" } { "encoding" "an encoding descriptor" } { "quot" "a quotation" } }
-{ $description "Opens a file for reading and calls the quotation using " { $link with-stream } "." }
+{ $description "Opens a file for reading and calls the quotation using " { $link with-input-stream } "." }
 { $errors "Throws an error if the file is unreadable." } ;
 
 HELP: with-file-writer
 { $values { "path" "a pathname string" } { "encoding" "an encoding descriptor" } { "quot" "a quotation" } }
-{ $description "Opens a file for writing using the given encoding and calls the quotation using " { $link with-stream } "." }
+{ $description "Opens a file for writing using the given encoding and calls the quotation using " { $link with-output-stream } "." }
 { $errors "Throws an error if the file cannot be opened for writing." } ;
 
 HELP: with-file-appender
 { $values { "path" "a pathname string" } { "encoding" "an encoding descriptor" } { "quot" "a quotation" } }
-{ $description "Opens a file for appending using the given encoding and calls the quotation using " { $link with-stream } "." }
+{ $description "Opens a file for appending using the given encoding and calls the quotation using " { $link with-output-stream } "." }
 { $errors "Throws an error if the file cannot be opened for writing." } ;
 
 HELP: set-file-lines
index 576307b58920a137daab965b64ab000cf473fc98..76c7b144d0aa9a37862767dba6b7f15bad83f97e 100755 (executable)
@@ -25,13 +25,13 @@ HOOK: (file-appender) io-backend ( path -- stream )
     <file-reader> lines ;
 
 : with-file-reader ( path encoding quot -- )
-    >r <file-reader> r> with-stream ; inline
+    >r <file-reader> r> with-input-stream ; inline
 
 : file-contents ( path encoding -- str )
     <file-reader> contents ;
 
 : with-file-writer ( path encoding quot -- )
-    >r <file-writer> r> with-stream ; inline
+    >r <file-writer> r> with-output-stream ; inline
 
 : set-file-lines ( seq path encoding -- )
     [ [ print ] each ] with-file-writer ;
@@ -40,7 +40,7 @@ HOOK: (file-appender) io-backend ( path -- stream )
     [ write ] with-file-writer ;
 
 : with-file-appender ( path encoding quot -- )
-    >r <file-appender> r> with-stream ; inline
+    >r <file-appender> r> with-output-stream ; inline
 
 ! Pathnames
 : path-separator? ( ch -- ? ) os windows? "/\\" "/" ? member? ;
index fd40950e62e7f2692754efa0e729d16099301a8b..ddea4da5563e5e6631634f04e51e41d115c3c7ad 100755 (executable)
@@ -5,7 +5,7 @@ IN: io
 ARTICLE: "stream-protocol" "Stream protocol"
 "The stream protocol consists of a large number of generic words, many of which are optional."
 $nl
-"Stream protocol words are rarely called directly, since code which only works with one stream at a time should be written use " { $link "stdio" } " instead, wrapping I/O operations such as " { $link read } " and " { $link write } " in a " { $link with-stream } ". This leads more simpler, more reusable and more robust code."
+"Stream protocol words are rarely called directly, since code which only works with one stream at a time should be written use " { $link "stdio" } " instead, wrapping I/O operations such as " { $link read } " and " { $link write } " in " { $link with-input-stream } " and " { $link with-output-stream } "."
 $nl
 "All streams must implement the " { $link dispose } " word in addition to the stream protocol."
 $nl
@@ -26,24 +26,24 @@ $nl
 { $subsection stream-write-table }
 { $see-also "io.timeouts" } ;
 
-ARTICLE: "stdio" "The default stream"
-"Most I/O code only operates on one stream at a time. The " { $emphasis "default stream" } " is an implicit parameter used by many I/O words designed for this particular use-case. Using this idiom improves code in three ways:"
+ARTICLE: "stdio" "Default input and output streams"
+"Most I/O code only operates on one stream at a time. The " { $link input-stream } " and " { $link output-stream } " variables are implicit parameters used by many I/O words. Using this idiom improves code in three ways:"
 { $list
     { "Code becomes simpler because there is no need to keep a stream around on the stack." }
-    { "Code becomes more robust because " { $link with-stream } " automatically closes the stream if there is an error." }
-    { "Code becomes more reusable because it can be written to not worry about which stream is being used, and instead the caller can use " { $link with-stream } " to specify the source or destination for I/O operations." }
+    { "Code becomes more robust because " { $link with-input-stream } " and " { $link with-output-stream } " automatically close the streams if there is an error." }
+    { "Code becomes more reusable because it can be written to not worry about which stream is being used, and instead the caller can use " { $link with-input-stream } " or " { $link with-output-stream } " to specify the source or destination for I/O operations." }
 }
 "For example, here is a program which reads the first line of a file, converts it to an integer, then reads that many characters, and splits them into groups of 16:"
 { $code
     "USING: continuations kernel io io.files math.parser splitting ;"
-    "\"data.txt\" <file-reader>"
+    "\"data.txt\" utf8 <file-reader>"
     "dup stream-readln number>string over stream-read 16 group"
     "swap dispose"
 }
 "This code has two problems: it has some unnecessary stack shuffling, and if either " { $link stream-readln } " or " { $link stream-read } " throws an I/O error, the stream is not closed because " { $link dispose } " is never reached. So we can add a call to " { $link with-disposal } " to ensure the stream is always closed:"
 { $code
     "USING: continuations kernel io io.files math.parser splitting ;"
-    "\"data.txt\" <file-reader> ["
+    "\"data.txt\" utf8 <file-reader> ["
     "    dup stream-readln number>string over stream-read"
     "    16 group"
     "] with-disposal"
@@ -51,17 +51,34 @@ ARTICLE: "stdio" "The default stream"
 "This code is robust however it is more complex than it needs to be since. This is where the default stream words come in; using them, the above can be rewritten as follows:"
 { $code
     "USING: continuations kernel io io.files math.parser splitting ;"
-    "\"data.txt\" <file-reader> ["
+    "\"data.txt\" utf8 <file-reader> ["
     "    readln number>string read 16 group"
-    "] with-stream"
+    "] with-input-stream"
 }
-"The default stream is stored in a dynamically-scoped variable:"
-{ $subsection stdio }
-"Unless rebound in a child namespace, this variable will be set to a console stream for interacting with the user."
+"An even better implementation that takes advantage of a utility word:"
+{ $code
+    "USING: continuations kernel io io.files math.parser splitting ;"
+    "\"data.txt\" utf8 ["
+    "    readln number>string read 16 group"
+    "] with-file-reader"
+}
+"The default input stream is stored in a dynamically-scoped variable:"
+{ $subsection input-stream }
+"Unless rebound in a child namespace, this variable will be set to a console stream for reading input from the user."
+$nl
+"Words reading from the default input stream:"
 { $subsection read1 }
 { $subsection read }
 { $subsection read-until }
 { $subsection readln }
+"A pair of combinators for rebinding the " { $link input-stream } " variable:"
+{ $subsection with-input-stream }
+{ $subsection with-input-stream* }
+"The default output stream is stored in a dynamically-scoped variable:"
+{ $subsection output-stream }
+"Unless rebound in a child namespace, this variable will be set to a console stream for showing output to the user."
+$nl
+"Words writing to the default input stream:"
 { $subsection flush }
 { $subsection write1 }
 { $subsection write }
@@ -78,9 +95,12 @@ ARTICLE: "stdio" "The default stream"
 { $subsection with-row }
 { $subsection with-cell }
 { $subsection write-cell }
-"A pair of combinators support rebinding the " { $link stdio } " variable:"
-{ $subsection with-stream }
-{ $subsection with-stream* } ;
+"A pair of combinators for rebinding the " { $link output-stream } " variable:"
+{ $subsection with-output-stream }
+{ $subsection with-output-stream* }
+"A pair of combinators for rebinding both default streams at once:"
+{ $subsection with-streams }
+{ $subsection with-streams* } ;
 
 ARTICLE: "stream-utils" "Stream utilities"
 "There are a few useful stream-related words which are not generic, but merely built up from the stream protocol."
@@ -204,62 +224,65 @@ HELP: stream-copy
 { $description "Copies the contents of one stream into another, closing both streams when done." } 
 $io-error ;
 
-HELP: stdio
-{ $var-description "Holds a stream, used for various implicit stream operations. Rebound using " { $link with-stream } " and " { $link with-stream* } "." } ;
+HELP: input-stream
+{ $var-description "Holds an input stream for various implicit stream operations. Rebound using " { $link with-input-stream } " and " { $link with-input-stream* } "." } ;
+
+HELP: output-stream
+{ $var-description "Holds an output stream for various implicit stream operations. Rebound using " { $link with-output-stream } " and " { $link with-output-stream* } "." } ;
 
 HELP: readln
 { $values { "str/f" "a string or " { $link f } } }
-{ $description "Reads a line of input from the " { $link stdio } " stream. Outputs " { $link f } " on stream exhaustion." }
+{ $description "Reads a line of input from " { $link input-stream } ". Outputs " { $link f } " on stream exhaustion." }
 $io-error ;
 
 HELP: read1
 { $values { "ch/f" "a character or " { $link f } } }
-{ $description "Reads a character of input from the " { $link stdio } " stream. Outputs " { $link f } " on stream exhaustion." }
+{ $description "Reads a character of input from " { $link input-stream } ". Outputs " { $link f } " on stream exhaustion." }
 $io-error ;
 
 HELP: read
 { $values { "n" "a non-negative integer" } { "str/f" "a string or " { $link f } } }
-{ $description "Reads " { $snippet "n" } " characters of input from the " { $link stdio } " stream. Outputs a truncated string or " { $link f } " on stream exhaustion." }
+{ $description "Reads " { $snippet "n" } " characters of input from " { $link input-stream } ". Outputs a truncated string or " { $link f } " on stream exhaustion." }
 $io-error ;
 
 HELP: read-until
 { $values { "seps" string } { "str/f" "a string or " { $link f } } { "sep/f" "a character or " { $link f } } }
-{ $contract "Reads characters from the " { $link stdio } " stream. until the first occurrence of a separator character, or stream exhaustion. In the former case, the separator character is pushed on the stack, and is not part of the output string. In the latter case, the entire stream contents are output, along with " { $link f } "." }
+{ $contract "Reads characters from " { $link input-stream } ". until the first occurrence of a separator character, or stream exhaustion. In the former case, the separator character is pushed on the stack, and is not part of the output string. In the latter case, the entire stream contents are output, along with " { $link f } "." }
 $io-error ;
 
 HELP: write1
 { $values { "ch" "a character" } }
-{ $contract "Writes a character of output to the " { $link stdio } " stream. If the stream does buffering, output may not be performed immediately; use " { $link flush } " to force output." }
+{ $contract "Writes a character of output to " { $link output-stream } ". If the stream does buffering, output may not be performed immediately; use " { $link flush } " to force output." }
 $io-error ;
 
 HELP: write
 { $values { "str" string } }
-{ $description "Writes a string of output to the " { $link stdio } " stream. If the stream does buffering, output may not be performed immediately; use " { $link flush } " to force output." }
+{ $description "Writes a string of output to " { $link output-stream } ". If the stream does buffering, output may not be performed immediately; use " { $link flush } " to force output." }
 $io-error ;
 
 HELP: flush
-{ $description "Waits for any pending output to the " { $link stdio } " stream to complete." }
+{ $description "Waits for any pending output on " { $link output-stream } " to complete." }
 $io-error ;
 
 HELP: nl
-{ $description "Writes a line terminator to the " { $link stdio } " stream. If the stream does buffering, output may not be performed immediately; use " { $link flush } " to force output." }
+{ $description "Writes a line terminator to " { $link output-stream } ". If the stream does buffering, output may not be performed immediately; use " { $link flush } " to force output." }
 $io-error ;
 
 HELP: format
 { $values { "str" string } { "style" "a hashtable" } }
-{ $description "Writes formatted text to the " { $link stdio } " stream. If the stream does buffering, output may not be performed immediately; use " { $link flush } " to force output." }
+{ $description "Writes formatted text to " { $link output-stream } ". If the stream does buffering, output may not be performed immediately; use " { $link flush } " to force output." }
 { $notes "Details are in the documentation for " { $link stream-format } "." }
 $io-error ;
 
 HELP: with-nesting
-{ $values { "style" "a hashtable" } { "quot" "a quotation" } }
-{ $description "Calls the quotation in a new dynamic scope with the " { $link stdio } " stream rebound to a nested paragraph stream, with formatting information applied." }
+{ $values { "style" "a hashtable" } { "quot" quotation } }
+{ $description "Calls the quotation in a new dynamic scope with " { $link output-stream } " rebound to a nested paragraph stream, with formatting information applied." }
 { $notes "Details are in the documentation for " { $link make-block-stream } "." }
 $io-error ;
 
 HELP: tabular-output
 { $values { "style" "a hashtable" } { "quot" quotation } }
-{ $description "Calls a quotation which emits a series of equal-length table rows using " { $link with-row } ". The results are laid out in a tabular fashion on the " { $link stdio } " stream."
+{ $description "Calls a quotation which emits a series of equal-length table rows using " { $link with-row } ". The results are laid out in a tabular fashion on " { $link output-stream } "."
 $nl
 "The " { $snippet "style" } " hashtable holds table style information. See " { $link "table-styles" } "." }
 { $examples
@@ -279,7 +302,7 @@ $io-error ;
 
 HELP: with-cell
 { $values { "quot" quotation } }
-{ $description "Calls a quotation in a new scope with the " { $link stdio } " stream rebound. Output performed by the quotation is displayed in a table cell. This word can only be called inside the quotation given to " { $link with-row } "." }
+{ $description "Calls a quotation in a new scope with " { $link output-stream } " rebound. Output performed by the quotation is displayed in a table cell. This word can only be called inside the quotation given to " { $link with-row } "." }
 $io-error ;
 
 HELP: write-cell
@@ -288,34 +311,54 @@ HELP: write-cell
 $io-error ;
 
 HELP: with-style
-{ $values { "style" "a hashtable" } { "quot" "a quotation" } }
+{ $values { "style" "a hashtable" } { "quot" quotation } }
 { $description "Calls the quotation in a new dynamic scope where calls to " { $link write } ", " { $link format } " and other stream output words automatically inherit style settings from " { $snippet "style" } "." }
 { $notes "Details are in the documentation for " { $link make-span-stream } "." }
 $io-error ;
 
 HELP: print
 { $values { "string" string } }
-{ $description "Writes a newline-terminated string to the " { $link stdio } " stream." }
+{ $description "Writes a newline-terminated string to " { $link output-stream } "." }
 $io-error ;
 
-HELP: with-stream
-{ $values { "stream" "an input or output stream" } { "quot" "a quotation" } }
-{ $description "Calls the quotation in a new dynamic scope, with the " { $link stdio } " variable rebound to  " { $snippet "stream" } ". The stream is closed if the quotation returns or throws an error." } ;
+HELP: with-input-stream
+{ $values { "stream" "an input stream" } { "quot" quotation } }
+{ $description "Calls the quotation in a new dynamic scope, with " { $link input-stream } " rebound to  " { $snippet "stream" } ". The stream is closed if the quotation returns or throws an error." } ;
+
+HELP: with-output-stream
+{ $values { "stream" "an output stream" } { "quot" quotation } }
+{ $description "Calls the quotation in a new dynamic scope, with " { $link output-stream } " rebound to  " { $snippet "stream" } ". The stream is closed if the quotation returns or throws an error." } ;
+
+HELP: with-streams
+{ $values { "input" "an input stream" } { "output" "an output stream" } { "quot" quotation } }
+{ $description "Calls the quotation in a new dynamic scope, with " { $link input-stream } " rebound to  " { $snippet "input" } " and " { $link output-stream } " rebound to  " { $snippet "output" } ". The stream is closed if the quotation returns or throws an error." } ;
+
+HELP: with-streams*
+{ $values { "input" "an input stream" } { "output" "an output stream" } { "quot" quotation } }
+{ $description "Calls the quotation in a new dynamic scope, with " { $link input-stream } " rebound to  " { $snippet "input" } " and " { $link output-stream } " rebound to  " { $snippet "output" } "." }
+{ $notes "This word does not close the stream. Compare with " { $link with-streams } "." } ;
+
+{ with-input-stream with-input-stream* } related-words
+
+{ with-output-stream with-output-stream* } related-words
 
-{ with-stream with-stream* } related-words
+HELP: with-input-stream*
+{ $values { "stream" "an input stream" } { "quot" quotation } }
+{ $description "Calls the quotation in a new dynamic scope, with " { $link input-stream } " rebound to  " { $snippet "stream" } "." }
+{ $notes "This word does not close the stream. Compare with " { $link with-input-stream } "." } ;
 
-HELP: with-stream*
-{ $values { "stream" "an input or output stream" } { "quot" "a quotation" } }
-{ $description "Calls the quotation in a new dynamic scope, with the " { $link stdio } " variable rebound to  " { $snippet "stream" } "." }
-{ $notes "This word does not close the stream. Compare with " { $link with-stream } "." } ;
+HELP: with-output-stream*
+{ $values { "stream" "an output stream" } { "quot" quotation } }
+{ $description "Calls the quotation in a new dynamic scope, with " { $link output-stream } " rebound to  " { $snippet "stream" } "." }
+{ $notes "This word does not close the stream. Compare with " { $link with-output-stream } "." } ;
 
 HELP: bl
-{ $description "Outputs a space character (" { $snippet "\" \"" } ")." }
+{ $description "Outputs a space character (" { $snippet "\" \"" } ") to " { $link output-stream } "." }
 $io-error ;
 
 HELP: write-object
 { $values { "str" string } { "obj" "an object" } }
-{ $description "Writes a string to the " { $link stdio } " stream, associating it with the object. If formatted output is supported, the string will become a clickable presentation of the object, otherwise this word behaves like a call to " { $link write } "." }
+{ $description "Writes a string to " { $link output-stream } ", associating it with the object. If formatted output is supported, the string will become a clickable presentation of the object, otherwise this word behaves like a call to " { $link write } "." }
 $io-error ;
 
 HELP: lines
index b7d1cf81c875567381ec16ec595d0bd33cfb5227..50a798d290e2b6d6fe9e691b942e338818b1dac9 100755 (executable)
@@ -8,21 +8,18 @@ IN: io.tests
     "foo" "io.tests" lookup
 ] unit-test
 
-: <resource-reader> ( resource -- stream )
-    resource-path latin1 <file-reader> ;
-
 [
     "This is a line.\rThis is another line.\r"
 ] [
-    "core/io/test/mac-os-eol.txt" <resource-reader>
-    [ 500 read ] with-stream
+    "resource:core/io/test/mac-os-eol.txt" latin1 <file-reader>
+    [ 500 read ] with-input-stream
 ] unit-test
 
 [
     255
 ] [
-    "core/io/test/binary.txt" <resource-reader>
-    [ read1 ] with-stream >fixnum
+    "resource:core/io/test/binary.txt" latin1 <file-reader>
+    [ read1 ] with-input-stream >fixnum
 ] unit-test
 
 ! Make sure we use correct to_c_string form when writing
@@ -36,11 +33,12 @@ IN: io.tests
     }
 ] [
     [
-        "core/io/test/separator-test.txt" <resource-reader> [
+        "resource:core/io/test/separator-test.txt"
+        latin1 <file-reader> [
             "J" read-until 2array ,
             "i" read-until 2array ,
             "X" read-until 2array ,
-        ] with-stream
+        ] with-input-stream
     ] { } make
 ] unit-test
 
@@ -49,12 +47,3 @@ IN: io.tests
         10 [ 65536 read drop ] times
     ] with-file-reader
 ] unit-test
-
-! [ "" ] [ 0 read ] unit-test
-
-! [ ] [ "123" write 9000 CHAR: x <string> write flush ] unit-test
-
-! [
-!     "/core/io/test/binary.txt" <resource-reader>
-!     [ 0.2 read ] with-stream
-! ] must-fail
index ef9eae790286118ace704db838437566f2cc4594..e28fd28fb399e4828d1f662cfa185de91eb9b666 100755 (executable)
@@ -30,39 +30,52 @@ GENERIC: stream-write-table ( table-cells style stream -- )
     [ 2dup (stream-copy) ] [ dispose dispose ] [ ]
     cleanup ;
 
-! Default stream
-SYMBOL: stdio
+! Default streams
+SYMBOL: input-stream
+SYMBOL: output-stream
+SYMBOL: error-stream
 
-! Default error stream
-SYMBOL: stderr
+: readln ( -- str/f ) input-stream get stream-readln ;
+: read1 ( -- ch/f ) input-stream get stream-read1 ;
+: read ( n -- str/f ) input-stream get stream-read ;
+: read-until ( seps -- str/f sep/f ) input-stream get stream-read-until ;
 
-: readln ( -- str/f ) stdio get stream-readln ;
-: read1 ( -- ch/f ) stdio get stream-read1 ;
-: read ( n -- str/f ) stdio get stream-read ;
-: read-until ( seps -- str/f sep/f ) stdio get stream-read-until ;
+: write1 ( ch -- ) output-stream get stream-write1 ;
+: write ( str -- ) output-stream get stream-write ;
+: flush ( -- ) output-stream get stream-flush ;
 
-: write1 ( ch -- ) stdio get stream-write1 ;
-: write ( str -- ) stdio get stream-write ;
-: flush ( -- ) stdio get stream-flush ;
+: nl ( -- ) output-stream get stream-nl ;
+: format ( str style -- ) output-stream get stream-format ;
 
-: nl ( -- ) stdio get stream-nl ;
-: format ( str style -- ) stdio get stream-format ;
+: with-input-stream* ( stream quot -- )
+    input-stream swap with-variable ; inline
 
-: with-stream* ( stream quot -- )
-    stdio swap with-variable ; inline
+: with-input-stream ( stream quot -- )
+    [ with-input-stream* ] curry with-disposal ; inline
 
-: with-stream ( stream quot -- )
-    [ with-stream* ] curry with-disposal ; inline
+: with-output-stream* ( stream quot -- )
+    output-stream swap with-variable ; inline
+
+: with-output-stream ( stream quot -- )
+    [ with-output-stream* ] curry with-disposal ; inline
+
+: with-streams* ( input output quot -- )
+    [ output-stream set input-stream set ] prepose with-scope ; inline
+
+: with-streams ( input output quot -- )
+    [ [ with-streams* ] 3curry ]
+    [ [ drop dispose dispose ] 3curry ] 3bi
+    [ ] cleanup ; inline
 
 : tabular-output ( style quot -- )
-    swap >r { } make r> stdio get stream-write-table ; inline
+    swap >r { } make r> output-stream get stream-write-table ; inline
 
 : with-row ( quot -- )
     { } make , ; inline
 
 : with-cell ( quot -- )
-    H{ } stdio get make-cell-stream
-    [ swap with-stream ] keep , ; inline
+    H{ } output-stream get make-cell-stream
+    [ swap with-output-stream ] keep , ; inline
 
 : write-cell ( str -- )
     [ write ] with-cell ; inline
@@ -71,13 +84,14 @@ SYMBOL: stderr
     swap dup assoc-empty? [
         drop call
     ] [
-        stdio get make-span-stream swap with-stream
+        output-stream get make-span-stream swap with-output-stream
     ] if ; inline
 
 : with-nesting ( style quot -- )
-    >r stdio get make-block-stream r> with-stream ; inline
+    >r output-stream get make-block-stream
+    r> with-output-stream ; inline
 
-: print ( string -- ) stdio get stream-print ;
+: print ( string -- ) output-stream get stream-print ;
 
 : bl ( -- ) " " write ;
 
@@ -85,9 +99,9 @@ SYMBOL: stderr
     presented associate format ;
 
 : lines ( stream -- seq )
-    [ [ readln dup ] [ ] [ drop ] unfold ] with-stream ;
+    [ [ readln dup ] [ ] [ drop ] unfold ] with-input-stream ;
 
 : contents ( stream -- str )
     [
         [ 65536 read dup ] [ ] [ drop ] unfold concat f like
-    ] with-stream  ;
+    ] with-input-stream ;
index 741725af41f4c94d04d584aeef62c2caca2f3b28..7b276213437770bee91e8a05612f67a2997efb53 100644 (file)
@@ -25,10 +25,10 @@ HELP: <byte-writer>
 HELP: with-byte-reader
 { $values { "encoding" "an encoding descriptor" }
     { "quot" quotation } { "byte-array" byte-array } }
-{ $description "Calls the quotation in a new dynamic scope with " { $link stdio } " rebound to an input stream for reading from a byte array using an encoding." } ;
+{ $description "Calls the quotation in a new dynamic scope with " { $link input-stream } " rebound to an input stream for reading from a byte array using an encoding." } ;
 
 HELP: with-byte-writer
 { $values  { "encoding" "an encoding descriptor" }
     { "quot" quotation }
     { "byte-array" byte-array } }
-{ $description "Calls the quotation in a new dynamic scope with " { $link stdio } " rebound to an output stream writing data to a byte array using an encoding." } ;
+{ $description "Calls the quotation in a new dynamic scope with " { $link output-stream } " rebound to an output stream writing data to a byte array using an encoding." } ;
index 2a8441ff23d6894fc6df312862603969740ccf1f..28d789d66f1ee514e070746c74d422c9307e412c 100644 (file)
@@ -1,16 +1,16 @@
 USING: byte-arrays byte-vectors kernel io.encodings io.streams.string
-sequences io namespaces io.encodings.private ;
+sequences io namespaces io.encodings.private accessors ;
 IN: io.streams.byte-array
 
 : <byte-writer> ( encoding -- stream )
     512 <byte-vector> swap <encoder> ;
 
 : with-byte-writer ( encoding quot -- byte-array )
-    >r <byte-writer> r> [ stdio get ] compose with-stream*
-    dup encoder? [ encoder-stream ] when >byte-array ; inline
+    >r <byte-writer> r> [ output-stream get ] compose with-output-stream*
+    dup encoder? [ stream>> ] when >byte-array ; inline
 
 : <byte-reader> ( byte-array encoding -- stream )
     >r >byte-vector dup reverse-here r> <decoder> ;
 
 : with-byte-reader ( byte-array encoding quot -- )
-    >r <byte-reader> r> with-stream ; inline
+    >r <byte-reader> r> with-input-stream* ; inline
index 372acbe0c1e2ebfa418009457ef1ffac042bdce2..91732f3211b9f1739a26ce30c632b3509c742570 100755 (executable)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel kernel.private namespaces io io.encodings
 sequences math generic threads.private classes io.backend
-io.streams.duplex io.files continuations byte-arrays ;
+io.files continuations byte-arrays ;
 IN: io.streams.c
 
 TUPLE: c-writer handle ;
diff --git a/core/io/streams/duplex/authors.txt b/core/io/streams/duplex/authors.txt
deleted file mode 100644 (file)
index 1901f27..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Slava Pestov
diff --git a/core/io/streams/duplex/duplex-docs.factor b/core/io/streams/duplex/duplex-docs.factor
deleted file mode 100755 (executable)
index c9691af..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-USING: help.markup help.syntax io continuations ;
-IN: io.streams.duplex
-
-ARTICLE: "io.streams.duplex" "Duplex streams"
-"Duplex streams combine an input stream and an output stream into a bidirectional stream."
-{ $subsection duplex-stream }
-{ $subsection <duplex-stream> } ;
-
-ABOUT: "io.streams.duplex"
-
-HELP: duplex-stream
-{ $class-description "A bidirectional stream wrapping an input and output stream." } ;
-
-HELP: <duplex-stream>
-{ $values { "in" "an input stream" } { "out" "an output stream" } { "stream" " a duplex stream" } }
-{ $description "Creates a duplex stream. Writing to a duplex stream will write to " { $snippet "out" } ", and reading from a duplex stream will read from " { $snippet "in" } ". Closing a duplex stream closes both the input and output streams." } ;
-
-HELP: stream-closed-twice
-{ $error-description "This error is thrown when performing an I/O operation on a " { $link duplex-stream } " which has been closed with " { $link dispose } "." } ;
diff --git a/core/io/streams/duplex/duplex-tests.factor b/core/io/streams/duplex/duplex-tests.factor
deleted file mode 100755 (executable)
index ebc6b3b..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-USING: io.streams.duplex io kernel continuations tools.test ;
-IN: io.streams.duplex.tests
-
-! Test duplex stream close behavior
-TUPLE: closing-stream closed? ;
-
-: <closing-stream> closing-stream new ;
-
-M: closing-stream dispose
-    dup closing-stream-closed? [
-        "Closing twice!" throw
-    ] [
-        t swap set-closing-stream-closed?
-    ] if ;
-
-TUPLE: unclosable-stream ;
-
-: <unclosable-stream> unclosable-stream new ;
-
-M: unclosable-stream dispose
-    "Can't close me!" throw ;
-
-[ ] [
-    <closing-stream> <closing-stream> <duplex-stream>
-    dup dispose dispose
-] unit-test
-
-[ t ] [
-    <unclosable-stream> <closing-stream> [
-        <duplex-stream>
-        [ dup dispose ] [ 2drop ] recover
-    ] keep closing-stream-closed?
-] unit-test
-
-[ t ] [
-    <closing-stream> [ <unclosable-stream>
-        <duplex-stream>
-        [ dup dispose ] [ 2drop ] recover
-    ] keep closing-stream-closed?
-] unit-test
diff --git a/core/io/streams/duplex/duplex.factor b/core/io/streams/duplex/duplex.factor
deleted file mode 100755 (executable)
index 40f0cb6..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-! Copyright (C) 2005, 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: kernel continuations io accessors ;
-IN: io.streams.duplex
-
-! We ensure that the stream can only be closed once, to preserve
-! integrity of duplex I/O ports.
-
-TUPLE: duplex-stream in out closed ;
-
-: <duplex-stream> ( in out -- stream )
-    f duplex-stream boa ;
-
-ERROR: stream-closed-twice ;
-
-<PRIVATE
-
-: check-closed ( stream -- stream )
-    dup closed>> [ stream-closed-twice ] when ; inline
-
-: in ( duplex -- stream ) check-closed in>> ;
-
-: out ( duplex -- stream ) check-closed out>> ;
-
-PRIVATE>
-
-M: duplex-stream stream-flush
-    out stream-flush ;
-
-M: duplex-stream stream-readln
-    in stream-readln ;
-
-M: duplex-stream stream-read1
-    in stream-read1 ;
-
-M: duplex-stream stream-read-until
-    in stream-read-until ;
-
-M: duplex-stream stream-read-partial
-    in stream-read-partial ;
-
-M: duplex-stream stream-read
-    in stream-read ;
-
-M: duplex-stream stream-write1
-    out stream-write1 ;
-
-M: duplex-stream stream-write
-    out stream-write ;
-
-M: duplex-stream stream-nl
-    out stream-nl ;
-
-M: duplex-stream stream-format
-    out stream-format ;
-
-M: duplex-stream make-span-stream
-    out make-span-stream ;
-
-M: duplex-stream make-block-stream
-    out make-block-stream ;
-
-M: duplex-stream make-cell-stream
-    out make-cell-stream ;
-
-M: duplex-stream stream-write-table
-    out stream-write-table ;
-
-M: duplex-stream dispose
-    #! The output stream is closed first, in case both streams
-    #! are attached to the same file descriptor, the output
-    #! buffer needs to be flushed before we close the fd.
-    dup closed>> [
-        t >>closed
-        [ dup out>> dispose ]
-        [ dup in>> dispose ] [ ] cleanup
-    ] unless drop ;
diff --git a/core/io/streams/duplex/summary.txt b/core/io/streams/duplex/summary.txt
deleted file mode 100644 (file)
index b15d3aa..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Combine an input and an output stream into a single duplex stream
index 5b09baa56d06e10f37a5543272b9cb45156d4010..b87e5ca59139838bc0cf9a0316191953e3658060 100644 (file)
@@ -17,7 +17,7 @@ HELP: <string-writer>
 
 HELP: with-string-writer
 { $values { "quot" quotation } { "str" string } }
-{ $description "Calls the quotation in a new dynamic scope with " { $link stdio } " rebound to a new string writer. The accumulated string is output when the quotation returns." } ;
+{ $description "Calls the quotation in a new dynamic scope with " { $link output-stream } " rebound to a new string writer. The accumulated string is output when the quotation returns." } ;
 
 HELP: <string-reader>
 { $values { "str" string } { "stream" "an input stream" } }
@@ -26,4 +26,4 @@ HELP: <string-reader>
 
 HELP: with-string-reader
 { $values { "str" string } { "quot" quotation } }
-{ $description "Calls the quotation in a new dynamic scope with " { $link stdio } " rebound to an input stream reading " { $snippet "str" } " from beginning to end." } ;
+{ $description "Calls the quotation in a new dynamic scope with " { $link input-stream } " rebound to an input stream reading " { $snippet "str" } " from beginning to end." } ;
index ca117534da460783c0ac760030998278204ec1a1..3512ac871db8010701cb59f1254707e3eeab0e48 100644 (file)
@@ -35,7 +35,7 @@ unit-test
             "J" read-until 2array ,
             "i" read-until 2array ,
             "X" read-until 2array ,
-        ] with-stream
+        ] with-input-stream
     ] { } make
 ] unit-test
 
index 531d0401b217d6882d93abd951a1c5123d3d09b9..d43599776b6ee62c761075c767a499e77a85232d 100755 (executable)
@@ -15,7 +15,7 @@ M: growable stream-flush drop ;
     512 <sbuf> ;
 
 : with-string-writer ( quot -- str )
-    <string-writer> swap [ stdio get ] compose with-stream*
+    <string-writer> swap [ output-stream get ] compose with-output-stream*
     >string ; inline
 
 M: growable stream-read1 dup empty? [ drop f ] [ pop ] if ;
@@ -56,7 +56,7 @@ M: null decode-char drop stream-read1 ;
     >sbuf dup reverse-here null <decoder> ;
 
 : with-string-reader ( str quot -- )
-    >r <string-reader> r> with-stream ; inline
+    >r <string-reader> r> with-input-stream ; inline
 
 INSTANCE: growable plain-writer
 
@@ -67,15 +67,14 @@ INSTANCE: growable plain-writer
     ] unless ;
 
 : map-last ( seq quot -- seq )
-    swap dup length <reversed>
-    [ zero? rot [ call ] keep swap ] 2map nip ; inline
+    >r dup length <reversed> [ zero? ] r> compose 2map ; inline
 
 : format-table ( table -- seq )
     flip [ format-column ] map-last
     flip [ " " join ] map ;
 
 M: plain-writer stream-write-table
-    [ drop format-table [ print ] each ] with-stream* ;
+    [ drop format-table [ print ] each ] with-output-stream* ;
 
 M: plain-writer make-cell-stream 2drop <string-writer> ;
 
index 755c79ac6884fca4ea21e5cf6b1937b43307070c..beea9005b4c440d1f63e47fcdf83f2cdbcd12bdf 100755 (executable)
@@ -32,14 +32,14 @@ HELP: listener-hook
 
 HELP: read-quot
 { $values { "quot/f" "a parsed quotation, or " { $link f } " indicating end of file" } }
-{ $description "Reads a Factor expression which possibly spans more than one line from " { $link stdio } " stream. Additional lines of input are read while the parser stack height is greater than one. Since structural parsing words push partial quotations on the stack, this will keep on reading input until all delimited parsing words are terminated." } ;
+{ $description "Reads a Factor expression which possibly spans more than one line from " { $link input-stream } ". Additional lines of input are read while the parser stack height is greater than one. Since structural parsing words push partial quotations on the stack, this will keep on reading input until all delimited parsing words are terminated." } ;
 
 HELP: listen
-{ $description "Prompts for an expression on the " { $link stdio } " stream and evaluates it. On end of file, " { $link quit-flag } " is set to terminate the listener loop." }
-{ $errors "If the expression input by the user throws an error, the error is printed to the " { $link stdio } " stream and the word returns normally." } ;
+{ $description "Prompts for an expression on " { $link input-stream } " and evaluates it. On end of file, " { $link quit-flag } " is set to terminate the listener loop." }
+{ $errors "If the expression input by the user throws an error, the error is printed to " { $link output-stream } " and the word returns normally." } ;
 
 HELP: listener
-{ $description "Prompts for expressions on the " { $link stdio } " stream and evaluates them until end of file is reached." } ;
+{ $description "Prompts for expressions on " { $link input-stream } " and evaluates them until end of file is reached." } ;
 
 HELP: bye
 { $description "Exits the current listener." }
index 2c05c049a77d0b1398d0113bcfe62126765cba08..24449049e02fbf706a7c4bf25c11226a7a575220 100755 (executable)
@@ -51,6 +51,6 @@ IN: listener.tests
 [
     [ ] [
         "IN: listener.tests : hello\n\"world\" ;" parse-interactive
-    drop
+        drop
     ] unit-test
 ] with-file-vocabs
index ddb29bb7686ddfa10ae5731b37b763027304f0c7..e00e64f4bcfc7e0f0d656747760bb687071eb86e 100755 (executable)
@@ -2,8 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays hashtables io kernel math math.parser memory
 namespaces parser sequences strings io.styles
-io.streams.duplex vectors words generic system combinators
-continuations debugger definitions compiler.units accessors ;
+vectors words generic system combinators continuations debugger
+definitions compiler.units accessors ;
 IN: listener
 
 SYMBOL: quit-flag
@@ -35,10 +35,7 @@ GENERIC: stream-read-quot ( stream -- quot/f )
 M: object stream-read-quot
     V{ } clone read-quot-loop ;
 
-M: duplex-stream stream-read-quot
-    duplex-stream-in stream-read-quot ;
-
-: read-quot ( -- quot/f ) stdio get stream-read-quot ;
+: read-quot ( -- quot/f ) input-stream get stream-read-quot ;
 
 : bye ( -- ) quit-flag on ;
 
@@ -46,9 +43,13 @@ M: duplex-stream stream-read-quot
     "( " in get " )" 3append
     H{ { background { 1 0.7 0.7 1 } } } format bl flush ;
 
+SYMBOL: error-hook
+
+[ print-error-and-restarts ] error-hook set-global
+
 : listen ( -- )
     listener-hook get call prompt.
-    [ read-quot [ try ] [ bye ] if* ]
+    [ read-quot [ [ error-hook get call ] recover ] [ bye ] if* ]
     [
         dup parse-error? [
             error-hook get call
index 98ff1920fa2fa9c4b822583ff1d580a743a26ca7..23ea1058ad92b8c648f151cd6963c26a80fba58c 100644 (file)
@@ -25,8 +25,8 @@ HELP: +gt+
 { $description "Returned by " { $link <=> } " when the first object is strictly greater than the second object." } ;
 
 HELP: invert-comparison
-{ $values { "symbol" "a comparison symbol, +lt+, +eq+, or +gt+" }
-          { "new-symbol" "a comparison symbol, +lt+, +eq+, or +gt+" } }
+{ $values { "symbol" symbol }
+          { "new-symbol" symbol } }
 { $description "Invert the comparison symbol returned by " { $link <=> } ". The output for the symbol " { $snippet "+eq+" } " is itself." }
 { $examples
     { $example "USING: math.order prettyprint ;" "+lt+ invert-comparison ." "+gt+" } } ;
index baa6634a9fb01eeeeb5acddc9089b8740c17b848..15234ee3108b60c7f8aaae478f1909e57fdedca8 100755 (executable)
@@ -98,3 +98,9 @@ unit-test
 [ 1 1 >base ] must-fail
 [ 1 0 >base ] must-fail
 [ 1 -1 >base ] must-fail
+
+[ "0.0/0.0" ] [ 0.0 0.0 / number>string ] unit-test
+
+[ "1.0/0.0" ] [ 1.0 0.0 / number>string ] unit-test
+
+[ "-1.0/0.0" ] [ -1.0 0.0 / number>string ] unit-test
index 1a1a080564ab1637cbd92e13fde0e0069631ed62..d1b8e6fd37dafc30fbdc6fa09a3a0d1d7dcf0e6e 100755 (executable)
@@ -140,9 +140,9 @@ M: ratio >base
 
 M: float >base
     drop {
+        { [ dup fp-nan? ] [ drop "0.0/0.0" ] }
         { [ dup 1.0/0.0 = ] [ drop "1.0/0.0" ] }
         { [ dup -1.0/0.0 = ] [ drop "-1.0/0.0" ] }
-        { [ dup fp-nan? ] [ drop "0.0/0.0" ] }
         [ float>string fix-float ]
     } cond ;
 
index ef829da9f2796fbd397a47e5ddccdd5706480464..f49ab7fcba8bc57c559a38e28153692c9acdce10 100755 (executable)
@@ -1,6 +1,6 @@
 IN: optimizer.def-use.tests
 USING: inference inference.dataflow optimizer optimizer.def-use
-namespaces assocs kernel sequences math tools.test words ;
+namespaces assocs kernel sequences math tools.test words sets ;
 
 [ 3 { 1 1 1 } ] [
     [ 1 2 3 ] dataflow compute-def-use drop
index b69985fb1d34f108799e8c02b4fcbefca042d0cf..418278baeedea73385999404db1b0d97126311af 100755 (executable)
@@ -5,7 +5,7 @@ quotations namespaces compiler.units assocs ;
 IN: parser
 
 ARTICLE: "vocabulary-search-shadow" "Shadowing word names"
-"If adding a vocabulary to the search path results in a word in another vocabulary becoming inaccessible due to the new vocabulary defining a word with the same name, a message is printed to the " { $link stdio } " stream. Except when debugging suspected name clashes, these messages can be ignored."
+"If adding a vocabulary to the search path results in a word in another vocabulary becoming inaccessible due to the new vocabulary defining a word with the same name, we say that the old word has been " { $emphasis "shadowed" } "."
 $nl
 "Here is an example where shadowing occurs:"
 { $code
@@ -13,18 +13,18 @@ $nl
     "USING: sequences io ;"
     ""
     ": append"
-    "    \"foe::append calls sequences::append\" print  append ;"
+    "    \"foe::append calls sequences:append\" print  append ;"
     ""
     "IN: fee"
     ""
     ": append"
-    "    \"fee::append calls fee::append\" print  append ;"
+    "    \"fee::append calls fee:append\" print  append ;"
     ""
     "IN: fox"
     "USE: foe"
     ""
     ": append"
-    "    \"fox::append calls foe::append\" print  append ;"
+    "    \"fox::append calls foe:append\" print  append ;"
     ""
     "\"1234\" \"5678\" append print"
     ""
@@ -33,12 +33,13 @@ $nl
 }
 "When placed in a source file and run, the above code produces the following output:"
 { $code
-    "foe::append calls sequences::append"
+    "foe:append calls sequences:append"
     "12345678"
-    "fee::append calls foe::append"
-    "foe::append calls sequences::append"
+    "fee:append calls foe:append"
+    "foe:append calls sequences:append"
     "12345678"
-} ;
+}
+"The " { $vocab-link "qualified" } " vocabulary contains some tools for helping with shadowing." ;
 
 ARTICLE: "vocabulary-search-errors" "Word lookup errors"
 "If the parser cannot not find a word in the current vocabulary search path, it attempts to look for the word in all loaded vocabularies. Then, one of three things happen:"
@@ -215,7 +216,7 @@ HELP: save-location
 { $description "Saves the location of a definition and associates this definition with the current source file." } ;
 
 HELP: parser-notes
-{ $var-description "A boolean controlling whether the parser will print various notes and warnings. Switched on by default. If a source file is being run for its effect on the " { $link stdio } " stream, this variable should be switched off, to prevent parser notes from polluting the output." } ;
+{ $var-description "A boolean controlling whether the parser will print various notes and warnings. Switched on by default. If a source file is being run for its effect on " { $link output-stream } ", this variable should be switched off, to prevent parser notes from polluting the output." } ;
 
 HELP: parser-notes?
 { $values { "?" "a boolean" } }
@@ -506,7 +507,7 @@ HELP: bootstrap-file
 
 HELP: eval>string
 { $values { "str" string } { "output" string } }
-{ $description "Evaluates the Factor code in " { $snippet "str" } " with the " { $link stdio } " stream rebound to a string output stream, then outputs the resulting string." } ;
+{ $description "Evaluates the Factor code in " { $snippet "str" } " with " { $link output-stream } " rebound to a string output stream, then outputs the resulting string." } ;
 
 HELP: staging-violation
 { $values { "word" word } }
index 2933c8ee6fc943b2cfe3a5db8d396f4f6fc84894..f7f0f7ee4496c69132288a57cc7e2e8114d5901b 100755 (executable)
@@ -135,7 +135,7 @@ ARTICLE: "prettyprint" "The prettyprinter"
 $nl
 "Prettyprinter words are found in the " { $vocab-link "prettyprint" } " vocabulary."
 $nl
-"The key words to print an object to the " { $link stdio } " stream; the first two emit a trailing newline, the second two do not:"
+"The key words to print an object to " { $link output-stream } "; the first two emit a trailing newline, the second two do not:"
 { $subsection . }
 { $subsection short. }
 { $subsection pprint }
@@ -161,17 +161,17 @@ ABOUT: "prettyprint"
 
 HELP: with-pprint
 { $values { "obj" object } { "quot" quotation } }
-{ $description "Sets up the prettyprinter and calls the quotation in a new scope. The quotation should add sections to the top-level block. When the quotation returns, the top-level block is printed to the " { $link stdio } " stream." } ;
+{ $description "Sets up the prettyprinter and calls the quotation in a new scope. The quotation should add sections to the top-level block. When the quotation returns, the top-level block is printed to " { $link output-stream } "." } ;
 
 HELP: pprint
 { $values { "obj" object } }
-{ $description "Prettyprints an object to the " { $link stdio } " stream. Output is influenced by many variables; see " { $link "prettyprint-variables" } "." } ;
+{ $description "Prettyprints an object to " { $link output-stream } ". Output is influenced by many variables; see " { $link "prettyprint-variables" } "." } ;
 
 { pprint pprint* with-pprint } related-words
 
 HELP: .
 { $values { "obj" object } }
-{ $description "Prettyprints an object to the " { $link stdio } " stream with a trailing line break. Output is influenced by many variables; see " { $link "prettyprint-variables" } "." } ;
+{ $description "Prettyprints an object to " { $link output-stream } " with a trailing line break. Output is influenced by many variables; see " { $link "prettyprint-variables" } "." } ;
 
 HELP: unparse
 { $values { "obj" object } { "str" "Factor source string" } }
@@ -179,11 +179,11 @@ HELP: unparse
 
 HELP: pprint-short
 { $values { "obj" object } }
-{ $description "Prettyprints an object to the " { $link stdio } " stream. This word rebinds printer control variables to enforce ``shorter'' output. See " { $link "prettyprint-variables" } "." } ;
+{ $description "Prettyprints an object to " { $link output-stream } ". This word rebinds printer control variables to enforce ``shorter'' output. See " { $link "prettyprint-variables" } "." } ;
 
 HELP: short.
 { $values { "obj" object } }
-{ $description "Prettyprints an object to the " { $link stdio } " stream with a trailing line break. This word rebinds printer control variables to enforce ``shorter'' output." } ;
+{ $description "Prettyprints an object to " { $link output-stream } " with a trailing line break. This word rebinds printer control variables to enforce ``shorter'' output." } ;
 
 HELP: .b
 { $values { "n" "an integer" } }
index e94670992c67c5c6b1354de70f4aa3e95e3dede0..0faae398e934d68a169a5b9e51a7af967aebe50a 100755 (executable)
@@ -114,7 +114,7 @@ unit-test
             [ parse-fresh drop ] with-compilation-unit
             [
                 "prettyprint.tests" lookup see
-            ] with-string-writer "\n" split 1 head*
+            ] with-string-writer "\n" split but-last
         ] keep =
     ] with-scope ;
 
index ceb37c2fe40ea5a59ef5862b372c14e3cdc17c68..842a36a13b5163feff5409e9032b1541f05d93c8 100755 (executable)
@@ -15,7 +15,7 @@ HELP: line-limit?
 
 
 HELP: do-indent
-{ $description "Outputs the current indent nesting to the " { $link stdio } " stream." } ;
+{ $description "Outputs the current indent nesting to " { $link output-stream } "." } ;
 
 HELP: fresh-line
 { $values { "n" "the current column position" } }
index 5f32539115ec02e49a865b40d4d21cd7d159b091..11fa4da28ee990199377ef7de0760d3134822b15 100644 (file)
@@ -15,9 +15,9 @@ SYMBOL: pprinter-stack
 SYMBOL: pprinter-in
 SYMBOL: pprinter-use
 
-TUPLE: pprinter last-newline line-count end-printing indent ;
+TUPLE: pprinter last-newline line-count indent ;
 
-: <pprinter> ( -- pprinter ) 0 1 0 pprinter boa ;
+: <pprinter> ( -- pprinter ) 0 1 0 pprinter boa ;
 
 : record-vocab ( word -- )
     word-vocabulary [ dup pprinter-use get set-at ] when* ;
@@ -34,7 +34,7 @@ TUPLE: pprinter last-newline line-count end-printing indent ;
     ] [
         pprinter get (>>last-newline)
         line-limit? [
-            "..." write pprinter get end-printing>> continue
+            "..." write pprinter get return
         ] when
         pprinter get [ 1+ ] change-line-count drop
         nl do-indent
@@ -275,16 +275,15 @@ M: colon unindent-first-line? drop t ;
         [
             dup style>> [
                 [
-                    >r pprinter get (>>end-printing) r>
                     short-section
-                ] curry callcc0
+                ] curry with-return
             ] with-nesting
         ] if-nonempty
     ] with-variable ;
 
 ! Long section layout algorithm
 : chop-break ( seq -- seq )
-    dup peek line-break? [ 1 head-slice* chop-break ] when ;
+    dup peek line-break? [ but-last-slice chop-break ] when ;
 
 SYMBOL: prev
 SYMBOL: next
index 2a2fcf29cd7f7a6e9c06bb972b715b47b1756638..8b15f5b980bd8ec3d6b0ac995668a96cb6af61b3 100755 (executable)
@@ -92,9 +92,11 @@ ARTICLE: "sequences-slices" "Subsequences and slices"
 { $subsection subseq }
 { $subsection head }
 { $subsection tail }
-{ $subsection rest }
 { $subsection head* }
 { $subsection tail* }
+"Removing the first or last element:"
+{ $subsection rest }
+{ $subsection but-last }
 "Taking a sequence apart into a head and a tail:"
 { $subsection unclip }
 { $subsection cut }
@@ -106,6 +108,7 @@ ARTICLE: "sequences-slices" "Subsequences and slices"
 { $subsection <slice> }
 { $subsection head-slice }
 { $subsection tail-slice }
+{ $subsection but-last-slice }
 { $subsection rest-slice }
 { $subsection head-slice* }
 { $subsection tail-slice* }
@@ -836,11 +839,16 @@ HELP: tail-slice
 { $description "Outputs a virtual sequence sharing storage with all elements from the " { $snippet "n" } "th index until the end of the input sequence." }
 { $errors "Throws an error if the index is out of bounds." } ;
 
+HELP: but-last-slice
+{ $values { "seq" sequence } { "slice" "a slice" } }
+{ $description "Outputs a virtual sequence sharing storage with all but the last element of the input sequence." }
+{ $errors "Throws an error on an empty sequence." } ;
+
 HELP: rest-slice
 { $values { "seq" sequence } { "slice" "a slice" } }
 { $description "Outputs a virtual sequence sharing storage with all elements from the 1st index until the end of the input sequence." }
 { $notes "Equivalent to " { $snippet "1 tail" } }
-{ $errors "Throws an error if the index is out of bounds." } ;
+{ $errors "Throws an error on an empty sequence." } ;
 
 HELP: head-slice*
 { $values { "seq" sequence } { "n" "a non-negative integer" } { "slice" "a slice" } }
@@ -862,6 +870,11 @@ HELP: tail
 { $description "Outputs a new sequence consisting of the input sequence with the first n items removed." }
 { $errors "Throws an error if the index is out of bounds." } ;
 
+HELP: but-last
+{ $values { "seq" sequence } { "headseq" "a new sequence" } }
+{ $description "Outputs a new sequence consisting of the input sequence with the last item removed." }
+{ $errors "Throws an error on an empty sequence." } ;
+
 HELP: rest
 { $values { "seq" sequence } { "tailseq" "a new sequence" } }
 { $description "Outputs a new sequence consisting of the input sequence with the first item removed." }
index a63e6d28359d9ceaf0ab5b2f819e3e5dd3c35cc0..8d0e3eec18d5512bbc0d3e9af2e4596482f63e99 100755 (executable)
@@ -216,6 +216,8 @@ M: slice length dup slice-to swap slice-from - ;
 
 : tail-slice* ( seq n -- slice ) from-end tail-slice ;
 
+: but-last-slice ( seq -- slice ) 1 head-slice* ;
+
 INSTANCE: slice virtual-sequence
 
 ! One element repeated many times
@@ -263,6 +265,8 @@ PRIVATE>
 
 : tail* ( seq n -- tailseq ) from-end tail ;
 
+: but-last ( seq -- headseq ) 1 head* ;
+
 : copy ( src i dst -- )
     pick length >r 3dup check-copy spin 0 r>
     (copy) drop ; inline
@@ -670,9 +674,15 @@ PRIVATE>
 : unclip ( seq -- rest first )
     [ rest ] [ first ] bi ;
 
+: unclip-last ( seq -- butfirst last )
+    [ but-last ] [ peek ] bi ;
+
 : unclip-slice ( seq -- rest first )
     [ rest-slice ] [ first ] bi ;
 
+: unclip-last-slice ( seq -- butfirst last )
+    [ but-last-slice ] [ peek ] bi ;
+
 : <flat-slice> ( seq -- slice )
     dup slice? [ { } like ] when 0 over length rot <slice> ;
     inline
index eb10b9fe4a044abc407e38d762a9799b77a545eb..9f6ae75d321dc5b3463f3481752a0e9bb208ddbd 100755 (executable)
@@ -1,42 +1,72 @@
-! Copyright (C) 2005, 2007 Slava Pestov.
+! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel math namespaces strings arrays vectors sequences
-sets math.order ;
+sets math.order accessors ;
 IN: splitting
 
-TUPLE: groups seq n sliced? ;
+TUPLE: abstract-groups seq n ;
 
-: check-groups 0 <= [ "Invalid group count" throw ] when ;
+: check-groups dup 0 <= [ "Invalid group count" throw ] when ; inline
 
-: <groups> ( seq n -- groups )
-    dup check-groups f groups boa ; inline
+: construct-groups ( seq n class -- groups )
+    >r check-groups r> boa ; inline
 
-: <sliced-groups> ( seq n -- groups )
-    <groups> t over set-groups-sliced? ;
+GENERIC: group@ ( n groups -- from to seq )
+
+M: abstract-groups nth group@ subseq ;
+
+M: abstract-groups set-nth group@ <slice> 0 swap copy ;
+
+M: abstract-groups like drop { } like ;
+
+INSTANCE: abstract-groups sequence
+
+TUPLE: groups < abstract-groups ;
+
+: <groups> ( seq n -- groups )
+    groups construct-groups ; inline
 
 M: groups length
-    dup groups-seq length swap groups-n [ + 1- ] keep /i ;
+    [ seq>> length ] [ n>> ] bi [ + 1- ] keep /i ;
 
 M: groups set-length
-    [ groups-n * ] keep groups-seq set-length ;
+    [ n>> * ] [ seq>> ] bi set-length ;
 
-: group@ ( n groups -- from to seq )
-    [ groups-n [ * dup ] keep + ] keep
-    groups-seq [ length min ] keep ;
+M: groups group@
+    [ n>> [ * dup ] keep + ] [ seq>> ] bi [ length min ] keep ;
 
-M: groups nth
-    [ group@ ] keep
-    groups-sliced? [ <slice> ] [ subseq ] if ;
+TUPLE: sliced-groups < groups ;
 
-M: groups set-nth
-    group@ <slice> 0 swap copy ;
+: <sliced-groups> ( seq n -- groups )
+    sliced-groups construct-groups ; inline
+
+M: sliced-groups nth group@ <slice> ;
+
+TUPLE: clumps < abstract-groups ;
+
+: <clumps> ( seq n -- groups )
+    clumps construct-groups ; inline
+
+M: clumps length
+    [ seq>> length ] [ n>> ] bi - 1+ ;
 
-M: groups like drop { } like ;
+M: clumps set-length
+    [ n>> + 1- ] [ seq>> ] bi set-length ;
 
-INSTANCE: groups sequence
+M: clumps group@
+    [ n>> over + ] [ seq>> ] bi ;
+
+TUPLE: sliced-clumps < groups ;
+
+: <sliced-clumps> ( seq n -- groups )
+    sliced-clumps construct-groups ; inline
+
+M: sliced-clumps nth group@ <slice> ;
 
 : group ( seq n -- array ) <groups> { } like ;
 
+: clump ( seq n -- array ) <clumps> { } like ;
+
 : ?head ( seq begin -- newseq ? )
     2dup head? [ length tail t ] [ drop f ] if ;
 
@@ -74,7 +104,7 @@ INSTANCE: groups sequence
         1array
     ] [
         "\n" split [
-            1 head-slice* [
+            but-last-slice [
                 "\r" ?tail drop "\r" split
             ] map
         ] keep peek "\r" split suffix concat
index 3f9ff54ac858553543d8fef5bc60cf629a5b28a3..7d8791d493c80bda4c15f0094ebaa15ab5810b86 100755 (executable)
@@ -116,10 +116,13 @@ $nl
 "Other threads may interrupt the sleep by calling " { $link interrupt } "." } ;
 
 HELP: sleep
-{ $values { "ms" "a non-negative integer" } }
-{ $description "Suspends the current thread for " { $snippet "ms" } " milliseconds."
+{ $values { "dt" "a duration" } }
+{ $description "Suspends the current thread for the given duration."
 $nl
-"Other threads may interrupt the sleep by calling " { $link interrupt } "." } ;
+"Other threads may interrupt the sleep by calling " { $link interrupt } "." }
+{ $examples
+    { $code "USING: threads calendar ;" "10 seconds sleep" }
+} ;
 
 HELP: interrupt
 { $values { "thread" thread } }
index 0ac607f0ede98baf658806fe7f19a73838079a3c..0e33ccd94cde7365dd7256771886afdf5d53a0fa 100755 (executable)
@@ -1,5 +1,6 @@
 USING: namespaces io tools.test threads kernel
-concurrency.combinators math ;
+concurrency.combinators concurrency.promises locals math
+words ;
 IN: threads.tests
 
 3 "x" set
@@ -27,3 +28,16 @@ yield
         "i" tget
     ] parallel-map
 ] unit-test
+
+[ [ 3 throw ] "A" suspend ] [ 3 = ] must-fail-with
+
+:: spawn-namespace-test ( -- )
+    [let | p [ <promise> ] g [ gensym ] |
+        [
+            g "x" set
+            [ "x" get p fulfill ] "B" spawn drop
+        ] with-scope
+        p ?promise g eq?
+    ] ;
+
+[ t ] [ spawn-namespace-test ] unit-test
index 8b89cd5732ffdba3018438f494bc09dfef7f6c02..a1c7e208dc15021682ed287dd43a9ec6c62eb53c 100755 (executable)
@@ -12,7 +12,7 @@ SYMBOL: initial-thread
 TUPLE: thread
 name quot exit-handler
 id
-continuation state
+continuation state runnable
 mailbox variables sleep-entry ;
 
 : self ( -- thread ) 40 getenv ; inline
@@ -91,9 +91,11 @@ PRIVATE>
         [ sleep-queue heap-peek nip millis [-] ]
     } cond ;
 
+DEFER: stop
+
 <PRIVATE
 
-: schedule-sleep ( thread ms -- )
+: schedule-sleep ( thread dt -- )
     >r check-registered dup r> sleep-queue heap-push*
     >>sleep-entry drop ;
 
@@ -111,36 +113,57 @@ PRIVATE>
     [ ] while
     drop ;
 
+: start ( namestack thread -- )
+    [
+        set-self
+        set-namestack
+        V{ } set-catchstack
+        { } set-retainstack
+        { } set-datastack
+        self quot>> [ call stop ] call-clear
+    ] 2 (throw) ;
+
+DEFER: next
+
+: no-runnable-threads ( -- * )
+    ! We should never be in a state where the only threads
+    ! are sleeping; the I/O wait thread is always runnable.
+    ! However, if it dies, we handle this case
+    ! semi-gracefully.
+    !
+    ! And if sleep-time outputs f, there are no sleeping
+    ! threads either... so WTF.
+    sleep-time [ die 0 ] unless* (sleep) next ;
+
+: (next) ( arg thread -- * )
+    f >>state
+    dup set-self
+    dup runnable>> [
+        continuation>> box> continue-with
+    ] [
+        t >>runnable start
+    ] if ;
+
 : next ( -- * )
     expire-sleep-loop
     run-queue dup dlist-empty? [
-        ! We should never be in a state where the only threads
-        ! are sleeping; the I/O wait thread is always runnable.
-        ! However, if it dies, we handle this case
-        ! semi-gracefully.
-        !
-        ! And if sleep-time outputs f, there are no sleeping
-        ! threads either... so WTF.
-        drop sleep-time [ die 0 ] unless* (sleep) next
+        drop no-runnable-threads
     ] [
-        pop-back
-        dup array? [ first2 ] [ f swap ] if dup set-self
-        f >>state
-        continuation>> box>
-        continue-with
+        pop-back dup array? [ first2 ] [ f swap ] if (next)
     ] if ;
 
 PRIVATE>
 
 : stop ( -- )
-    self dup exit-handler>> call
-    unregister-thread next ;
+    self [ exit-handler>> call ] [ unregister-thread ] bi next ;
 
 : suspend ( quot state -- obj )
     [
-        self continuation>> >box
-        self (>>state)
-        self swap call next
+        >r
+        >r self swap call
+        r> self (>>state)
+        r> self continuation>> >box
+        next
     ] callcc1 2nip ; inline
 
 : yield ( -- ) [ resume ] f suspend drop ;
@@ -153,7 +176,7 @@ M: integer sleep-until
 M: f sleep-until
     drop [ drop ] "interrupt" suspend drop ;
 
-GENERIC: sleep ( ms -- )
+GENERIC: sleep ( dt -- )
 
 M: real sleep
     millis + >integer sleep-until ;
@@ -166,16 +189,7 @@ M: real sleep
     ] when drop ;
 
 : (spawn) ( thread -- )
-    [
-        resume-now [
-            dup set-self
-            dup register-thread
-            V{ } set-catchstack
-            { } set-retainstack
-            >r { } set-datastack r>
-            quot>> [ call stop ] call-clear
-        ] 1 (throw)
-    ] "spawn" suspend 2drop ;
+    [ register-thread ] [ namestack swap resume-with ] bi ;
 
 : spawn ( quot name -- thread )
     <thread> [ (spawn) ] keep ;
@@ -184,8 +198,8 @@ M: real sleep
     >r [ [ ] [ ] while ] curry r> spawn ;
 
 : in-thread ( quot -- )
-    >r datastack namestack r>
-    [ >r set-namestack set-datastack r> call ] 3curry
+    >r datastack r>
+    [ >r set-datastack r> call ] 2curry
     "Thread" spawn drop ;
 
 GENERIC: error-in-thread ( error thread -- )
@@ -199,6 +213,7 @@ GENERIC: error-in-thread ( error thread -- )
     initial-thread global
     [ drop f "Initial" <thread> ] cache
     <box> >>continuation
+    t >>runnable
     f >>state
     dup register-thread
     set-self ;
index 329ba8256d05df136459abfab482409ba7992ead..1908e28d39365d30ecb350a51850e15bca3ea173 100755 (executable)
@@ -1,16 +1,16 @@
 USING: asn1 asn1.ldap io io.streams.string tools.test ;
 
 [ 6 ] [
-    "\u000002\u000001\u000006" <string-reader> [ asn-syntax read-ber ] with-stream
+    "\u000002\u000001\u000006" <string-reader> [ asn-syntax read-ber ] with-input-stream
 ] unit-test
 
 [ "testing" ] [
-    "\u000004\u000007testing" <string-reader> [ asn-syntax read-ber ] with-stream
+    "\u000004\u000007testing" <string-reader> [ asn-syntax read-ber ] with-input-stream
 ] unit-test
 
 [ { 1 { 3 "Administrator" "ad_is_bogus" } } ] [
     "0$\u000002\u000001\u000001`\u00001f\u000002\u000001\u000003\u000004\rAdministrator\u000080\u00000bad_is_bogus"
-    <string-reader> [ asn-syntax read-ber ] with-stream
+    <string-reader> [ asn-syntax read-ber ] with-input-stream
 ] unit-test
 
 [
index 32e3602f8fa9936d166d3816d7f408239ae677cc..50102d19292973af4a694e1a2e5b727c5486a1cd 100644 (file)
@@ -98,7 +98,7 @@ DEFER: read-ber
 
 SYMBOL: end
 
-: (read-array) ( stream -- )
+: (read-array) ( -- )
     elements get element-id [
         elements get element-syntax read-ber
         dup end = [ drop ] [ , (read-array) ] if
@@ -106,7 +106,7 @@ SYMBOL: end
 
 : read-array ( -- array ) [ (read-array) ] { } make ;
 
-: set-case ( -- )
+: set-case ( -- object )
     elements get element-newobj
     elements get element-objtype {
         { "boolean" [ "\0" = not ] }
index 35d1337afc937a6f2522228f424c7b175012af63..abe3250ecfc86e1a5ba366683aaf082ce18b3284 100644 (file)
@@ -26,8 +26,6 @@ C: <transaction> transaction
 : daily-rate>> ( account date -- rate )
     [ interest-rate>> ] dip daily-rate ;
 
-: before? ( date date -- ? ) <=> 0 < ;
-
 : transactions-on-date ( account date -- transactions )
     [ before? ] curry filter ;
 
index 215b677e1620a934d8fb794de841a35dc5c81ef4..d449c0fc5b43a0d044ab4dd96a1167f844e585d0 100755 (executable)
@@ -81,7 +81,7 @@ HINTS: random fixnum ;
     write-description
     [let | k! [ 0 ] alu [ ] |
         [| len | k len alu make-repeat-fasta k! ] split-lines
-    ] with-locals ; inline
+    ] ; inline
 
 : fasta ( n out -- )
     homo-sapiens make-cumulative
@@ -103,7 +103,7 @@ HINTS: random fixnum ;
             drop
         ] with-file-writer
 
-    ] with-locals ;
+    ] ;
 
 : run-fasta 2500000 reverse-complement-in fasta ;
 
index e06b81f6deb7e49eb6195e9ae45db45b6f93d266..6bd2d69cfa50a1f58ef820243adcf15658942cb9 100644 (file)
@@ -56,7 +56,7 @@ IN: benchmark.knucleotide
     drop ;
 
 : knucleotide ( -- )
-    "extra/benchmark/knucleotide/knucleotide-input.txt" resource-path
+    "resource:extra/benchmark/knucleotide/knucleotide-input.txt"
     ascii [ read-input ] with-file-reader
     process-input ;
 
index d83b72018799976f11277f7c3726fbcbaad47d86..5fdaf49d8f4bad3132d9d25fece63910a865c497 100755 (executable)
@@ -32,13 +32,11 @@ HINTS: do-line vector string ;
     readln [ do-line (reverse-complement) ] [ show-seq ] if* ;
 
 : reverse-complement ( infile outfile -- )
-    ascii <file-writer> [
-        swap ascii <file-reader> [
-            swap <duplex-stream> [
-                500000 <vector> (reverse-complement)
-            ] with-stream
-        ] with-disposal
-    ] with-disposal ;
+    ascii [
+        ascii [
+            500000 <vector> (reverse-complement)
+        ] with-file-reader
+    ] with-file-writer ;
 
 : reverse-complement-in
     "reverse-complement-in.txt" temp-file ;
index 25212c7264ca7ad633d222a1c166ab303b3740c8..6defd94290c8fb1496da9417fb3932b676c4e311 100755 (executable)
@@ -1,6 +1,6 @@
 USING: io.sockets io kernel math threads io.encodings.ascii
-debugger tools.time prettyprint concurrency.count-downs
-namespaces arrays continuations ;
+io.streams.duplex debugger tools.time prettyprint
+concurrency.count-downs namespaces arrays continuations ;
 IN: benchmark.sockets
 
 SYMBOL: counter
@@ -10,7 +10,7 @@ SYMBOL: counter
 : server-addr "127.0.0.1" 7777 <inet4> ;
 
 : server-loop ( server -- )
-    dup accept [
+    dup accept drop [
         [
             read1 CHAR: x = [
                 "server" get dispose
@@ -30,17 +30,17 @@ SYMBOL: counter
     ] ignore-errors ;
 
 : simple-client ( -- )
-    server-addr ascii <client> [
+    server-addr ascii [
         CHAR: b write1 flush
         number-of-requests
         [ CHAR: a dup write1 flush read1 assert= ] times
         counter get count-down
-    ] with-stream ;
+    ] with-client ;
 
 : stop-server ( -- )
-    server-addr ascii <client> [
+    server-addr ascii [
         CHAR: x write1
-    ] with-stream ;
+    ] with-client ;
 
 : clients ( n -- )
     dup pprint " clients: " write [
index 3b0834b19056556137265a969d6d7184b9a2f1c7..c40efaaa04f47d949dde79477d5c550d34f3d1e4 100644 (file)
@@ -16,7 +16,7 @@ IN: builder.util
 
 : minutes>ms ( min -- ms ) 60 * 1000 * ;
 
-: file>string ( file -- string ) utf8 [ stdio get contents ] with-file-reader ;
+: file>string ( file -- string ) utf8 file-contents ;
 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
@@ -107,5 +107,5 @@ USE: prettyprint
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
 : git-id ( -- id )
-  { "git" "show" } utf8 <process-stream> [ readln ] with-stream
+  { "git" "show" } utf8 <process-reader> [ readln ] with-input-stream
   " " split second ;
index 1bbad298358fd478df9291d01ac66499462b003f..a3b13c9691e56f7e1aa2a0521077f84691bf7cd3 100755 (executable)
@@ -21,7 +21,7 @@ ERROR: cairo-error string ;
         { CAIRO_STATUS_FILE_NOT_FOUND [ "Cairo: file not found" cairo-error ] }
         { CAIRO_STATUS_READ_ERROR [ "Cairo: read error" cairo-error ] }
         [ drop ]
-    } cond ;
+    } case ;
 
 : <png> ( path -- png )
     normalize-path
index 78494a40c0bb1a92636a0958ad3ea020b7091ca4..a385f6d04f9303fcf8d7be148304fcef8df9b3fb 100755 (executable)
@@ -180,4 +180,4 @@ SINGLETON: md5
 INSTANCE: md5 checksum
 
 M: md5 checksum-stream ( stream -- byte-array )
-    drop [ initialize-md5 stream>md5 get-md5 ] with-stream ;
+    drop [ initialize-md5 stream>md5 get-md5 ] with-input-stream ;
index d2dc305ac2ea6e19c8a4e6c7969bf216be403218..d3ab878a126bfafa697d13d1498f83e7d5345626 100644 (file)
@@ -1,8 +1,8 @@
-USING: checksums ;
+USING: checksums kernel ;
 IN: checksums.null
 
 SINGLETON: null
 
 INSTANCE: null checksum
 
-M: null checksum-bytes ;
+M: null checksum-bytes drop ;
index 2efab873bc5bfb7ce8f89a09d0c5a9bb4407dc68..6427e0e8ebe244d7aee794504a042c7c57f0422c 100755 (executable)
@@ -111,7 +111,7 @@ SINGLETON: sha1
 INSTANCE: sha1 checksum
 
 M: sha1 checksum-stream ( stream -- sha1 )
-    drop [ initialize-sha1 stream>sha1 get-sha1 ] with-stream ;
+    drop [ initialize-sha1 stream>sha1 get-sha1 ] with-input-stream ;
 
 : sha1-interleave ( string -- seq )
     [ zero? ] left-trim
index 84b41a91ff6ae3006c23ecd70b61907f5add5f0a..5dfe8527c1a80d75b24f6d95535bafacee4338b4 100755 (executable)
@@ -169,3 +169,8 @@ MACRO: multikeep ( word out-indexes -- ... )
 : generate ( generator predicate -- obj )
     [ dup ] swap [ dup [ nip ] unless not ] 3compose
     swap [ ] do-while ;
+
+MACRO: predicates ( seq -- quot/f )
+    dup [ 1quotation [ drop ] prepend ] map
+    >r [ [ dup ] prepend ] map r> zip [ drop f ] suffix
+    [ cond ] curry ;
index bbf8fb0f5fdad6f925a651d1eee525ffd05d153f..a23301c1e281a238def0312b3ec0159b0da5b2b9 100755 (executable)
@@ -6,11 +6,21 @@ HELP: parallel-map
 { $description "Spawns a new thread for applying " { $snippet "quot" } " to every element of " { $snippet "seq" } ", collecting the results at the end." }\r
 { $errors "Throws an error if one of the iterations throws an error." } ;\r
 \r
+HELP: 2parallel-map\r
+{ $values { "seq1" sequence } { "seq2" sequence } { "quot" "a quotation with stack effect " { $snippet "( elt -- newelt )" } } { "newseq" sequence } }\r
+{ $description "Spawns a new thread for applying " { $snippet "quot" } " to pairwise elements of " { $snippet "seq1" } " and " { $snippet "seq2" } ", collecting the results at the end." }\r
+{ $errors "Throws an error if one of the iterations throws an error." } ;\r
+\r
 HELP: parallel-each\r
 { $values { "seq" sequence } { "quot" "a quotation with stack effect " { $snippet "( elt -- )" } } }\r
 { $description "Spawns a new thread for applying " { $snippet "quot" } " to every element of " { $snippet "seq" } ", blocking until all quotations complete." }\r
 { $errors "Throws an error if one of the iterations throws an error." } ;\r
 \r
+HELP: 2parallel-each\r
+{ $values { "seq1" sequence } { "seq2" sequence } { "quot" "a quotation with stack effect " { $snippet "( elt -- )" } } }\r
+{ $description "Spawns a new thread for applying " { $snippet "quot" } " to pairwise elements of " { $snippet "seq1" } " and " { $snippet "seq2" } ", blocking until all quotations complete." }\r
+{ $errors "Throws an error if one of the iterations throws an error." } ;\r
+\r
 HELP: parallel-filter\r
 { $values { "seq" sequence } { "quot" "a quotation with stack effect " { $snippet "( elt -- ? )" } } { "newseq" sequence } }\r
 { $description "Spawns a new thread for applying " { $snippet "quot" } " to every element of " { $snippet "seq" } ", collecting the elements for which the quotation yielded a true value." }\r
@@ -19,7 +29,9 @@ HELP: parallel-filter
 ARTICLE: "concurrency.combinators" "Concurrent combinators"\r
 "The " { $vocab-link "concurrency.combinators" } " vocabulary provides concurrent variants of " { $link each } ", " { $link map } " and " { $link filter } ":"\r
 { $subsection parallel-each }\r
+{ $subsection 2parallel-each }\r
 { $subsection parallel-map }\r
+{ $subsection 2parallel-map }\r
 { $subsection parallel-filter } ;\r
 \r
 ABOUT: "concurrency.combinators"\r
index 3381cba5e81ff2d3b7a24a4d5565cd20848f275e..562111242d0040d56d629b572e896e7d1dd27358 100755 (executable)
@@ -1,9 +1,11 @@
 IN: concurrency.combinators.tests\r
 USING: concurrency.combinators tools.test random kernel math \r
-concurrency.mailboxes threads sequences accessors ;\r
+concurrency.mailboxes threads sequences accessors arrays ;\r
 \r
 [ [ drop ] parallel-each ] must-infer\r
+{ 2 0 } [ [ 2drop ] 2parallel-each ] must-infer-as\r
 [ [ ] parallel-map ] must-infer\r
+{ 2 1 } [ [ 2array ] 2parallel-map ] must-infer-as\r
 [ [ ] parallel-filter ] must-infer\r
 \r
 [ { 1 4 9 } ] [ { 1 2 3 } [ sq ] parallel-map ] unit-test\r
@@ -22,3 +24,24 @@ concurrency.mailboxes threads sequences accessors ;
     10 over [ push ] curry parallel-each\r
     length\r
 ] unit-test\r
+\r
+[ { 10 20 30 } ] [\r
+    { 1 4 3 } { 10 5 10 } [ * ] 2parallel-map\r
+] unit-test\r
+\r
+[ { -9 -1 -7 } ] [\r
+    { 1 4 3 } { 10 5 10 } [ - ] 2parallel-map\r
+] unit-test\r
+\r
+[\r
+    { 1 4 3 } { 1 0 1 } [ / drop ] 2parallel-each\r
+] must-fail\r
+\r
+[ 20 ]\r
+[\r
+    V{ } clone\r
+    10 10 pick [ [ push ] [ push ] bi ] curry 2parallel-each\r
+    length\r
+] unit-test\r
+\r
+[ { f } [ "OOPS" throw ] parallel-each ] must-fail\r
index 3c4101e3811ba325b31850a4c1d8704de267116f..eab0ed4cb415efccab028709fbcc5e96b9fbc5c9 100755 (executable)
@@ -4,14 +4,27 @@ USING: concurrency.futures concurrency.count-downs sequences
 kernel ;\r
 IN: concurrency.combinators\r
 \r
-: parallel-map ( seq quot -- newseq )\r
-    [ curry future ] curry map dup [ ?future ] change-each ;\r
-    inline\r
+: (parallel-each) ( n quot -- )\r
+    >r <count-down> r> keep await ; inline\r
 \r
 : parallel-each ( seq quot -- )\r
-    over length <count-down>\r
-    [ [ >r curry r> spawn-stage ] 2curry each ] keep await ;\r
-    inline\r
+    over length [\r
+        [ >r curry r> spawn-stage ] 2curry each\r
+    ] (parallel-each) ; inline\r
+\r
+: 2parallel-each ( seq1 seq2 quot -- )\r
+    2over min-length [\r
+        [ >r 2curry r> spawn-stage ] 2curry 2each\r
+    ] (parallel-each) ; inline\r
 \r
 : parallel-filter ( seq quot -- newseq )\r
     over >r pusher >r each r> r> like ; inline\r
+\r
+: future-values dup [ ?future ] change-each ; inline\r
+\r
+: parallel-map ( seq quot -- newseq )\r
+    [ curry future ] curry map future-values ;\r
+    inline\r
+\r
+: 2parallel-map ( seq1 seq2 quot -- newseq )\r
+    [ 2curry future ] curry 2map future-values ;\r
index 6a75f7206c8cf183ad7cc69f489db2608c2ecd26..93cef250a193625abe8aa853c1fb996a4ae12890 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.\r
 ! See http://factorcode.org/license.txt for BSD license.\r
 USING: dlists kernel math concurrency.promises\r
-concurrency.mailboxes ;\r
+concurrency.mailboxes debugger accessors ;\r
 IN: concurrency.count-downs\r
 \r
 ! http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/CountDownLatch.html\r
@@ -9,9 +9,7 @@ IN: concurrency.count-downs
 TUPLE: count-down n promise ;\r
 \r
 : count-down-check ( count-down -- )\r
-    dup count-down-n zero? [\r
-        t swap count-down-promise fulfill\r
-    ] [ drop ] if ;\r
+    dup n>> zero? [ t swap promise>> fulfill ] [ drop ] if ;\r
 \r
 : <count-down> ( n -- count-down )\r
     dup 0 < [ "Invalid count for count down" throw ] when\r
@@ -19,15 +17,12 @@ TUPLE: count-down n promise ;
     dup count-down-check ;\r
 \r
 : count-down ( count-down -- )\r
-    dup count-down-n dup zero? [\r
-        "Count down already done" throw\r
-    ] [\r
-        1- over set-count-down-n\r
-        count-down-check\r
-    ] if ;\r
+    dup n>> dup zero?\r
+    [ "Count down already done" throw ]\r
+    [ 1- >>n count-down-check ] if ;\r
 \r
 : await-timeout ( count-down timeout -- )\r
-    >r count-down-promise r> ?promise-timeout drop ;\r
+    >r promise>> r> ?promise-timeout ?linked t assert= ;\r
 \r
 : await ( count-down -- )\r
     f await-timeout ;\r
@@ -35,5 +30,4 @@ TUPLE: count-down n promise ;
 : spawn-stage ( quot count-down -- )\r
     [ [ count-down ] curry compose ] keep\r
     "Count down stage"\r
-    swap count-down-promise\r
-    promise-mailbox spawn-linked-to drop ;\r
+    swap promise>> mailbox>> spawn-linked-to drop ;\r
index 6704272305e16cc1afd520953f54f57d97016000..c637f4baa34bf3e4a51116a1a97bdcb6292a01c8 100755 (executable)
@@ -3,7 +3,7 @@
 USING: serialize sequences concurrency.messaging threads io
 io.server qualified arrays namespaces kernel io.encodings.binary
 accessors ;
-QUALIFIED: io.sockets
+FROM: io.sockets => host-name <inet> with-client ;
 IN: concurrency.distributed
 
 SYMBOL: local-node
@@ -23,7 +23,7 @@ SYMBOL: local-node
 
 : start-node ( port -- )
     [ internet-server ]
-    [ io.sockets:host-name swap io.sockets:<inet> ] bi
+    [ host-name swap <inet> ] bi
     (start-node) ;
 
 TUPLE: remote-process id node ;
@@ -31,8 +31,7 @@ TUPLE: remote-process id node ;
 C: <remote-process> remote-process
 
 : send-remote-message ( message node -- )
-    binary io.sockets:<client>
-    [ serialize ] with-stream ;
+    binary [ serialize ] with-client ;
 
 M: remote-process send ( message thread -- )
     [ id>> 2array ] [ node>> ] bi
index f23ea951670ae2283cc81bcaa56e2c9af0476c4d..9d3f6de98cb0cba25824145fc231d369960a58f2 100755 (executable)
@@ -1,11 +1,12 @@
 IN: concurrency.flags.tests\r
-USING: tools.test concurrency.flags kernel threads locals ;\r
+USING: tools.test concurrency.flags concurrency.combinators\r
+kernel threads locals accessors ;\r
 \r
 :: flag-test-1 ( -- )\r
     [let | f [ <flag> ] |\r
         [ f raise-flag ] "Flag test" spawn drop\r
         f lower-flag\r
-        f flag-value?\r
+        f value>>\r
     ] ;\r
 \r
 [ f ] [ flag-test-1 ] unit-test\r
@@ -14,7 +15,7 @@ USING: tools.test concurrency.flags kernel threads locals ;
     [let | f [ <flag> ] |\r
         [ 1000 sleep f raise-flag ] "Flag test" spawn drop\r
         f lower-flag\r
-        f flag-value?\r
+        f value>>\r
     ] ;\r
 \r
 [ f ] [ flag-test-2 ] unit-test\r
@@ -22,7 +23,7 @@ USING: tools.test concurrency.flags kernel threads locals ;
 :: flag-test-3 ( -- )\r
     [let | f [ <flag> ] |\r
         f raise-flag\r
-        f flag-value?\r
+        f value>>\r
     ] ;\r
 \r
 [ t ] [ flag-test-3 ] unit-test\r
@@ -31,7 +32,7 @@ USING: tools.test concurrency.flags kernel threads locals ;
     [let | f [ <flag> ] |\r
         [ f raise-flag ] "Flag test" spawn drop\r
         f wait-for-flag\r
-        f flag-value?\r
+        f value>>\r
     ] ;\r
 \r
 [ t ] [ flag-test-4 ] unit-test\r
@@ -40,7 +41,13 @@ USING: tools.test concurrency.flags kernel threads locals ;
     [let | f [ <flag> ] |\r
         [ 1000 sleep f raise-flag ] "Flag test" spawn drop\r
         f wait-for-flag\r
-        f flag-value?\r
+        f value>>\r
     ] ;\r
 \r
 [ t ] [ flag-test-5 ] unit-test\r
+\r
+[ ] [\r
+    { 1 2 } <flag>\r
+    [ [ 1000 sleep raise-flag ] curry "Flag test" spawn drop ]\r
+    [ [ wait-for-flag drop ] curry parallel-each ] bi\r
+] unit-test\r
index b3c76a7a01694bd7a6ee4ac6989194c1e7109a99..ec260961d0417c7ca3a2407d2ba320cb92c2a3be 100755 (executable)
@@ -1,22 +1,20 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: boxes kernel threads ;
+USING: dlists kernel threads concurrency.conditions accessors ;
 IN: concurrency.flags
 
-TUPLE: flag value? thread ;
+TUPLE: flag value threads ;
 
-: <flag> ( -- flag ) f <box> flag boa ;
+: <flag> ( -- flag ) f <dlist> flag boa ;
 
 : raise-flag ( flag -- )
-    dup flag-value? [
-        t over set-flag-value?
-        dup flag-thread [ resume ] if-box?
-    ] unless drop ;
+    dup value>> [ drop ] [ t >>value threads>> notify-all ] if ;
+
+: wait-for-flag-timeout ( flag timeout -- )
+    over value>> [ 2drop ] [ >r threads>> r> "flag" wait ] if ;
 
 : wait-for-flag ( flag -- )
-    dup flag-value? [ drop ] [
-        [ flag-thread >box ] curry "flag" suspend drop
-    ] if ;
+    f wait-for-flag-timeout ;
 
 : lower-flag ( flag -- )
-    dup wait-for-flag f swap set-flag-value? ;
+    [ wait-for-flag ] [ f >>value drop ] bi ;
index ac0319770817a0fc3814e110d29c804744609f82..aa4dc2df3d1878e29f633c506e646c5e8f2431e9 100755 (executable)
@@ -3,7 +3,7 @@
 IN: concurrency.mailboxes\r
 USING: dlists threads sequences continuations\r
 namespaces random math quotations words kernel arrays assocs\r
-init system concurrency.conditions accessors ;\r
+init system concurrency.conditions accessors debugger ;\r
 \r
 TUPLE: mailbox threads data closed ;\r
 \r
@@ -83,6 +83,9 @@ M: mailbox dispose
 \r
 TUPLE: linked-error error thread ;\r
 \r
+M: linked-error error.\r
+    [ thread>> error-in-thread. ] [ error>> error. ] bi ;\r
+\r
 C: <linked-error> linked-error\r
 \r
 : ?linked dup linked-error? [ rethrow ] when ;\r
diff --git a/extra/contributors/contributors-tests.factor b/extra/contributors/contributors-tests.factor
new file mode 100644 (file)
index 0000000..1476715
--- /dev/null
@@ -0,0 +1,5 @@
+IN: contributors.tests
+USING: contributors tools.test ;
+
+\ contributors must-infer
+[ ] [ contributors ] unit-test
index 868e9681696344c79e6e2ded3d6c753fcee913a1..9f2d5a55fa1cc1f8e51b6dc93be9723cea782b97 100755 (executable)
@@ -1,13 +1,13 @@
 ! Copyright (C) 2007 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: io.files io.launcher io.styles io hashtables kernel
-sequences sequences.lib assocs system sorting math.parser
-sets ;
+USING: io.files io.launcher io.styles io.encodings.ascii io
+hashtables kernel sequences sequences.lib assocs system sorting
+math.parser sets ;
 IN: contributors
 
 : changelog ( -- authors )
     image parent-directory [
-        "git-log --pretty=format:%an" <process-stream> lines
+        "git-log --pretty=format:%an" ascii <process-reader> lines
     ] with-directory ;
 
 : patch-counts ( authors -- assoc )
index 85f27d7e4081e527847d2eb42560aa02394113ae..f88db2935fa39363385a77006b6d998e4dd19ab2 100755 (executable)
@@ -1,5 +1,5 @@
 USING: kernel cpu.8080 cpu.8080.emulator math math io\r
-tools.time combinators sequences io.files ;\r
+tools.time combinators sequences io.files io.encodings.ascii ;\r
 IN: cpu.8080.test\r
 \r
 : step ( cpu -- )\r
@@ -29,7 +29,7 @@ IN: cpu.8080.test
 \r
 : >ppm ( cpu filename -- cpu )\r
   #! Dump the current screen image to a ppm image file with the given name.\r
-  <file-writer> [\r
+  ascii [\r
     "P3" print\r
     "256 224" print\r
     "1" print\r
@@ -45,7 +45,7 @@ IN: cpu.8080.test
         ] each-8bit drop\r
       ] each drop nl\r
     ] each\r
-  ] with-stream ;\r
+  ] with-file-writer ;\r
 \r
 : time-test ( -- )\r
   test-cpu [ 1000000 run-n drop ] time ;\r
index fe77aa8969a4e7c72db015b9a591ba9bcef03545..6e30f19775cd1f1ec596124dad8775ae420eec94 100755 (executable)
@@ -30,7 +30,7 @@ MEMO: opad ( -- seq ) 64 HEX: 5c <array> ;
     ipad seq-bitxor ;
 
 : stream>sha1-hmac ( K stream -- hmac )
-    [ init-hmac sha1-hmac ] with-stream ;
+    [ init-hmac sha1-hmac ] with-input-stream ;
 
 : file>sha1-hmac ( K path -- hmac )
     binary <file-reader> stream>sha1-hmac ;
@@ -39,7 +39,7 @@ MEMO: opad ( -- seq ) 64 HEX: 5c <array> ;
     binary <byte-reader> stream>sha1-hmac ;
 
 : stream>md5-hmac ( K stream -- hmac )
-    [ init-hmac md5-hmac ] with-stream ;
+    [ init-hmac md5-hmac ] with-input-stream ;
 
 : file>md5-hmac ( K path -- hmac )
     binary <file-reader> stream>md5-hmac ;
index b1953f5b5763a775521b347c4f09f98def1595e8..8ba0832b291091922a8e902b648e1785c69e61ca 100644 (file)
@@ -61,11 +61,11 @@ VAR: delimiter
   
 : csv-row ( stream -- row )
   init-vars
-  [ row nip ] with-stream ;
+  [ row nip ] with-input-stream ;
 
 : csv ( stream -- rows )
   init-vars
-  [ [ (csv) ] { } make ] with-stream ;
+  [ [ (csv) ] { } make ] with-input-stream ;
 
 : with-delimiter ( char quot -- )
   delimiter swap with-variable ; inline
index f1ad068fe22efbdf06f070764ff536be7c036a4c..c1d7e1e4ab12b8f875495e6207f489b32bc6beb7 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007 Daniel Ehrenberg
 ! See http://factorcode.org/license.txt for BSD license.
 USING: delegate sequences.private sequences assocs prettyprint.sections 
-io definitions kernel continuations ;
+io definitions kernel continuations listener ;
 IN: delegate.protocols
 
 PROTOCOL: sequence-protocol
@@ -12,8 +12,10 @@ PROTOCOL: assoc-protocol
     at* assoc-size >alist set-at assoc-clone-like { assoc-find 1 }
     delete-at clear-assoc new-assoc assoc-like ;
 
-PROTOCOL: stream-protocol
-    stream-read1 stream-read stream-read-until dispose
+PROTOCOL: input-stream-protocol
+    stream-read1 stream-read stream-read-until stream-read-quot ;
+
+PROTOCOL: output-stream-protocol
     stream-flush stream-write1 stream-write stream-format
     stream-nl make-span-stream make-block-stream stream-readln
     make-cell-stream stream-write-table ;
index c3914e9c935fc9369acc6197f10a4bd4e47334b5..6fc7ab249f7956361864fc74d378159964b7cae6 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: continuations io.backend libc kernel namespaces
-sequences system vectors ;
+USING: continuations io.backend io.nonblocking libc kernel
+namespaces sequences system vectors ;
 IN: destructors
 
 SYMBOL: error-destructors
@@ -59,10 +59,8 @@ TUPLE: handle-destructor alien ;
 
 C: <handle-destructor> handle-destructor
 
-HOOK: destruct-handle io-backend ( obj -- )
-
 M: handle-destructor dispose ( obj -- )
-    handle-destructor-alien destruct-handle ;
+    handle-destructor-alien close-handle ;
 
 : close-always ( handle -- )
     <handle-destructor> add-always-destructor ;
index e4f19781ef83c80cb6fed370bfc742355a2afbfc..fe9abc0e76b4640cb9f50f2f09583f926a235271 100755 (executable)
@@ -25,11 +25,11 @@ IN: editors.jedit
     ] with-byte-writer ;
 
 : send-jedit-request ( request -- )
-    jedit-server-info "localhost" rot <inet> binary <client> [
+    jedit-server-info "localhost" rot <inet> binary [
         4 >be write
         dup length 2 >be write
         write
-    ] with-stream ;
+    ] with-client ;
 
 : jedit-location ( file line -- )
     number>string "+line:" prepend 2array
index 84d02d529d4be2cd4da108d0d5b957ee78b245f6..7a444fecbc1a28765582f3cb6774252509b63986 100755 (executable)
@@ -87,7 +87,7 @@ $nl
 } ;\r
 \r
 ARTICLE: "fry.limitations" "Fried quotation limitations"\r
-"As with " { $link "locals" } ", fried quotations cannot contain " { $link >r } " and " { $link r> } ". Unlike " { $link "locals" } ", using " { $link dip } " is not a suitable workaround since unlike closure conversion, fry conversion is not recursive, and so the quotation passed to " { $link dip } " cannot contain fry specifiers." ;\r
+"As with " { $vocab-link "locals" } ", fried quotations cannot contain " { $link >r } " and " { $link r> } "." ;\r
 \r
 ARTICLE: "fry" "Fried quotations"\r
 "A " { $emphasis "fried quotation" } " differs from a literal quotation in that when it is evaluated, instead of just pushing itself on the stack, it consumes zero or more stack values and inserts them into the quotation."\r
index 7586e254b2ee0b8048b906e9cb01a9dfd43611a6..eb59ffae4e7282c19ace7f8b9d11adc2196ebbc0 100755 (executable)
@@ -48,3 +48,7 @@ sequences ;
 [ { 1 2 3 } ] [
     3 1 '[ , [ , + ] map ] call
 ] unit-test
+
+[ { 1 { 2 { 3 } } } ] [
+    1 2 3 '[ , [ , [ , 1array ] call 2array ] call 2array ] call
+] unit-test
index 1b9e2dc82bb11ef4959781dea443675f90fa04a4..27a321ed921f84b771e1feb9d433a98de799a4de 100755 (executable)
@@ -54,7 +54,7 @@ DEFER: (shallow-fry)
                     [ { , namespaces:, @ } member? ] filter length
                     \ , <repetition> %
                 ]
-                [ deep-fry % ] bi
+                [ fry % ] bi
             ] [ namespaces:, ] if
         ] each
     ] [ ] make deep-fry ;
index fd3a2d285ada1995d8d0a244ffb5254cceafc7b6..b5e44711345a2ec40e4b941bccbdf15452da3aef 100644 (file)
@@ -1,2 +1,2 @@
 collections
-collections sequences
+sequences
diff --git a/extra/geo-ip/authors.txt b/extra/geo-ip/authors.txt
new file mode 100644 (file)
index 0000000..1901f27
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
diff --git a/extra/geo-ip/geo-ip.factor b/extra/geo-ip/geo-ip.factor
new file mode 100644 (file)
index 0000000..5926dd5
--- /dev/null
@@ -0,0 +1,46 @@
+USING: kernel sequences io.files io.launcher io.encodings.ascii
+io.streams.string http.client sequences.lib combinators
+math.parser math.vectors math.intervals interval-maps memoize
+csv accessors assocs strings math splitting ;
+IN: geo-ip
+
+: db-path "IpToCountry.csv" temp-file ;
+
+: db-url "http://software77.net/cgi-bin/ip-country/geo-ip.pl?action=download" ;
+
+: download-db ( -- path )
+    db-path dup exists? [
+        db-url over ".gz" append download-to
+        { "gunzip" } over ".gz" append (normalize-path) suffix try-process
+    ] unless ;
+
+TUPLE: ip-entry from to registry assigned city cntry country ;
+
+: parse-ip-entry ( row -- ip-entry )
+    7 firstn {
+        [ string>number ]
+        [ string>number ]
+        [ ]
+        [ ]
+        [ ]
+        [ ]
+        [ ]
+    } spread ip-entry boa ;
+
+MEMO: ip-db ( -- seq )
+    download-db ascii file-lines
+    [ "#" head? not ] filter "\n" join <string-reader> csv
+    [ parse-ip-entry ] map ;
+
+MEMO: ip-intervals ( -- interval-map )
+    ip-db [ [ [ from>> ] [ to>> ] bi [a,b] ] keep ] { } map>assoc
+    <interval-map> ;
+
+GENERIC: lookup-ip ( ip -- ip-entry )
+
+M: string lookup-ip
+    "." split [ string>number ] map
+    { HEX: 1000000 HEX: 10000 HEX: 100 1 } v.
+    lookup-ip ;
+
+M: integer lookup-ip ip-intervals interval-at ;
diff --git a/extra/geo-ip/summary.txt b/extra/geo-ip/summary.txt
new file mode 100644 (file)
index 0000000..402d323
--- /dev/null
@@ -0,0 +1 @@
+IP address geolocation using database from http://software77.net/cgi-bin/ip-country/
diff --git a/extra/geo-ip/tags.txt b/extra/geo-ip/tags.txt
new file mode 100644 (file)
index 0000000..0aef4fe
--- /dev/null
@@ -0,0 +1 @@
+enterprise
index 1977efd3f930c8fd0a92adacb35000f5875063e0..b9de7c1b74fbd109c0b3f3739346d1291e15bdd9 100644 (file)
@@ -15,13 +15,13 @@ TUPLE: gesture-logger stream ;
 M: gesture-logger handle-gesture*
     drop
     dup T{ button-down } = [ over request-focus ] when
-    swap gesture-logger-stream [ . ] with-stream*
+    swap gesture-logger-stream [ . ] with-output-stream*
     t ;
 
 M: gesture-logger user-input*
     gesture-logger-stream [
         "User input: " write print
-    ] with-stream* t ;
+    ] with-output-stream* t ;
 
 : gesture-logger ( -- )
     [
index 995b8540f59d8d0d1fae23fa366e074b2b0d3287..c2e12469c559c6fbc67d75aacf0f590208d8cc95 100755 (executable)
@@ -205,8 +205,8 @@ ARTICLE: "cookbook-io" "Input and output cookbook"
 }
 "Send some bytes to a remote host:"
 { $code
-    "\"myhost\" 1033 <inet> <client>"
-    "[ { 12 17 102 } >string write ] with-stream"
+    "\"myhost\" 1033 <inet>"
+    "[ { 12 17 102 } >string write ] with-client"
 }
 { $references
     { }
index a9e94466c49a72509a898b21d3e98f505e654e3b..a8271a0e3b7f13bb3c2eec65a4bd8927346481cc 100755 (executable)
@@ -31,7 +31,7 @@ $nl
     { { $snippet "set-" { $emphasis "foo" } } { "sets " { $snippet "foo" } " to a new value" } { $links set-length } }
     { { $snippet { $emphasis "foo" } "-" { $emphasis "bar" } } { "(tuple accessors) outputs the value of the " { $snippet "bar" } " slot of the " { $snippet "foo" } " at the top of the stack" } { } }
     { { $snippet "set-" { $emphasis "foo" } "-" { $emphasis "bar" } } { "(tuple mutators) sets the value of the " { $snippet "bar" } " slot of the " { $snippet "foo" } " at the top of the stack" } { } }
-    { { $snippet "with-" { $emphasis "foo" } } { "performs some kind of initialization and cleanup related to " { $snippet "foo" } ", usually in a new dynamic scope" } { $links with-scope with-stream } }
+    { { $snippet "with-" { $emphasis "foo" } } { "performs some kind of initialization and cleanup related to " { $snippet "foo" } ", usually in a new dynamic scope" } { $links with-scope with-input-stream with-output-stream } }
     { { $snippet "$" { $emphasis "foo" } } { "help markup" } { $links $heading $emphasis } }
 }
 { $heading "Stack effect conventions" }
@@ -193,17 +193,19 @@ ARTICLE: "io" "Input and output"
 "Utilities:"
 { $subsection "stream-binary" }
 { $subsection "styles" }
-{ $heading "Files" }
-{ $subsection "io.files" }
-{ $subsection "io.mmap" }
-{ $subsection "io.monitors" }
 { $heading "Encodings" }
 { $subsection "encodings-introduction" }
 { $subsection "io.encodings" }
 { $subsection "io.encodings.string" }
-{ $heading "Other features" }
+{ $heading "Files" }
+{ $subsection "io.files" }
+{ $subsection "io.mmap" }
+{ $subsection "io.monitors" }
+{ $heading "Communications" }
 { $subsection "network-streams" }
 { $subsection "io.launcher" }
+{ $subsection "io.pipes" }
+{ $heading "Other features" }
 { $subsection "io.timeouts" }
 { $subsection "checksums" } ;
 
index d4981751e2e23aa5f18f04b7f61e16d9535666b6..f20ce89263dfc5857c085f41c8e1653a282ff6c3 100755 (executable)
@@ -126,7 +126,7 @@ HELP: $title
 HELP: help
 { $values { "topic" "an article name or a word" } }
 { $description
-    "Displays a help article or documentation associated to a word on the " { $link stdio } " stream."
+    "Displays a help article or documentation associated to a word on " { $link output-stream } "."
 } ;
 
 HELP: about
@@ -151,7 +151,7 @@ HELP: $index
 
 HELP: ($index)
 { $values { "articles" "a sequence of help articles" } }
-{ $description "Writes a list of " { $link $subsection } " elements to the " { $link stdio } " stream." } ;
+{ $description "Writes a list of " { $link $subsection } " elements to " { $link output-stream } "." } ;
 
 HELP: xref-help
 { $description "Update help cross-referencing. Usually this is done automatically." } ;
@@ -168,11 +168,11 @@ HELP: $predicate
 
 HELP: print-element
 { $values { "element" "a markup element" } }
-{ $description "Prints a markup element to the " { $link stdio } " stream." } ;
+{ $description "Prints a markup element to " { $link output-stream } "." } ;
 
 HELP: print-content
 { $values { "element" "a markup element" } }
-{ $description "Prints a top-level markup element to the " { $link stdio } " stream." } ;
+{ $description "Prints a top-level markup element to " { $link output-stream } "." } ;
 
 HELP: simple-element
 { $class-description "Class of simple elements, which are just arrays of elements." } ;
index fc4b7f6f25abb9c94674ed6d99a6793ab82b01d9..a9ec7f92675abf0b61d5b4e90d6c45b2cff071be 100755 (executable)
@@ -10,7 +10,7 @@ IN: help.lint
 
 : check-example ( element -- )
     rest [
-        1 head* "\n" join 1vector
+        but-last "\n" join 1vector
         [
             use [ clone ] change
             [ eval>string ] with-datastack
index fffcda69b692307685cea8b0822e29f687fb8999..cafa758c7e80adb62cf2d5bce0a3a49dee968069 100755 (executable)
@@ -135,7 +135,7 @@ $nl
 { $code "[ Letter? ] filter >lower" }
 "This code starts with a string on the stack, removes non-alphabetical characters, and converts the result to lower case, leaving a new string on the stack. We put this code in a new word, and add the new word to " { $snippet "palindrome.factor" } ":"
 { $code ": normalize ( str -- newstr ) [ Letter? ] filter >lower ;" }
-"You will need to add " { $vocab-link "unicode.categories" } " to the vocabulary search path, so that " { $link Letter? } " can be used in the source file."
+"You will need to add " { $vocab-link "unicode.case" } " and " { $vocab-link "unicode.categories" } " to the vocabulary search path, so that " { $link Letter? } " can be used in the source file."
 $nl
 "We modify " { $snippet "palindrome?" } " to first apply " { $snippet "normalize" } " to its input:"
 { $code ": palindrome? ( str -- ? ) normalize dup reverse = ;" }
index ce320ca75b447c4c66c84fece801070a9e279cd5..9f1ce6b6896b79bfd445a5b80ea18bfce77cdb35 100644 (file)
@@ -24,7 +24,7 @@ IN: html.tests
 ] unit-test
 
 [ "<" ] [
-    [ "<" H{ } stdio get format-html-span ] make-html-string
+    [ "<" H{ } output-stream get format-html-span ] make-html-string
 ] unit-test
 
 TUPLE: funky town ;
index f0ae42476064358a0522455ceb819b8ae94063d1..c154c35223d9b5ffa3329d955de20b12f9665e46 100755 (executable)
@@ -44,7 +44,7 @@ TUPLE: html-sub-stream style stream ;
     rot html-sub-stream-stream ;
 
 : delegate-write ( string -- )
-    stdio get delegate stream-write ;
+    output-stream get delegate stream-write ;
 
 : object-link-tag ( style quot -- )
     presented pick at [
@@ -101,7 +101,7 @@ TUPLE: html-sub-stream style stream ;
 : format-html-span ( string style stream -- )
     [
         [ [ drop delegate-write ] span-tag ] object-link-tag
-    ] with-stream* ;
+    ] with-output-stream* ;
 
 TUPLE: html-span-stream ;
 
@@ -134,7 +134,7 @@ M: html-span-stream dispose
 : format-html-div ( string style stream -- )
     [
         [ [ delegate-write ] div-tag ] object-link-tag
-    ] with-stream* ;
+    ] with-output-stream* ;
 
 TUPLE: html-block-stream ;
 
@@ -184,17 +184,17 @@ M: html-stream stream-write-table ( grid style stream -- )
                 </td>
             ] with each </tr>
         ] with each </table>
-    ] with-stream* ;
+    ] with-output-stream* ;
 
 M: html-stream make-cell-stream ( style stream -- stream' )
     (html-sub-stream) ;
 
 M: html-stream stream-nl ( stream -- )
-    dup test-last-div? [ drop ] [ [ <br/> ] with-stream* ] if ;
+    dup test-last-div? [ drop ] [ [ <br/> ] with-output-stream* ] if ;
 
 ! Utilities
 : with-html-stream ( quot -- )
-    stdio get <html-stream> swap with-stream* ; inline
+    output-stream get <html-stream> swap with-output-stream* ; inline
 
 : xhtml-preamble
     "<?xml version=\"1.0\"?>" write-html
@@ -225,13 +225,13 @@ M: html-stream stream-nl ( stream -- )
 
 : vertical-layout ( list -- )
     #! Given a list of HTML components, arrange them vertically.
-    <table> 
+    <table>
     [ <tr> <td> call </td> </tr> ] each
     </table> ;
 
 : horizontal-layout ( list -- )
     #! Given a list of HTML components, arrange them horizontally.
-    <table> 
+    <table>
      <tr "top" =valign tr> [ <td> call </td> ] each </tr>
     </table> ;
 
@@ -246,8 +246,8 @@ M: html-stream stream-nl ( stream -- )
 : simple-page ( title quot -- )
     #! Call the quotation, with all output going to the
     #! body of an html page with the given title.
-    <html>  
-        <head> <title> swap write </title> </head> 
+    <html>
+        <head> <title> swap write </title> </head>
         <body> call </body>
     </html> ;
 
@@ -255,10 +255,13 @@ M: html-stream stream-nl ( stream -- )
     #! Call the quotation, with all output going to the
     #! body of an html page with the given title. stylesheet-quot
     #! is called to generate the required stylesheet.
-    <html>  
-        <head>  
-             <title> rot write </title> 
-             swap call 
-        </head> 
+    <html>
+        <head>
+             <title> rot write </title>
+             swap call
+        </head>
         <body> call </body>
     </html> ;
+
+: render-error ( message -- )
+    <span "error" =class span> escape-string write </span> ;
index 160b95ab1d3209a04b5205343ca8ff03dd51a183..e9906f3f2a048b333dba6d1c67d577f9ee2b6e78 100755 (executable)
@@ -99,7 +99,7 @@ IN: html.parser.analyzer
     
 : find-between ( i/f tag/f vector -- vector )
     find-between* dup length 3 >= [
-        [ rest-slice 1 head-slice* ] keep like
+        [ rest-slice but-last-slice ] keep like
     ] when ;
 
 : find-between-first ( string vector -- vector' )
index 0ae75e41fdef302f51a6a02b03bb0e41c9050709..5083b1cec26581618def86f4bad67224f041d22e 100644 (file)
@@ -36,7 +36,7 @@ IN: html.parser.utils
     dup quoted? [ quote ] unless ;
 
 : unquote ( str -- newstr )
-    dup quoted? [ 1 head-slice* rest-slice >string ] when ;
+    dup quoted? [ but-last-slice rest-slice >string ] when ;
 
 : quote? ( ch -- ? ) "'\"" member? ;
 
index 7762b0184398b8a29881ebf4df13ece672011519..17882277a3bdb66578fc7d89d321042a27e764e1 100755 (executable)
@@ -3,7 +3,8 @@
 USING: assocs http kernel math math.parser namespaces sequences
 io io.sockets io.streams.string io.files io.timeouts strings
 splitting calendar continuations accessors vectors math.order
-io.encodings.8-bit io.encodings.binary fry debugger inspector ;
+io.encodings.8-bit io.encodings.binary io.streams.duplex
+fry debugger inspector ;
 IN: http.client
 
 : max-redirects 10 ;
@@ -26,73 +27,56 @@ DEFER: http-request
 : store-path ( request path -- request )
     "?" split1 >r >>path r> dup [ query>assoc ] when >>query ;
 
-: request-with-url ( url request -- request )
-    swap parse-url >r >r store-path r> >>host r> >>port ;
-
-! This is all pretty complex because it needs to handle
-! HTTP redirects, which might be absolute or relative
-: absolute-redirect ( url -- request )
-    request get request-with-url ;
-
-: relative-redirect ( path -- request )
-    request get swap store-path ;
+: request-with-url ( request url -- request )
+    parse-url >r >r store-path r> >>host r> >>port ;
 
 SYMBOL: redirects
 
 : absolute-url? ( url -- ? )
     [ "http://" head? ] [ "https://" head? ] bi or ;
 
-: do-redirect ( response -- response stream )
-    dup response-code 300 399 between? [
-        stdio get dispose
+: do-redirect ( response data -- response data )
+    over code>> 300 399 between? [
+        drop
         redirects inc
         redirects get max-redirects < [
-            header>> "location" swap at
-            dup absolute-url? [
-                absolute-redirect
-            ] [
-                relative-redirect
-            ] if "GET" >>method http-request
+            request get
+            swap "location" header dup absolute-url?
+            [ request-with-url ] [ store-path ] if
+            "GET" >>method http-request
         ] [
             too-many-redirects
         ] if
-    ] [
-        stdio get
-    ] if ;
-
-: close-on-error ( stream quot -- )
-    '[ , with-stream* ] [ ] pick '[ , dispose ] cleanup ; inline
+    ] when ;
 
 PRIVATE>
 
-: http-request ( request -- response stream )
-    dup request [
-        dup request-addr latin1 <client>
-        1 minutes over set-timeout
-        [
-            write-request flush
-            read-response
-            do-redirect
-        ] close-on-error
-    ] with-variable ;
-
 : read-chunks ( -- )
     read-crlf ";" split1 drop hex> dup { f 0 } member?
     [ drop ] [ read % read-crlf "" assert= read-chunks ] if ;
 
-: do-chunked-encoding ( response stream -- response stream/string )
-    over "transfer-encoding" header "chunked" = [
-        [ [ read-chunks ] "" make ] with-stream
-    ] when ;
+: read-response-body ( response -- response data )
+    dup "transfer-encoding" header "chunked" =
+    [ [ read-chunks ] "" make ] [ input-stream get contents ] if ;
 
-: <get-request> ( url -- request )
-    <request> request-with-url "GET" >>method ;
+: http-request ( request -- response data )
+    dup request [
+        dup request-addr latin1 [
+            1 minutes timeouts
+            write-request
+            read-response
+            read-response-body
+        ] with-client
+        do-redirect
+    ] with-variable ;
 
-: string-or-contents ( stream/string -- string )
-    dup string? [ contents ] unless ;
+: <get-request> ( url -- request )
+    <request>
+        swap request-with-url
+        "GET" >>method ;
 
-: http-get-stream ( url -- response stream/string )
-    <get-request> http-request do-chunked-encoding ;
+: http-get* ( url -- response data )
+    <get-request> http-request ;
 
 : success? ( code -- ? ) 200 = ;
 
@@ -112,29 +96,24 @@ M: download-failed error.
     over code>> success? [ nip ] [ download-failed ] if ;
 
 : http-get ( url -- string )
-    http-get-stream string-or-contents check-response ;
+    http-get* check-response ;
 
 : download-name ( url -- name )
     file-name "?" split1 drop "/" ?tail drop ;
 
 : download-to ( url file -- )
     #! Downloads the contents of a URL to a file.
-    swap http-get-stream check-response
-    dup string? [
-        latin1 [ write ] with-file-writer
-    ] [
-        [ swap latin1 <file-writer> stream-copy ] with-disposal
-    ] if ;
+    >r http-get r> latin1 [ write ] with-file-writer ;
 
 : download ( url -- )
     dup download-name download-to ;
 
 : <post-request> ( content-type content url -- request )
     <request>
-    request-with-url
-    "POST" >>method
-    swap >>post-data
-    swap >>post-data-type ;
+        "POST" >>method
+        swap request-with-url
+        swap >>post-data
+        swap >>post-data-type ;
 
-: http-post ( content-type content url -- response string )
-    <post-request> http-request do-chunked-encoding string-or-contents ;
+: http-post ( content-type content url -- response data )
+    <post-request> http-request ;
index 831becd264760e00a8a4eb2dfb2a03a5342097fa..21eb241b846fd5896de99ad1a2d58d2a76a6d0b2 100755 (executable)
@@ -30,6 +30,8 @@ IN: http.tests
 
 [ H{ { "a" { "b" "c" } } } ] [ "a=b&a=c" query>assoc ] unit-test
 
+[ "a=3" ] [ { { "a" 3 } } assoc>query ] unit-test
+
 : lf>crlf "\n" split "\r\n" join ;
 
 STRING: read-request-test-1
@@ -164,7 +166,7 @@ test-db [
         <dispatcher>
             add-quit-action
             <dispatcher>
-                "extra/http/test" resource-path <static> >>default
+                "resource:extra/http/test" <static> >>default
             "nested" add-responder
             <action>
                 [ "redirect-loop" f <standard-redirect> ] >>display
@@ -176,18 +178,18 @@ test-db [
 ] unit-test
 
 [ t ] [
-    "extra/http/test/foo.html" resource-path ascii file-contents
+    "resource:extra/http/test/foo.html" ascii file-contents
     "http://localhost:1237/nested/foo.html" http-get =
 ] unit-test
 
 ! Try with a slightly malformed request
 [ t ] [
-    "localhost" 1237 <inet> ascii <client> [
+    "localhost" 1237 <inet> ascii [
         "GET nested HTTP/1.0\r\n" write flush
         "\r\n" write flush
         read-crlf drop
         read-header
-    ] with-stream "location" swap at "/" head?
+    ] with-client "location" swap at "/" head?
 ] unit-test
 
 [ "http://localhost:1237/redirect-loop" http-get ]
index 315250692bff6315ee6c40205978fb3f6551f27e..786210123d5aadb592b1ae6f8cba530e3d1be6db 100755 (executable)
@@ -143,7 +143,7 @@ IN: http
 : assoc>query ( hash -- str )
     [
         {
-            { [ dup number? ] [ number>string ] }
+            { [ dup number? ] [ number>string 1array ] }
             { [ dup string? ] [ 1array ] }
             { [ dup sequence? ] [ ] }
         } cond
@@ -472,7 +472,7 @@ M: string write-response-body* write ;
 
 M: callable write-response-body* call ;
 
-M: object write-response-body* stdio get stream-copy ;
+M: object write-response-body* output-stream get stream-copy ;
 
 : write-response-body ( response -- response )
     dup body>> write-response-body* ;
index 6e1aac96272ceb0d4780a782b4ef7d1325c99fe2..2d73cb46a786ed0b58b812b65b193385fde561a1 100755 (executable)
@@ -2,13 +2,20 @@
 ! See http://factorcode.org/license.txt for BSD license.\r
 USING: accessors sequences kernel assocs combinators\r
 http.server http.server.validators http hashtables namespaces\r
-fry continuations locals ;\r
+fry continuations locals boxes xml.entities html.elements io ;\r
 IN: http.server.actions\r
 \r
-SYMBOL: +path+\r
-\r
 SYMBOL: params\r
 \r
+SYMBOL: validation-message\r
+\r
+: render-validation-message ( -- )\r
+    validation-message get value>> [\r
+        <span "error" =class span>\r
+            escape-string write\r
+        </span>\r
+    ] when* ;\r
+\r
 TUPLE: action init display submit get-params post-params ;\r
 \r
 : <action>\r
@@ -37,11 +44,16 @@ TUPLE: action init display submit get-params post-params ;
 : validation-failed ( -- * )\r
     action get display>> call exit-with ;\r
 \r
+: validation-failed-with ( string -- * )\r
+    validation-message get >box\r
+    validation-failed ;\r
+\r
 M: action call-responder* ( path action -- response )\r
     '[\r
         , [ CHAR: / = ] right-trim empty? [\r
             , action set\r
             request get\r
+            <box> validation-message set\r
             [ request-params params set ]\r
             [\r
                 method>> {\r
index e762103d7b2d9215711de17e521c83eb29d56f62..21e1a6181b8c44a495e0ec181a0e7372c2b10e94 100644 (file)
@@ -82,10 +82,8 @@ IN: http.server.auth.admin
 
             same-password-twice
 
-            user new "username" value >>username select-tuple [
-                user-exists? on
-                validation-failed
-            ] when
+            user new "username" value >>username select-tuple
+            [ user-exists ] when
 
             "username" value <user>
                 "realname" value >>realname
index 1864c3c4bf69edf49620054616ba966f08631ac7..05817565ed6e6c3c63f409471ecdce68eb1c02c9 100644 (file)
@@ -2,8 +2,6 @@
 
 <t:chloe xmlns:t="http://factorcode.org/chloe/1.0">
 
-       <t:style t:include="resource:extra/http/server/auth/admin/admin.css" />
-
        <div class="navbar">
                  <t:a t:href="$user-admin">List Users</t:a>
                | <t:a t:href="$user-admin/new">Add User</t:a>
@@ -12,9 +10,7 @@
                        | <t:a t:href="$login/edit-profile" t:flow="begin">Edit Profile</t:a>
                </t:if>
 
-               <t:form t:action="$login/logout" t:flow="begin" class="inline">
-                       | <button type="submit" class="link-button link">Logout</button>
-               </t:form>
+               | <t:button t:action="$login/logout" t:flow="begin" class="link-button link">Logout</t:button>
        </div>
 
        <h1><t:write-title /></h1>
index b8c235532b691d92a9cbe29f0a63102a95276baf..9c0fe702bbcd6cd66ec408eb74ffa970bcfcd645 100644 (file)
@@ -4,9 +4,7 @@
 
        <t:title>Edit User</t:title>
 
-       <t:form t:action="$user-admin/edit">
-
-       <t:edit t:component="username" />
+       <t:form t:action="$user-admin/edit" t:for="username">
 
        <table>
        
        
        <p>
                <button type="submit" class="link-button link">Update</button>
-
-               <t:if t:var="http.server.auth.login:password-mismatch?">
-                       <t:error>passwords do not match</t:error>
-               </t:if>
+               <t:validation-message />
        </p>
 
        </t:form>
 
-       <t:form t:action="$user-admin/delete">
-               <t:edit t:component="username" />
-
-               <button type="submit" class="link-button link">Delete</button>
-       </t:form>
+       <t:button t:action="$user-admin/delete" t:for="username" class="link-button link">Delete</t:button>
 </t:chloe>
index 072e0c95bdbb7f5a55625c7a628002983a50b32c..2d67639985699de19df902a26be8557b7ef45c64 100644 (file)
        
        <p>
                <button type="submit" class="link-button link">Create</button>
-
-               <t:if t:var="http.server.auth.login:user-exists?">
-                               <t:error>username taken</t:error>
-               </t:if>
-
-               <t:if t:var="http.server.auth.login:password-mismatch?">
-                       <t:error>passwords do not match</t:error>
-               </t:if>
+               <t:validation-message />
        </p>
 
        </t:form>
index 107dbba2b891cd4651d98295614848e8a4ee32b7..1eaf65fa07e09d52519edf9b3457525f717db1c7 100644 (file)
 
        <p>
                <input type="submit" value="Update" />
-
-               <t:if t:var="http.server.auth.login:login-failed?">
-                       <t:error>invalid password</t:error>
-               </t:if>
-               
-               <t:if t:var="http.server.auth.login:password-mismatch?">
-                       <t:error>passwords do not match</t:error>
-               </t:if>
+               <t:validation-message />
        </p>
 
        </t:form>
index 28486f33624b1cd915ff02d1e0b412771fb0a44d..9f1fe6fe77b842d0e1311872989bd11a07988888 100755 (executable)
@@ -30,8 +30,6 @@ http.server.validators ;
 IN: http.server.auth.login\r
 QUALIFIED: smtp\r
 \r
-SYMBOL: login-failed?\r
-\r
 TUPLE: login < dispatcher users checksum ;\r
 \r
 : users ( -- provider )\r
@@ -82,6 +80,8 @@ M: user-saver dispose
     username>> set-uid\r
     "$login" end-flow ;\r
 \r
+: login-failed "invalid username or password" validation-failed-with ;\r
+\r
 :: <login-action> ( -- action )\r
     [let | form [ <login-form> ] |\r
         <action>\r
@@ -94,12 +94,8 @@ M: user-saver dispose
 \r
                 form validate-form\r
 \r
-                "password" value "username" value check-login [\r
-                    successful-login\r
-                ] [\r
-                    login-failed? on\r
-                    validation-failed\r
-                ] if*\r
+                "password" value "username" value check-login\r
+                [ successful-login ] [ login-failed ] if*\r
             ] >>submit\r
     ] ;\r
 \r
@@ -121,14 +117,13 @@ M: user-saver dispose
         "email" <email> add-field\r
         "captcha" <captcha> add-field ;\r
 \r
-SYMBOL: password-mismatch?\r
-SYMBOL: user-exists?\r
+: password-mismatch "passwords do not match" validation-failed-with ;\r
+\r
+: user-exists "username taken" validation-failed-with ;\r
 \r
 : same-password-twice ( -- )\r
-    "new-password" value "verify-password" value = [ \r
-        password-mismatch? on\r
-        validation-failed\r
-    ] unless ;\r
+    "new-password" value "verify-password" value =\r
+    [ password-mismatch ] unless ;\r
 \r
 :: <register-action> ( -- action )\r
     [let | form [ <register-form> ] |\r
@@ -150,10 +145,7 @@ SYMBOL: user-exists?
                     "email" value >>email\r
                     H{ } clone >>profile\r
 \r
-                users new-user [\r
-                    user-exists? on\r
-                    validation-failed\r
-                ] unless*\r
+                users new-user [ user-exists ] unless*\r
 \r
                 successful-login\r
 \r
@@ -201,7 +193,7 @@ SYMBOL: user-exists?
                     same-password-twice\r
 \r
                     "password" value uid check-login\r
-                    [ login-failed? on validation-failed ] unless\r
+                    [ login-failed ] unless\r
 \r
                     "new-password" value >>encoded-password\r
                 ] unless\r
index 0524d0889fdc04ca1debf4d99ce607f5ae34bc79..d0a73a4d8b07046b19660899ffbb36f41f70a93a 100644 (file)
                <p>
 
                        <input type="submit" value="Log in" />
+                       <t:validation-message />
 
-                       <t:if t:var="http.server.auth.login:login-failed?">
-                               <t:error>invalid username or password</t:error>
-                       </t:if>
                </p>
 
        </t:form>
index 61ef0aef869229ec7f9cd0bb3a1b80144a051b29..6c60b257a890bdd5fd80a677c8c8d9487435bb9c 100644 (file)
 
                <p>
                        <input type="submit" value="Set password" />
-
-                       <t:if t:var="http.server.auth.login:password-mismatch?">
-                               <t:error>passwords do not match</t:error>
-                       </t:if>
+                       <t:validation-message />
                </p>
 
        </t:form>
index 19917002b5d621e72b1dd5706f165881ddd69cb1..9b45a7f0876d70a7bc66286886adb903c2c71213 100644 (file)
                <p>
 
                        <input type="submit" value="Register" />
-
-                       <t:if t:var="http.server.auth.login:user-exists?">
-                               <t:error>username taken</t:error>
-                       </t:if>
-
-                       <t:if t:var="http.server.auth.login:password-mismatch?">
-                               <t:error>passwords do not match</t:error>
-                       </t:if>
+                       <t:validation-message />
 
                </p>
 
index 509943faa8fe7d0c3c7d8462ce3484d4a985c561..20eb7318d0d6fc9d6c230418dee028a36d025378 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007, 2008 Slava Pestov.\r
 ! See http://factorcode.org/license.txt for BSD license.\r
-USING: namespaces kernel assocs io.files combinators\r
-arrays io.launcher io http.server.static http.server\r
+USING: namespaces kernel assocs io.files io.streams.duplex\r
+combinators arrays io.launcher io http.server.static http.server\r
 http accessors sequences strings math.parser fry ;\r
 IN: http.server.cgi\r
 \r
@@ -51,9 +51,9 @@ IN: http.server.cgi
     200 >>code\r
     "CGI output follows" >>message\r
     swap '[\r
-        , stdio get swap <cgi-process> <process-stream> [\r
+        , output-stream get swap <cgi-process> <process-stream> [\r
             post? [ request get post-data>> write flush ] when\r
-            stdio get swap (stream-copy)\r
+            input-stream get swap (stream-copy)\r
         ] with-stream\r
     ] >>body ;\r
 \r
index 8bf07700e81d690467d1f0d28221decc8401b1bf..19fc8c5ca87475f62135abd176773d980ce3efce 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
 USING: splitting kernel io sequences xmode.code2html accessors
-http.server.components xml.entities ;
+http.server.components html xml.entities ;
 IN: http.server.components.code
 
 TUPLE: code-renderer < text-renderer mode ;
@@ -11,7 +11,9 @@ TUPLE: code-renderer < text-renderer mode ;
         swap >>mode ;
 
 M: code-renderer render-view*
-    [ string-lines ] [ mode>> value ] bi* htmlize-lines ;
+    [
+        [ string-lines ] [ mode>> value ] bi* htmlize-lines
+    ] with-html-stream ;
 
 : <code> ( id mode -- component )
     swap <text>
index c0bac1fb99bd626ec4597b4c00b64b4ada428fbd..7f2a5a9ce182928699e78cfae99324b91394b1d5 100755 (executable)
@@ -3,7 +3,7 @@
 USING: accessors namespaces kernel io math.parser assocs classes
 words classes.tuple arrays sequences splitting mirrors
 hashtables fry locals combinators continuations math
-calendar.format html.elements xml.entities
+calendar.format html html.elements xml.entities
 http.server.validators ;
 IN: http.server.components
 
@@ -24,9 +24,6 @@ M: field render-view*
 M: field render-edit*
     <input type>> =type =name =value input/> ;
 
-: render-error ( message -- )
-    <span "error" =class span> escape-string write </span> ;
-
 TUPLE: hidden < field ;
 
 : hidden ( -- renderer ) T{ hidden f "hidden" } ; inline
index f6dd6c57bb156a300f0b3115f7b4032a0f4a9284..70c1e9a1f56abf5c0d029d6a4b600836ca6a5ed2 100755 (executable)
@@ -260,15 +260,13 @@ SYMBOL: exit-continuation
         bi
     ] recover ;
 
-: default-timeout 1 minutes stdio get set-timeout ;
-
 : ?refresh-all ( -- )
     development-mode get-global
     [ global [ refresh-all ] bind ] when ;
 
 : handle-client ( -- )
     [
-        default-timeout
+        1 minutes timeouts
         ?refresh-all
         read-request
         do-request
index 2ecc347d76eb942d09f24bd81dcb3c52b261cd35..b9a8e9d46ee2f493e579ccdc4fa48ae423543789 100755 (executable)
@@ -36,7 +36,7 @@ TUPLE: file-responder root hook special allow-listings ;
             [ size>> "content-length" set-header ]\r
             [ modified>> "last-modified" set-header ] bi\r
         ]\r
-        [ '[ , binary <file-reader> stdio get stream-copy ] >>body ] bi\r
+        [ '[ , binary <file-reader> output-stream get stream-copy ] >>body ] bi\r
     ] <file-responder> ;\r
 \r
 : serve-static ( filename mime-type -- response )\r
index a8a456cdb2472d2ec38d501a9876447a97942f96..c3d93f59099a202ea9f188fb48e39ef95fe87d4d 100644 (file)
@@ -1,10 +1,14 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
 USING: accessors kernel sequences combinators kernel namespaces
 classes.tuple assocs splitting words arrays memoize
-io io.files io.encodings.utf8 html.elements unicode.case
-tuple-syntax xml xml.data xml.writer xml.utilities
+io io.files io.encodings.utf8 io.streams.string
+unicode.case tuple-syntax html html.elements
+multiline xml xml.data xml.writer xml.utilities
 http.server
 http.server.auth
 http.server.flows
+http.server.actions
 http.server.components
 http.server.sessions
 http.server.templating
@@ -21,7 +25,10 @@ DEFER: process-template
 
 : chloe-ns "http://factorcode.org/chloe/1.0" ; inline
 
-: filter-chloe-attrs ( assoc -- assoc' )
+: chloe-attrs-only ( assoc -- assoc' )
+    [ drop name-url chloe-ns = ] assoc-filter ;
+
+: non-chloe-attrs-only ( assoc -- assoc' )
     [ drop name-url chloe-ns = not ] assoc-filter ;
 
 : chloe-tag? ( tag -- ? )
@@ -45,6 +52,12 @@ MEMO: chloe-name ( string -- name )
 : optional-attr ( tag name -- value )
     chloe-name swap at ;
 
+: children>string ( tag -- string )
+    [ [ process-template ] each ] with-string-writer ;
+
+: title-tag ( tag -- )
+    children>string set-title ;
+
 : write-title-tag ( tag -- )
     drop
     "head" tags get member? "title" tags get member? not and
@@ -131,16 +144,20 @@ MEMO: chloe-name ( string -- name )
 
 : form-start-tag ( tag -- )
     [
-        <form
-        "POST" =method
-        {
-            [ flow-attr ]
-            [ session-attr ]
-            [ "action" required-attr resolve-base-path =action ]
-            [ tag-attrs filter-chloe-attrs print-attrs ]
-        } cleave
-        form>
-        hidden-form-field
+        [
+            <form
+            "POST" =method
+            {
+                [ flow-attr ]
+                [ session-attr ]
+                [ "action" required-attr resolve-base-path =action ]
+                [ tag-attrs non-chloe-attrs-only print-attrs ]
+            } cleave
+            form>
+        ] [
+            hidden-form-field
+            "for" optional-attr [ component render-edit ] when*
+        ] bi
     ] with-scope ;
 
 : form-tag ( tag -- )
@@ -149,6 +166,26 @@ MEMO: chloe-name ( string -- name )
     [ drop </form> ]
     tri ;
 
+DEFER: process-chloe-tag
+
+STRING: button-tag-markup
+<t:form class="inline" xmlns:t="http://factorcode.org/chloe/1.0">
+    <button type="submit"></button>
+</t:form>
+;
+
+: add-tag-attrs ( attrs tag -- )
+    tag-attrs swap update ;
+
+: button-tag ( tag -- )
+    button-tag-markup string>xml delegate
+    {
+        [ >r tag-attrs chloe-attrs-only r> add-tag-attrs ]
+        [ >r tag-attrs non-chloe-attrs-only r> "button" tag-named add-tag-attrs ]
+        [ >r children>string 1array r> "button" tag-named set-tag-children ]
+        [ nip ]
+    } 2cleave process-chloe-tag ;
+
 : attr>word ( value -- word/f )
     dup ":" split1 swap lookup
     [ ] [ "No such word: " swap append throw ] ?if ;
@@ -159,23 +196,25 @@ MEMO: chloe-name ( string -- name )
     ] unless ;
 
 : if-satisfied? ( tag -- ? )
+    t swap
     {
-        [ "code" optional-attr [ attr>word execute ] [ t ] if* ]
-        [  "var" optional-attr [ attr>var      get ] [ t ] if* ]
-        [ "svar" optional-attr [ attr>var     sget ] [ t ] if* ]
-        [ "uvar" optional-attr [ attr>var     uget ] [ t ] if* ]
-    } cleave 4array [ ] all? ;
+        [ "code"  optional-attr [ attr>word execute and ] when* ]
+        [  "var"  optional-attr [ attr>var      get and ] when* ]
+        [ "svar"  optional-attr [ attr>var     sget and ] when* ]
+        [ "uvar"  optional-attr [ attr>var     uget and ] when* ]
+        [ "value" optional-attr [ value             and ] when* ]
+    } cleave ;
 
 : if-tag ( tag -- )
     dup if-satisfied? [ process-tag-children ] [ drop ] if ;
 
-: error-tag ( tag -- )
+: error-message-tag ( tag -- )
     children>string render-error ;
 
 : process-chloe-tag ( tag -- )
     dup name-tag {
         { "chloe" [ [ process-template ] each ] }
-        { "title" [ children>string set-title ] }
+        { "title" [ title-tag ] }
         { "write-title" [ write-title-tag ] }
         { "style" [ style-tag ] }
         { "write-style" [ write-style-tag ] }
@@ -186,7 +225,9 @@ MEMO: chloe-name ( string -- name )
         { "summary" [ summary-tag ] }
         { "a" [ a-tag ] }
         { "form" [ form-tag ] }
-        { "error" [ error-tag ] }
+        { "button" [ button-tag ] }
+        { "error-message" [ error-message-tag ] }
+        { "validation-message" [ drop render-validation-message ] }
         { "if" [ if-tag ] }
         { "comment" [ drop ] }
         { "call-next-template" [ drop call-next-template ] }
index e88301c7f88ac7d8d45d7747def55e53580bd88e..ca6f9d590553ac9cc3d6e610caa0494bbc56fbd0 100755 (executable)
@@ -148,4 +148,4 @@ SYMBOL: open-arrays
     init f exec-loop ;
 
 : run-sand ( -- )
-    "extra/icfp/2006/sandmark.umz" resource-path run-prog ;
+    "resource:extra/icfp/2006/sandmark.umz" run-prog ;
diff --git a/extra/interval-maps/authors.txt b/extra/interval-maps/authors.txt
new file mode 100755 (executable)
index 0000000..504363d
--- /dev/null
@@ -0,0 +1 @@
+Daniel Ehrenberg\r
diff --git a/extra/interval-maps/interval-maps-docs.factor b/extra/interval-maps/interval-maps-docs.factor
new file mode 100755 (executable)
index 0000000..1a862fb
--- /dev/null
@@ -0,0 +1,29 @@
+USING: help.markup help.syntax ;\r
+IN: interval-maps\r
+\r
+HELP: interval-at*\r
+{ $values { "key" "an object" } { "map" "an interval map" } { "value" "the value for the key, or f" } { "?" "whether the key is present" } }\r
+{ $description "Looks up a key in an interval map, returning the corresponding value if the item is in an interval in the map, and a boolean flag. The operation takes O(log n) time." } ;\r
+\r
+HELP: interval-at\r
+{ $values { "key" "an object" } { "map" "an interval map" } { "value" "the value for the key, or f" } }\r
+{ $description "Looks up a key in an interval map, returning the value of the corresponding interval, or f if the interval is not present in the map." } ;\r
+\r
+HELP: interval-key?\r
+{ $values { "key" "an object" } { "map" "an interval map" } { "?" "a boolean" } }\r
+{ $description "Tests whether an object is in an interval in the interval map, returning t if the object is present." } ;\r
+\r
+HELP: <interval-map>\r
+{ $values { "specification" "an assoc" } { "map" "an interval map" } }\r
+{ $description "From a specification, produce an interval tree. The specification is an assoc where the keys are intervals, or pairs of numbers to represent intervals, or individual numbers to represent singleton intervals. The values are the values int he interval map. Construction time is O(n log n)." } ;\r
+\r
+ARTICLE: "interval-maps" "Interval maps"\r
+"Interval maps are a mechanism, similar to assocs, where a set of closed intervals of keys are associated with values. As such, interval maps do not conform to the assoc protocol, because intervals of floats, for example, can be used, and it is impossible to get a list of keys in between."\r
+"The following operations are used to query interval maps:"\r
+{ $subsection interval-at* }\r
+{ $subsection interval-at }\r
+{ $subsection interval-key? }\r
+"Use the following to construct interval maps"\r
+{ $subsection <interval-map> } ;\r
+\r
+ABOUT: "interval-maps"\r
diff --git a/extra/interval-maps/interval-maps-tests.factor b/extra/interval-maps/interval-maps-tests.factor
new file mode 100755 (executable)
index 0000000..5a4b508
--- /dev/null
@@ -0,0 +1,18 @@
+USING: kernel namespaces interval-maps tools.test ;\r
+IN: interval-maps.test\r
+\r
+SYMBOL: test\r
+\r
+[ ] [ { { { 4 8 } 3 } { 1 2 } } <interval-map> test set ] unit-test\r
+[ 3 ] [ 5 test get interval-at ] unit-test\r
+[ 3 ] [ 8 test get interval-at ] unit-test\r
+[ 3 ] [ 4 test get interval-at ] unit-test\r
+[ f ] [ 9 test get interval-at ] unit-test\r
+[ 2 ] [ 1 test get interval-at ] unit-test\r
+[ f ] [ 2 test get interval-at ] unit-test\r
+[ f ] [ 0 test get interval-at ] unit-test\r
+\r
+[ { { { 1 4 } 3 } { { 4 8 } 6 } } <interval-map> ] must-fail\r
+\r
+[ { { { 1 3 } 2 } { { 4 5 } 4 } { { 7 8 } 4 } } ]\r
+[ { { 1 2 } { 2 2 } { 3 2 } { 4 4 } { 5 4 } { 7 4 } { 8 4 } } coalesce ] unit-test\r
diff --git a/extra/interval-maps/interval-maps.factor b/extra/interval-maps/interval-maps.factor
new file mode 100755 (executable)
index 0000000..7dcb946
--- /dev/null
@@ -0,0 +1,56 @@
+USING: kernel sequences arrays math.intervals accessors\r
+math.order sorting math assocs locals namespaces ;\r
+IN: interval-maps\r
+\r
+TUPLE: interval-map array ;\r
+\r
+<PRIVATE\r
+TUPLE: interval-node interval value ;\r
+\r
+: fixup-value ( value ? -- value/f ? )\r
+    [ drop f f ] unless* ;\r
+\r
+: find-interval ( key interval-map -- i )\r
+    [ interval>> from>> first <=> ] binsearch ;\r
+\r
+GENERIC: >interval ( object -- interval )\r
+M: number >interval [a,a] ;\r
+M: sequence >interval first2 [a,b] ;\r
+M: interval >interval ;\r
+\r
+: all-intervals ( sequence -- intervals )\r
+    [ >r >interval r> ] assoc-map ;\r
+\r
+: ensure-disjoint ( intervals -- intervals )\r
+    dup keys [ interval-intersect not ] monotonic?\r
+    [ "Intervals are not disjoint" throw ] unless ;\r
+\r
+\r
+PRIVATE>\r
+\r
+: interval-at* ( key map -- value ? )\r
+    array>> [ find-interval ] 2keep swapd nth\r
+    [ nip value>> ] [ interval>> interval-contains? ] 2bi\r
+    fixup-value ;\r
+\r
+: interval-at ( key map -- value ) interval-at* drop ;\r
+: interval-key? ( key map -- ? ) interval-at* nip ;\r
+\r
+: <interval-map> ( specification -- map )\r
+    all-intervals { } assoc-like\r
+    [ [ first to>> ] compare ] sort ensure-disjoint\r
+    [ interval-node boa ] { } assoc>map\r
+    interval-map boa ;\r
+\r
+:: coalesce ( alist -- specification )\r
+    ! Only works with integer keys, because they're discrete\r
+    ! Makes 2array keys\r
+    [\r
+        alist sort-keys unclip first2 dupd roll\r
+        [| oldkey oldval key val | ! Underneath is start\r
+            oldkey 1+ key =\r
+            oldval val = and\r
+            [ oldkey 2array oldval 2array , key ] unless\r
+            key val\r
+        ] assoc-each [ 2array ] bi@ ,\r
+    ] { } make ;\r
diff --git a/extra/interval-maps/summary.txt b/extra/interval-maps/summary.txt
new file mode 100755 (executable)
index 0000000..d252632
--- /dev/null
@@ -0,0 +1 @@
+Interval maps for disjoint closed ranges\r
diff --git a/extra/interval-maps/tags.txt b/extra/interval-maps/tags.txt
new file mode 100755 (executable)
index 0000000..5e9549f
--- /dev/null
@@ -0,0 +1 @@
+collections\r
index 265675f8dfd441bb3aff268a5df92abb697b3619..705c2d070b7b061eec157846fbd0eccea74f4f2c 100755 (executable)
@@ -197,7 +197,7 @@ DEFER: _
 
 \ prefix [ unclip ] define-inverse
 \ unclip [ prefix ] define-inverse
-\ suffix [ dup 1 head* swap peek ] define-inverse
+\ suffix [ dup but-last swap peek ] define-inverse
 
 ! Constructor inverse
 : deconstruct-pred ( class -- quot )
index 3fbb3908e272254c24f01bf3e329a9497e43e09b..88414efd16bfaab66d22c6e7c3713914e464d759 100755 (executable)
@@ -30,9 +30,8 @@ IN: io.encodings.8-bit
 } ;
 
 : encoding-file ( file-name -- stream )
-    "extra/io/encodings/8-bit/" ".TXT"
-    swapd 3append resource-path
-    ascii <file-reader> ;
+    "resource:extra/io/encodings/8-bit/" ".TXT"
+    swapd 3append ascii <file-reader> ;
 
 : tail-if ( seq n -- newseq )
     2dup swap length <= [ tail ] [ drop ] if ;
index dadb627fc073fcf2ce826438b61c858d7b3bf553..45bbec20e345cd0cd9d70a4da7c26edfd56e1752 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: help.markup help.syntax quotations kernel io math
-calendar ;
+USING: help.markup help.syntax quotations kernel io io.files
+math calendar ;
 IN: io.launcher
 
 ARTICLE: "io.launcher.command" "Specifying a command"
@@ -26,10 +26,10 @@ $nl
 "To specify redirection, set the " { $snippet "stdin" } ", " { $snippet "stdout" } " and " { $snippet "stderr" } " slots of a " { $link process } " to one of the following values:"
 { $list
     { { $link f } " - default value; the stream is either inherited from the current process, or is a " { $link <process-stream> } " pipe" }
-    { { $link +inherit+ } " - the stream is inherited from the current process, overriding a " { $link <process-stream> } " pipe" }
     { { $link +closed+ } " - the stream is closed; reads will return end of file and writes will fails" }
     { { $link +stdout+ } " - a special value for the " { $snippet "stderr" } " slot only, indicating that the standard output and standard error streams should be merged" }
     { "a path name - the stream is sent to the given file, which must exist for input and is created automatically on output" }
+    { "an " { $link appender } " wrapping a path name - output is sent to the end given file, as with " { $link <file-appender> } }
     { "a file stream or a socket - the stream is connected to the given Factor stream, which cannot be used again from within Factor and must be closed after the process has been started" }
 } ;
 
@@ -47,12 +47,16 @@ ARTICLE: "io.launcher.priority" "Setting process priority"
 HELP: +closed+
 { $description "Possible value for the " { $snippet "stdin" } ", " { $snippet "stdout" } ", and " { $snippet "stderr" } " slots of a " { $link process } "." } ;
 
-HELP: +inherit+
-{ $description "Possible value for the " { $snippet "stdin" } ", " { $snippet "stdout" } ", and " { $snippet "stderr" } " slots of a " { $link process } "." } ;
-
 HELP: +stdout+
 { $description "Possible value for the " { $snippet "stderr" } " slot of a " { $link process } "." } ;
 
+HELP: appender
+{ $class-description "An object representing a file to append to. Instances are created with " { $link <appender> } "." } ;
+
+HELP: <appender>
+{ $values { "path" "a pathname string" } { "appender" appender } }
+{ $description "Creates an object which may be stored in the " { $snippet "stdout" } " or " { $snippet "stderr" } " slot of a " { $link process } " instance." } ;
+
 HELP: +prepend-environment+
 { $description "Possible value of " { $snippet "environment-mode" } " slot of a " { $link process } "."
 $nl
@@ -138,13 +142,6 @@ HELP: <process-stream>
   { "stream" "a bidirectional stream" } }
 { $description "Launches a process and redirects its input and output via a pair of pipes which may be read and written as a stream of the given encoding." } ;
 
-HELP: with-process-stream
-{ $values
-  { "desc" "a launch descriptor" }
-  { "quot" quotation }
-  { "status" "an exit code" } }
-{ $description "Calls " { $snippet "quot" } " in a dynamic scope where " { $link stdio } " is rebound to a process stream. After the quotation returns, waits for the process to end and outputs the exit code." } ;
-
 HELP: wait-for-process
 { $values { "process" process } { "status" integer } }
 { $description "If the process is still running, waits for it to exit, otherwise outputs the exit code immediately. Can be called multiple times on the same process." } ;
@@ -175,8 +172,9 @@ ARTICLE: "io.launcher.launch" "Launching processes"
 { $subsection try-process }
 { $subsection run-detached }
 "Redirecting standard input and output to a pipe:"
-{ $subsection <process-stream> }
-{ $subsection with-process-stream } ;
+{ $subsection <process-reader> }
+{ $subsection <process-writer> }
+{ $subsection <process-stream> } ;
 
 ARTICLE: "io.launcher.examples" "Launcher examples"
 "Starting a command and waiting for it to finish:"
@@ -212,7 +210,7 @@ ARTICLE: "io.launcher.examples" "Launcher examples"
     "    <process>"
     "        swap >>stderr"
     "        \"report\" >>command"
-    "    ascii <process-stream> lines sort reverse [ print ] each"
+    "    ascii <process-reader> lines sort reverse [ print ] each"
     "] with-disposal"
 } ;
 
index bacb8eb5a965d1a3f0911c857589530b6bdc433c..003f38202073b19339ba25eacf182cfa3857bd25 100755 (executable)
@@ -2,3 +2,5 @@ IN: io.launcher.tests
 USING: tools.test io.launcher ;
 
 \ <process-stream> must-infer
+\ <process-reader> must-infer
+\ <process-writer> must-infer
index 6ee866052866b8ef007215c15505806ca1b42471..e9fbdaea62d6a9f70a2a139b85771c0d5a7ddc2e 100755 (executable)
@@ -1,9 +1,10 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: io io.backend io.timeouts system kernel namespaces
-strings hashtables sequences assocs combinators vocabs.loader
-init threads continuations math io.encodings io.streams.duplex
-io.nonblocking accessors concurrency.flags ;
+USING: system kernel namespaces strings hashtables sequences 
+assocs combinators vocabs.loader init threads continuations
+math accessors concurrency.flags destructors
+io io.backend io.timeouts io.pipes io.pipes.private io.encodings
+io.streams.duplex io.nonblocking ;
 IN: io.launcher
 
 TUPLE: process < identity-tuple
@@ -26,9 +27,12 @@ handle status
 killed ;
 
 SYMBOL: +closed+
-SYMBOL: +inherit+
 SYMBOL: +stdout+
 
+TUPLE: appender path ;
+
+: <appender> ( path -- appender ) appender boa ;
+
 SYMBOL: +prepend-environment+
 SYMBOL: +replace-environment+
 SYMBOL: +append-environment+
@@ -145,20 +149,63 @@ M: process set-timeout set-process-timeout ;
 
 M: process timed-out kill-process ;
 
-HOOK: (process-stream) io-backend ( process -- handle in out )
+M: object run-pipeline-element
+    [ >process swap >>stdout swap >>stdin run-detached ]
+    [ drop [ [ close-handle ] when* ] bi@ ]
+    3bi
+    wait-for-process ;
 
-: <process-stream*> ( desc encoding -- stream process )
-    >r >process dup dup (process-stream) <reader&writer>
-    r> <encoder-duplex> -roll
-    process-started ;
+: <process-reader*> ( process encoding -- process stream )
+    [
+        >r (pipe) {
+            [ add-error-destructor ]
+            [
+                swap >process
+                    [ swap out>> or ] change-stdout
+                run-detached
+            ]
+            [ out>> close-handle ]
+            [ in>> <reader> ]
+        } cleave r> <decoder>
+    ] with-destructors ;
+
+: <process-reader> ( desc encoding -- stream )
+    <process-reader*> nip ; inline
+
+: <process-writer*> ( process encoding -- process stream )
+    [
+        >r (pipe) {
+            [ add-error-destructor ]
+            [
+                swap >process
+                    [ swap in>> or ] change-stdout
+                run-detached
+            ]
+            [ in>> close-handle ]
+            [ out>> <writer> ]
+        } cleave r> <encoder>
+    ] with-destructors ;
+
+: <process-writer> ( desc encoding -- stream )
+    <process-writer*> nip ; inline
+
+: <process-stream*> ( process encoding -- process stream )
+    [
+        >r (pipe) (pipe) {
+            [ [ add-error-destructor ] bi@ ]
+            [
+                rot >process
+                    [ swap out>> or ] change-stdout
+                    [ swap in>> or ] change-stdin
+                run-detached
+            ]
+            [ [ in>> close-handle ] [ out>> close-handle ] bi* ]
+            [ [ in>> <reader> ] [ out>> <writer> ] bi* ]
+        } 2cleave r> <encoder-duplex>
+    ] with-destructors ;
 
 : <process-stream> ( desc encoding -- stream )
-    <process-stream*> drop ; inline
-
-: with-process-stream ( desc quot -- status )
-    swap <process-stream*> >r
-    [ swap with-stream ] keep
-    r> wait-for-process ; inline
+    <process-stream*> nip ; inline
 
 : notify-exit ( process status -- )
     >>status
@@ -168,9 +215,9 @@ HOOK: (process-stream) io-backend ( process -- handle in out )
 
 GENERIC: underlying-handle ( stream -- handle )
 
-M: port underlying-handle port-handle ;
+M: port underlying-handle handle>> ;
 
 M: duplex-stream underlying-handle
-    dup duplex-stream-in underlying-handle
-    swap duplex-stream-out underlying-handle tuck =
-    [ "Invalid duplex stream" throw ] when ;
+    [ in>> underlying-handle ]
+    [ out>> underlying-handle ] bi
+    [ = [ "Invalid duplex stream" throw ] when ] keep ;
index fc8ade5758287c9dc0409d666b44471a1df31a2c..d25d4b70504f191add8f1adb502716d000ded2b1 100755 (executable)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2005, 2008 Slava Pestov, Doug Coleman
 ! See http://factorcode.org/license.txt for BSD license.
 USING: math kernel io sequences io.buffers io.timeouts generic
-byte-vectors system io.streams.duplex io.encodings math.order
-io.backend continuations debugger classes byte-arrays namespaces
-splitting dlists assocs io.encodings.binary inspector accessors ;
+byte-vectors system io.encodings math.order io.backend
+continuations debugger classes byte-arrays namespaces splitting
+dlists assocs io.encodings.binary inspector accessors ;
 IN: io.nonblocking
 
 SYMBOL: default-buffer-size
diff --git a/extra/io/pipes/pipes-docs.factor b/extra/io/pipes/pipes-docs.factor
new file mode 100644 (file)
index 0000000..d51ae94
--- /dev/null
@@ -0,0 +1,47 @@
+USING: help.markup help.syntax continuations io ;
+IN: io.pipes
+
+HELP: pipe
+{ $class-description "A low-level pipe. Instances are created by calling " { $link (pipe) } " and closed by calling " { $link dispose } "." } ;
+
+HELP: (pipe)
+{ $values { "pipe" pipe } }
+{ $description "Opens a new pipe. This is a low-level word; the " { $link <pipe> } " and " { $link run-pipeline } " words can be used in most cases instead." } ;
+
+HELP: <pipe>
+{ $values { "encoding" "an encoding specifier" } { "stream" "a bidirectional stream" } }
+{ $description "Opens a new pipe and wraps it in a stream. Data written from the stream can be read back from the same stream instance." }
+{ $notes "Pipe streams must be disposed by calling " { $link dispose } " or " { $link with-disposal } " to avoid resource leaks." } ;
+
+HELP: run-pipeline
+{ $values { "seq" "a sequence of pipeline components" } { "results" "a sequence of pipeline results" } }
+{ $description
+    "Creates a pipe between each pipeline component, with the output of each component becoming the input of the next."
+    $nl
+    "The first component reads input from " { $link input-stream } " and the last component writes output to " { $link output-stream } "."
+    $nl
+    "Each component runs in its own thread, and the word returns when all components finish executing. Each component outputs a result value."
+    $nl
+    "Pipeline components must be one of the following:"
+    { $list
+        { "A quotation. The quotation is called with both " { $link input-stream } " and " { $link output-stream } " rebound, except for the first and last pipeline components, and it must output a single value." }
+        { "A process launch descriptor. See " { $link "io.launcher.descriptors" } "." }
+    }
+}
+{ $examples
+    "Print the lines of a log file which contain the string ``error'', sort them and filter out duplicates, using Unix shell commands only:"
+    { $code "{ \"cat log.txt\" \"grep error\" \"sort\" \"uniq\" } run-pipeline" }
+} ;
+
+ARTICLE: "io.pipes" "Pipes"
+"A " { $emphasis "pipe" } " is a unidirectional channel for transfer of bytes. Data written to one end of the pipe can be read from the other. Pipes can be used to pass data between processes; they can also be used within a single process to implement communication between coroutines."
+$nl
+"Low-level pipes:"
+{ $subsection pipe }
+{ $subsection (pipe) }
+"High-level pipe streams:"
+{ $subsection <pipe> }
+"Pipelines of coroutines and processes:"
+{ $subsection run-pipeline } ;
+
+ABOUT: "io.pipes"
diff --git a/extra/io/pipes/pipes-tests.factor b/extra/io/pipes/pipes-tests.factor
new file mode 100755 (executable)
index 0000000..c1b37f6
--- /dev/null
@@ -0,0 +1,26 @@
+USING: io io.pipes io.streams.string io.encodings.utf8
+io.streams.duplex io.encodings namespaces continuations
+tools.test kernel ;
+IN: io.pipes.tests
+
+[ "Hello" ] [
+    utf8 <pipe> [
+        "Hello" print flush
+        readln
+    ] with-stream
+] unit-test
+
+[ { } ] [ { } run-pipeline ] unit-test
+[ { f } ] [ { [ f ] } run-pipeline ] unit-test
+[ { "Hello" } ] [
+    "Hello" [
+        { [ input-stream [ utf8 <decoder> ] change readln ] } run-pipeline
+    ] with-string-reader
+] unit-test
+
+[ { f "Hello" } ] [
+    {
+        [ output-stream [ utf8 <encoder> ] change "Hello" print flush f ]
+        [ input-stream [ utf8 <decoder> ] change readln ]
+    } run-pipeline
+] unit-test
diff --git a/extra/io/pipes/pipes.factor b/extra/io/pipes/pipes.factor
new file mode 100644 (file)
index 0000000..72d2737
--- /dev/null
@@ -0,0 +1,53 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings io.backend io.nonblocking io.streams.duplex
+io splitting sequences sequences.lib namespaces kernel
+destructors math concurrency.combinators accessors
+arrays continuations quotations ;
+IN: io.pipes
+
+TUPLE: pipe in out ;
+
+M: pipe dispose ( pipe -- )
+    [ in>> close-handle ] [ out>> close-handle ] bi ;
+
+HOOK: (pipe) io-backend ( -- pipe )
+
+: <pipe> ( encoding -- stream )
+    [
+        >r (pipe)
+        [ add-error-destructor ]
+        [ in>> <reader> ]
+        [ out>> <writer> ]
+        tri
+        r> <encoder-duplex>
+    ] with-destructors ;
+
+<PRIVATE
+
+: ?reader [ <reader> dup add-always-destructor ] [ input-stream get ] if* ;
+: ?writer [ <writer> dup add-always-destructor ] [ output-stream get ] if* ;
+
+GENERIC: run-pipeline-element ( input-fd output-fd obj -- quot )
+
+M: callable run-pipeline-element
+    [
+        >r [ ?reader ] [ ?writer ] bi*
+        r> with-streams*
+    ] with-destructors ;
+
+: <pipes> ( n -- pipes )
+    [
+        [ (pipe) dup add-error-destructor ] replicate
+        T{ pipe } [ prefix ] [ suffix ] bi
+        2 <clumps>
+    ] with-destructors ;
+
+PRIVATE>
+
+: run-pipeline ( seq -- results )
+    [ length dup zero? [ drop { } ] [ 1- <pipes> ] if ] keep
+    [
+        >r [ first in>> ] [ second out>> ] bi
+        r> run-pipeline-element
+    ] 2parallel-map ;
index 7eda48f747e3458a909ed686456e0f412691c5f0..50f38cb1465fc08224082d8085c2d175511f5f2b 100755 (executable)
@@ -3,8 +3,8 @@ IN: io.server
 
 HELP: with-server
 { $values { "seq" "a sequence of address specifiers" } { "service" "a string or " { $link f } } { "encoding" "an encoding to use for client connections" } { "quot" "a quotation" } }
-{ $description "Starts a TCP/IP server. The quotation is called in a new thread for each client connection, with the client connection being the " { $link stdio } " stream. Client connections are logged to the " { $link stdio } " stream at the time the server was started." } ;
+{ $description "Starts a TCP/IP server. The quotation is called in a new thread for each client connection, with the client connection being both the " { $link input-stream } " and " { $link output-stream } "." } ;
 
 HELP: with-datagrams
 { $values { "seq" "a sequence of address specifiers" } { "service" "a string or " { $link f } } { "quot" "a quotation" } }
-{ $description "Starts a UDP/IP server. The quotation is called for each datagram packet received. Datagram packets are logged to the " { $link stdio } " stream at the time the server was started." } ;
+{ $description "Starts a UDP/IP server. The quotation is called for each datagram packet received." } ;
index 45e3b1de6687a4d9b59310c7b2eef1dc55c0ad32..1d626a9e152a1bb6822ca2e10a2a62981a4c665d 100755 (executable)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2003, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: io io.sockets io.files logging continuations kernel
-math math.parser namespaces parser sequences strings
-prettyprint debugger quotations calendar
+USING: io io.sockets io.files io.streams.duplex logging
+continuations kernel math math.parser namespaces parser
+sequences strings prettyprint debugger quotations calendar
 threads concurrency.combinators assocs ;
 IN: io.server
 
index ad78b4631cac2472f3b5dacb9d204575f5b98ecc..ee3cb3aa7ba0ad77945ec8c353ac232b452a34ca 100755 (executable)
@@ -14,6 +14,7 @@ ARTICLE: "network-addressing" "Address specifiers"
 ARTICLE: "network-connection" "Connection-oriented networking"
 "Network connections can be established with this word:"
 { $subsection <client> }
+{ $subsection with-client }
 "Connection-oriented network servers are implemented by first opening a server socket, then waiting for connections:"
 { $subsection <server> }
 { $subsection accept }
index 859dcb4cdc69a31f53f389112e32e553272df0b4..f835f0beb2d03ac1e876061cd91a236c35b1f843 100755 (executable)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2007, 2008 Slava Pestov, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: generic kernel io.backend namespaces continuations
-sequences arrays io.encodings io.nonblocking accessors ;
+sequences arrays io.encodings io.nonblocking io.streams.duplex
+accessors ;
 IN: io.sockets
 
 TUPLE: local path ;
@@ -30,6 +31,9 @@ M: object (client) ((client)) ;
 : <client> ( addrspec encoding -- stream )
     >r (client) r> <encoder-duplex> ;
 
+: with-client ( addrspec encoding quot -- )
+    >r <client> r> with-stream ; inline
+
 HOOK: (server) io-backend ( addrspec -- handle )
 
 : <server> ( addrspec encoding -- server )
diff --git a/extra/io/streams/duplex/authors.txt b/extra/io/streams/duplex/authors.txt
new file mode 100644 (file)
index 0000000..1901f27
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
diff --git a/extra/io/streams/duplex/duplex-docs.factor b/extra/io/streams/duplex/duplex-docs.factor
new file mode 100755 (executable)
index 0000000..15d401a
--- /dev/null
@@ -0,0 +1,39 @@
+USING: help.markup help.syntax io continuations quotations ;
+IN: io.streams.duplex
+
+ARTICLE: "io.streams.duplex" "Duplex streams"
+"Duplex streams combine an input stream and an output stream into a bidirectional stream."
+{ $subsection duplex-stream }
+{ $subsection <duplex-stream> }
+"A pair of combinators for rebinding both default streams at once:"
+{ $subsection with-stream }
+{ $subsection with-stream* } ;
+
+ABOUT: "io.streams.duplex"
+
+HELP: duplex-stream
+{ $class-description "A bidirectional stream wrapping an input and output stream." } ;
+
+HELP: <duplex-stream>
+{ $values { "in" "an input stream" } { "out" "an output stream" } { "stream" " a duplex stream" } }
+{ $description "Creates a duplex stream. Writing to a duplex stream will write to " { $snippet "out" } ", and reading from a duplex stream will read from " { $snippet "in" } ". Closing a duplex stream closes both the input and output streams." } ;
+
+HELP: stream-closed-twice
+{ $error-description "This error is thrown when performing an I/O operation on a " { $link duplex-stream } " which has been closed with " { $link dispose } "." } ;
+
+HELP: with-stream
+{ $values { "stream" duplex-stream } { "quot" quotation } }
+{ $description "Calls the quotation in a new dynamic scope, with both " { $link input-stream } " and " { $link output-stream } " rebound to  " { $snippet "stream" } ". The stream is closed if the quotation returns or throws an error." } ;
+
+HELP: with-stream*
+{ $values { "stream" duplex-stream } { "quot" quotation } }
+{ $description "Calls the quotation in a new dynamic scope, with both " { $link input-stream } " and " { $link output-stream } " rebound to  " { $snippet "stream" } "." }
+{ $notes "This word does not close the stream. Compare with " { $link with-stream } "." } ;
+
+HELP: <encoder-duplex>
+{ $values { "stream-in" "an input stream" }
+    { "stream-out" "an output stream" }
+    { "encoding" "an encoding descriptor" }
+    { "duplex" "an encoded duplex stream" } }
+{ $description "Wraps the given streams in an encoder or decoder stream, and puts them together in a duplex stream for input and output. If either input stream is already encoded, that encoding is stripped off before it is reencoded. The encoding descriptor must conform to the " { $link "encodings-protocol" } "." }
+$low-level-note ;
diff --git a/extra/io/streams/duplex/duplex-tests.factor b/extra/io/streams/duplex/duplex-tests.factor
new file mode 100755 (executable)
index 0000000..ebc6b3b
--- /dev/null
@@ -0,0 +1,40 @@
+USING: io.streams.duplex io kernel continuations tools.test ;
+IN: io.streams.duplex.tests
+
+! Test duplex stream close behavior
+TUPLE: closing-stream closed? ;
+
+: <closing-stream> closing-stream new ;
+
+M: closing-stream dispose
+    dup closing-stream-closed? [
+        "Closing twice!" throw
+    ] [
+        t swap set-closing-stream-closed?
+    ] if ;
+
+TUPLE: unclosable-stream ;
+
+: <unclosable-stream> unclosable-stream new ;
+
+M: unclosable-stream dispose
+    "Can't close me!" throw ;
+
+[ ] [
+    <closing-stream> <closing-stream> <duplex-stream>
+    dup dispose dispose
+] unit-test
+
+[ t ] [
+    <unclosable-stream> <closing-stream> [
+        <duplex-stream>
+        [ dup dispose ] [ 2drop ] recover
+    ] keep closing-stream-closed?
+] unit-test
+
+[ t ] [
+    <closing-stream> [ <unclosable-stream>
+        <duplex-stream>
+        [ dup dispose ] [ 2drop ] recover
+    ] keep closing-stream-closed?
+] unit-test
diff --git a/extra/io/streams/duplex/duplex.factor b/extra/io/streams/duplex/duplex.factor
new file mode 100755 (executable)
index 0000000..cb96d80
--- /dev/null
@@ -0,0 +1,56 @@
+! Copyright (C) 2005, 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel continuations io io.encodings io.encodings.private
+io.timeouts debugger inspector listener accessors delegate
+delegate.protocols ;
+IN: io.streams.duplex
+
+! We ensure that the stream can only be closed once, to preserve
+! integrity of duplex I/O ports.
+
+TUPLE: duplex-stream in out closed ;
+
+: <duplex-stream> ( in out -- stream )
+    f duplex-stream boa ;
+
+ERROR: stream-closed-twice ;
+
+M: stream-closed-twice summary
+    drop "Attempt to perform I/O on closed stream" ;
+
+<PRIVATE
+
+: check-closed ( stream -- stream )
+    dup closed>> [ stream-closed-twice ] when ; inline
+
+: in ( duplex -- stream ) check-closed in>> ;
+
+: out ( duplex -- stream ) check-closed out>> ;
+
+PRIVATE>
+
+CONSULT: input-stream-protocol duplex-stream in ;
+
+CONSULT: output-stream-protocol duplex-stream out ;
+
+M: duplex-stream set-timeout
+    [ in set-timeout ] [ out set-timeout ] 2bi ;
+
+M: duplex-stream dispose
+    #! The output stream is closed first, in case both streams
+    #! are attached to the same file descriptor, the output
+    #! buffer needs to be flushed before we close the fd.
+    dup closed>> [
+        t >>closed
+        [ dup out>> dispose ]
+        [ dup in>> dispose ] [ ] cleanup
+    ] unless drop ;
+
+: <encoder-duplex> ( stream-in stream-out encoding -- duplex )
+    tuck reencode >r redecode r> <duplex-stream> ;
+
+: with-stream* ( stream quot -- )
+    >r [ in>> ] [ out>> ] bi r> with-streams* ; inline
+
+: with-stream ( stream quot -- )
+    >r [ in>> ] [ out>> ] bi r> with-streams ; inline
diff --git a/extra/io/streams/duplex/summary.txt b/extra/io/streams/duplex/summary.txt
new file mode 100644 (file)
index 0000000..b15d3aa
--- /dev/null
@@ -0,0 +1 @@
+Combine an input and an output stream into a single duplex stream
index eee66239bed268c12515b778d84df2a1b857f0ce..384a3806b8511e249917bef338f28110a0ee251f 100755 (executable)
@@ -1,25 +1,38 @@
 ! Copyright (C) 2007 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 IN: io.streams.null
-USING: kernel io io.timeouts continuations ;
+USING: kernel io io.timeouts io.streams.duplex continuations ;
 
 TUPLE: null-stream ;
 
 M: null-stream dispose drop ;
 M: null-stream set-timeout 2drop ;
-M: null-stream stream-readln drop f ;
-M: null-stream stream-read1 drop f ;
-M: null-stream stream-read-until 2drop f f ;
-M: null-stream stream-read 2drop f ;
-M: null-stream stream-write1 2drop ;
-M: null-stream stream-write 2drop ;
-M: null-stream stream-nl drop ;
-M: null-stream stream-flush drop ;
-M: null-stream stream-format 3drop ;
-M: null-stream make-span-stream nip ;
-M: null-stream make-block-stream nip ;
-M: null-stream make-cell-stream nip ;
-M: null-stream stream-write-table 3drop ;
+
+TUPLE: null-reader < null-stream ;
+
+M: null-reader stream-readln drop f ;
+M: null-reader stream-read1 drop f ;
+M: null-reader stream-read-until 2drop f f ;
+M: null-reader stream-read 2drop f ;
+
+TUPLE: null-writer < null-stream ;
+
+M: null-writer stream-write1 2drop ;
+M: null-writer stream-write 2drop ;
+M: null-writer stream-nl drop ;
+M: null-writer stream-flush drop ;
+M: null-writer stream-format 3drop ;
+M: null-writer make-span-stream nip ;
+M: null-writer make-block-stream nip ;
+M: null-writer make-cell-stream nip ;
+M: null-writer stream-write-table 3drop ;
+
+: with-null-reader ( quot -- )
+    T{ null-reader } swap with-input-stream* ; inline
+
+: with-null-writer ( quot -- )
+    T{ null-writer } swap with-output-stream* ; inline
 
 : with-null-stream ( quot -- )
-    T{ null-stream } swap with-stream* ; inline
+    T{ duplex-stream f T{ null-reader } T{ null-writer } }
+    swap with-stream* ; inline
index f1031e98e2b0619b873795796458937d31753143..f9ffd5e98ffd6aee7e6e05c45b61bc72ccc6a62d 100755 (executable)
@@ -1,20 +1,16 @@
 ! Copyright (C) 2008 Slava Pestov, Doug Coleman\r
 ! See http://factorcode.org/license.txt for BSD license.\r
-USING: kernel calendar alarms io.streams.duplex io.encodings ;\r
+USING: kernel calendar alarms io io.encodings accessors\r
+namespaces ;\r
 IN: io.timeouts\r
 \r
 ! Won't need this with new slot accessors\r
 GENERIC: timeout ( obj -- dt/f )\r
 GENERIC: set-timeout ( dt/f obj -- )\r
 \r
-M: duplex-stream set-timeout\r
-    2dup\r
-    duplex-stream-in set-timeout\r
-    duplex-stream-out set-timeout ;\r
+M: decoder set-timeout stream>> set-timeout ;\r
 \r
-M: decoder set-timeout decoder-stream set-timeout ;\r
-\r
-M: encoder set-timeout encoder-stream set-timeout ;\r
+M: encoder set-timeout stream>> set-timeout ;\r
 \r
 GENERIC: timed-out ( obj -- )\r
 \r
@@ -29,3 +25,7 @@ M: object timed-out drop ;
     ] [\r
         2drop call\r
     ] if ; inline\r
+\r
+: timeouts ( dt -- )\r
+    [ input-stream get set-timeout ]\r
+    [ output-stream get set-timeout ] bi ;\r
index ba4e587d13f918dd9912d1364bfb041f4f99506f..08ff526f14ac9849ecfe19b920547d1a78c6af6e 100644 (file)
@@ -1,10 +1,10 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien generic assocs kernel kernel.private math
-io.nonblocking sequences strings structs sbufs
-threads unix vectors io.buffers io.backend io.encodings
-io.streams.duplex math.parser continuations system libc
-qualified namespaces io.timeouts io.encodings.utf8 accessors ;
+io.nonblocking sequences strings structs sbufs threads unix
+vectors io.buffers io.backend io.encodings math.parser
+continuations system libc qualified namespaces io.timeouts
+io.encodings.utf8 accessors ;
 QUALIFIED: io
 IN: io.unix.backend
 
@@ -78,7 +78,8 @@ M: integer init-handle ( fd -- )
     #! since on OS X 10.3, this operation fails from init-io
     #! when running the Factor.app (presumably because fd 0 and
     #! 1 are closed).
-    F_SETFL O_NONBLOCK fcntl drop ;
+    [ F_SETFL O_NONBLOCK fcntl drop ]
+    [ F_SETFD FD_CLOEXEC fcntl drop ] bi ;
 
 M: integer close-handle ( fd -- )
     close ;
index 7e527196be012b579b8ab2fb9ecee12a2afe5fc3..177c5775dcd86d83eeb559b952e7cc9c7f7c2b5b 100755 (executable)
@@ -31,16 +31,7 @@ accessors kernel sequences io.encodings.utf8 ;
     "cat"
     "launcher-test-1" temp-file
     2array
-    ascii <process-stream> contents
-] unit-test
-
-[ f ] [
-    <process>
-        "cat"
-        "launcher-test-1" temp-file
-        2array >>command
-        +inherit+ >>stdout
-    ascii <process-stream> contents
+    ascii <process-reader> contents
 ] unit-test
 
 [ ] [
@@ -59,7 +50,7 @@ accessors kernel sequences io.encodings.utf8 ;
     "cat"
     "launcher-test-1" temp-file
     2array
-    ascii <process-stream> contents
+    ascii <process-reader> contents
 ] unit-test
 
 [ ] [
@@ -77,14 +68,14 @@ accessors kernel sequences io.encodings.utf8 ;
     "cat"
     "launcher-test-1" temp-file
     2array
-    ascii <process-stream> contents
+    ascii <process-reader> contents
 ] unit-test
 
 [ t ] [
     <process>
         "env" >>command
         { { "A" "B" } } >>environment
-    ascii <process-stream> lines
+    ascii <process-reader> lines
     "A=B" swap member?
 ] unit-test
 
@@ -93,7 +84,7 @@ accessors kernel sequences io.encodings.utf8 ;
         "env" >>command
         { { "A" "B" } } >>environment
         +replace-environment+ >>environment-mode
-    ascii <process-stream> lines
+    ascii <process-reader> lines
 ] unit-test
 
 [ "hi\n" ] [
@@ -107,3 +98,15 @@ accessors kernel sequences io.encodings.utf8 ;
     temp-directory "aloha" append-path
     utf8 file-contents
 ] unit-test
+
+[ "append-test" temp-file delete-file ] ignore-errors
+
+[ "hi\nhi\n" ] [
+    2 [
+        <process>
+            "echo hi" >>command
+            "append-test" temp-file <appender> >>stdout
+        try-process
+    ] times
+    "append-test" temp-file utf8 file-contents
+] unit-test
index 2c1e6261c045301224a8aa24ab86d1f5dfcfde74..043b2bd73ed9fdb2e9cfbd29f71cb63160468a98 100755 (executable)
@@ -1,10 +1,12 @@
 ! Copyright (C) 2007, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: io io.backend io.launcher io.nonblocking io.unix.backend
-io.unix.files io.nonblocking sequences kernel namespaces math
-system alien.c-types debugger continuations arrays assocs
-combinators unix.process strings threads unix
-io.unix.launcher.parser accessors io.files io.files.private ;
+USING: kernel namespaces math system sequences debugger
+continuations arrays assocs combinators alien.c-types strings
+threads accessors
+io io.backend io.launcher io.nonblocking io.files
+io.files.private io.unix.files io.unix.backend
+io.unix.launcher.parser
+unix unix.process ;
 IN: io.unix.launcher
 
 ! Search unix first
@@ -34,7 +36,8 @@ USE: unix
 : reset-fd ( fd -- )
     #! We drop the error code because on *BSD, fcntl of
     #! /dev/null fails.
-    F_SETFL 0 fcntl drop ;
+    [ F_SETFL 0 fcntl drop ]
+    [ F_SETFD 0 fcntl drop ] bi ;
 
 : redirect-inherit ( obj mode fd -- )
     2nip reset-fd ;
@@ -43,19 +46,20 @@ USE: unix
     >r >r normalize-path r> file-mode
     open dup io-error r> redirect-fd ;
 
+: redirect-file-append ( obj mode fd -- )
+    >r drop path>> normalize-path open-append r> redirect-fd ;
+
 : redirect-closed ( obj mode fd -- )
     >r >r drop "/dev/null" r> r> redirect-file ;
 
-: redirect-stream ( obj mode fd -- )
-    >r drop underlying-handle dup reset-fd r> redirect-fd ;
-
 : redirect ( obj mode fd -- )
     {
         { [ pick not ] [ redirect-inherit ] }
         { [ pick string? ] [ redirect-file ] }
+        { [ pick appender? ] [ redirect-file-append ] }
         { [ pick +closed+ eq? ] [ redirect-closed ] }
-        { [ pick +inherit+ eq? ] [ redirect-closed ] }
-        [ redirect-stream ]
+        { [ pick integer? ] [ >r drop dup reset-fd r> redirect-fd ] }
+        [ >r >r underlying-handle r> r> redirect ]
     } cond ;
 
 : ?closed dup +closed+ eq? [ drop "/dev/null" ] when ;
@@ -90,27 +94,10 @@ M: unix run-process* ( process -- pid )
 M: unix kill-process* ( pid -- )
     SIGTERM kill io-error ;
 
-: open-pipe ( -- pair )
-    2 "int" <c-array> dup pipe zero?
-    [ 2 c-int-array> ] [ drop f ] if ;
-
-: setup-stdio-pipe ( stdin stdout -- )
-    2dup first close second close
-    >r first 0 dup2 drop r> second 1 dup2 drop ;
-
-M: unix (process-stream)
-    >r open-pipe open-pipe r>
-    [ >r setup-stdio-pipe r> spawn-process ] curry
-    [ -rot 2dup second close first close ]
-    with-fork
-    first swap second ;
-
 : find-process ( handle -- process )
     processes get swap [ nip swap handle>> = ] curry
     assoc-find 2drop ;
 
-! Inefficient process wait polling, used on Linux and Solaris.
-! On BSD and Mac OS X, we use kqueue() which scales better.
 M: unix wait-for-processes ( -- ? )
     -1 0 <int> tuck WNOHANG waitpid
     dup 0 <= [
index 0a0aec6ab66b2f8290ae63971e7755cb2c4777f4..8a5d0c490fca037c54b2ae954fbb17b60db11f42 100644 (file)
@@ -13,9 +13,11 @@ TUPLE: macosx-monitor < monitor handle ;
     ] curry each ;
 
 M:: macosx (monitor) ( path recursive? mailbox -- monitor )
-    path mailbox macosx-monitor new-monitor
-    dup [ enqueue-notifications ] curry
-    path 1array 0 0 <event-stream> >>handle ;
+    [let | path [ path normalize-path ] |
+        path mailbox macosx-monitor new-monitor
+        dup [ enqueue-notifications ] curry
+        path 1array 0 0 <event-stream> >>handle
+    ] ;
 
 M: macosx-monitor dispose
     handle>> dispose ;
diff --git a/extra/io/unix/pipes/pipes-tests.factor b/extra/io/unix/pipes/pipes-tests.factor
new file mode 100644 (file)
index 0000000..27a490d
--- /dev/null
@@ -0,0 +1,17 @@
+USING: tools.test io.pipes io.unix.pipes io.encodings.utf8
+io.encodings io namespaces sequences ;
+IN: io.unix.pipes.tests
+
+[ { 0 0 } ] [ { "ls" "grep x" } run-pipeline ] unit-test
+
+[ { 0 f 0 } ] [
+    {
+        "ls"
+        [
+            input-stream [ utf8 <decoder> ] change
+            output-stream [ utf8 <encoder> ] change
+            input-stream get lines reverse [ print ] each f
+        ]
+        "grep x"
+    } run-pipeline
+] unit-test
diff --git a/extra/io/unix/pipes/pipes.factor b/extra/io/unix/pipes/pipes.factor
new file mode 100644 (file)
index 0000000..4fc5acf
--- /dev/null
@@ -0,0 +1,12 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: system alien.c-types kernel unix math sequences
+qualified io.unix.backend io.nonblocking ;
+IN: io.unix.pipes
+QUALIFIED: io.pipes
+
+M: unix io.pipes:(pipe) ( -- pair )
+    2 "int" <c-array>
+    dup pipe io-error
+    2 c-int-array> first2
+    [ [ init-handle ] bi@ ] [ io.pipes:pipe boa ] 2bi ;
index ff315bc5299e7433f864e2f7dc237e0293491358..61a667b70f4f648c91526a5ab90e92fecee57e2a 100755 (executable)
@@ -1,6 +1,7 @@
 USING: io.files io.sockets io kernel threads
 namespaces tools.test continuations strings byte-arrays
-sequences prettyprint system io.encodings.binary io.encodings.ascii ;
+sequences prettyprint system io.encodings.binary io.encodings.ascii
+io.streams.duplex ;
 IN: io.unix.tests
 
 ! Unix domain stream sockets
@@ -24,12 +25,11 @@ yield
 
 [ { "Hello world" "FOO" } ] [
     [
-        socket-server <local> ascii <client>
-        [
+        socket-server <local> ascii [
             readln ,
             "XYZ" print flush
             readln ,
-        ] with-stream
+        ] with-client
     ] { } make
 ] unit-test
 
@@ -125,16 +125,16 @@ datagram-client delete-file
 ! Invalid parameter tests
 
 [
-    image binary [ stdio get accept ] with-file-reader
+    image binary [ input-stream get accept ] with-file-reader
 ] must-fail
 
 [
-    image binary [ stdio get receive ] with-file-reader
+    image binary [ input-stream get receive ] with-file-reader
 ] must-fail
 
 [
     image binary [
         B{ 1 2 } datagram-server <local>
-        stdio get send
+        input-stream get send
     ] with-file-reader
 ] must-fail
index 1e5638fb4a1c66d1de1bdce41869cd349569dc75..e8e7135e1a1f50f9d9fa311df0f82751c5522e41 100755 (executable)
@@ -1,5 +1,6 @@
-USING: io.unix.backend io.unix.files io.unix.sockets io.timeouts
-io.unix.launcher io.unix.mmap io.backend combinators namespaces
-system vocabs.loader sequences words init ;
+USING: io.unix.backend io.unix.files io.unix.sockets
+io.unix.launcher io.unix.mmap io.unix.pipes io.timeouts
+io.backend combinators namespaces system vocabs.loader
+sequences words init ;
 
 "io.unix." os word-name append require
index 670ea18f5eb3b61800f7139d747eaa9fadbff883..a5d7338cd6d687bc3d4e71f8456e3dfe62966e95 100755 (executable)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien alien.c-types arrays continuations io
 io.windows io.windows.nt.pipes libc io.nonblocking
-io.streams.duplex windows.types math windows.kernel32
+windows.types math windows.kernel32
 namespaces io.launcher kernel sequences windows.errors
 splitting system threads init strings combinators
 io.backend accessors concurrency.flags io.files assocs
index c9f17147d34c633c6483a7f10d8004996b9fc74d..8839410d915c5d2478005d54993a438d0eaad2da 100755 (executable)
@@ -52,6 +52,10 @@ M: winnt CreateFile-flags ( DWORD -- DWORD )
 M: winnt FileArgs-overlapped ( port -- overlapped )
     make-overlapped ;
 
+M: winnt open-append
+    [ dup file-info size>> ] [ drop 0 ] recover
+    >r (open-append) r> ;
+
 : update-file-ptr ( n port -- )
     port-handle
     dup win32-file-ptr [
index 8b13b9b3b952bbe007e2a8b49829acbf769b2f5d..254f845c48413817505538e0d15d88bf44919f4d 100755 (executable)
@@ -1,7 +1,7 @@
 IN: io.windows.launcher.nt.tests\r
 USING: io.launcher tools.test calendar accessors\r
 namespaces kernel system arrays io io.files io.encodings.ascii\r
-sequences parser assocs hashtables math ;\r
+sequences parser assocs hashtables math continuations ;\r
 \r
 [ ] [\r
     <process>\r
@@ -41,7 +41,7 @@ sequences parser assocs hashtables math ;
 ] unit-test\r
 \r
 [ ] [\r
-    "extra/io/windows/nt/launcher/test" resource-path [\r
+    "resource:extra/io/windows/nt/launcher/test" [\r
         <process>\r
             vm "-script" "stderr.factor" 3array >>command\r
             "out.txt" temp-file >>stdout\r
@@ -59,7 +59,7 @@ sequences parser assocs hashtables math ;
 ] unit-test\r
 \r
 [ ] [\r
-    "extra/io/windows/nt/launcher/test" resource-path [\r
+    "resource:extra/io/windows/nt/launcher/test" [\r
         <process>\r
             vm "-script" "stderr.factor" 3array >>command\r
             "out.txt" temp-file >>stdout\r
@@ -73,11 +73,11 @@ sequences parser assocs hashtables math ;
 ] unit-test\r
 \r
 [ "output" ] [\r
-    "extra/io/windows/nt/launcher/test" resource-path [\r
+    "resource:extra/io/windows/nt/launcher/test" [\r
         <process>\r
             vm "-script" "stderr.factor" 3array >>command\r
             "err2.txt" temp-file >>stderr\r
-        ascii <process-stream> lines first\r
+        ascii <process-reader> lines first\r
     ] with-directory\r
 ] unit-test\r
 \r
@@ -86,45 +86,45 @@ sequences parser assocs hashtables math ;
 ] unit-test\r
 \r
 [ t ] [\r
-    "extra/io/windows/nt/launcher/test" resource-path [\r
+    "resource:extra/io/windows/nt/launcher/test" [\r
         <process>\r
             vm "-script" "env.factor" 3array >>command\r
-        ascii <process-stream> contents\r
+        ascii <process-reader> contents\r
     ] with-directory eval\r
 \r
     os-envs =\r
 ] unit-test\r
 \r
 [ t ] [\r
-    "extra/io/windows/nt/launcher/test" resource-path [\r
+    "resource:extra/io/windows/nt/launcher/test" [\r
         <process>\r
             vm "-script" "env.factor" 3array >>command\r
             +replace-environment+ >>environment-mode\r
             os-envs >>environment\r
-        ascii <process-stream> contents\r
+        ascii <process-reader> contents\r
     ] with-directory eval\r
     \r
     os-envs =\r
 ] unit-test\r
 \r
 [ "B" ] [\r
-    "extra/io/windows/nt/launcher/test" resource-path [\r
+    "resource:extra/io/windows/nt/launcher/test" [\r
         <process>\r
             vm "-script" "env.factor" 3array >>command\r
             { { "A" "B" } } >>environment\r
-        ascii <process-stream> contents\r
+        ascii <process-reader> contents\r
     ] with-directory eval\r
 \r
     "A" swap at\r
 ] unit-test\r
 \r
 [ f ] [\r
-    "extra/io/windows/nt/launcher/test" resource-path [\r
+    "resource:extra/io/windows/nt/launcher/test" [\r
         <process>\r
             vm "-script" "env.factor" 3array >>command\r
             { { "HOME" "XXX" } } >>environment\r
             +prepend-environment+ >>environment-mode\r
-        ascii <process-stream> contents\r
+        ascii <process-reader> contents\r
     ] with-directory eval\r
 \r
     "HOME" swap at "XXX" =\r
@@ -140,3 +140,18 @@ sequences parser assocs hashtables math ;
 \r
     [ ] [ "dir.txt" temp-file delete-file ] unit-test\r
 ] times\r
+\r
+[ "append-test" temp-file delete-file ] ignore-errors\r
+\r
+[ "Hello appender\r\nHello appender\r\n" ] [\r
+    2 [\r
+        "resource:extra/io/windows/nt/launcher/test" [\r
+            <process>\r
+                vm "-script" "append.factor" 3array >>command\r
+                "append-test" temp-file <appender> >>stdout\r
+            try-process\r
+        ] with-directory\r
+    ] times\r
+   \r
+    "append-test" temp-file ascii file-contents\r
+] unit-test\r
index f57902608f5acad544f01dace0370b495ce5265c..39edd931b17ec6e687a93e41fd176da1b6c4ba2f 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007, 2008 Doug Coleman, Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien alien.c-types arrays continuations destructors io
-io.windows libc io.nonblocking io.streams.duplex windows.types
+io.windows libc io.nonblocking io.pipes windows.types
 math windows.kernel32 windows namespaces io.launcher kernel
 sequences windows.errors assocs splitting system strings
 io.windows.launcher io.windows.nt.pipes io.backend io.files
@@ -19,15 +19,25 @@ IN: io.windows.nt.launcher
         DuplicateHandle win32-error=0/f
     ] keep *void* ;
 
+! /dev/null simulation
+: null-input ( -- pipe )
+    (pipe) [ in>> handle>> ] [ out>> close-handle ] bi ;
+
+: null-output ( -- pipe )
+    (pipe) [ in>> close-handle ] [ out>> handle>> ] bi ;
+
+: null-pipe ( mode -- pipe )
+    {
+        { GENERIC_READ [ null-input ] }
+        { GENERIC_WRITE [ null-output ] }
+    } case ;
+
 ! The below code is based on the example given in
 ! http://msdn2.microsoft.com/en-us/library/ms682499.aspx
 
 : redirect-default ( default obj access-mode create-mode -- handle )
     3drop ;
 
-: redirect-inherit ( default obj access-mode create-mode -- handle )
-    4drop f ;
-
 : redirect-closed ( default obj access-mode create-mode -- handle )
     drop 2nip null-pipe ;
 
@@ -41,25 +51,34 @@ IN: io.windows.nt.launcher
     f ! template file
     CreateFile dup invalid-handle? dup close-always ;
 
+: redirect-append ( default path access-mode create-mode -- handle )
+    >r >r path>> r> r>
+    drop OPEN_ALWAYS
+    redirect-file
+    dup 0 FILE_END set-file-pointer ;
+
 : set-inherit ( handle ? -- )
     >r HANDLE_FLAG_INHERIT r> >BOOLEAN SetHandleInformation win32-error=0/f ;
 
-: redirect-stream ( default stream access-mode create-mode -- handle )
+: redirect-handle ( default handle access-mode create-mode -- handle )
     2drop nip
-    underlying-handle win32-file-handle
-    duplicate-handle dup t set-inherit ;
+    handle>> duplicate-handle dup t set-inherit ;
+
+: redirect-stream ( default stream access-mode create-mode -- handle )
+    >r >r underlying-handle r> r> redirect-handle ;
 
 : redirect ( default obj access-mode create-mode -- handle )
     {
         { [ pick not ] [ redirect-default ] }
-        { [ pick +inherit+ eq? ] [ redirect-inherit ] }
         { [ pick +closed+ eq? ] [ redirect-closed ] }
         { [ pick string? ] [ redirect-file ] }
+        { [ pick appender? ] [ redirect-append ] }
+        { [ pick win32-file? ] [ redirect-handle ] }
         [ redirect-stream ]
     } cond ;
 
 : default-stdout ( args -- handle )
-    stdout-pipe>> dup [ pipe-out ] when ;
+    stdout-pipe>> dup [ out>> ] when ;
 
 : redirect-stdout ( process args -- handle )
     default-stdout
@@ -85,7 +104,7 @@ IN: io.windows.nt.launcher
     ] if ;
 
 : default-stdin ( args -- handle )
-    stdin-pipe>> dup [ pipe-in ] when ;
+    stdin-pipe>> dup [ in>> ] when ;
 
 : redirect-stdin ( process args -- handle )
     default-stdin
@@ -95,46 +114,8 @@ IN: io.windows.nt.launcher
     redirect
     STD_INPUT_HANDLE GetStdHandle or ;
 
-: add-pipe-dtors ( pipe -- )
-    dup
-    in>> close-later
-    out>> close-later ;
-
-: fill-stdout-pipe ( args -- args )
-    <unique-incoming-pipe>
-    dup add-pipe-dtors
-    dup pipe-in f set-inherit
-    >>stdout-pipe ;
-
-: fill-stdin-pipe ( args -- args )
-    <unique-outgoing-pipe>
-    dup add-pipe-dtors
-    dup pipe-out f set-inherit
-    >>stdin-pipe ;
-
 M: winnt fill-redirection ( process args -- )
     [ 2dup redirect-stdout ] keep lpStartupInfo>> set-STARTUPINFO-hStdOutput
     [ 2dup redirect-stderr ] keep lpStartupInfo>> set-STARTUPINFO-hStdError
     [ 2dup redirect-stdin  ] keep lpStartupInfo>> set-STARTUPINFO-hStdInput
     2drop ;
-
-M: winnt (process-stream)
-    [
-        current-directory get (normalize-path) cd
-
-        dup make-CreateProcess-args
-
-        fill-stdout-pipe
-        fill-stdin-pipe
-
-        tuck fill-redirection
-
-        dup call-CreateProcess
-
-        dup stdin-pipe>> pipe-in CloseHandle drop
-        dup stdout-pipe>> pipe-out CloseHandle drop
-
-        dup lpProcessInformation>>
-        over stdout-pipe>> in>> f <win32-file>
-        rot stdin-pipe>> out>> f <win32-file>
-    ] with-destructors ;
diff --git a/extra/io/windows/nt/launcher/test/append.factor b/extra/io/windows/nt/launcher/test/append.factor
new file mode 100755 (executable)
index 0000000..4c1de0c
--- /dev/null
@@ -0,0 +1,2 @@
+USE: io\r
+"Hello appender" print\r
index 0b97387cf7cd264a168f29a3af917cbf64dc88ec..f22f50e406e73f57ee78cdc52ee1a769a1e83501 100755 (executable)
@@ -2,4 +2,4 @@ USE: io
 USE: namespaces\r
 \r
 "output" write flush\r
-"error" stderr get stream-write stderr get stream-flush\r
+"error" error-stream get stream-write error-stream get stream-flush\r
index 2397d207b9c81cbccf5f92498e5b72ace2159b3c..37784c673c612dcbc3c38d72fccb9740848685c6 100755 (executable)
@@ -3,9 +3,9 @@
 USING: alien alien.c-types libc destructors locals
 kernel math assocs namespaces continuations sequences hashtables
 sorting arrays combinators math.bitfields strings system
-accessors threads
-io.backend io.windows io.windows.nt.backend io.monitors
-io.nonblocking io.buffers io.files io.timeouts io
+accessors threads splitting
+io.backend io.windows io.windows.nt.backend io.windows.nt.files
+io.monitors io.nonblocking io.buffers io.files io.timeouts io
 windows windows.kernel32 windows.types ;
 IN: io.windows.nt.monitors
 
@@ -79,9 +79,12 @@ TUPLE: win32-monitor < monitor port ;
 : file-notify-records ( buffer -- seq )
     [ (file-notify-records) drop ] { } make ;
 
-: parse-notify-records ( monitor buffer -- )
-    file-notify-records
-    [ parse-notify-record rot queue-change ] with each ;
+:: parse-notify-records ( monitor buffer -- )
+    buffer file-notify-records [
+        parse-notify-record
+        [ monitor path>> prepend-path normalize-path ] dip
+        monitor queue-change
+    ] each ;
 
 : fill-queue ( monitor -- )
     dup port>> check-closed
index b164d5872b048eeb2276b223f6f0f87075889c35..aa565b52e804a3c32d2428ad448816ebed048a02 100755 (executable)
@@ -1,16 +1,16 @@
 ! Copyright (C) 2007, 2008 Doug Coleman, Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien alien.c-types arrays destructors io io.windows libc
-windows.types math windows.kernel32 windows namespaces kernel
-sequences windows.errors assocs math.parser system random
-combinators accessors ;
+windows.types math.bitfields windows.kernel32 windows namespaces
+kernel sequences windows.errors assocs math.parser system random
+combinators accessors io.pipes io.nonblocking ;
 IN: io.windows.nt.pipes
 
 ! This code is based on
 ! http://twistedmatrix.com/trac/browser/trunk/twisted/internet/iocpreactor/process.py
 
-: create-named-pipe ( name mode -- handle )
-    FILE_FLAG_OVERLAPPED bitor
+: create-named-pipe ( name -- handle )
+    { PIPE_ACCESS_INBOUND FILE_FLAG_OVERLAPPED } flags
     PIPE_TYPE_BYTE
     1
     4096
@@ -19,37 +19,20 @@ IN: io.windows.nt.pipes
     security-attributes-inherit
     CreateNamedPipe
     dup win32-error=0/f
-    dup add-completion ;
+    dup add-completion
+    f <win32-file> ;
 
-: open-other-end ( name mode -- handle )
-    FILE_SHARE_READ FILE_SHARE_WRITE bitor
+: open-other-end ( name -- handle )
+    GENERIC_WRITE
+    { FILE_SHARE_READ FILE_SHARE_WRITE } flags
     security-attributes-inherit
     OPEN_EXISTING
     FILE_FLAG_OVERLAPPED
     f
     CreateFile
     dup win32-error=0/f
-    dup add-completion ;
-
-TUPLE: pipe in out ;
-
-: <pipe> ( name in-mode out-mode -- pipe )
-    [
-        >r over >r create-named-pipe dup close-later
-        r> r> open-other-end dup close-later
-        pipe boa
-    ] with-destructors ;
-
-: close-pipe ( pipe -- )
-    dup
-    in>> CloseHandle drop
-    out>> CloseHandle drop ;
-
-: <incoming-pipe> ( name -- pipe )
-    PIPE_ACCESS_INBOUND GENERIC_WRITE <pipe> ;
-
-: <outgoing-pipe> ( name -- pipe )
-    PIPE_ACCESS_DUPLEX GENERIC_READ <pipe> ;
+    dup add-completion
+    f <win32-file> ;
 
 : unique-pipe-name ( -- string )
     [
@@ -61,25 +44,10 @@ TUPLE: pipe in out ;
         millis #
     ] "" make ;
 
-: <unique-incoming-pipe> ( -- pipe )
-    unique-pipe-name <incoming-pipe> ;
-
-: <unique-outgoing-pipe> ( -- pipe )
-    unique-pipe-name <outgoing-pipe> ;
-
-! /dev/null simulation
-: null-input ( -- pipe )
-    <unique-outgoing-pipe>
-    dup out>> CloseHandle drop
-    in>> ;
-
-: null-output ( -- pipe )
-    <unique-incoming-pipe>
-    dup in>> CloseHandle drop
-    out>> ;
-
-: null-pipe ( mode -- pipe )
-    {
-        { [ dup GENERIC_READ = ] [ drop null-input ] }
-        { [ dup GENERIC_WRITE = ] [ drop null-output ] }
-    } cond ;
+M: winnt (pipe) ( -- pipe )
+    [
+        unique-pipe-name
+        [ create-named-pipe dup close-later ]
+        [ open-other-end dup close-later ]
+        bi pipe boa
+    ] with-destructors ;
index 772ad9124f519888185f1aa44b024f2d1ac6e3d4..85c448bdbdf2b093639320d1785ae1d7b6511a63 100755 (executable)
@@ -2,14 +2,12 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien alien.c-types arrays destructors io io.backend
 io.buffers io.files io.nonblocking io.sockets io.binary
-io.sockets.impl windows.errors strings io.streams.duplex
+io.sockets.impl windows.errors strings
 kernel math namespaces sequences windows windows.kernel32
 windows.shell32 windows.types windows.winsock splitting
 continuations math.bitfields system accessors ;
 IN: io.windows
 
-M: windows destruct-handle CloseHandle drop ;
-
 M: windows destruct-socket closesocket drop ;
 
 TUPLE: win32-file handle ptr ;
@@ -43,7 +41,10 @@ M: win32-file init-handle ( handle -- )
     drop ;
 
 M: win32-file close-handle ( handle -- )
-    win32-file-handle CloseHandle drop ;
+    win32-file-handle close-handle ;
+
+M: alien close-handle ( handle -- )
+    CloseHandle drop ;
 
 ! Clean up resources (open handle) if add-completion fails
 : open-file ( path access-mode create-mode flags -- handle )
@@ -85,15 +86,13 @@ M: win32-file close-handle ( handle -- )
     f CreateFileW dup win32-error=0/f
     GetLastError ERROR_ALREADY_EXISTS = not ;
 
-: set-file-pointer ( handle length -- )
-    dupd d>w/w <uint> FILE_BEGIN SetFilePointer
+: set-file-pointer ( handle length method -- )
+    >r dupd d>w/w <uint> r> SetFilePointer
     INVALID_SET_FILE_POINTER = [
         CloseHandle "SetFilePointer failed" throw
     ] when drop ;
 
-: open-append ( path -- handle length )
-    [ dup file-info size>> ] [ drop 0 ] recover
-    >r (open-append) r> 2dup set-file-pointer ;
+HOOK: open-append os ( path -- handle length )
 
 TUPLE: FileArgs
     hFile lpBuffer nNumberOfBytesToRead
index e9de82ebb64fb5036a082f3dd333aed7e604c949..aecae1cf881d92102d29cfb6763e3896c55dc837 100755 (executable)
@@ -184,7 +184,7 @@ DEFER: (d)
     [ length ] keep [ (graded-ker/im-d) ] curry map ;
 
 : graded-betti ( generators -- seq )
-    basis graded graded-ker/im-d flip first2 1 head* 0 prefix v- ;
+    basis graded graded-ker/im-d flip first2 but-last 0 prefix v- ;
 
 ! Bi-graded for two-step complexes
 : (bigraded-ker/im-d) ( u-deg z-deg bigraded-basis -- null/rank )
diff --git a/extra/lcs/authors.txt b/extra/lcs/authors.txt
new file mode 100755 (executable)
index 0000000..504363d
--- /dev/null
@@ -0,0 +1 @@
+Daniel Ehrenberg\r
diff --git a/extra/lcs/lcs-docs.factor b/extra/lcs/lcs-docs.factor
new file mode 100755 (executable)
index 0000000..49e46c7
--- /dev/null
@@ -0,0 +1,35 @@
+USING: help.syntax help.markup ;\r
+IN: lcs\r
+\r
+HELP: levenshtein\r
+{ $values { "old" "a sequence" } { "new" "a sequence" } { "n" "the Levenshtein distance" } }\r
+{ $description "Calculates the Levenshtein distance between old and new, that is, the minimal number of changes from the old sequence to the new one, in terms of deleting, inserting and replacing characters." } ;\r
+\r
+HELP: lcs\r
+{ $values { "seq1" "a sequence" } { "seq2" "a sequence" } { "lcs" "a longest common subsequence" } }\r
+{ $description "Given two sequences, calculates a longest common subsequence between them. Note two things: this is only one of the many possible LCSs, and the LCS may not be contiguous." } ;\r
+\r
+HELP: diff\r
+{ $values { "old" "a sequence" } { "new" "a sequence" } { "diff" "an edit script" } }\r
+{ $description "Given two sequences, find a minimal edit script from the old to the new. There may be more than one minimal edit script, and this chooses one arbitrarily. This script is in the form of an array of the tuples of the classes " { $link retain } ", " { $link delete } " and " { $link insert } " which have their information stored in the 'item' slot." } ;\r
+\r
+HELP: retain\r
+{ $class-description "Represents an action in an edit script where an item is kept, going from the initial sequence to the final sequence. This has one slot, called item, containing the thing which is retained" } ;\r
+\r
+HELP: delete\r
+{ $class-description "Represents an action in an edit script where an item is deleted, going from the initial sequence to the final sequence. This has one slot, called item, containing the thing which is deleted" } ;\r
+\r
+HELP: insert\r
+{ $class-description "Represents an action in an edit script where an item is added, going from the initial sequence to the final sequence. This has one slot, called item, containing the thing which is inserted" } ;\r
+\r
+ARTICLE: "lcs" "LCS, Diffing and Distance"\r
+"This vocabulary provides words for three apparently unrelated but in fact very similar problems: finding a longest common subsequence between two sequences, getting a minimal edit script (diff) between two sequences, and calculating the Levenshtein distance between two sequences. The implementations of these algorithms are very closely related, and all running times are O(nm), where n and m are the lengths of the input sequences."\r
+{ $subsection lcs }\r
+{ $subsection diff }\r
+{ $subsection levenshtein }\r
+"The " { $link diff } " word returns a sequence of tuples of the following classes. They all hold their contents in the 'item' slot."\r
+{ $subsection insert }\r
+{ $subsection delete }\r
+{ $subsection retain } ;\r
+\r
+ABOUT: "lcs"\r
diff --git a/extra/lcs/lcs-tests.factor b/extra/lcs/lcs-tests.factor
new file mode 100755 (executable)
index 0000000..3aa10a0
--- /dev/null
@@ -0,0 +1,25 @@
+! Copyright (C) 2006 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: tools.test lcs ;
+
+[ 3 ] [ "sitting" "kitten" levenshtein ] unit-test
+[ 3 ] [ "kitten" "sitting" levenshtein ] unit-test
+[ 1 ] [ "freshpak" "freshpack" levenshtein ] unit-test
+[ 1 ] [ "freshpack" "freshpak" levenshtein ] unit-test
+
+[ "hell" ] [ "hello" "hell" lcs ] unit-test
+[ "hell" ] [ "hell" "hello" lcs ] unit-test
+[ "ell" ] [ "ell" "hell" lcs ] unit-test
+[ "ell" ] [ "hell" "ell" lcs ] unit-test
+[ "abd" ] [ "faxbcd" "abdef" lcs ] unit-test
+
+[ {
+        T{ delete f CHAR: f }
+        T{ retain f CHAR: a }
+        T{ delete f CHAR: x }
+        T{ retain f CHAR: b }
+        T{ delete f CHAR: c }
+        T{ retain f CHAR: d }
+        T{ insert f CHAR: e }
+        T{ insert f CHAR: f }
+} ] [ "faxbcd" "abdef" diff ] unit-test
diff --git a/extra/lcs/lcs.factor b/extra/lcs/lcs.factor
new file mode 100755 (executable)
index 0000000..cdebfc4
--- /dev/null
@@ -0,0 +1,97 @@
+USING: sequences kernel math locals math.order math.ranges\r
+accessors combinators.lib arrays namespaces combinators ;\r
+IN: lcs\r
+\r
+<PRIVATE\r
+: levenshtein-step ( insert delete change same? -- next )\r
+    0 1 ? + >r [ 1+ ] bi@ r> min min ;\r
+\r
+: lcs-step ( insert delete change same? -- next )\r
+    1 -9999 ? + max max ; ! Replace -9999 with -inf when added\r
+\r
+:: loop-step ( i j matrix old new step -- )\r
+    i j 1+ matrix nth nth ! insertion\r
+    i 1+ j matrix nth nth ! deletion\r
+    i j matrix nth nth ! replace/retain\r
+    i old nth j new nth = ! same?\r
+    step call\r
+    i 1+ j 1+ matrix nth set-nth ; inline\r
+\r
+: lcs-initialize ( |str1| |str2| -- matrix )\r
+    [ drop 0 <array> ] with map ;\r
+\r
+: levenshtein-initialize ( |str1| |str2| -- matrix )\r
+    [ [ + ] curry map ] with map ;\r
+\r
+:: run-lcs ( old new init step -- matrix )\r
+    [let | matrix [ old length 1+ new length 1+ init call ] |\r
+        old length [0,b) [| i |\r
+            new length [0,b)\r
+            [| j | i j matrix old new step loop-step ]\r
+            each\r
+        ] each matrix ] ; inline\r
+PRIVATE>\r
+\r
+: levenshtein ( old new -- n )\r
+    [ levenshtein-initialize ] [ levenshtein-step ]\r
+    run-lcs peek peek ;\r
+\r
+TUPLE: retain item ;\r
+TUPLE: delete item ;\r
+TUPLE: insert item ;\r
+\r
+<PRIVATE\r
+TUPLE: trace-state old new table i j ;\r
+\r
+: old-nth ( state -- elt )\r
+    [ i>> 1- ] [ old>> ] bi nth ;\r
+\r
+: new-nth ( state -- elt )\r
+    [ j>> 1- ] [ new>> ] bi nth ;\r
+\r
+: top-beats-side? ( state -- ? )\r
+    [ [ i>> ] [ j>> 1- ] [ table>> ] tri nth nth ]\r
+    [ [ i>> 1- ] [ j>> ] [ table>> ] tri nth nth ] bi > ;\r
+\r
+: retained? ( state -- ? )\r
+    {\r
+        [ i>> 0 > ] [ j>> 0 > ]\r
+        [ [ old-nth ] [ new-nth ] bi = ]\r
+    } <-&& ;\r
+\r
+: do-retain ( state -- state )\r
+    dup old-nth retain boa ,\r
+    [ 1- ] change-i [ 1- ] change-j ;\r
+\r
+: inserted? ( state -- ? )\r
+    [ j>> 0 > ]\r
+    [ [ i>> zero? ] [ top-beats-side? ] or? ] and? ;\r
+\r
+: do-insert ( state -- state )\r
+    dup new-nth insert boa , [ 1- ] change-j ;\r
+\r
+: deleted? ( state -- ? )\r
+    [ i>> 0 > ]\r
+    [ [ j>> zero? ] [ top-beats-side? not ] or? ] and? ;\r
+\r
+: do-delete ( state -- state )\r
+    dup old-nth delete boa , [ 1- ] change-i ;\r
+\r
+: (trace-diff) ( state -- )\r
+    {\r
+        { [ dup retained? ] [ do-retain (trace-diff) ] }\r
+        { [ dup inserted? ] [ do-insert (trace-diff) ] }\r
+        { [ dup deleted? ] [ do-delete (trace-diff) ] }\r
+        [ drop ] ! i=j=0\r
+    } cond ;\r
+\r
+: trace-diff ( old new table -- diff )\r
+    [ ] [ first length 1- ] [ length 1- ] tri trace-state boa\r
+    [ (trace-diff) ] { } make reverse ;\r
+PRIVATE>\r
+\r
+: diff ( old new -- diff )\r
+    2dup [ lcs-initialize ] [ lcs-step ] run-lcs trace-diff ;\r
+\r
+: lcs ( seq1 seq2 -- lcs )\r
+    [ diff [ retain? ] filter ] keep [ item>> ] swap map-as ;\r
diff --git a/extra/lcs/summary.txt b/extra/lcs/summary.txt
new file mode 100755 (executable)
index 0000000..9e70fd7
--- /dev/null
@@ -0,0 +1 @@
+Levenshtein distance and diff between sequences\r
diff --git a/extra/lcs/tags.txt b/extra/lcs/tags.txt
new file mode 100755 (executable)
index 0000000..4d914f4
--- /dev/null
@@ -0,0 +1 @@
+algorithms\r
diff --git a/extra/levenshtein/authors.txt b/extra/levenshtein/authors.txt
deleted file mode 100644 (file)
index 1901f27..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Slava Pestov
diff --git a/extra/levenshtein/levenshtein-tests.factor b/extra/levenshtein/levenshtein-tests.factor
deleted file mode 100644 (file)
index 722ccb8..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-! Copyright (C) 2006 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-IN: levenshtein.tests
-USING: tools.test levenshtein ;
-
-[ 3 ] [ "sitting" "kitten" levenshtein ] unit-test
-[ 3 ] [ "kitten" "sitting" levenshtein ] unit-test
-[ 1 ] [ "freshpak" "freshpack" levenshtein ] unit-test
-[ 1 ] [ "freshpack" "freshpak" levenshtein ] unit-test
diff --git a/extra/levenshtein/levenshtein.factor b/extra/levenshtein/levenshtein.factor
deleted file mode 100644 (file)
index 07731bf..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-! Copyright (C) 2006 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: arrays help io kernel math namespaces sequences
-math.order ;
-IN: levenshtein
-
-: <matrix> ( m n -- matrix )
-    [ drop 0 <array> ] with map ; inline
-
-: matrix-> nth nth ; inline
-: ->matrix nth set-nth ; inline
-
-SYMBOL: d
-
-: ->d ( n i j -- ) d get ->matrix ; inline
-: d-> ( i j -- n ) d get matrix-> ; inline
-
-SYMBOL: costs
-
-: init-d ( str1 str2 -- )
-    [ length 1+ ] bi@ 2dup <matrix> d set
-    [ 0 over ->d ] each
-    [ dup 0 ->d ] each ; inline
-
-: compute-costs ( str1 str2 -- )
-    swap [
-        [ = 0 1 ? ] with { } map-as
-    ] curry { } map-as costs set ; inline
-
-: levenshtein-step ( i j -- )
-    [ 1+ d-> 1+ ] 2keep
-    [ >r 1+ r> d-> 1+ ] 2keep
-    [ d-> ] 2keep
-    [ costs get matrix-> + min min ] 2keep
-    >r 1+ r> 1+ ->d ; inline
-
-: levenshtein-result ( -- n ) d get peek peek ; inline
-
-: levenshtein ( str1 str2 -- n )
-    [
-        2dup init-d
-        2dup compute-costs
-        [ length ] bi@ [
-            [ levenshtein-step ] curry each
-        ] with each
-        levenshtein-result
-    ] with-scope ;
diff --git a/extra/levenshtein/summary.txt b/extra/levenshtein/summary.txt
deleted file mode 100644 (file)
index 583669a..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Levenshtein edit distance algorithm
index 96485825ff55d33ddfbacd3075b5936ea34fc6cd..961017f39ec1c779bd1001b9d70162e0a002360f 100644 (file)
@@ -2,15 +2,6 @@ USING: help.syntax help.markup kernel macros prettyprint
 memoize ;
 IN: locals
 
-<PRIVATE
-
-: $with-locals-note
-    drop {
-        "This form must appear either in a word defined by " { $link POSTPONE: :: } " or " { $link POSTPONE: MACRO:: } ", or alternatively, " { $link with-locals } " must be called on the top-level form of the word to perform closure conversion."
-    } $notes ;
-
-PRIVATE>
-
 HELP: [|
 { $syntax "[| bindings... | body... ]" }
 { $description "A lambda abstraction. When called, reads stack values into the bindings from left to right; the body may then refer to these bindings." }
@@ -22,8 +13,7 @@ HELP: [|
         "3 5 adder call ."
         "8"
     }
-}
-$with-locals-note ;
+} ;
 
 HELP: [let
 { $syntax "[let | binding1 [ value1... ]\n       binding2 [ value2... ]\n       ... |\n    body... ]" }
@@ -38,8 +28,7 @@ HELP: [let
         "6 { 36 14 } frobnicate ."
         "{ 36 2 }"
     }
-}
-$with-locals-note ;
+} ;
 
 HELP: [let*
 { $syntax "[let* | binding1 [ value1... ]\n       binding2 [ value2... ]\n       ... |\n    body... ]" }
@@ -55,8 +44,7 @@ HELP: [let*
         "1 { 32 48 } frobnicate ."
         "{ 2 3 }"
     }
-}
-$with-locals-note ;
+} ;
 
 { POSTPONE: [let POSTPONE: [let* } related-words
 
@@ -75,10 +63,6 @@ HELP: [wlet
     }
 } ;
 
-HELP: with-locals
-{ $values { "form" "a quotation, lambda, let or wlet form" } { "quot" "a quotation" } }
-{ $description "Performs closure conversion of a lexically-scoped form. All nested sub-forms are converted. This word must be applied to a " { $link POSTPONE: [| } ", " { $link POSTPONE: [let } " or " { $link POSTPONE: [wlet } " used in an ordinary definition, however forms in " { $link POSTPONE: :: } " and " { $link POSTPONE: MACRO:: } " definitions are automatically closure-converted and there is no need to use this word." } ;
-
 HELP: ::
 { $syntax ":: word ( bindings... -- outputs... ) body... ;" }
 { $description "Defines a word with named inputs; it reads stack values into bindings from left to right, then executes the body with those bindings in lexical scope. Any " { $link POSTPONE: [| } ", " { $link POSTPONE: [let } " or " { $link POSTPONE: [wlet } " forms used in the body of the word definition are automatically closure-converted." }
@@ -136,8 +120,6 @@ $nl
 { $subsection POSTPONE: :: }
 { $subsection POSTPONE: MEMO:: }
 { $subsection POSTPONE: MACRO:: }
-"Explicit closure conversion outside of applicative word definitions:"
-{ $subsection with-locals }
 "Lexical binding forms:"
 { $subsection POSTPONE: [let }
 { $subsection POSTPONE: [let* }
index bb2fd9893c9b70eeb0467d0aa85f19d02073eb68..5c3d2005a8a03f375030b9b037af3d8cdba37358 100755 (executable)
@@ -1,6 +1,6 @@
 USING: locals math sequences tools.test hashtables words kernel
 namespaces arrays strings prettyprint io.streams.string parser
-;
+accessors ;
 IN: locals.tests
 
 :: foo ( a b -- a a ) a a ;
@@ -55,7 +55,6 @@ IN: locals.tests
 
 [ 5 ] [
     [let | a [ 3 ] | [wlet | func [ a + ] | 2 func ] ]
-    with-locals
 ] unit-test
 
 :: wlet-test-2 ( a b -- seq )
@@ -108,7 +107,7 @@ write-test-2 "q" set
 
 [ 10 20 ]
 [
-    20 10 [| a! | [| b! | a b ] ] with-locals call call
+    20 10 [| a! | [| b! | a b ] ] call call
 ] unit-test
 
 :: write-test-3 ( a! -- q ) [| b | b a! ] ;
@@ -170,16 +169,22 @@ M:: string lambda-generic ( a b -- c ) a b lambda-generic-2 ;
 
 [ ] [ \ lambda-generic see ] unit-test
 
+:: unparse-test-1 ( a -- ) [let | a! [ ] | ] ;
+
 [ "[let | a! [ ] | ]" ] [
-    [let | a! [ ] | ] unparse
+    \ unparse-test-1 "lambda" word-prop body>> first unparse
 ] unit-test
 
+:: unparse-test-2 ( -- ) [wlet | a! [ ] | ] ;
+
 [ "[wlet | a! [ ] | ]" ] [
-    [wlet | a! [ ] | ] unparse
+    \ unparse-test-2 "lambda" word-prop body>> first unparse
 ] unit-test
 
+:: unparse-test-3 ( -- b ) [| a! | ] ;
+
 [ "[| a! | ]" ] [
-    [| a! | ] unparse
+    \ unparse-test-3 "lambda" word-prop body>> first unparse
 ] unit-test
 
 DEFER: xyzzy
@@ -237,3 +242,7 @@ M: integer next-method-test 3 + ;
 M:: fixnum next-method-test ( a -- b ) a call-next-method 1 + ;
 
 [ 5 ] [ 1 next-method-test ] unit-test
+
+: no-with-locals-test { 1 2 3 } [| x | x 3 + ] map ;
+
+[ { 4 5 6 } ] [ no-with-locals-test ] unit-test
index d18017f69bf893e04d2a0e1558c6fca596bc2994..4b7ab8cdadbf1a01110e2b398ac396edaa64bf60 100755 (executable)
@@ -101,7 +101,7 @@ UNION: special local quote local-word local-reader local-writer ;
     ] if ;
 
 : point-free-body ( quot args -- newquot )
-    >r 1 head-slice* r> [ localize ] curry map concat ;
+    >r but-last-slice r> [ localize ] curry map concat ;
 
 : point-free-end ( quot args -- newquot )
     over peek special?
@@ -201,8 +201,11 @@ M: object local-rewrite* , ;
 : pop-locals ( assoc -- )
     use get delete ;
 
+SYMBOL: in-lambda?
+
 : (parse-lambda) ( assoc end -- quot )
-    parse-until >quotation swap pop-locals ;
+    t in-lambda? [ parse-until ] with-variable
+    >quotation swap pop-locals ;
 
 : parse-lambda ( -- lambda )
     "|" parse-tokens make-locals dup push-locals
@@ -283,24 +286,24 @@ M: wlet local-rewrite*
     CREATE-METHOD
     [ parse-locals-definition ] with-method-definition ;
 
+: parsed-lambda ( form -- )
+    in-lambda? get [ parsed ] [ lambda-rewrite over push-all ] if ;
+
 PRIVATE>
 
-: [| parse-lambda parsed ; parsing
+: [| parse-lambda parsed-lambda ; parsing
 
 : [let
     scan "|" assert= parse-bindings
-\ ] (parse-lambda) <let> parsed ; parsing
+    \ ] (parse-lambda) <let> parsed-lambda ; parsing
 
 : [let*
     scan "|" assert= parse-bindings*
-    >r \ ] parse-until >quotation <let*> parsed r> pop-locals ;
-    parsing
+    \ ] (parse-lambda) <let*> parsed-lambda ; parsing
 
 : [wlet
     scan "|" assert= parse-wbindings
-    \ ] (parse-lambda) <wlet> parsed ; parsing
-
-MACRO: with-locals ( form -- quot ) lambda-rewrite ;
+    \ ] (parse-lambda) <wlet> parsed-lambda ; parsing
 
 : :: (::) define ; parsing
 
index 7601d1cc2e121b6c41a7a8066c233b7d9eb1e52d..3bc8637f9061a41cd693a4f7458d113dc22a9231 100755 (executable)
@@ -48,7 +48,7 @@ SYMBOL: log-files
 \r
 : (log-message) ( msg -- )\r
     #! msg: { msg word-name level service }\r
-    first4 log-stream [ write-message flush ] with-stream* ;\r
+    first4 log-stream [ write-message flush ] with-output-stream* ;\r
 \r
 : try-dispose ( stream -- )\r
     [ dispose ] curry [ error. ] recover ;\r
diff --git a/extra/monads/authors.txt b/extra/monads/authors.txt
new file mode 100644 (file)
index 0000000..1901f27
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
diff --git a/extra/monads/monads-tests.factor b/extra/monads/monads-tests.factor
new file mode 100644 (file)
index 0000000..52cdc47
--- /dev/null
@@ -0,0 +1,128 @@
+USING: tools.test monads math kernel sequences lazy-lists promises ;
+IN: monads.tests
+
+[ 5 ] [ 1 identity-monad return [ 4 + ] fmap run-identity ] unit-test
+[ "OH HAI" identity-monad fail ] must-fail
+
+[ 666 ] [
+    111 just [ 6 * ] fmap [ ] [ "OOPS" throw ] if-maybe
+] unit-test
+
+[ nothing ] [
+    111 just [ maybe-monad fail ] bind
+] unit-test
+
+[ 100 ] [
+    5 either-monad return [ 10 * ] [ 20 * ] if-either
+] unit-test
+
+[ T{ left f "OOPS" } ] [
+    5 either-monad return >>= [ drop "OOPS" either-monad fail ] swap call
+] unit-test
+
+[ { 10 20 30 } ] [
+    { 1 2 3 } [ 10 * ] fmap
+] unit-test
+
+[ { } ] [
+    { 1 2 3 } [ drop "OOPS" array-monad fail ] bind
+] unit-test
+
+[ 5 ] [
+    5 state-monad return "initial state" run-st
+] unit-test
+
+[ 8 ] [
+    5 state-monad return [ 3 + state-monad return ] bind
+    "initial state" run-st
+] unit-test
+
+[ 8 ] [
+    5 state-monad return >>=
+    [ 3 + state-monad return ] swap call
+    "initial state" run-st
+] unit-test
+
+[ 11 ] [
+    f state-monad return >>=
+    [ drop get-st ] swap call
+    11 run-st
+] unit-test
+
+[ 15 ] [
+    f state-monad return
+    [ drop get-st ] bind
+    [ 4 + put-st ] bind
+    [ drop get-st ] bind
+    11 run-st
+] unit-test
+
+[ 15 ] [
+    {
+        [ f return-st ]
+        [ drop get-st ]
+        [ 4 + put-st ]
+        [ drop get-st ]
+    } do
+    11 run-st
+] unit-test
+
+[ nothing ] [
+    {
+        [ "hi" just ]
+        [ " bye" append just ]
+        [ drop nothing ]
+        [ reverse just ]
+    } do
+] unit-test
+
+LAZY: nats-from ( n -- list )
+    dup 1+ nats-from cons ;
+
+: nats 0 nats-from ;
+
+[ 3 ] [
+    {
+        [ nats ]
+        [ dup 3 = [ list-monad return ] [ list-monad fail ] if ]
+    } do car
+] unit-test
+
+[ 9/11 ] [
+    {
+        [ ask ]
+    } do 9/11 run-reader
+] unit-test
+
+[ 8 ] [
+    {
+        [ ask ]
+        [ 3 + reader-monad return ]
+    } do
+    5 run-reader
+] unit-test
+
+[ 6 ] [
+    f reader-monad return [ drop ask ] bind [ 1 + ] local 5 run-reader
+] unit-test
+
+[ f { 1 2 3 } ] [
+    5 writer-monad return
+    [ drop { 1 2 3 } tell ] bind
+    run-writer
+] unit-test
+
+[ T{ identity f 7 } ]
+[
+    4 identity-monad return
+    [ 3 + ] identity-monad return
+    identity-monad apply
+] unit-test
+
+[ nothing ] [
+    5 just nothing maybe-monad apply
+] unit-test
+
+[ T{ just f 15 } ] [
+    5 just [ 10 + ] just maybe-monad apply
+] unit-test
diff --git a/extra/monads/monads.factor b/extra/monads/monads.factor
new file mode 100644 (file)
index 0000000..0f4138c
--- /dev/null
@@ -0,0 +1,192 @@
+! Copyright (C) 2008 Slava Pestov
+! See http://factorcode.org/license.txt for BSD license.
+USING: arrays kernel sequences sequences.deep splitting
+accessors fry locals combinators namespaces lazy-lists
+shuffle ;
+IN: monads
+
+! Functors
+GENERIC# fmap 1 ( functor quot -- functor' ) inline
+
+! Monads
+
+! Mixin type for monad singleton classes, used for return/fail only
+MIXIN: monad
+
+GENERIC: monad-of ( mvalue -- singleton )
+GENERIC: return ( string singleton -- mvalue )
+GENERIC: fail ( value singleton -- mvalue )
+GENERIC: >>= ( mvalue -- quot )
+
+M: monad return monad-of return ;
+M: monad fail   monad-of fail   ;
+
+: bind ( mvalue quot -- mvalue' ) swap >>= call ;
+: >>   ( mvalue k -- mvalue' ) '[ drop , ] bind ;
+
+:: lift-m2 ( m1 m2 f monad -- m3 )
+    m1 [| x1 | m2 [| x2 | x1 x2 f monad return ] bind ] bind ;
+
+:: apply ( mvalue mquot monad -- result )
+    mvalue [| value |
+        mquot [| quot |
+            value quot call monad return
+        ] bind
+    ] bind ;
+
+M: monad fmap over '[ @ , return ] bind ;
+
+! 'do' notation
+: do ( quots -- result ) unclip dip [ bind ] each ;
+
+! Identity
+SINGLETON: identity-monad
+INSTANCE:  identity-monad monad
+
+TUPLE: identity value ;
+INSTANCE: identity monad
+
+M: identity monad-of drop identity-monad ;
+
+M: identity-monad return drop identity boa ;
+M: identity-monad fail   "Fail" throw ;
+
+M: identity >>= value>> '[ , _ call ] ;
+
+: run-identity ( identity -- value ) value>> ;
+
+! Maybe
+SINGLETON: maybe-monad
+INSTANCE:  maybe-monad monad
+
+SINGLETON: nothing
+
+TUPLE: just value ;
+: just \ just boa ;
+
+UNION: maybe just nothing ;
+INSTANCE: maybe monad
+
+M: maybe monad-of drop maybe-monad ;
+
+M: maybe-monad return drop just ;
+M: maybe-monad fail   2drop nothing ;
+
+M: nothing >>= '[ drop , ] ;
+M: just    >>= value>> '[ , _ call ] ;
+
+: if-maybe ( maybe just-quot nothing-quot -- )
+    pick nothing? [ 2nip call ] [ drop [ value>> ] dip call ] if ; inline
+
+! Either
+SINGLETON: either-monad
+INSTANCE:  either-monad monad
+
+TUPLE: left value ;
+: left \ left boa ;
+
+TUPLE: right value ;
+: right \ right boa ;
+
+UNION: either left right ;
+INSTANCE: either monad
+
+M: either monad-of drop either-monad ;
+
+M: either-monad return  drop right ;
+M: either-monad fail    drop left ;
+
+M: left  >>= '[ drop , ] ;
+M: right >>= value>> '[ , _ call ] ;
+
+: if-either ( value left-quot right-quot -- )
+    [ [ value>> ] [ left? ] bi ] 2dip if ; inline
+
+! Arrays
+SINGLETON: array-monad
+INSTANCE:  array-monad monad
+INSTANCE:  array monad
+
+M: array-monad return  drop 1array ;
+M: array-monad fail   2drop { } ;
+
+M: array monad-of drop array-monad ;
+
+M: array >>= '[ , _ map concat ] ;
+
+! List
+SINGLETON: list-monad
+INSTANCE:  list-monad monad
+INSTANCE:  list monad
+
+M: list-monad return drop 1list ;
+M: list-monad fail   2drop nil ;
+
+M: list monad-of drop list-monad ;
+
+M: list >>= '[ , _ lmap lconcat ] ;
+
+! State
+SINGLETON: state-monad
+INSTANCE:  state-monad monad
+
+TUPLE: state quot ;
+: state \ state boa ;
+
+INSTANCE: state monad
+
+M: state monad-of drop state-monad ;
+
+M: state-monad return drop '[ , 2array ] state ;
+M: state-monad fail   "Fail" throw ;
+
+: mcall quot>> call ;
+
+M: state >>= '[ , _ '[ , mcall first2 @ mcall ] state ] ;
+
+: get-st ( -- state ) [ dup 2array ] state ;
+: put-st ( value -- state ) '[ drop , f 2array ] state ;
+
+: run-st ( state initial -- ) swap mcall second ;
+
+: return-st state-monad return ;
+
+! Reader
+SINGLETON: reader-monad
+INSTANCE:  reader-monad monad
+
+TUPLE: reader quot ;
+: reader \ reader boa ;
+INSTANCE: reader monad
+
+M: reader monad-of drop reader-monad ;
+
+M: reader-monad return drop '[ drop , ] reader ;
+M: reader-monad fail   "Fail" throw ;
+
+M: reader >>= '[ , _ '[ dup , mcall @ mcall ] reader ] ;
+
+: run-reader ( reader env -- ) swap mcall ;
+
+: ask ( -- reader ) [ ] reader ;
+: local ( reader quot -- reader' ) swap '[ @ , mcall ] reader ;
+
+! Writer
+SINGLETON: writer-monad
+INSTANCE:  writer-monad monad
+
+TUPLE: writer value log ;
+: writer \ writer boa ;
+
+M: writer monad-of drop writer-monad ;
+
+M: writer-monad return drop { } writer ;
+M: writer-monad fail   "Fail" throw ;
+
+: run-writer ( writer -- value log ) [ value>> ] [ log>> ] bi ;
+
+M: writer >>= '[ , run-writer _ '[ @ run-writer ] dip append writer ] ;
+
+: pass ( writer -- writer' ) run-writer [ first2 ] dip swap call writer ;
+: listen ( writer -- writer' ) run-writer [ 2array ] keep writer ;
+: tell ( seq -- writer ) f swap writer ;
diff --git a/extra/monads/summary.txt b/extra/monads/summary.txt
new file mode 100644 (file)
index 0000000..359722c
--- /dev/null
@@ -0,0 +1 @@
+Haskell-style monads
diff --git a/extra/monads/tags.txt b/extra/monads/tags.txt
new file mode 100644 (file)
index 0000000..f427429
--- /dev/null
@@ -0,0 +1 @@
+extensions
index f31b741c8559ea5447cfeb02379767a6cb4d77be..e35967d3e965e85f5703f8faa547991241e8686d 100644 (file)
@@ -24,6 +24,10 @@ HELP: morse>
 { $description "Translates morse code into ASCII text" }
 { $see-also >morse morse>ch } ;
 
-HELP: play-as-morse
+HELP: play-as-morse*
 { $values { "str" "A string of ascii characters which can be translated into morse code" } { "unit-length" "The length of a dot" } }
 { $description "Plays a string as morse code" } ;
+
+HELP: play-as-morse
+{ $values { "str" "A string of ascii characters which can be translated into morse code" } }
+{ $description "Plays a string as morse code" } ;
index dabb93579dd1eaa1371b41361db953ad322d2a97..9bfdc6b50c76bc4427bf6846c4b22a0998a54807 100644 (file)
@@ -9,5 +9,5 @@ USING: arrays morse strings tools.test ;
 [ "-- --- .-. ... . / -.-. --- -.. ." ] [ "morse code" >morse ] unit-test
 [ "morse code" ] [ "-- --- .-. ... . / -.-. --- -.. ." morse> ] unit-test
 [ "hello, world!" ] [ "Hello, World!" >morse morse> ] unit-test
-[ ] [ "sos" 0.075 play-as-morse ] unit-test
+[ ] [ "sos" 0.075 play-as-morse* ] unit-test
 [ ] [ "Factor rocks!" play-as-morse ] unit-test
index b7862af7ac4e59a3f5d061e7b55412d455be2e02..6173669ad031e7fc93cc964bc835e2eaf093e0bf 100644 (file)
@@ -122,7 +122,7 @@ over class-class-methods assoc-stack call ;
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
 : send-message-next ( object message -- )
-over object-class class-methods 1 head* assoc-stack call ;
+over object-class class-methods but-last assoc-stack call ;
 
 : <-~ scan parsed \ send-message-next parsed ; parsing
 
index e140c5227c254310c76b0571203fb089222f3290..ce79bdaf5f8f88ef150776edaad939c67b1500ae 100755 (executable)
@@ -14,7 +14,7 @@ IN: multiline
     ] [ ";" unexpected-eof ] if* ;
 
 : parse-here ( -- str )
-    [ (parse-here) ] "" make 1 head*
+    [ (parse-here) ] "" make but-last
     lexer get next-line ;
 
 : STRING:
@@ -34,7 +34,7 @@ IN: multiline
     [
         lexer get lexer-column swap (parse-multiline-string)
         lexer get set-lexer-column
-    ] "" make rest 1 head* ;
+    ] "" make rest but-last ;
 
 : <"
     "\">" parse-multiline-string parsed ; parsing
index 2788ebdfc2d72fe5c8e22e6ef723ca50ec6f6336..b168f4cad136a995329b347727e263d44b99035f 100644 (file)
@@ -7,7 +7,7 @@ HELP: gl-color
 { $description "Wrapper for " { $link glColor4d } " taking a color specifier." } ;
 
 HELP: gl-error
-{ $description "If the most recent OpenGL call resulted in an error, print the error to the " { $link stdio } " stream." } ;
+{ $description "If the most recent OpenGL call resulted in an error, print the error to " { $link output-stream } "." } ;
 
 HELP: do-state
   {
diff --git a/extra/openssl/authors.txt b/extra/openssl/authors.txt
deleted file mode 100644 (file)
index 7c29e7c..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Elie Chaftari
diff --git a/extra/openssl/libcrypto/libcrypto.factor b/extra/openssl/libcrypto/libcrypto.factor
deleted file mode 100755 (executable)
index 312c7b0..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-! Copyright (C) 2007 Elie CHAFTARI
-! See http://factorcode.org/license.txt for BSD license.
-!
-! Tested with OpenSSL 0.9.8a_0 on Mac OS X 10.4.9 PowerPC
-!
-! export LD_LIBRARY_PATH=/opt/local/lib
-
-USING: alien alien.syntax combinators kernel system ;
-
-IN: openssl.libcrypto
-
-<<
-"libcrypto" {
-    { [ os winnt? ]  [ "libeay32.dll" "cdecl" ] }
-    { [ os macosx? ] [ "libcrypto.dylib" "cdecl" ] }
-    { [ os unix? ]   [ "libcrypto.so" "cdecl" ] }
-} cond add-library
->>
-
-C-STRUCT: bio-method
-    { "int" "type" }
-    { "void*" "name" }
-    { "void*" "bwrite" }
-    { "void*" "bread" }
-    { "void*" "bputs" }
-    { "void*" "bgets" }
-    { "void*" "ctrl" }
-    { "void*" "create" }
-    { "void*" "destroy" }
-    { "void*" "callback-ctrl" } ;
-
-C-STRUCT: bio
-    { "void*" "method" }
-    { "void*" "callback" }
-    { "void*" "cb-arg" }
-    { "int" "init" }
-    { "int" "shutdown" }
-    { "int" "flags" }
-    { "int" "retry-reason" }
-    { "int" "num" }
-    { "void*" "ptr" }
-    { "void*" "next-bio" }
-    { "void*" "prev-bio" }
-    { "int" "references" } 
-    { "ulong" "num-read" }
-    { "ulong" "num-write" } 
-    { "void*" "crypto-ex-data-stack" }
-    { "int" "crypto-ex-data-dummy" } ;
-
-: BIO_NOCLOSE       HEX: 00 ; inline
-: BIO_CLOSE         HEX: 01 ; inline
-
-: RSA_3             HEX: 3 ; inline
-: RSA_F4            HEX: 10001 ; inline
-
-: BIO_C_SET_SSL     109 ; inline
-: BIO_C_GET_SSL     110 ; inline
-
-LIBRARY: libcrypto
-
-! ===============================================
-! bio.h
-! ===============================================
-
-FUNCTION: bio* BIO_new_file ( char* filename, char* mode ) ;
-
-FUNCTION: int BIO_printf ( bio* bio, char* format ) ;
-
-FUNCTION: long BIO_ctrl ( void* bio, int cmd, long larg, void* parg ) ;
-
-FUNCTION: void* BIO_new_socket ( int fd, int close-flag ) ;
-
-FUNCTION: void* BIO_new ( void* method ) ;
-
-FUNCTION: int BIO_set ( void* bio, void* method ) ;
-
-FUNCTION: int BIO_free ( void* bio ) ;
-
-FUNCTION: void* BIO_push ( void* bio, void* append ) ;
-
-FUNCTION: int BIO_read ( void* b, void* buf, int len ) ;
-
-FUNCTION: int BIO_gets ( void* b, char* buf, int size ) ;
-
-FUNCTION: int BIO_write ( void* b, void* buf, int len ) ;
-
-FUNCTION: int BIO_puts ( void* bp, char* buf ) ;
-
-FUNCTION: ulong ERR_get_error (  ) ;
-
-FUNCTION: char* ERR_error_string ( ulong e, void* buf ) ;
-
-FUNCTION: void* BIO_f_buffer (  ) ;
-
-! ===============================================
-! evp.h
-! ===============================================
-
-! Initialize ciphers and digest tables
-FUNCTION: void OpenSSL_add_all_ciphers (  ) ;
-
-FUNCTION: void OpenSSL_add_all_digests (  ) ;
-
-! Clean them up before exiting
-FUNCTION: void EVP_cleanup (  ) ;
-
-FUNCTION: void* EVP_get_digestbyname ( char* name ) ;
-
-FUNCTION: void EVP_MD_CTX_init ( void* ctx ) ;
-
-FUNCTION: void* PEM_read_bio_DHparams ( void* bp, void* x, void* cb,
-                                        void* u ) ;
-
-! ===============================================
-! md5.h
-! ===============================================
-
-FUNCTION: uchar* MD5 ( uchar* d, ulong n, uchar* md ) ;
-
-! ===============================================
-! rsa.h
-! ===============================================
-
-FUNCTION: void* RSA_generate_key ( int num, ulong e, void* callback,
-                                   void* cb_arg ) ;
-
-FUNCTION: int RSA_check_key ( void* rsa ) ;
-
-FUNCTION: void RSA_free ( void* rsa ) ;
-
-FUNCTION: int RSA_print_fp ( void* fp, void* x, int offset ) ;
diff --git a/extra/openssl/libssl/libssl.factor b/extra/openssl/libssl/libssl.factor
deleted file mode 100755 (executable)
index 0f2e7b3..0000000
+++ /dev/null
@@ -1,174 +0,0 @@
-! Copyright (C) 2007 Elie CHAFTARI
-! See http://factorcode.org/license.txt for BSD license.
-!
-! Tested with OpenSSL 0.9.8a_0 on Mac OS X 10.4.9 PowerPC
-!
-! export LD_LIBRARY_PATH=/opt/local/lib
-
-USING: alien alien.syntax combinators kernel system ;
-
-IN: openssl.libssl
-
-<< "libssl" {
-    { [ os winnt? ]  [ "ssleay32.dll" "cdecl" ] }
-    { [ os macosx? ] [ "libssl.dylib" "cdecl" ] }
-    { [ os unix? ]   [ "libssl.so" "cdecl" ] }
-} cond add-library >>
-
-: X509_FILETYPE_PEM       1 ; inline
-: X509_FILETYPE_ASN1      2 ; inline
-: X509_FILETYPE_DEFAULT   3 ; inline
-
-: SSL_FILETYPE_ASN1  X509_FILETYPE_ASN1 ; inline
-: SSL_FILETYPE_PEM   X509_FILETYPE_PEM ; inline
-
-: SSL_CTRL_NEED_TMP_RSA      1 ; inline
-: SSL_CTRL_SET_TMP_RSA       2 ; inline
-: SSL_CTRL_SET_TMP_DH        3 ; inline
-: SSL_CTRL_SET_TMP_RSA_CB    4 ; inline
-: SSL_CTRL_SET_TMP_DH_CB     5 ; inline
-
-: SSL_ERROR_NONE             0 ; inline
-: SSL_ERROR_SSL              1 ; inline
-: SSL_ERROR_WANT_READ        2 ; inline
-: SSL_ERROR_WANT_WRITE       3 ; inline
-: SSL_ERROR_WANT_X509_LOOKUP 4 ; inline
-: SSL_ERROR_SYSCALL          5 ; inline ! consult errno for details
-: SSL_ERROR_ZERO_RETURN      6 ; inline
-: SSL_ERROR_WANT_CONNECT     7 ; inline
-: SSL_ERROR_WANT_ACCEPT      8 ; inline
-
-! Error messages table
-: error-messages ( -- hash )
-    H{
-        { 0  "SSL_ERROR_NONE" }
-        { 1  "SSL_ERROR_SSL" }
-        { 2  "SSL_ERROR_WANT_READ" }
-        { 3  "SSL_ERROR_WANT_WRITE" }
-        { 4  "SSL_ERROR_WANT_X509_LOOKUP" }
-        { 5  "SSL_ERROR_SYSCALL" }
-        { 6  "SSL_ERROR_ZERO_RETURN" }
-        { 7  "SSL_ERROR_WANT_CONNECT" }
-        { 8  "SSL_ERROR_WANT_ACCEPT" }
-    } ;
-
-TYPEDEF: void* ssl-method
-TYPEDEF: void* ssl-ctx
-TYPEDEF: void* ssl-pointer
-
-LIBRARY: libssl
-
-! ===============================================
-! ssl.h
-! ===============================================
-
-FUNCTION: char* SSL_get_version ( ssl-pointer ssl ) ;
-
-! Maps OpenSSL errors to strings
-FUNCTION: void SSL_load_error_strings (  ) ;
-
-! Must be called before any other action takes place
-FUNCTION: int SSL_library_init (  ) ;
-
-! Sets the default SSL version
-FUNCTION: ssl-method SSLv2_client_method (  ) ;
-
-FUNCTION: ssl-method SSLv23_client_method (  ) ;
-
-FUNCTION: ssl-method SSLv23_server_method (  ) ;
-
-FUNCTION: ssl-method SSLv23_method (  ) ; ! SSLv3 but can rollback to v2
-
-FUNCTION: ssl-method SSLv3_client_method (  ) ;
-
-FUNCTION: ssl-method SSLv3_server_method (  ) ;
-
-FUNCTION: ssl-method SSLv3_method (  ) ;
-
-FUNCTION: ssl-method TLSv1_client_method (  ) ;
-
-FUNCTION: ssl-method TLSv1_server_method (  ) ;
-
-FUNCTION: ssl-method TLSv1_method (  ) ;
-
-! Creates the context
-FUNCTION: ssl-ctx SSL_CTX_new ( ssl-method method ) ;
-
-! Load the certificates and private keys into the SSL_CTX
-FUNCTION: int SSL_CTX_use_certificate_chain_file ( ssl-ctx ctx,
-                                                   char* file ) ; ! PEM type
-FUNCTION: ssl-pointer SSL_new ( ssl-ctx ctx ) ;
-
-FUNCTION: int SSL_set_fd ( ssl-pointer ssl, int fd ) ;
-
-FUNCTION: void SSL_set_bio ( ssl-pointer ssl, void* rbio, void* wbio ) ;
-
-FUNCTION: int SSL_get_error ( ssl-pointer ssl, int ret ) ;
-
-FUNCTION: void SSL_set_connect_state ( ssl-pointer ssl ) ;
-
-FUNCTION: void SSL_set_accept_state ( ssl-pointer ssl ) ;
-
-FUNCTION: int SSL_connect ( ssl-pointer ssl ) ;
-
-FUNCTION: int SSL_accept ( ssl-pointer ssl ) ;
-
-FUNCTION: int SSL_write ( ssl-pointer ssl, void* buf, int num ) ;
-
-FUNCTION: int SSL_read ( ssl-pointer ssl, void* buf, int num ) ;
-
-FUNCTION: void SSL_shutdown ( ssl-pointer ssl ) ;
-
-FUNCTION: void SSL_free ( ssl-pointer ssl ) ;
-
-FUNCTION: void SSL_CTX_free ( ssl-ctx ctx ) ;
-
-FUNCTION: void RAND_seed ( void* buf, int num ) ;
-
-FUNCTION: int SSL_set_cipher_list ( ssl-pointer ssl, char* str ) ;
-
-FUNCTION: int SSL_use_RSAPrivateKey_file ( ssl-pointer ssl, char* str ) ;
-
-FUNCTION: int SSL_CTX_use_RSAPrivateKey_file ( ssl-ctx ctx, int type ) ;
-
-FUNCTION: int SSL_use_certificate_file ( ssl-pointer ssl,
-                                         char* str, int type ) ;
-
-FUNCTION: int SSL_CTX_load_verify_locations ( ssl-ctx ctx, char* CAfile,
-                                              char* CApath ) ;
-
-FUNCTION: void SSL_CTX_set_client_CA_list ( ssl-ctx ctx, ssl-pointer list ) ;
-
-FUNCTION: ssl-pointer SSL_load_client_CA_file ( char* file ) ;
-
-! Used to manipulate settings of the SSL_CTX and SSL objects.
-! This function should never be called directly
-FUNCTION: long SSL_CTX_ctrl ( ssl-ctx ctx, int cmd, long larg, void* parg ) ;
-
-FUNCTION: void SSL_CTX_set_default_passwd_cb ( ssl-ctx ctx, void* cb ) ;
-
-FUNCTION: void SSL_CTX_set_default_passwd_cb_userdata ( ssl-ctx ctx,
-                                                        void* u ) ;
-
-FUNCTION: int SSL_CTX_use_PrivateKey_file ( ssl-ctx ctx, char* file,
-                                            int type ) ;
-
-! Sets the maximum depth for the allowed ctx certificate chain verification 
-FUNCTION: void SSL_CTX_set_verify_depth ( ssl-ctx ctx, int depth ) ;
-
-! Sets DH parameters to be used to be dh.
-! The key is inherited by all ssl objects created from ctx
-FUNCTION: void SSL_CTX_set_tmp_dh_callback ( ssl-ctx ctx, void* dh ) ;
-
-FUNCTION: void SSL_CTX_set_tmp_rsa_callback ( ssl-ctx ctx, void* rsa ) ;
-
-FUNCTION: void* BIO_f_ssl (  ) ;
-
-! ===============================================
-! sha.h
-! ===============================================
-
-! For a high level interface to message digests
-! use the EVP digest routines in libcrypto.factor
-
-FUNCTION: uchar* SHA1 ( uchar* d, ulong n, uchar* md ) ;
diff --git a/extra/openssl/openssl-docs.factor b/extra/openssl/openssl-docs.factor
deleted file mode 100644 (file)
index dd31bfd..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-
-USING: help.syntax help.markup ;
-
-IN: openssl
-
-ARTICLE: "openssl" "OpenSSL"
-
-"Factor on Windows has been tested with this version of OpenSSL: "
-
-{ $url "http://www.openssl.org/related/binaries.html" } ;
\ No newline at end of file
diff --git a/extra/openssl/openssl-tests.factor b/extra/openssl/openssl-tests.factor
deleted file mode 100755 (executable)
index f42c611..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-USING: alien alien.c-types alien.strings assocs bit-arrays
-hashtables io io.files io.encodings.ascii io.sockets kernel
-mirrors openssl.libcrypto openssl.libssl namespaces math
-math.parser openssl prettyprint sequences tools.test ;
-
-! =========================================================
-! Some crypto functions (still to be turned into words)
-! =========================================================
-
-[
-    B{ 201 238 222 100 92 200 182 188 138 255 129 163 115 88 240 136 }
-]
-[ "Hello world from the openssl binding" >md5 ] unit-test
-
-! Not found on netbsd, windows -- why?
-! [
-    ! B{ 63 113 237 255 181 5 152 241 136 181 43 95 160 105 44 87 49
-    ! 82 115 0 }
-! ]
-! [ "Hello world from the openssl binding" >sha1 ] unit-test
-
-! =========================================================
-! Initialize context
-! =========================================================
-
-[ ] [ init load-error-strings ] unit-test
-
-[ ] [ ssl-v23 new-ctx ] unit-test
-
-[ ] [ get-ctx "extra/openssl/test/server.pem" resource-path use-cert-chain ] unit-test
-
-! TODO: debug 'Memory protection fault at address 6c'
-! get-ctx 1024 "char" malloc-array 1024 0 f password-cb set-default-passwd
-
-[ ] [ get-ctx "password" ascii string>alien set-default-passwd-userdata ] unit-test
-
-! Enter PEM pass phrase: password
-[ ] [ get-ctx "extra/openssl/test/server.pem" resource-path
-SSL_FILETYPE_PEM use-private-key ] unit-test
-
-[ ] [ get-ctx "extra/openssl/test/root.pem" resource-path f
-verify-load-locations ] unit-test
-
-[ ] [ get-ctx 1 set-verify-depth ] unit-test
-
-! =========================================================
-! Load Diffie-Hellman parameters
-! =========================================================
-
-[ ] [ "extra/openssl/test/dh1024.pem" resource-path "r" bio-new-file ] unit-test
-
-[ ] [ get-bio f f f read-pem-dh-params ] unit-test
-
-[ ] [ get-bio bio-free ] unit-test
-
-! TODO: debug SSL_CTX_set_tmp_dh 'No such symbol'
-[ ] [ get-ctx get-dh set-tmp-dh-callback ] unit-test
-
-! Workaround (this function should never be called directly)
-! [ ] [ get-ctx SSL_CTRL_SET_TMP_DH 0 get-dh set-ctx-ctrl ] unit-test
-
-! =========================================================
-! Generate ephemeral RSA key
-! =========================================================
-
-[ ] [ 512 RSA_F4 f f generate-rsa-key ] unit-test
-
-! TODO: debug SSL_CTX_set_tmp_rsa 'No such symbol'
-! get-ctx get-rsa set-tmp-rsa-callback
-
-! Workaround (this function should never be called directly)
-[ ] [ get-ctx SSL_CTRL_SET_TMP_RSA 0 get-rsa set-ctx-ctrl ] unit-test
-
-[ ] [ get-rsa free-rsa ] unit-test
-
-! =========================================================
-! Listen and accept on socket
-! =========================================================
-
-! SYMBOL: sock
-! SYMBOL: fdset
-! SYMBOL: acset
-! SYMBOL: sbio
-! SYMBOL: ssl
-! 
-! : is-set ( seq -- newseq )
-!     <enum> >alist [ nip ] assoc-filter >hashtable keys ;
-! 
-! ! 1234 server-socket sock set
-! "127.0.0.1" 1234 <inet4> SOCK_STREAM server-fd sock set
-! 
-! FD_SETSIZE 8 * <bit-array> fdset set
-! 
-! FD_SETSIZE 8 * <bit-array> t 8 rot [ set-nth ] keep fdset set
-! 
-! fdset get is-set .
-
-! : loop ( -- )
-!     sock get f f accept
-!     dup -1 = [ drop ] [
-!         dup number>string print flush
-!         ! BIO_NOCLOSE bio-new-socket sbio set
-!         [ get-ctx new-ssl ssl set ] keep
-!         ssl get swap set-ssl-fd
-!         ! ssl get sbio get dup set-ssl-bio
-!         ! ssl get ssl-accept
-!         ! dup 0 <= [ 
-!         !     ssl get swap ssl-get-error 
-!         ! ] [ drop ] if
-!     ] if
-!     loop ;
-
-! { } acset set
-! 
-! : loop ( -- )
-!     ! FD_SETSIZE fdset get f f f select . flush
-!     FD_SETSIZE fdset get f f 10000 make-timeval select 
-!     0 <= [ acset get [ close ] each "timeout" print ] [
-!         fdset get is-set sock get swap member? [ 
-!              sock get f f accept dup . flush 
-!              acset get swap add acset set
-!     ] [ ] if
-!         loop
-!     ] if ;
-! 
-! loop
-! 
-! sock get close
-
-! =========================================================
-! Dump errors to file
-! =========================================================
-
-[ ] [ "extra/openssl/test/errors.txt" resource-path "w" bio-new-file ] unit-test
-
-[ 6 ] [ get-bio "Hello\n" bio-print ] unit-test
-
-[ ] [ get-bio bio-free ] unit-test
-
-! =========================================================
-! Clean-up
-! =========================================================
-
-! sock get close
-
-get-ctx destroy-ctx
diff --git a/extra/openssl/openssl.factor b/extra/openssl/openssl.factor
deleted file mode 100755 (executable)
index 9b23774..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-! Copyright (C) 2007 Elie CHAFTARI
-! See http://factorcode.org/license.txt for BSD license.
-!
-! Tested with OpenSSL 0.9.8a_0 on Mac OS X 10.4.9 PowerPC
-
-USING: alien alien.c-types alien.strings assocs kernel libc
-namespaces openssl.libcrypto openssl.libssl sequences
-io.encodings.ascii ;
-
-IN: openssl
-
-SYMBOL: bio
-SYMBOL: ssl-bio
-
-SYMBOL: ctx
-SYMBOL: dh
-SYMBOL: rsa
-
-! =========================================================
-! Callback routines
-! =========================================================
-
-: password-cb ( -- alien )
-    "int" { "char*" "int" "int" "void*" } "cdecl"
-    [ 3drop "password" ascii string>alien 1023 memcpy
-    "password" length ] alien-callback ;
-
-! =========================================================
-! Error-handling routines
-! =========================================================
-
-: get-error ( -- num )
-    ERR_get_error ;
-
-: error-string ( num -- str )
-    f ERR_error_string ;
-
-: check-result ( result -- )
-    1 = [  ] [
-        get-error error-string throw
-    ] if ;
-
-: ssl-get-error ( ssl ret -- )
-    SSL_get_error error-messages at throw ;
-
-! Write errors to a file
-: bio-new-file ( path mode -- )
-    BIO_new_file bio set ;
-
-: bio-print ( bio str -- n )
-    BIO_printf ;
-
-: bio-free ( bio -- )
-    BIO_free check-result ;
-
-! =========================================================
-! Initialization routines
-! =========================================================
-
-: init ( -- )
-    SSL_library_init drop ; ! always returns 1
-
-: load-error-strings ( -- )
-    SSL_load_error_strings ;
-
-: ssl-v23 ( -- method )
-    SSLv23_method ;
-
-: new-ctx ( method -- )
-    SSL_CTX_new ctx set ;
-
-: use-cert-chain ( ctx file -- )
-    SSL_CTX_use_certificate_chain_file check-result ;
-
-: set-default-passwd ( ctx cb -- )
-    SSL_CTX_set_default_passwd_cb ;
-
-: set-default-passwd-userdata ( ctx passwd -- )
-    SSL_CTX_set_default_passwd_cb_userdata ;
-
-: use-private-key ( ctx file type -- )
-    SSL_CTX_use_PrivateKey_file check-result ;
-
-: verify-load-locations ( ctx file path -- )
-    SSL_CTX_load_verify_locations check-result ;
-
-: set-verify-depth ( ctx depth -- )
-    SSL_CTX_set_verify_depth ;
-
-: read-pem-dh-params ( bio x cb u -- )
-    PEM_read_bio_DHparams dh set ;
-
-: set-tmp-dh-callback ( ctx dh -- )
-    SSL_CTX_set_tmp_dh_callback ;
-
-: set-ctx-ctrl ( ctx cmd larg parg -- )
-    SSL_CTX_ctrl check-result ;
-
-: generate-rsa-key ( n e cb cbarg -- )
-    RSA_generate_key rsa set ;
-
-: set-tmp-rsa-callback ( ctx rsa -- )
-    SSL_CTX_set_tmp_rsa_callback ;
-
-: free-rsa ( rsa -- )
-    RSA_free ;
-
-: bio-new-socket ( fd flag -- sbio )
-    BIO_new_socket ;
-
-: new-ssl ( ctx -- ssl )
-    SSL_new ;
-
-: set-ssl-bio ( ssl bio bio -- )
-    SSL_set_bio ;
-
-: set-ssl-fd ( ssl fd -- )
-    SSL_set_fd check-result ;
-
-: ssl-accept ( ssl -- result )
-    SSL_accept ;
-
-! =========================================================
-! Clean-up and termination routines
-! =========================================================
-
-: destroy-ctx ( ctx -- )
-    SSL_CTX_free ;
-
-! =========================================================
-! Public routines
-! =========================================================
-
-: get-bio ( -- bio )
-    bio get ;
-
-: get-ssl-bio ( -- bio )
-    ssl-bio get ;
-
-: get-ctx ( -- ctx )
-    ctx get ;
-
-: get-dh ( -- dh )
-    dh get ;
-
-: get-rsa ( -- rsa )
-    rsa get ;
-
-: >md5 ( str -- byte-array )
-    dup length 16 "uchar" <c-array> [ MD5 ] keep nip ;
-
-: >sha1 ( str -- byte-array )
-    dup length 20 "uchar" <c-array> [ SHA1 ] keep nip ;
-
diff --git a/extra/openssl/summary.txt b/extra/openssl/summary.txt
deleted file mode 100755 (executable)
index 42db29f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-OpenSSL binding
diff --git a/extra/openssl/tags.txt b/extra/openssl/tags.txt
deleted file mode 100644 (file)
index 93e252c..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-enterprise
-network
-bindings
diff --git a/extra/openssl/test/dh1024.pem b/extra/openssl/test/dh1024.pem
deleted file mode 100644 (file)
index aa68d98..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
------BEGIN DH PARAMETERS-----
-MIGHAoGBANmAnfkETuKHOCWaE+W+F3kM/e7z5A8hZb7OqwGMQrUOaBEAr4BWeZBn
-G/87hhwZgNP69/KUchm714qd/PpOspCaUJ20x6PcmKujpAgca/f19HGMBjRawQMk
-R9oaBwazuQT0l0rTTKmvpMEcrQQIcVWii3CZI56I56oqF8biGPD7AgEC
------END DH PARAMETERS-----
diff --git a/extra/openssl/test/errors.txt b/extra/openssl/test/errors.txt
deleted file mode 100644 (file)
index e965047..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Hello
diff --git a/extra/openssl/test/root.pem b/extra/openssl/test/root.pem
deleted file mode 100644 (file)
index db0c59f..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
------BEGIN CERTIFICATE-----
-MIICIjCCAYugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJVUzET
-MBEGA1UEChMKUlRGTSwgSW5jLjEZMBcGA1UECxMQV2lkZ2V0cyBEaXZpc2lvbjEY
-MBYGA1UEAxMPVGVzdCBDQTIwMDEwNTE3MB4XDTAxMDUxNzE2MDExNFoXDTA2MTIy
-NTE2MDExNFowVzELMAkGA1UEBhMCVVMxEzARBgNVBAoTClJURk0sIEluYy4xGTAX
-BgNVBAsTEFdpZGdldHMgRGl2aXNpb24xGDAWBgNVBAMTD1Rlc3QgQ0EyMDAxMDUx
-NzCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAmkX40warmH0+lnwD9YjsJhRz
-ZX6qXadFry0y2trZ6gMs8Mv33IKPwOu8TE7V+3PESEtjI2wr8juV9OkbIPOm+td5
-M8+6vXyIW+JBo3ch99i0QMTf5/jTgsW+3IjV8yEdiGcZFp2NWKLRvZPq2VRbuF7R
-1pvgcaRuBJ0wGOohwnsCAwEAATANBgkqhkiG9w0BAQQFAAOBgQCUB8zMKIlX5io8
-TalbzH9Qke7BcvFAL+wp/5w1ToVsWkNrINSWKv6bl/jcqOD3aPhK7qhaeOU8ZWKL
-PoPPCnRl9Wo+1JtsOO3qIgJP79Bl9ooLGahixF2v/gea5qNISjQvwYllLSa//APP
-6kXHngO0RIRbiTBYHSkAzm6hDdsvVA==
------END CERTIFICATE-----
diff --git a/extra/openssl/test/server.pem b/extra/openssl/test/server.pem
deleted file mode 100644 (file)
index 87376db..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-Proc-Type: 4,ENCRYPTED
-DEK-Info: DES-EDE3-CBC,5772A2A7BE34B611
-
-1yJ+xAn4MudcIfXXy7ElYngJ9EohIh8yvcyVLmE4kVd0xeaL/Bqhvk25BjYCK5d9
-k1K8cjgnKEBjbC++0xtJxFSbUhwoKTLwn+sBoJDcFzMKkmJXXDbSTOaNr1sVwiAR
-SnB4lhUcHguYoV5zlRJn53ft7t1mjB6RwGH+d1Zx6t95OqM1lnKqwekwmotVAWHj
-ncu3N8qhmoPMppmzEv0fOo2/pK2WohcJykSeN5zBrZCUxoO0NBNEZkFUcVjR+KsA
-1ZeI1mU60szqg+AoU/XtFcow8RtG1QZKQbbXzyfbwaG+6LqkHaWYKHQEI1546yWK
-us1HJ734uUkZoyyyazG6PiGCYV2u/aY0i3qdmyDqTvmVIvve7E4glBrtDS9h7D40
-nPShIvOatoPzIK4Y0QSvrI3G1vTsIZT3IOZto4AWuOkLNfYS2ce7prOreF0KjhV0
-3tggw9pHdDmTjHTiIkXqheZxZ7TVu+pddZW+CuB62I8lCBGPW7os1f21e3eOD/oY
-YPCI44aJvgP+zUORuZBWqaSJ0AAIuVW9S83Yzkz/tlSFHViOebyd8Cug4TlxK1VI
-q6hbSafh4C8ma7YzlvqjMzqFifcIolcbx+1A6ot0UiayJTUra4d6Uc4Rbc9RIiG0
-jfDWC6aii9YkAgRl9WqSd31yASge/HDqVXFwR48qdlYQ57rcHviqxyrwRDnfw/lX
-Mf6LPiDKEco4MKej7SR2kK2c2AgxUzpGZeAY6ePyhxbdhA0eY21nDeFd/RbwSc5s
-eTiCCMr41OB4hfBFXKDKqsM3K7klhoz6D5WsgE6u3lDoTdz76xOSTg==
------END RSA PRIVATE KEY-----
------BEGIN CERTIFICATE-----
-MIICGDCCAYECAgEBMA0GCSqGSIb3DQEBBAUAMFcxCzAJBgNVBAYTAlVTMRMwEQYD
-VQQKEwpSVEZNLCBJbmMuMRkwFwYDVQQLExBXaWRnZXRzIERpdmlzaW9uMRgwFgYD
-VQQDEw9UZXN0IENBMjAwMTA1MTcwHhcNMDEwNTE3MTYxMDU5WhcNMDQwMzA2MTYx
-MDU5WjBRMQswCQYDVQQGEwJVUzETMBEGA1UEChMKUlRGTSwgSW5jLjEZMBcGA1UE
-CxMQV2lkZ2V0cyBEaXZpc2lvbjESMBAGA1UEAxMJbG9jYWxob3N0MIGfMA0GCSqG
-SIb3DQEBAQUAA4GNADCBiQKBgQCiWhMjNOPlPLNW4DJFBiL2fFEIkHuRor0pKw25
-J0ZYHW93lHQ4yxA6afQr99ayRjMY0D26pH41f0qjDgO4OXskBsaYOFzapSZtQMbT
-97OCZ7aHtK8z0ZGNW/cslu+1oOLomgRxJomIFgW1RyUUkQP1n0hemtUdCLOLlO7Q
-CPqZLQIDAQABMA0GCSqGSIb3DQEBBAUAA4GBAIumUwl1OoWuyN2xfoBHYAs+lRLY
-KmFLoI5+iMcGxWIsksmA+b0FLRAN43wmhPnums8eXgYbDCrKLv2xWcvKDP3mps7m
-AMivwtu/eFpYz6J8Mo1fsV4Ys08A/uPXkT23jyKo2hMu8mywkqXCXYF2e+7pEeBr
-dsbmkWK5NgoMl8eM
------END CERTIFICATE-----
index 510e44d34e5589110b1d0c630075077fcd0af1fb..d58ccbd0f263a1067555bc9a5c12606b368f4164 100755 (executable)
@@ -38,7 +38,7 @@ USING: io io.streams.string kernel namespaces pack strings tools.test ;
 
 [ 2 ] [
     [ 2 "int" b, ] B{ } make
-    <string-reader> [ "int" read-native ] with-stream
+    <string-reader> [ "int" read-native ] with-input-stream
 ] unit-test
 
 [ "FRAM" ] [ "FRAM\0" [ read-c-string ] with-string-reader ] unit-test
index 65912244dd190a45fccbd387b914142e28a33faf..5320583df0e11fa20955ce43a1640ada6c452e51 100755 (executable)
@@ -154,13 +154,12 @@ MACRO: (pack) ( seq str -- quot )
 
 MACRO: (unpack) ( str -- quot )
     [
-        \ <string-reader> ,
         [
             [ unpack-table at , \ , , ] each
         ] [ ] make
         1quotation [ { } make ] append
         1quotation %
-        \ with-stream ,
+        \ with-string-reader ,
     ] [ ] make ;
 
 : unpack-native ( seq str -- seq )
index 0ee7bf515f2fd85e0c1e49216398273fec9ae099..c3252de5006bb2da5db90ab974236b32e7812c12 100644 (file)
@@ -324,7 +324,7 @@ M: ebnf-sequence build-locals ( code ast -- code )
         ] 2each\r
         " | " %\r
         %  \r
-        " ] with-locals" %     \r
+        " ]" %     \r
     ] "" make \r
   ] if ;\r
 \r
@@ -334,7 +334,7 @@ M: ebnf-var build-locals ( code ast -- )
     name>> % " [ dup ] " %\r
     " | " %\r
     %  \r
-    " ] with-locals" %     \r
+    " ]" %     \r
   ] "" make ;\r
 \r
 M: object build-locals ( code ast -- )\r
index 32386fed2b961c411dc7f52b098609226f7dfd2f..42c358646bde23172e313ed7a9d914d7dbecf3e3 100644 (file)
@@ -56,11 +56,9 @@ io.files io.encodings.utf8 ;
 [ "hell" ] [ "hell" step5 "" like ] unit-test
 [ "mate" ] [ "mate" step5 "" like ] unit-test
 
-: resource-lines resource-path utf8 file-lines ;
-
 [ { } ] [
-    "extra/porter-stemmer/test/voc.txt" resource-lines
+    "resource:extra/porter-stemmer/test/voc.txt" utf8 file-lines
     [ stem ] map
-    "extra/porter-stemmer/test/output.txt" resource-lines
+    "resource:extra/porter-stemmer/test/output.txt" utf8 file-lines
     [ 2array ] 2map [ first2 = not ] filter
 ] unit-test
index 81820e0152801d685c89bbe8353f5468049c113e..9a2a08bcbeb45b4f7fea169f678f8a596ff5e192 100644 (file)
@@ -66,8 +66,6 @@ USING: kernel math parser sequences combinators splitting ;
 : r ( str oldsuffix newsuffix -- str )
     pick consonant-seq 0 > [ nip ] [ drop ] if append ;
 
-: butlast ( seq -- seq ) 1 head-slice* ;
-
 : step1a ( str -- newstr )
     dup peek CHAR: s = [
         {
@@ -95,7 +93,7 @@ USING: kernel math parser sequences combinators splitting ;
         { [ "iz" ?tail ] [ "ize" append ] }
         {
             [ dup length 1- over double-consonant? ]
-            [ dup "lsz" last-is? [ butlast ] unless ]
+            [ dup "lsz" last-is? [ but-last-slice ] unless ]
         }
         {
             [ t ]
@@ -122,7 +120,7 @@ USING: kernel math parser sequences combinators splitting ;
     } cond ;
 
 : step1c ( str -- newstr )
-    dup butlast stem-vowel? [
+    dup but-last-slice stem-vowel? [
         "y" ?tail [ "i" append ] when
     ] when ;
 
@@ -198,18 +196,18 @@ USING: kernel math parser sequences combinators splitting ;
 : remove-e? ( str -- ? )
     dup consonant-seq dup 1 >
     [ 2drop t ]
-    [ 1 = [ butlast cvc? not ] [ drop f ] if ] if ;
+    [ 1 = [ but-last-slice cvc? not ] [ drop f ] if ] if ;
 
 : remove-e ( str -- newstr )
     dup peek CHAR: e = [
-        dup remove-e? [ butlast ] when
+        dup remove-e? [ but-last-slice ] when
     ] when ;
 
 : ll->l ( str -- newstr )
     {
         { [ dup peek CHAR: l = not ] [ ] }
         { [ dup length 1- over double-consonant? not ] [ ] }
-        { [ dup consonant-seq 1 > ] [ butlast ] }
+        { [ dup consonant-seq 1 > ] [ but-last-slice ] }
         [ ]
     } cond ;
 
index c2def03ace0167ea31c99e270a08841ded85986d..108f5c1e94a1072d418ca92204daccbd320a916d 100644 (file)
@@ -41,7 +41,7 @@ PRIVATE>
 
 : fib-upto* ( n -- seq )
     0 1 [ pick over >= ] [ tuck + dup ] [ ] unfold 3nip
-    1 head-slice* { 0 1 } prepend ;
+    but-last-slice { 0 1 } prepend ;
 
 : euler002a ( -- answer )
     1000000 fib-upto* [ even? ] filter sum ;
index 452d2ec63730f080aa5ce93232acafb5964405d6..82054ce014048b6b5cb790415259b359ed736371 100644 (file)
@@ -28,7 +28,7 @@ IN: project-euler.022
 <PRIVATE
 
 : source-022 ( -- seq )
-    "extra/project-euler/022/names.txt" resource-path
+    "resource:extra/project-euler/022/names.txt"
     ascii file-contents [ quotable? ] filter "," split ;
 
 : name-scores ( seq -- seq )
index 1fda8a402a78e55dd6cd5e170f957d0f355916e8..4111fe80091555644b38941deaf45164624e83ed 100644 (file)
@@ -30,7 +30,7 @@ IN: project-euler.042
 <PRIVATE
 
 : source-042 ( -- seq )
-    "extra/project-euler/042/words.txt" resource-path
+    "resource:extra/project-euler/042/words.txt"
     ascii file-contents [ quotable? ] filter "," split ;
 
 : (triangle-upto) ( limit n -- )
index bb95ab9024d689010bb48a8068fa6a704d80c22a..dceb01bd16837ac2224dfa5cb774826c8c8d8b35 100644 (file)
@@ -52,7 +52,7 @@ IN: project-euler.059
 <PRIVATE
 
 : source-059 ( -- seq )
-    "extra/project-euler/059/cipher1.txt" resource-path
+    "resource:extra/project-euler/059/cipher1.txt"
     ascii file-contents [ blank? ] right-trim "," split
     [ string>number ] map ;
 
@@ -78,7 +78,7 @@ INSTANCE: rollover immutable-sequence
     frequency-analysis sort-values keys peek ;
 
 : crack-key ( seq key-length -- key )
-    [ " " decrypt ] dip group 1 head-slice*
+    [ " " decrypt ] dip group but-last-slice
     flip [ most-frequent ] map ;
 
 PRIVATE>
index 436ccde77609ba8fc9e50d85a3f2005c99c36a2e..3e16996e0424c4cea61404d9349996ce286e5ca2 100644 (file)
@@ -38,7 +38,7 @@ IN: project-euler.067
 <PRIVATE
 
 : source-067 ( -- seq )
-    "extra/project-euler/067/triangle.txt" resource-path
+    "resource:extra/project-euler/067/triangle.txt"
     ascii file-lines [ " " split [ string>number ] map ] map ;
 
 PRIVATE>
index 3674804b0c2d49945782b80894bb166fb708b4c8..cde4dc079b3401aa1912e6549ab2e78b2988f0e9 100644 (file)
@@ -27,7 +27,7 @@ IN: project-euler.079
 <PRIVATE
 
 : source-079 ( -- seq )
-    "extra/project-euler/079/keylog.txt" resource-path ascii file-lines ;
+    "resource:extra/project-euler/079/keylog.txt" ascii file-lines ;
 
 : >edges ( seq -- seq )
     [
index 6016a6e9cbecaa4066fd2e1aa2a5858098fce061..7fda7c5d1daa634883af018b2fd5e0e992393d5a 100644 (file)
@@ -9,7 +9,7 @@ C: <unix-random> unix-random
 
 : file-read-unbuffered ( n path -- bytes )
     over default-buffer-size [
-        binary <file-reader> [ read ] with-stream
+        binary [ read ] with-file-reader
     ] with-variable ;
 
 M: unix-random random-bytes* ( n tuple -- byte-array )
index 252defe99bb59e3dcc19f99250e3e1446cb2927c..0e6bb0b9c15c91fe11289fcb605a3869c4ae3219 100755 (executable)
@@ -22,7 +22,7 @@ IN: rss.tests
             f
         }
     }
-} ] [ "extra/rss/rss1.xml" resource-path load-news-file ] unit-test
+} ] [ "resource:extra/rss/rss1.xml" load-news-file ] unit-test
 [ T{
     feed
     f
@@ -39,4 +39,4 @@ IN: rss.tests
             T{ timestamp f 2003 12 13 8 29 29 T{ duration f 0 0 0 -4 0 0 } }
         }
     }
-} ] [ "extra/rss/atom.xml" resource-path load-news-file ] unit-test
+} ] [ "resource:extra/rss/atom.xml" load-news-file ] unit-test
index 33587bb7fafa40f2a4833f2ddf0e9dbc2af6d852..89522d1f76b685fefe88f0c8f1baee3458a4ff80 100644 (file)
@@ -5,6 +5,8 @@ USING: kernel sequences namespaces math inference.transforms
 
 IN: shuffle
 
+: 2dip -rot 2slip ; inline
+
 MACRO: npick ( n -- ) 1- dup saver [ dup ] rot [ r> swap ] n*quot 3append ;
 
 MACRO: ndup ( n -- ) dup [ npick ] curry n*quot ;
index 5b6f26acea8d17646904669a91b0e8a5470d82e0..a2b47fc0aab9f72a6f75ce44f6ee541233ba28d2 100644 (file)
@@ -36,4 +36,4 @@ VAR: headers
   { "gcc" c-file "-o" exe } to-strings
   [ "Error compiling generated C program" print ] run-or-bail
 
-  exe ascii <process-stream> contents string>number ;
\ No newline at end of file
+  exe ascii <process-reader> contents string>number ;
\ No newline at end of file
index 737a887f9fa868d12adb66e8767cc4fc2dc84414..f23ee138d5be4dc5059cc8ed70063eced4784571 100755 (executable)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2007 Elie CHAFTARI
 ! See http://factorcode.org/license.txt for BSD license.
 USING: combinators kernel prettyprint io io.timeouts io.server
-sequences namespaces io.sockets continuations calendar io.encodings.ascii ;
+sequences namespaces io.sockets continuations calendar
+io.encodings.ascii io.streams.duplex ;
 IN: smtp.server
 
 ! Mock SMTP server for testing purposes.
@@ -65,7 +66,7 @@ SYMBOL: data-mode
     "Starting SMTP server on port " write dup . flush
     "127.0.0.1" swap <inet4> ascii <server> [
         accept drop [
-            1 minutes stdio get set-timeout
+            1 minutes timeouts
             "220 hello\r\n" write flush
             process
             global [ flush ] bind
index 4d548738d2c9efed894f36b0dfb435027b36b9db..8fdc0e07a4cf04cdf61a9a2429accc93c856276a 100755 (executable)
@@ -17,11 +17,11 @@ LOG: log-smtp-connection NOTICE ( addrspec -- )
 : with-smtp-connection ( quot -- )
     smtp-server get
     dup log-smtp-connection
-    ascii <client> [
+    ascii [
         smtp-domain [ host-name or ] change
-        read-timeout get stdio get set-timeout
+        read-timeout get timeouts
         call
-    ] with-stream ; inline
+    ] with-client ; inline
 
 : crlf "\r\n" write ;
 
index 200257b31c53ef442a1aa502be553ca3191288e4..f773d331b1266a7dd5532f3f6b103a8e5bd9493b 100755 (executable)
@@ -45,21 +45,21 @@ TUPLE: space-invaders port1 port2i port2o port3o port4lo port4hi port5o bitmap s
 
 : init-sound ( index cpu filename  -- )
   swapd >r space-invaders-sounds nth AL_BUFFER r> 
-  resource-path create-buffer-from-wav set-source-param ; 
+  create-buffer-from-wav set-source-param ; 
 
 : init-sounds ( cpu -- )
   init-openal
   [ 9 gen-sources swap set-space-invaders-sounds ] keep
-  [ SOUND-SHOT        "extra/space-invaders/resources/Shot.wav" init-sound ] keep 
-  [ SOUND-UFO         "extra/space-invaders/resources/Ufo.wav" init-sound ] keep 
+  [ SOUND-SHOT        "resource:extra/space-invaders/resources/Shot.wav" init-sound ] keep 
+  [ SOUND-UFO         "resource:extra/space-invaders/resources/Ufo.wav" init-sound ] keep 
   [ space-invaders-sounds SOUND-UFO swap nth AL_LOOPING AL_TRUE set-source-param ] keep
-  [ SOUND-BASE-HIT    "extra/space-invaders/resources/BaseHit.wav" init-sound ] keep 
-  [ SOUND-INVADER-HIT "extra/space-invaders/resources/InvHit.wav" init-sound ] keep 
-  [ SOUND-WALK1       "extra/space-invaders/resources/Walk1.wav" init-sound ] keep 
-  [ SOUND-WALK2       "extra/space-invaders/resources/Walk2.wav" init-sound ] keep 
-  [ SOUND-WALK3       "extra/space-invaders/resources/Walk3.wav" init-sound ] keep 
-  [ SOUND-WALK4       "extra/space-invaders/resources/Walk4.wav" init-sound ] keep 
-  [ SOUND-UFO-HIT    "extra/space-invaders/resources/UfoHit.wav" init-sound ] keep
+  [ SOUND-BASE-HIT    "resource:extra/space-invaders/resources/BaseHit.wav" init-sound ] keep 
+  [ SOUND-INVADER-HIT "resource:extra/space-invaders/resources/InvHit.wav" init-sound ] keep 
+  [ SOUND-WALK1       "resource:extra/space-invaders/resources/Walk1.wav" init-sound ] keep 
+  [ SOUND-WALK2       "resource:extra/space-invaders/resources/Walk2.wav" init-sound ] keep 
+  [ SOUND-WALK3       "resource:extra/space-invaders/resources/Walk3.wav" init-sound ] keep 
+  [ SOUND-WALK4       "resource:extra/space-invaders/resources/Walk4.wav" init-sound ] keep 
+  [ SOUND-UFO-HIT    "resource:extra/space-invaders/resources/UfoHit.wav" init-sound ] keep
   f swap set-space-invaders-looping? ;
 
 : <space-invaders> ( -- cpu )
index cac0e30175c13cedfec6394be96ae45666414e70..3027c01c19531544f5ca4665b9c2a3bb75b7ea4f 100644 (file)
@@ -69,4 +69,4 @@ HELP: next
 { $description "originally written as " { $code "spot inc" } ", code that would no longer run, this word moves the state of the XML parser to the next place in the source file, keeping track of appropriate debugging information." } ;
 
 HELP: parsing-error
-{ $class-description "class to which parsing errors delegate, containing information about which line and column the error occured on, and what the line was. Contains three slots, line, an integer, column, another integer, and line-str, a string" } ;
+{ $class-description "class from which parsing errors inherit, containing information about which line and column the error occured on, and what the line was. Contains three slots, line, an integer, column, another integer, and line-str, a string" } ;
index 96ad4ca0b4b07da0a06550166328646380e76a1b..b41d7f5023865356dca6406d6c0bafae6eb1bb87 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2005, 2006 Daniel Ehrenberg\r
 ! See http://factorcode.org/license.txt for BSD license.\r
 USING: io io.streams.string kernel math namespaces sequences\r
-strings circular prettyprint debugger ascii ;\r
+strings circular prettyprint debugger ascii sbufs fry inspector\r
+accessors sequences.lib ;\r
 IN: state-parser\r
 \r
 ! * Basic underlying words\r
@@ -11,50 +12,56 @@ TUPLE: spot char line column next ;
 \r
 C: <spot> spot\r
 \r
-: get-char ( -- char ) spot get spot-char ;\r
-: set-char ( char -- ) spot get set-spot-char ;\r
-: get-line ( -- line ) spot get spot-line ;\r
-: set-line ( line -- ) spot get set-spot-line ;\r
-: get-column ( -- column ) spot get spot-column ;\r
-: set-column ( column -- ) spot get set-spot-column ;\r
-: get-next ( -- char ) spot get spot-next ;\r
-: set-next ( char -- ) spot get set-spot-next ;\r
+: get-char ( -- char ) spot get char>> ;\r
+: set-char ( char -- ) spot get swap >>char drop ;\r
+: get-line ( -- line ) spot get line>> ;\r
+: set-line ( line -- ) spot get swap >>line drop ;\r
+: get-column ( -- column ) spot get column>> ;\r
+: set-column ( column -- ) spot get swap >>column drop ;\r
+: get-next ( -- char ) spot get next>> ;\r
+: set-next ( char -- ) spot get swap >>next drop ;\r
 \r
 ! * Errors\r
 TUPLE: parsing-error line column ;\r
-: <parsing-error> ( -- parsing-error )\r
-    get-line get-column parsing-error boa ;\r
-\r
-: construct-parsing-error ( ... slots class -- error )\r
-    construct <parsing-error> over set-delegate ; inline\r
-\r
-: parsing-error. ( parsing-error -- )\r
-    "Parsing error" print\r
-    "Line: " write dup parsing-error-line .\r
-    "Column: " write parsing-error-column . ;\r
-\r
-TUPLE: expected should-be was ;\r
-: <expected> ( should-be was -- error )\r
-    { set-expected-should-be set-expected-was }\r
-    expected construct-parsing-error ;\r
-M: expected error.\r
-    dup parsing-error.\r
-    "Token expected: " write dup expected-should-be print\r
-    "Token present: " write expected-was print ;\r
-\r
-TUPLE: unexpected-end ;\r
-: <unexpected-end> ( -- unexpected-end )\r
-    { } unexpected-end construct-parsing-error ;\r
-M: unexpected-end error.\r
-    parsing-error.\r
-    "File unexpectedly ended." print ;\r
-\r
-TUPLE: missing-close ;\r
-: <missing-close> ( -- missing-close )\r
-    { } missing-close construct-parsing-error ;\r
-M: missing-close error.\r
-    parsing-error.\r
-    "Missing closing token." print ;\r
+\r
+: parsing-error ( class -- obj )\r
+    new\r
+        get-line >>line\r
+        get-column >>column ;\r
+M: parsing-error summary ( obj -- str )\r
+    [\r
+        "Parsing error" print\r
+        "Line: " write dup line>> .\r
+        "Column: " write column>> .\r
+    ] with-string-writer ;\r
+\r
+TUPLE: expected < parsing-error should-be was ;\r
+: expected ( should-be was -- * )\r
+    \ expected parsing-error\r
+        swap >>was\r
+        swap >>should-be throw ;\r
+M: expected summary ( obj -- str )\r
+    [\r
+        dup call-next-method write\r
+        "Token expected: " write dup should-be>> print\r
+        "Token present: " write was>> print\r
+    ] with-string-writer ;\r
+\r
+TUPLE: unexpected-end < parsing-error ;\r
+: unexpected-end \ unexpected-end parsing-error throw ;\r
+M: unexpected-end summary ( obj -- str )\r
+    [\r
+        call-next-method write\r
+        "File unexpectedly ended." print\r
+    ] with-string-writer ;\r
+\r
+TUPLE: missing-close < parsing-error ;\r
+: missing-close \ missing-close parsing-error throw ;\r
+M: missing-close summary ( obj -- str )\r
+    [\r
+        call-next-method write\r
+        "Missing closing token." print\r
+    ] with-string-writer ;\r
 \r
 SYMBOL: prolog-data\r
 \r
@@ -65,7 +72,8 @@ SYMBOL: prolog-data
     [ 0 get-line 1+ set-line ] [ get-column 1+ ] if\r
     set-column ;\r
 \r
-: (next) ( -- char ) ! this normalizes \r\n and \r\r
+! (next) normalizes \r\n and \r\r
+: (next) ( -- char )\r
     get-next read1\r
     2dup swap CHAR: \r = [\r
         CHAR: \n =\r
@@ -75,10 +83,7 @@ SYMBOL: prolog-data
 \r
 : next ( -- )\r
     #! Increment spot.\r
-    get-char [\r
-        <unexpected-end> throw\r
-    ] unless\r
-    (next) record ;\r
+    get-char [ unexpected-end ] unless (next) record ;\r
 \r
 : next* ( -- )\r
     get-char [ (next) record ] when ;\r
@@ -95,9 +100,9 @@ SYMBOL: prolog-data
     #! Take the substring of a string starting at spot\r
     #! from code until the quotation given is true and\r
     #! advance spot to after the substring.\r
-    [ [\r
-        dup slip swap dup [ get-char , ] unless\r
-    ] skip-until ] "" make nip ; inline\r
+    10 <sbuf> [\r
+        '[ @ [ t ] [ get-char , push f ] if ] skip-until\r
+    ] keep >string ; inline\r
 \r
 : take-rest ( -- string )\r
     [ f ] take-until ;\r
@@ -105,6 +110,20 @@ SYMBOL: prolog-data
 : take-char ( ch -- string )\r
     [ dup get-char = ] take-until nip ;\r
 \r
+TUPLE: not-enough-characters < parsing-error ;\r
+: not-enough-characters\r
+    \ not-enough-characters parsing-error throw ;\r
+M: not-enough-characters summary ( obj -- str )\r
+    [\r
+        call-next-method write\r
+        "Not enough characters" print\r
+    ] with-string-writer ;\r
+\r
+: take ( n -- string )\r
+    [ 1- ] [ <sbuf> ] bi [\r
+        '[ drop get-char [ next , push f ] [ t ] if* ] attempt-each drop\r
+    ] keep get-char [ over push ] when* >string ;\r
+\r
 : pass-blank ( -- )\r
     #! Advance code past any whitespace, including newlines\r
     [ get-char blank? not ] skip-until ;\r
@@ -117,24 +136,24 @@ SYMBOL: prolog-data
     dup length <circular-string>\r
     [ 2dup string-matches? ] take-until nip\r
     dup length rot length 1- - head\r
-    get-char [ <missing-close> throw ] unless next ;\r
+    get-char [ missing-close ] unless next ;\r
 \r
 : expect ( ch -- )\r
     get-char 2dup = [ 2drop ] [\r
-        >r 1string r> 1string <expected> throw\r
+        >r 1string r> 1string expected\r
     ] if next ;\r
 \r
 : expect-string ( string -- )\r
     dup [ drop get-char next ] map 2dup =\r
-    [ 2drop ] [ <expected> throw ] if ;\r
+    [ 2drop ] [ expected ] if ;\r
 \r
 : init-parser ( -- )\r
     0 1 0 f <spot> spot set\r
     read1 set-next next ;\r
 \r
 : state-parse ( stream quot -- )\r
-    ! with-stream implicitly creates a new scope which we use\r
-    swap [ init-parser call ] with-stream ; inline\r
+    ! with-input-stream implicitly creates a new scope which we use\r
+    swap [ init-parser call ] with-input-stream ; inline\r
 \r
 : string-parse ( input quot -- )\r
     >r <string-reader> r> state-parse ; inline\r
index afaf3da3cd9c24d1c7aee765a1c3eec3fc6a9ed8..52c454f97f3bbfae98880f06f3ec3b2b71f9aea7 100644 (file)
@@ -65,7 +65,7 @@ TUPLE: tangle-dispatcher < dispatcher tangle ;
 : <tangle-dispatcher> ( tangle -- dispatcher )
     tangle-dispatcher new-dispatcher swap >>tangle
     <path-responder> >>default
-    "extra/tangle/resources" resource-path <static> "resources" add-responder
+    "resource:extra/tangle/resources" <static> "resources" add-responder
     <node-responder> "node" add-responder
     <action> [ all-node-ids <json-response> ] >>display "all" add-responder ;
 
index 9b3d2ae79f4cea7174848176588b6ca9374d8e98..b5d01b6ed2f00c0df839f335b9dd79b73ab6048a 100755 (executable)
@@ -1,7 +1,6 @@
-USING: combinators io io.files io.streams.duplex
-io.streams.string kernel math math.parser continuations
-namespaces pack prettyprint sequences strings system
-hexdump io.encodings.binary inspector accessors ;
+USING: combinators io io.files io.streams.string kernel math
+math.parser continuations namespaces pack prettyprint sequences
+strings system hexdump io.encodings.binary inspector accessors ;
 IN: tar
 
 : zero-checksum 256 ;
@@ -61,9 +60,7 @@ SYMBOL: filename
     ] if* ;
 
 : read-data-blocks ( tar-header out -- )
-    >r stdio get r> <duplex-stream> [
-        (read-data-blocks)
-    ] with-stream* ;
+    [ (read-data-blocks) ] with-output-stream* ;
 
 : parse-tar-header ( seq -- obj )
     [ header-checksum ] keep over zero-checksum = [
index 6aeb5aa0983fd3859a8c76478f03f864b2758dba..32dbd0d6258ca99af9820612c829b3df1b4d159e 100644 (file)
@@ -96,3 +96,21 @@ IN: taxes.tests
     1000000 2008 3 t <w4> <minnesota> net
     dollars/cents
 ] unit-test
+
+
+[ 30 97 ] [
+    24000 2008 2 f <w4> <minnesota> withholding biweekly dollars/cents
+] unit-test
+
+[ 173 66 ] [
+    78250 2008 2 f <w4> <minnesota> withholding biweekly dollars/cents
+] unit-test
+
+
+[ 138 69 ] [
+    24000 2008 2 f <w4> <federal> withholding biweekly dollars/cents
+] unit-test
+
+[ 754 22 ] [
+    78250 2008 2 f <w4> <federal> withholding biweekly dollars/cents
+] unit-test
index d4fbf1de7872df6e5776ae19a95448b4fd37075c..6dff51123839c08e2d1cf7cc12094b2a2e3e3122 100755 (executable)
@@ -4,7 +4,7 @@ USING: namespaces continuations.private kernel.private init
 assocs kernel vocabs words sequences memory io system arrays
 continuations math definitions mirrors splitting parser classes
 inspector layouts vocabs.loader prettyprint.config prettyprint
-debugger io.streams.c io.streams.duplex io.files io.backend
+debugger io.streams.c io.files io.backend
 quotations io.launcher words.private tools.deploy.config
 bootstrap.image io.encodings.utf8 accessors ;
 IN: tools.deploy.backend
@@ -31,10 +31,9 @@ IN: tools.deploy.backend
         +stdout+ >>stderr
         +closed+ >>stdin
         +low-priority+ >>priority
-    utf8 <process-stream*>
-    >r copy-lines r> wait-for-process zero? [
-        "Deployment failed" throw
-    ] unless ;
+    utf8 <process-reader*>
+    copy-lines
+    wait-for-process zero? [ "Deployment failed" throw ] unless ;
 
 : make-boot-image ( -- )
     #! If stage1 image doesn't exist, create one.
@@ -64,11 +63,11 @@ DEFER: ?make-staging-image
         dup empty? [
             "-i=" my-boot-image-name append ,
         ] [
-            dup 1 head* ?make-staging-image
+            dup but-last ?make-staging-image
 
             "-resource-path=" "" resource-path append ,
 
-            "-i=" over 1 head* staging-image-name append ,
+            "-i=" over but-last staging-image-name append ,
 
             "-run=tools.deploy.restage" ,
         ] if
index 1ad9957cc97bd27457c680c88c63aded0e649622..13742546125495ac083a3f3f6902dceb3536c645 100755 (executable)
@@ -114,14 +114,15 @@ IN: tools.deploy.shaker
             continuations:error-continuation
             continuations:error-thread
             continuations:restarts
-            error-hook
+            listener:error-hook
             init:init-hooks
             inspector:inspector-hook
             io.thread:io-thread
             libc.private:mallocs
             source-files:source-files
-            stderr
-            stdio
+            input-stream
+            output-stream
+            error-stream
         } %
 
         deploy-threads? [
@@ -145,7 +146,6 @@ IN: tools.deploy.shaker
                 classes:class-not-cache
                 classes:class-or-cache
                 classes:class<=-cache
-                classes:class<=>-cache
                 classes:classes-intersect-cache
                 classes:update-map
                 command-line:main-vocab-hook
index 89e84bbc86c9f7cfff5688e06ea733b3f25fb535..50bbc527d1d760f86aa1feb38a1a1fbab6621c52 100755 (executable)
@@ -27,7 +27,7 @@ HELP: counters
 
 HELP: counters.
 { $values { "assoc" "an association list mapping words to integers" } }
-{ $description "Prints an association list of call counts to the " { $link stdio } " stream." } ;
+{ $description "Prints an association list of call counts to " { $link output-stream } "." } ;
 
 HELP: profile
 { $values { "quot" quotation } }
index a605543bda96cfe722497a6f6e19b3b425bb1409..4b2521d19c4d401be2bb71b9313a2c85bcb8bc34 100755 (executable)
@@ -91,4 +91,4 @@ HELP: run-all-tests
 
 HELP: test-failures.
 { $values { "assoc" "an association list of unit test failures" } }
-{ $description "Prints unit test failures output by " { $link run-tests } " or " { $link run-all-tests } " to the " { $link stdio } " stream." } ;
+{ $description "Prints unit test failures output by " { $link run-tests } " or " { $link run-all-tests } " to " { $link output-stream } "." } ;
index 9b32bc9e10fa6ace95e1427eb7907fb4265ab46b..8825cffa4d2d2478b9844836d87890214ffea0e2 100755 (executable)
@@ -2,7 +2,7 @@ USING: dlists ui.gadgets kernel ui namespaces io.streams.string
 io ;
 IN: tools.test.ui
 
-! We can't print to stdio here because that might be a pane
+! We can't print to output-stream here because that might be a pane
 ! stream, and our graft-queue rebinding here would be captured
 ! by code adding children to the pane...
 : with-grafted-gadget ( gadget quot -- )
index 563cd04e3e91b570cdc59129bae436a0aab53ff1..ee5198a8f44f2e3eb4372f731291efb6ecdeae4e 100755 (executable)
@@ -13,9 +13,9 @@ IN: tools.vocabs.monitor
     dup ".factor" tail? [ parent-directory ] when ;\r
 \r
 : chop-vocab-root ( path -- path' )\r
-    "resource:" prepend-path (normalize-path)\r
+    "resource:" prepend-path normalize-path\r
     dup vocab-roots get\r
-    [ (normalize-path) ] map\r
+    [ normalize-path ] map\r
     [ head? ] with find nip\r
     ?head drop ;\r
 \r
@@ -29,17 +29,17 @@ IN: tools.vocabs.monitor
     reset-cache\r
     monitor-loop ;\r
 \r
-: add-monitor-for-path ( path -- ) \r
-    normalize-path dup exists? [ t my-mailbox (monitor) ] when drop ;\r
-    \r
+: add-monitor-for-path ( path -- )\r
+    dup exists? [ t my-mailbox (monitor) ] when drop ;\r
+\r
 : monitor-thread ( -- )\r
     [\r
         [\r
             vocab-roots get prune [ add-monitor-for-path ] each\r
-            \r
+\r
             H{ } clone changed-vocabs set-global\r
             vocabs [ changed-vocab ] each\r
-            \r
+\r
             monitor-loop\r
         ] with-monitors\r
     ] ignore-errors ;\r
old mode 100644 (file)
new mode 100755 (executable)
index 570125c..5cb6606
@@ -2,85 +2,79 @@ USING: kernel tools.test trees trees.avl math random sequences assocs ;
 IN: trees.avl.tests
 
 [ "key1" 0 "key2" 0 ] [
-    T{ avl-node T{ node f "key1" f f T{ avl-node T{ node f "key2" } 1 } } 2 }
+    T{ avl-node f "key1" f f T{ avl-node f "key2" f f 1 } 2 }
     [ single-rotate ] go-left
     [ node-left dup node-key swap avl-node-balance ] keep
     dup node-key swap avl-node-balance
 ] unit-test
 
 [ "key1" 0 "key2" 0 ] [
-    T{ avl-node T{ node f "key1" f f T{ avl-node T{ node f "key2" } 1 } } 2 }
+    T{ avl-node f "key1" f f T{ avl-node f "key2" f f f 1 } 2 }
     [ select-rotate ] go-left
     [ node-left dup node-key swap avl-node-balance ] keep
     dup node-key swap avl-node-balance
 ] unit-test
 
 [ "key1" 0 "key2" 0 ] [
-    T{ avl-node T{ node f "key1" f T{ avl-node T{ node f "key2" } -1 } } -2 }
+    T{ avl-node f "key1" f T{ avl-node f "key2" f f f -1 } f -2 }
     [ single-rotate ] go-right
     [ node-right dup node-key swap avl-node-balance ] keep
     dup node-key swap avl-node-balance
 ] unit-test
 
 [ "key1" 0 "key2" 0 ] [
-    T{ avl-node T{ node f "key1" f T{ avl-node T{ node f "key2" } -1 } } -2 }
+    T{ avl-node f "key1" f T{ avl-node f "key2" f f f -1 } f -2 }
     [ select-rotate ] go-right
     [ node-right dup node-key swap avl-node-balance ] keep
     dup node-key swap avl-node-balance
 ] unit-test
 
 [ "key1" -1 "key2" 0 "key3" 0 ]
-[ T{ avl-node T{ node f "key1" f f
-        T{ avl-node T{ node f "key2" f
-            T{ avl-node T{ node f "key3" } 1 } }
-        -1 } }
-    2 } [ double-rotate ] go-left
+[ T{ avl-node f "key1" f f
+        T{ avl-node f "key2" f 
+            T{ avl-node f "key3" f f f 1 } f -1 } 2 }
+    [ double-rotate ] go-left
     [ node-left dup node-key swap avl-node-balance ] keep
     [ node-right dup node-key swap avl-node-balance ] keep
     dup node-key swap avl-node-balance ] unit-test
 [ "key1" 0 "key2" 0 "key3" 0 ]
-[ T{ avl-node T{ node f "key1" f f
-        T{ avl-node T{ node f "key2" f
-            T{ avl-node T{ node f "key3" } 0 } }
-        -1 } }
-    2 } [ double-rotate ] go-left
+[ T{ avl-node f "key1" f f
+        T{ avl-node f "key2" f
+            T{ avl-node f "key3" f f f 0 } f -1 } 2 } 
+    [ double-rotate ] go-left
     [ node-left dup node-key swap avl-node-balance ] keep
     [ node-right dup node-key swap avl-node-balance ] keep
     dup node-key swap avl-node-balance ] unit-test
 [ "key1" 0 "key2" 1 "key3" 0 ]
-[ T{ avl-node T{ node f "key1" f f
-        T{ avl-node T{ node f "key2" f
-            T{ avl-node T{ node f "key3" } -1 } }
-        -1 } }
-    2 } [ double-rotate ] go-left
+[ T{ avl-node f "key1" f f
+        T{ avl-node f "key2" f
+            T{ avl-node f "key3" f f f -1 } f -1 } 2 } 
+    [ double-rotate ] go-left
     [ node-left dup node-key swap avl-node-balance ] keep
     [ node-right dup node-key swap avl-node-balance ] keep
     dup node-key swap avl-node-balance ] unit-test
 
 [ "key1" 1 "key2" 0 "key3" 0 ]
-[ T{ avl-node T{ node f "key1" f
-        T{ avl-node T{ node f "key2" f f
-            T{ avl-node T{ node f "key3" } -1 } }
-        1 } }
-    -2 } [ double-rotate ] go-right
+[ T{ avl-node f "key1" f
+        T{ avl-node f "key2" f f
+            T{ avl-node f "key3" f f f -1 } 1 } f -2 }
+    [ double-rotate ] go-right
     [ node-right dup node-key swap avl-node-balance ] keep
     [ node-left dup node-key swap avl-node-balance ] keep
     dup node-key swap avl-node-balance ] unit-test
 [ "key1" 0 "key2" 0 "key3" 0 ]
-[ T{ avl-node T{ node f "key1" f
-        T{ avl-node T{ node f "key2" f f
-            T{ avl-node T{ node f "key3" } 0 } }
-        1 } }
-    -2 } [ double-rotate ] go-right
+[ T{ avl-node f "key1" f
+        T{ avl-node f "key2" f f
+            T{ avl-node f "key3" f f f 0 } 1 } f -2 }
+    [ double-rotate ] go-right
     [ node-right dup node-key swap avl-node-balance ] keep
     [ node-left dup node-key swap avl-node-balance ] keep
     dup node-key swap avl-node-balance ] unit-test
 [ "key1" 0 "key2" -1 "key3" 0 ]
-[ T{ avl-node T{ node f "key1" f
-        T{ avl-node T{ node f "key2" f f
-            T{ avl-node T{ node f "key3" } 1 } }
-        1 } }
-    -2 } [ double-rotate ] go-right
+[ T{ avl-node f "key1" f
+        T{ avl-node f "key2" f f
+            T{ avl-node f "key3" f f f 1 } 1 } f -2 }
+    [ double-rotate ] go-right
     [ node-right dup node-key swap avl-node-balance ] keep
     [ node-left dup node-key swap avl-node-balance ] keep
     dup node-key swap avl-node-balance ] unit-test
index 3a37ec5fc761cfe2ea2bc5b1b13407d00ebfa675..866e035a2134e294ba8ffbf3687cc5f748453254 100755 (executable)
@@ -1,33 +1,34 @@
 ! Copyright (C) 2007 Alex Chapman
 ! See http://factorcode.org/license.txt for BSD license.
-USING: combinators kernel generic math math.functions math.parser
-namespaces io prettyprint.backend sequences trees assocs parser
-math.order ;
+USING: combinators kernel generic math math.functions
+math.parser namespaces io prettyprint.backend sequences trees
+assocs parser accessors math.order ;
 IN: trees.avl
 
-TUPLE: avl ;
-
-INSTANCE: avl tree-mixin
+TUPLE: avl < tree ;
 
 : <avl> ( -- tree )
-    avl construct-tree ;
+    avl new-tree ;
 
-TUPLE: avl-node balance ;
+TUPLE: avl-node < node balance ;
 
 : <avl-node> ( key value -- node )
-    swap <node> 0 avl-node boa tuck set-delegate ;
+    avl-node new-node
+        0 >>balance ;
 
-: change-balance ( node amount -- )
-    over avl-node-balance + swap set-avl-node-balance ;
+: increase-balance ( node amount -- )
+    swap [ + ] change-balance drop ;
 
 : rotate ( node -- node )
-    dup node+link dup node-link pick set-node+link tuck set-node-link ;    
+    dup node+link dup node-link pick set-node+link
+    tuck set-node-link ;    
 
 : single-rotate ( node -- node )
-    0 over set-avl-node-balance 0 over node+link set-avl-node-balance rotate ;
+    0 over (>>balance) 0 over node+link 
+    (>>balance) rotate ;
 
 : pick-balances ( a node -- balance balance )
-    avl-node-balance {
+    balance>> {
         { [ dup zero? ] [ 2drop 0 0 ] }
         { [ over = ] [ neg 0 ] }
         [ 0 swap ]
@@ -36,18 +37,22 @@ TUPLE: avl-node balance ;
 : double-rotate ( node -- node )
     [
         node+link [
-            node-link current-side get neg over pick-balances rot 0 swap set-avl-node-balance
-        ] keep set-avl-node-balance
-    ] keep tuck set-avl-node-balance
-    dup node+link [ rotate ] with-other-side over set-node+link rotate ;
+            node-link current-side get neg
+            over pick-balances rot 0 swap (>>balance)
+        ] keep (>>balance)
+    ] keep swap >>balance
+    dup node+link [ rotate ] with-other-side
+    over set-node+link rotate ;
 
 : select-rotate ( node -- node )
-    dup node+link avl-node-balance current-side get = [ double-rotate ] [ single-rotate ] if ;
+    dup node+link balance>> current-side get =
+    [ double-rotate ] [ single-rotate ] if ;
 
 : balance-insert ( node -- node taller? )
     dup avl-node-balance {
         { [ dup zero? ] [ drop f ] }
-        { [ dup abs 2 = ] [ sgn neg [ select-rotate ] with-side f ] }
+        { [ dup abs 2 = ]
+          [ sgn neg [ select-rotate ] with-side f ] }
         { [ drop t ] [ t ] } ! balance is -1 or 1, tree is taller
     } cond ;
 
@@ -57,7 +62,8 @@ DEFER: avl-set
     2dup node-key before? left right ? [
         [ node-link avl-set ] keep swap
         >r tuck set-node-link r>
-        [ dup current-side get change-balance balance-insert ] [ f ] if
+        [ dup current-side get increase-balance balance-insert ]
+        [ f ] if
     ] with-side ;
 
 : (avl-set) ( value key node -- node taller? )
@@ -66,10 +72,10 @@ DEFER: avl-set
     ] [ avl-insert ] if ;
 
 : avl-set ( value key node -- node taller? )
-    [ (avl-set) ] [ <avl-node> t ] if* ;
+    [ (avl-set) ] [ swap <avl-node> t ] if* ;
 
 M: avl set-at ( value key node -- node )
-    [ avl-set drop ] change-root ;
+    [ avl-set drop ] change-root drop ;
 
 : delete-select-rotate ( node -- node shorter? )
     dup node+link avl-node-balance zero? [
@@ -87,10 +93,10 @@ M: avl set-at ( value key node -- node )
     } cond ;
 
 : balance-delete ( node -- node shorter? )
-    current-side get over avl-node-balance {
+    current-side get over balance>> {
         { [ dup zero? ] [ drop neg over set-avl-node-balance f ] }
-        { [ dupd = ] [ drop 0 over set-avl-node-balance t ] }
-        [ dupd neg change-balance rebalance-delete ]
+        { [ dupd = ] [ drop 0 >>balance t ] }
+        [ dupd neg increase-balance rebalance-delete ]
     } cond ;
 
 : avl-replace-with-extremity ( to-replace node -- node shorter? )
@@ -135,12 +141,12 @@ M: avl-node avl-delete ( key node -- node shorter? deleted? )
     ] if ;
 
 M: avl delete-at ( key node -- )
-    [ avl-delete 2drop ] change-root ;
+    [ avl-delete 2drop ] change-root drop ;
 
 M: avl new-assoc 2drop <avl> ;
 
 : >avl ( assoc -- avl )
-    T{ avl T{ tree f f 0 } } assoc-clone-like ;
+    T{ avl f f 0 } assoc-clone-like ;
 
 M: avl assoc-like
     drop dup avl? [ >avl ] unless ;
old mode 100644 (file)
new mode 100755 (executable)
index 8931db3..ef5fcf8
@@ -4,12 +4,10 @@ USING: arrays kernel math namespaces sequences assocs parser
 prettyprint.backend trees generic math.order ;
 IN: trees.splay
 
-TUPLE: splay ;
+TUPLE: splay < tree ;
 
 : <splay> ( -- tree )
-    \ splay construct-tree ;
-
-INSTANCE: splay tree-mixin
+    \ splay new-tree ;
 
 : rotate-right ( node -- node )
     dup node-left
@@ -131,7 +129,7 @@ M: splay new-assoc
     2drop <splay> ;
 
 : >splay ( assoc -- tree )
-    T{ splay T{ tree f f 0 } } assoc-clone-like ;
+    T{ splay f f 0 } assoc-clone-like ;
 
 : SPLAY{
     \ } [ >splay ] parse-literal ; parsing
index 3cad81e447f30435e5438ceb7f324ee3f0d80488..3b0ab016660f122d300a3105a2780c472c7f2a30 100755 (executable)
@@ -5,23 +5,25 @@ prettyprint.private kernel.private assocs random combinators
 parser prettyprint.backend math.order accessors ;
 IN: trees
 
-MIXIN: tree-mixin
-
 TUPLE: tree root count ;
 
+: new-tree ( class -- tree )
+    new
+        f >>root
+        0 >>count ; inline
+
 : <tree> ( -- tree )
-    f 0 tree boa ;
+    tree new-tree ;
 
-: construct-tree ( class -- tree )
-    new <tree> over set-delegate ; inline
+INSTANCE: tree assoc
 
-INSTANCE: tree tree-mixin
+TUPLE: node key value left right ;
 
-INSTANCE: tree-mixin assoc
+: new-node ( key value class -- node )
+    new swap >>value swap >>key ;
 
-TUPLE: node key value left right ;
 : <node> ( key value -- node )
-    f f node boa ;
+    node new-node ;
 
 SYMBOL: current-side
 
@@ -57,9 +59,6 @@ SYMBOL: current-side
 : go-left ( quot -- ) left swap with-side ; inline
 : go-right ( quot -- ) right swap with-side ; inline
 
-: change-root ( tree quot -- )
-    swap [ root>> swap call ] keep set-tree-root ; inline
-
 : leaf? ( node -- ? )
     [ left>> ] [ right>> ] bi or not ;
 
@@ -91,7 +90,7 @@ M: tree at* ( key tree -- value ? )
     ] if ;
 
 M: tree set-at ( value key tree -- )
-    [ [ node-set ] [ swap <node> ] if* ] change-root ;
+    [ [ node-set ] [ swap <node> ] if* ] change-root drop ;
 
 : valid-node? ( node -- ? )
     [
@@ -117,10 +116,10 @@ M: tree set-at ( value key tree -- )
         [ >r right>> r> find-node ]
     } cond ; inline
 
-M: tree-mixin assoc-find ( tree quot -- key value ? )
+M: tree assoc-find ( tree quot -- key value ? )
     >r root>> r> find-node ;
 
-M: tree-mixin clear-assoc
+M: tree clear-assoc
     0 >>count
     f >>root drop ;
 
@@ -182,7 +181,7 @@ DEFER: delete-node
     ] if ;
 
 M: tree delete-at
-    [ delete-bst-node ] change-root ;
+    [ delete-bst-node ] change-root drop ;
 
 M: tree new-assoc
     2drop <tree> ;
@@ -192,14 +191,12 @@ M: tree clone dup assoc-clone-like ;
 : >tree ( assoc -- tree )
     T{ tree f f 0 } assoc-clone-like ;
 
-M: tree-mixin assoc-like drop dup tree? [ >tree ] unless ;
+M: tree assoc-like drop dup tree? [ >tree ] unless ;
 
 : TREE{
     \ } [ >tree ] parse-literal ; parsing
-
+                                                        
 M: tree pprint-delims drop \ TREE{ \ } ;
-
-M: tree-mixin assoc-size count>> ;
-M: tree-mixin clone dup assoc-clone-like ;
-M: tree-mixin >pprint-sequence >alist ;
-M: tree-mixin pprint-narrow? drop t ;
+M: tree assoc-size count>> ;
+M: tree >pprint-sequence >alist ;
+M: tree pprint-narrow? drop t ;
index 219df5197cfda5fc181ed85d8fbdad5f2b1cc84b..cf439f6407ca8f704db51dcd90f6b918694e3330 100755 (executable)
@@ -7,7 +7,7 @@ IN: tuple-syntax
 
 : parse-slot-writer ( tuple -- slot# )
     scan dup "}" = [ 2drop f ] [
-        1 head* swap object-slots slot-named slot-spec-offset
+        but-last swap object-slots slot-named slot-spec-offset
     ] if ;
 
 : parse-slots ( accum tuple -- accum tuple )
index dbe06ec8cdeba061241e404dfd876880e6f94b74..f88b2076038c3b50e11dad47957a7bd57718b8e6 100755 (executable)
@@ -124,7 +124,7 @@ M: mock-gadget ungraft*
     dup mock-gadget-ungraft-called 1+
     swap set-mock-gadget-ungraft-called ;
 
-! We can't print to stdio here because that might be a pane
+! We can't print to output-stream here because that might be a pane
 ! stream, and our graft-queue rebinding here would be captured
 ! by code adding children to the pane...
 [
index a684153b983cd14c63ddb6b23c0c88827f719bb1..99f8b2e82ac1cabcee12f082852d19e164c10177 100755 (executable)
@@ -23,7 +23,7 @@ HELP: print-gadget
 
 HELP: gadget.
 { $values { "gadget" gadget } }
-{ $description "Writes a gadget followed by a newline to the " { $link stdio } " stream." }
+{ $description "Writes a gadget followed by a newline to " { $link output-stream } "." }
 { $notes "Not all streams support this operation." } ;
 
 HELP: ?nl
@@ -32,11 +32,11 @@ HELP: ?nl
 
 HELP: with-pane
 { $values { "pane" pane } { "quot" quotation } }
-{ $description "Clears the pane and calls the quotation in a new scope where " { $link stdio } " is rebound to a " { $link pane-stream } " writing to the pane." } ;
+{ $description "Clears the pane and calls the quotation in a new scope where " { $link output-stream } " is rebound to a " { $link pane-stream } " writing to the pane." } ;
 
 HELP: make-pane
 { $values { "quot" quotation } { "gadget" "a new " { $link gadget } } }
-{ $description "Calls the quotation in a new scope where " { $link stdio } " is rebound to a " { $link pane-stream } " writing to a new pane. The output area of the new pane is output on the stack after the quotation returns. The pane itself is not output." } ;
+{ $description "Calls the quotation in a new scope where " { $link output-stream } " is rebound to a " { $link pane-stream } " writing to a new pane. The output area of the new pane is output on the stack after the quotation returns. The pane itself is not output." } ;
 
 HELP: <scrolling-pane>
 { $values { "pane" "a new " { $link pane } } }
index 0263b15d71c1a2d4f0f4a1ef1358e99917d13928..31bb4233bf6e68b40ebec30f2db1ecd6b183c36b 100755 (executable)
@@ -11,7 +11,7 @@ help.stylesheet splitting tools.test.ui models math inspector ;
 [ ] [ #children "num-children" set ] unit-test
 
 [ ] [
-    "pane" get <pane-stream> [ 10000 [ . ] each ] with-stream*
+    "pane" get <pane-stream> [ 10000 [ . ] each ] with-output-stream*
 ] unit-test
 
 [ t ] [ #children "num-children" get = ] unit-test
index bff0ca10adb6ef8a63fe4fa879338371f78021a2..533a6c42b7a436626e1d6a5501b16ba717fe5454 100755 (executable)
@@ -6,7 +6,7 @@ ui.gadgets.paragraphs ui.gadgets.incremental ui.gadgets.packs
 ui.gadgets.theme ui.clipboards ui.gestures ui.traverse ui.render
 hashtables io kernel namespaces sequences io.styles strings
 quotations math opengl combinators math.vectors
-io.streams.duplex sorting splitting io.streams.nested assocs
+sorting splitting io.streams.nested assocs
 ui.gadgets.presentations ui.gadgets.slots ui.gadgets.grids
 ui.gadgets.grid-lines classes.tuple models continuations ;
 IN: ui.gadgets.panes
@@ -113,14 +113,11 @@ GENERIC: write-gadget ( gadget stream -- )
 M: pane-stream write-gadget
     pane-stream-pane pane-current add-gadget ;
 
-M: duplex-stream write-gadget
-    duplex-stream-out write-gadget ;
-
 : print-gadget ( gadget stream -- )
     tuck write-gadget stream-nl ;
 
 : gadget. ( gadget -- )
-    stdio get print-gadget ;
+    output-stream get print-gadget ;
 
 : ?nl ( stream -- )
     dup pane-stream-pane pane-current gadget-children empty?
@@ -129,7 +126,7 @@ M: duplex-stream write-gadget
 : with-pane ( pane quot -- )
     over scroll>top
     over pane-clear >r <pane-stream> r>
-    over >r with-stream* r> ?nl ; inline
+    over >r with-output-stream* r> ?nl ; inline
 
 : make-pane ( quot -- gadget )
     <pane> [ swap with-pane ] keep smash-pane ; inline
index 0970bd6027720fa0537e41390371274724c2d8d2..5bba0952536bcd85b487197ebd30a91a94032dc3 100755 (executable)
@@ -54,7 +54,7 @@ TUPLE: zoom-in-action ;  C: <zoom-in-action> zoom-in-action
 TUPLE: zoom-out-action ; C: <zoom-out-action> zoom-out-action
 
 : generalize-gesture ( gesture -- newgesture )
-    tuple>array 1 head* >tuple ;
+    tuple>array but-last >tuple ;
 
 ! Modifiers
 SYMBOLS: C+ A+ M+ S+ ;
@@ -111,7 +111,8 @@ SYMBOL: double-click-timeout
     ] if ;
 
 : drag-gesture ( -- )
-    hand-buttons get-global first <drag> button-gesture ;
+    hand-buttons get-global
+    dup empty? [ drop ] [ first <drag> button-gesture ] if ;
 
 SYMBOL: drag-timer
 
index 99c005451db6f2614fd19e11cb864ddefa73a197..f8d5e33df98aa9925b3a5ec522f594e7c69d7132 100755 (executable)
@@ -1,18 +1,21 @@
 IN: ui.tools.interactor.tests
 USING: ui.tools.interactor ui.gadgets.panes namespaces
 ui.gadgets.editors concurrency.promises threads listener
-tools.test kernel calendar parser ;
+tools.test kernel calendar parser accessors ;
 
-[
-    \ <interactor> must-infer
+\ <interactor> must-infer
 
+[
     [ ] [ <pane> <pane-stream> <interactor> "interactor" set ] unit-test
 
+    [ ] [ "interactor" get register-self ] unit-test
+
     [ ] [ "[ 1 2 3" "interactor" get set-editor-string ] unit-test
 
     [ ] [ <promise> "promise" set ] unit-test
 
     [
+        self "interactor" get (>>thread)
         "interactor" get stream-read-quot "promise" get fulfill
     ] "Interactor test" spawn drop
 
@@ -27,3 +30,14 @@ tools.test kernel calendar parser ;
 
     [ [ [ 1 2 3 ] ] ] [ "promise" get 5 seconds ?promise-timeout ] unit-test
 ] with-interactive-vocabs
+
+! Hang
+[ ] [ <pane> <pane-stream> <interactor> "interactor" set ] unit-test
+
+[ ] [ [ "interactor" get stream-read-quot drop ] "A" spawn drop ] unit-test
+
+[ ] [ [ "interactor" get stream-read-quot drop ] "B" spawn drop ] unit-test
+
+[ ] [ 1000 sleep ] unit-test
+
+[ ] [ "interactor" get interactor-eof ] unit-test
index 6c8b77d1f2449a4e88bbfe25ac3c3bb11360c45c..2e59363531f5b9ce42014fdb407660400097dd23 100755 (executable)
@@ -1,53 +1,55 @@
 ! Copyright (C) 2006, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays assocs combinators continuations documents
- hashtables io io.styles kernel math
-math.vectors models namespaces parser prettyprint quotations
-sequences strings threads listener
-classes.tuple ui.commands ui.gadgets ui.gadgets.editors
-ui.gadgets.presentations ui.gadgets.worlds ui.gestures
-definitions boxes calendar concurrency.flags ui.tools.workspace
-accessors math.order ;
+hashtables io io.styles kernel math math.order math.vectors
+models namespaces parser prettyprint quotations sequences
+strings threads listener classes.tuple ui.commands ui.gadgets
+ui.gadgets.editors ui.gadgets.presentations ui.gadgets.worlds
+ui.gestures definitions calendar concurrency.flags
+concurrency.mailboxes ui.tools.workspace accessors ;
 IN: ui.tools.interactor
 
-TUPLE: interactor history output flag thread help ;
+! If waiting is t, we're waiting for user input, and invoking
+! evaluate-input resumes the thread.
+TUPLE: interactor output history flag mailbox thread waiting help ;
+
+: register-self ( interactor -- )
+    <mailbox> >>mailbox
+    self >>thread
+    drop ;
 
 : interactor-continuation ( interactor -- continuation )
-    interactor-thread box-value
-    thread-continuation box-value ;
+    thread>> continuation>> value>> ;
 
 : interactor-busy? ( interactor -- ? )
-    interactor-thread box-full? not ;
+    #! We're busy if there's no thread to resume.
+    [ waiting>> ]
+    [ thread>> dup [ thread-registered? ] when ]
+    bi and not ;
 
 : interactor-use ( interactor -- seq )
     dup interactor-busy? [ drop f ] [
         use swap
-        interactor-continuation continuation-name
+        interactor-continuation name>>
         assoc-stack
     ] if ;
 
-: init-caret-help ( interactor -- )
-    dup editor-caret 1/3 seconds <delay>
-    swap set-interactor-help ;
-
-: init-interactor-history ( interactor -- )
-    V{ } clone swap set-interactor-history ;
-
-: init-interactor-state ( interactor -- )
-    <flag> over set-interactor-flag
-    <box> swap set-interactor-thread ;
+: <help-model> ( interactor -- model )
+    editor-caret 1/3 seconds <delay> ;
 
 : <interactor> ( output -- gadget )
     <source-editor>
     interactor construct-editor
-    tuck set-interactor-output
-    dup init-interactor-history
-    dup init-interactor-state
-    dup init-caret-help ;
+        V{ } clone >>history
+        <flag> >>flag
+        dup <help-model> >>help
+        swap >>output ;
 
 M: interactor graft*
-    dup delegate graft*
-    dup interactor-help add-connection ;
+    [ delegate graft* ] [ dup help>> add-connection ] bi ;
+
+M: interactor ungraft*
+    [ dup help>> remove-connection ] [ delegate ungraft ] bi ;
 
 : word-at-loc ( loc interactor -- word )
     over [
@@ -58,7 +60,7 @@ M: interactor graft*
     ] if ;
 
 M: interactor model-changed
-    2dup interactor-help eq? [
+    2dup help>> eq? [
         swap model-value over word-at-loc swap show-summary
     ] [
         delegate model-changed
@@ -69,15 +71,15 @@ M: interactor model-changed
     [ H{ { font-style bold } } format ] with-nesting ;
 
 : interactor-input. ( string interactor -- )
-    interactor-output [
+    output>> [
         dup string? [ dup write-input nl ] [ short. ] if
-    ] with-stream* ;
+    ] with-output-stream* ;
 
 : add-interactor-history ( str interactor -- )
     over empty? [ 2drop ] [ interactor-history push-new ] if ;
 
 : interactor-continue ( obj interactor -- )
-    interactor-thread box> resume-with ;
+    mailbox>> mailbox-put ;
 
 : clear-input ( interactor -- ) gadget-model clear-doc ;
 
@@ -99,13 +101,17 @@ M: interactor model-changed
     ] unless drop ;
 
 : interactor-yield ( interactor -- obj )
-    [
-        [ interactor-thread >box ] keep
-        interactor-flag raise-flag
-    ] curry "input" suspend ;
+    dup thread>> self eq? [
+        {
+            [ t >>waiting drop ]
+            [ flag>> raise-flag ]
+            [ mailbox>> mailbox-get ]
+            [ f >>waiting drop ]
+        } cleave
+    ] [ drop f ] if ;
 
 M: interactor stream-readln
-    [ interactor-yield ] keep interactor-finish
+    [ interactor-yield ] [ interactor-finish ] bi
     dup [ first ] when ;
 
 : interactor-call ( quot interactor -- )
@@ -161,7 +167,8 @@ M: interactor stream-read-quot
     } cond ;
 
 M: interactor pref-dim*
-    0 over line-height 4 * 2array swap delegate pref-dim* vmax ;
+    [ line-height 4 * 0 swap 2array ] [ delegate pref-dim* ] bi
+    vmax ;
 
 interactor "interactor" f {
     { T{ key-down f f "RET" } evaluate-input }
index cc218533d818996eda0eb82f75749d0e152f24bd..2fae62a8fce98bada9179e1fe92879adce0d3f2a 100755 (executable)
@@ -2,7 +2,7 @@ USING: continuations documents ui.tools.interactor
 ui.tools.listener hashtables kernel namespaces parser sequences
 tools.test ui.commands ui.gadgets ui.gadgets.editors
 ui.gadgets.panes vocabs words tools.test.ui slots.private
-threads arrays generic ;
+threads arrays generic threads accessors listener ;
 IN: ui.tools.listener.tests
 
 [ f ] [ "word" source-editor command-map empty? ] unit-test
@@ -15,7 +15,7 @@ IN: ui.tools.listener.tests
     [ "dup" ] [
         \ dup word-completion-string
     ] unit-test
-
+  
     [ "equal?" ]
     [ \ array \ equal? method word-completion-string ] unit-test
 
@@ -28,9 +28,26 @@ IN: ui.tools.listener.tests
     [ ] [
         "i" get [ { "SYMBOL:" } parse-lines ] [ go-to-error ] recover
     ] unit-test
-
+    
     [ t ] [
         "i" get gadget-model doc-end
         "i" get editor-caret* =
     ] unit-test
+
+    ! Race condition discovered by SimonRC
+    [ ] [
+        [
+            "listener" get input>>
+            [ stream-read-quot drop ]
+            [ stream-read-quot drop ] bi
+        ] "OH, HAI" spawn drop
+    ] unit-test
+
+    [ ] [ "listener" get clear-output ] unit-test
+
+    [ ] [ "listener" get restart-listener ] unit-test
+
+    [ ] [ 1000 sleep ] unit-test
+
+    [ ] [ "listener" get com-end ] unit-test
 ] with-grafted-gadget
index d96270075f165c6f8be82f6bef1e37f3d85654f7..48800c0918c6dbce72974e9f9fffcbc254ec4dbb 100755 (executable)
@@ -1,13 +1,13 @@
 ! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: inspector ui.tools.interactor ui.tools.inspector
-ui.tools.workspace help.markup io io.streams.duplex io.styles
+ui.tools.workspace help.markup io io.styles
 kernel models namespaces parser quotations sequences ui.commands
 ui.gadgets ui.gadgets.editors ui.gadgets.labelled
 ui.gadgets.panes ui.gadgets.buttons ui.gadgets.scrollers
 ui.gadgets.tracks ui.gestures ui.operations vocabs words
 prettyprint listener debugger threads boxes concurrency.flags
-math arrays generic accessors combinators ;
+math arrays generic accessors combinators assocs ;
 IN: ui.tools.listener
 
 TUPLE: listener-gadget input output stack ;
@@ -16,13 +16,11 @@ TUPLE: listener-gadget input output stack ;
     <scrolling-pane> g-> set-listener-gadget-output
     <scroller> "Output" <labelled-gadget> 1 track, ;
 
-: listener-stream ( listener -- stream )
-    dup listener-gadget-input
-    swap listener-gadget-output <pane-stream>
-    <duplex-stream> ;
+: listener-streams ( listener -- input output )
+    [ input>> ] [ output>> <pane-stream> ] bi ;
 
 : <listener-input> ( listener -- gadget )
-    listener-gadget-output <pane-stream> <interactor> ;
+    output>> <pane-stream> <interactor> ;
 
 : listener-input, ( -- )
     g <listener-input> g-> set-listener-gadget-input
@@ -34,31 +32,29 @@ TUPLE: listener-gadget input output stack ;
    "cookbook" ($link) "." print nl ;
 
 M: listener-gadget focusable-child*
-    listener-gadget-input ;
+    input>> ;
 
 M: listener-gadget call-tool* ( input listener -- )
-    >r input-string r> listener-gadget-input set-editor-string ;
+    >r string>> r> input>> set-editor-string ;
 
 M: listener-gadget tool-scroller
-    listener-gadget-output find-scroller ;
+    output>> find-scroller ;
 
 : wait-for-listener ( listener -- )
     #! Wait for the listener to start.
-    listener-gadget-input interactor-flag wait-for-flag ;
+    input>> flag>> wait-for-flag ;
 
 : workspace-busy? ( workspace -- ? )
-    workspace-listener listener-gadget-input interactor-busy? ;
+    listener>> input>> interactor-busy? ;
 
 : listener-input ( string -- )
-    get-workspace
-    workspace-listener
-    listener-gadget-input set-editor-string ;
+    get-workspace listener>> input>> set-editor-string ;
 
 : (call-listener) ( quot listener -- )
-    listener-gadget-input interactor-call ;
+    input>> interactor-call ;
 
 : call-listener ( quot -- )
-    [ workspace-busy? not ] get-workspace* workspace-listener
+    [ workspace-busy? not ] get-workspace* listener>>
     [ dup wait-for-listener (call-listener) ] 2curry
     "Listener call" spawn drop ;
 
@@ -70,8 +66,7 @@ M: listener-operation invoke-command ( target command -- )
 
 : eval-listener ( string -- )
     get-workspace
-    workspace-listener
-    listener-gadget-input [ set-editor-string ] keep
+    listener>> input>> [ set-editor-string ] keep
     evaluate-input ;
 
 : listener-run-files ( seq -- )
@@ -82,10 +77,10 @@ M: listener-operation invoke-command ( target command -- )
     ] if ;
 
 : com-end ( listener -- )
-    listener-gadget-input interactor-eof ;
+    input>> interactor-eof ;
 
 : clear-output ( listener -- )
-    listener-gadget-output pane-clear ;
+    output>> pane-clear ;
 
 \ clear-output H{ { +listener+ t } } define-command
 
@@ -106,12 +101,11 @@ M: engine-word word-completion-string
     "engine-generic" word-prop word-completion-string ;
 
 : use-if-necessary ( word seq -- )
-    >r word-vocabulary vocab-words r>
-    {
-        { [ dup not ] [ 2drop ] }
-        { [ 2dup memq? ] [ 2drop ] }
-        [ push ]
-    } cond ;
+    over word-vocabulary [
+        2dup assoc-stack pick = [ 2drop ] [
+            >r word-vocabulary vocab-words r> push
+        ] if
+    ] [ 2drop ] if ;
 
 : insert-word ( word -- )
     get-workspace workspace-listener input>>
@@ -130,7 +124,7 @@ TUPLE: stack-display ;
     stack-display new
     g workspace-listener swap [
         dup <toolbar> f track,
-        listener-gadget-stack [ stack. ]
+        stack>> [ [ stack. ] curry try ]
         t "Data stack" <labelled-pane> 1 track,
     ] { 0 1 } build-track ;
 
@@ -148,22 +142,27 @@ M: stack-display tool-scroller
     swap show-tool inspect-object ;
 
 : listener-thread ( listener -- )
-    dup listener-stream [
-        dup [ ui-listener-hook ] curry listener-hook set
-        dup [ ui-error-hook ] curry error-hook set
-        [ ui-inspector-hook ] curry inspector-hook set
+    dup listener-streams [
+        [ [ ui-listener-hook ] curry listener-hook set ]
+        [ [ ui-error-hook ] curry error-hook set ]
+        [ [ ui-inspector-hook ] curry inspector-hook set ] tri
         welcome.
         listener
-    ] with-stream* ;
+    ] with-streams* ;
 
 : start-listener-thread ( listener -- )
-    [ listener-thread ] curry "Listener" spawn drop ;
+    [
+        [ input>> register-self ] [ listener-thread ] bi
+    ] curry "Listener" spawn drop ;
 
 : restart-listener ( listener -- )
     #! Returns when listener is ready to receive input.
-    dup com-end dup clear-output
-    dup start-listener-thread
-    wait-for-listener ;
+    {
+        [ com-end ]
+        [ clear-output ]
+        [ start-listener-thread ]
+        [ wait-for-listener ]
+    } cleave ;
 
 : init-listener ( listener -- )
     f <model> swap set-listener-gadget-stack ;
@@ -189,10 +188,7 @@ M: listener-gadget handle-gesture* ( gadget gesture delegate -- ? )
     [ default-gesture-handler ] [ 3drop f ] if ;
 
 M: listener-gadget graft*
-    dup delegate graft*
-    dup listener-gadget-input interactor-thread ?box 2drop
-    restart-listener ;
+    [ delegate graft* ] [ restart-listener ] bi ;
 
 M: listener-gadget ungraft*
-    dup com-end
-    delegate ungraft* ;
+    [ com-end ] [ delegate ungraft* ] bi ;
index d8e4f8c24ea2e968132a628abcf9cf7920dc078d..9635a62e49b45351b359b262693f5cd004700178 100644 (file)
@@ -30,7 +30,7 @@ CATEGORY: grapheme-control Zl Zp Cc Cf ;
     concat [ dup ] H{ } map>assoc ;
 
 : other-extend-lines ( -- lines )
-    "extra/unicode/PropList.txt" resource-path ascii file-lines ;
+    "resource:extra/unicode/PropList.txt" ascii file-lines ;
 
 VALUE: other-extend
 
@@ -105,9 +105,6 @@ VALUE: grapheme-table
 : string-reverse ( str -- rts )
     >graphemes reverse concat ;
 
-: unclip-last-slice ( seq -- beginning last )
-    dup 1 head-slice* swap peek ;
-
 : last-grapheme ( str -- i )
     unclip-last-slice grapheme-class swap
     [ grapheme-class dup rot grapheme-break? ] find-last-index ?1+ nip ;
index 85ce50acb9585c7c82d950d8d58a911f1e296027..f33338137a89a34653e14772e0def70eaf1841c3 100755 (executable)
@@ -14,7 +14,7 @@ IN: unicode.data
     ascii file-lines [ ";" split ] map ;
 
 : load-data ( -- data )
-    "extra/unicode/UnicodeData.txt" resource-path data ;
+    "resource:extra/unicode/UnicodeData.txt" data ;
 
 : (process-data) ( index data -- newdata )
     [ [ nth ] keep first swap 2array ] with map
@@ -120,7 +120,7 @@ VALUE: special-casing
 
 ! Special casing data
 : load-special-casing ( -- special-casing )
-    "extra/unicode/SpecialCasing.txt" resource-path data
+    "resource:extra/unicode/SpecialCasing.txt" data
     [ length 5 = ] filter
     [ [ set-code-point ] each ] H{ } make-assoc ;
 
diff --git a/extra/unicode/script/Scripts.txt b/extra/unicode/script/Scripts.txt
new file mode 100755 (executable)
index 0000000..7065486
--- /dev/null
@@ -0,0 +1,1747 @@
+# Scripts-5.1.0.txt
+# Date: 2008-03-20, 17:55:33 GMT [MD]
+#
+# Unicode Character Database
+# Copyright (c) 1991-2008 Unicode, Inc.
+# For terms of use, see http://www.unicode.org/terms_of_use.html
+# For documentation, see UCD.html
+
+# ================================================
+
+# Property:    Script
+
+#  All code points not explicitly listed for Script
+#  have the value Unknown (Zzzz).
+
+# @missing: 0000..10FFFF; Unknown
+
+# ================================================
+
+0000..001F    ; Common # Cc  [32] <control-0000>..<control-001F>
+0020          ; Common # Zs       SPACE
+0021..0023    ; Common # Po   [3] EXCLAMATION MARK..NUMBER SIGN
+0024          ; Common # Sc       DOLLAR SIGN
+0025..0027    ; Common # Po   [3] PERCENT SIGN..APOSTROPHE
+0028          ; Common # Ps       LEFT PARENTHESIS
+0029          ; Common # Pe       RIGHT PARENTHESIS
+002A          ; Common # Po       ASTERISK
+002B          ; Common # Sm       PLUS SIGN
+002C          ; Common # Po       COMMA
+002D          ; Common # Pd       HYPHEN-MINUS
+002E..002F    ; Common # Po   [2] FULL STOP..SOLIDUS
+0030..0039    ; Common # Nd  [10] DIGIT ZERO..DIGIT NINE
+003A..003B    ; Common # Po   [2] COLON..SEMICOLON
+003C..003E    ; Common # Sm   [3] LESS-THAN SIGN..GREATER-THAN SIGN
+003F..0040    ; Common # Po   [2] QUESTION MARK..COMMERCIAL AT
+005B          ; Common # Ps       LEFT SQUARE BRACKET
+005C          ; Common # Po       REVERSE SOLIDUS
+005D          ; Common # Pe       RIGHT SQUARE BRACKET
+005E          ; Common # Sk       CIRCUMFLEX ACCENT
+005F          ; Common # Pc       LOW LINE
+0060          ; Common # Sk       GRAVE ACCENT
+007B          ; Common # Ps       LEFT CURLY BRACKET
+007C          ; Common # Sm       VERTICAL LINE
+007D          ; Common # Pe       RIGHT CURLY BRACKET
+007E          ; Common # Sm       TILDE
+007F..009F    ; Common # Cc  [33] <control-007F>..<control-009F>
+00A0          ; Common # Zs       NO-BREAK SPACE
+00A1          ; Common # Po       INVERTED EXCLAMATION MARK
+00A2..00A5    ; Common # Sc   [4] CENT SIGN..YEN SIGN
+00A6..00A7    ; Common # So   [2] BROKEN BAR..SECTION SIGN
+00A8          ; Common # Sk       DIAERESIS
+00A9          ; Common # So       COPYRIGHT SIGN
+00AB          ; Common # Pi       LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+00AC          ; Common # Sm       NOT SIGN
+00AD          ; Common # Cf       SOFT HYPHEN
+00AE          ; Common # So       REGISTERED SIGN
+00AF          ; Common # Sk       MACRON
+00B0          ; Common # So       DEGREE SIGN
+00B1          ; Common # Sm       PLUS-MINUS SIGN
+00B2..00B3    ; Common # No   [2] SUPERSCRIPT TWO..SUPERSCRIPT THREE
+00B4          ; Common # Sk       ACUTE ACCENT
+00B5          ; Common # L&       MICRO SIGN
+00B6          ; Common # So       PILCROW SIGN
+00B7          ; Common # Po       MIDDLE DOT
+00B8          ; Common # Sk       CEDILLA
+00B9          ; Common # No       SUPERSCRIPT ONE
+00BB          ; Common # Pf       RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+00BC..00BE    ; Common # No   [3] VULGAR FRACTION ONE QUARTER..VULGAR FRACTION THREE QUARTERS
+00BF          ; Common # Po       INVERTED QUESTION MARK
+00D7          ; Common # Sm       MULTIPLICATION SIGN
+00F7          ; Common # Sm       DIVISION SIGN
+02B9..02C1    ; Common # Lm   [9] MODIFIER LETTER PRIME..MODIFIER LETTER REVERSED GLOTTAL STOP
+02C2..02C5    ; Common # Sk   [4] MODIFIER LETTER LEFT ARROWHEAD..MODIFIER LETTER DOWN ARROWHEAD
+02C6..02D1    ; Common # Lm  [12] MODIFIER LETTER CIRCUMFLEX ACCENT..MODIFIER LETTER HALF TRIANGULAR COLON
+02D2..02DF    ; Common # Sk  [14] MODIFIER LETTER CENTRED RIGHT HALF RING..MODIFIER LETTER CROSS ACCENT
+02E5..02EB    ; Common # Sk   [7] MODIFIER LETTER EXTRA-HIGH TONE BAR..MODIFIER LETTER YANG DEPARTING TONE MARK
+02EC          ; Common # Lm       MODIFIER LETTER VOICING
+02ED          ; Common # Sk       MODIFIER LETTER UNASPIRATED
+02EE          ; Common # Lm       MODIFIER LETTER DOUBLE APOSTROPHE
+02EF..02FF    ; Common # Sk  [17] MODIFIER LETTER LOW DOWN ARROWHEAD..MODIFIER LETTER LOW LEFT ARROW
+0374          ; Common # Lm       GREEK NUMERAL SIGN
+037E          ; Common # Po       GREEK QUESTION MARK
+0385          ; Common # Sk       GREEK DIALYTIKA TONOS
+0387          ; Common # Po       GREEK ANO TELEIA
+0589          ; Common # Po       ARMENIAN FULL STOP
+0600..0603    ; Common # Cf   [4] ARABIC NUMBER SIGN..ARABIC SIGN SAFHA
+060C          ; Common # Po       ARABIC COMMA
+061B          ; Common # Po       ARABIC SEMICOLON
+061F          ; Common # Po       ARABIC QUESTION MARK
+0640          ; Common # Lm       ARABIC TATWEEL
+0660..0669    ; Common # Nd  [10] ARABIC-INDIC DIGIT ZERO..ARABIC-INDIC DIGIT NINE
+06DD          ; Common # Cf       ARABIC END OF AYAH
+0964..0965    ; Common # Po   [2] DEVANAGARI DANDA..DEVANAGARI DOUBLE DANDA
+0970          ; Common # Po       DEVANAGARI ABBREVIATION SIGN
+0CF1..0CF2    ; Common # So   [2] KANNADA SIGN JIHVAMULIYA..KANNADA SIGN UPADHMANIYA
+0E3F          ; Common # Sc       THAI CURRENCY SYMBOL BAHT
+10FB          ; Common # Po       GEORGIAN PARAGRAPH SEPARATOR
+16EB..16ED    ; Common # Po   [3] RUNIC SINGLE PUNCTUATION..RUNIC CROSS PUNCTUATION
+1735..1736    ; Common # Po   [2] PHILIPPINE SINGLE PUNCTUATION..PHILIPPINE DOUBLE PUNCTUATION
+1802..1803    ; Common # Po   [2] MONGOLIAN COMMA..MONGOLIAN FULL STOP
+1805          ; Common # Po       MONGOLIAN FOUR DOTS
+2000..200A    ; Common # Zs  [11] EN QUAD..HAIR SPACE
+200B          ; Common # Cf       ZERO WIDTH SPACE
+200E..200F    ; Common # Cf   [2] LEFT-TO-RIGHT MARK..RIGHT-TO-LEFT MARK
+2010..2015    ; Common # Pd   [6] HYPHEN..HORIZONTAL BAR
+2016..2017    ; Common # Po   [2] DOUBLE VERTICAL LINE..DOUBLE LOW LINE
+2018          ; Common # Pi       LEFT SINGLE QUOTATION MARK
+2019          ; Common # Pf       RIGHT SINGLE QUOTATION MARK
+201A          ; Common # Ps       SINGLE LOW-9 QUOTATION MARK
+201B..201C    ; Common # Pi   [2] SINGLE HIGH-REVERSED-9 QUOTATION MARK..LEFT DOUBLE QUOTATION MARK
+201D          ; Common # Pf       RIGHT DOUBLE QUOTATION MARK
+201E          ; Common # Ps       DOUBLE LOW-9 QUOTATION MARK
+201F          ; Common # Pi       DOUBLE HIGH-REVERSED-9 QUOTATION MARK
+2020..2027    ; Common # Po   [8] DAGGER..HYPHENATION POINT
+2028          ; Common # Zl       LINE SEPARATOR
+2029          ; Common # Zp       PARAGRAPH SEPARATOR
+202A..202E    ; Common # Cf   [5] LEFT-TO-RIGHT EMBEDDING..RIGHT-TO-LEFT OVERRIDE
+202F          ; Common # Zs       NARROW NO-BREAK SPACE
+2030..2038    ; Common # Po   [9] PER MILLE SIGN..CARET
+2039          ; Common # Pi       SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+203A          ; Common # Pf       SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+203B..203E    ; Common # Po   [4] REFERENCE MARK..OVERLINE
+203F..2040    ; Common # Pc   [2] UNDERTIE..CHARACTER TIE
+2041..2043    ; Common # Po   [3] CARET INSERTION POINT..HYPHEN BULLET
+2044          ; Common # Sm       FRACTION SLASH
+2045          ; Common # Ps       LEFT SQUARE BRACKET WITH QUILL
+2046          ; Common # Pe       RIGHT SQUARE BRACKET WITH QUILL
+2047..2051    ; Common # Po  [11] DOUBLE QUESTION MARK..TWO ASTERISKS ALIGNED VERTICALLY
+2052          ; Common # Sm       COMMERCIAL MINUS SIGN
+2053          ; Common # Po       SWUNG DASH
+2054          ; Common # Pc       INVERTED UNDERTIE
+2055..205E    ; Common # Po  [10] FLOWER PUNCTUATION MARK..VERTICAL FOUR DOTS
+205F          ; Common # Zs       MEDIUM MATHEMATICAL SPACE
+2060..2064    ; Common # Cf   [5] WORD JOINER..INVISIBLE PLUS
+206A..206F    ; Common # Cf   [6] INHIBIT SYMMETRIC SWAPPING..NOMINAL DIGIT SHAPES
+2070          ; Common # No       SUPERSCRIPT ZERO
+2074..2079    ; Common # No   [6] SUPERSCRIPT FOUR..SUPERSCRIPT NINE
+207A..207C    ; Common # Sm   [3] SUPERSCRIPT PLUS SIGN..SUPERSCRIPT EQUALS SIGN
+207D          ; Common # Ps       SUPERSCRIPT LEFT PARENTHESIS
+207E          ; Common # Pe       SUPERSCRIPT RIGHT PARENTHESIS
+2080..2089    ; Common # No  [10] SUBSCRIPT ZERO..SUBSCRIPT NINE
+208A..208C    ; Common # Sm   [3] SUBSCRIPT PLUS SIGN..SUBSCRIPT EQUALS SIGN
+208D          ; Common # Ps       SUBSCRIPT LEFT PARENTHESIS
+208E          ; Common # Pe       SUBSCRIPT RIGHT PARENTHESIS
+20A0..20B5    ; Common # Sc  [22] EURO-CURRENCY SIGN..CEDI SIGN
+2100..2101    ; Common # So   [2] ACCOUNT OF..ADDRESSED TO THE SUBJECT
+2102          ; Common # L&       DOUBLE-STRUCK CAPITAL C
+2103..2106    ; Common # So   [4] DEGREE CELSIUS..CADA UNA
+2107          ; Common # L&       EULER CONSTANT
+2108..2109    ; Common # So   [2] SCRUPLE..DEGREE FAHRENHEIT
+210A..2113    ; Common # L&  [10] SCRIPT SMALL G..SCRIPT SMALL L
+2114          ; Common # So       L B BAR SYMBOL
+2115          ; Common # L&       DOUBLE-STRUCK CAPITAL N
+2116..2118    ; Common # So   [3] NUMERO SIGN..SCRIPT CAPITAL P
+2119..211D    ; Common # L&   [5] DOUBLE-STRUCK CAPITAL P..DOUBLE-STRUCK CAPITAL R
+211E..2123    ; Common # So   [6] PRESCRIPTION TAKE..VERSICLE
+2124          ; Common # L&       DOUBLE-STRUCK CAPITAL Z
+2125          ; Common # So       OUNCE SIGN
+2127          ; Common # So       INVERTED OHM SIGN
+2128          ; Common # L&       BLACK-LETTER CAPITAL Z
+2129          ; Common # So       TURNED GREEK SMALL LETTER IOTA
+212C..212D    ; Common # L&   [2] SCRIPT CAPITAL B..BLACK-LETTER CAPITAL C
+212E          ; Common # So       ESTIMATED SYMBOL
+212F..2131    ; Common # L&   [3] SCRIPT SMALL E..SCRIPT CAPITAL F
+2133..2134    ; Common # L&   [2] SCRIPT CAPITAL M..SCRIPT SMALL O
+2135..2138    ; Common # Lo   [4] ALEF SYMBOL..DALET SYMBOL
+2139          ; Common # L&       INFORMATION SOURCE
+213A..213B    ; Common # So   [2] ROTATED CAPITAL Q..FACSIMILE SIGN
+213C..213F    ; Common # L&   [4] DOUBLE-STRUCK SMALL PI..DOUBLE-STRUCK CAPITAL PI
+2140..2144    ; Common # Sm   [5] DOUBLE-STRUCK N-ARY SUMMATION..TURNED SANS-SERIF CAPITAL Y
+2145..2149    ; Common # L&   [5] DOUBLE-STRUCK ITALIC CAPITAL D..DOUBLE-STRUCK ITALIC SMALL J
+214A          ; Common # So       PROPERTY LINE
+214B          ; Common # Sm       TURNED AMPERSAND
+214C..214D    ; Common # So   [2] PER SIGN..AKTIESELSKAB
+214F          ; Common # So       SYMBOL FOR SAMARITAN SOURCE
+2153..215F    ; Common # No  [13] VULGAR FRACTION ONE THIRD..FRACTION NUMERATOR ONE
+2190..2194    ; Common # Sm   [5] LEFTWARDS ARROW..LEFT RIGHT ARROW
+2195..2199    ; Common # So   [5] UP DOWN ARROW..SOUTH WEST ARROW
+219A..219B    ; Common # Sm   [2] LEFTWARDS ARROW WITH STROKE..RIGHTWARDS ARROW WITH STROKE
+219C..219F    ; Common # So   [4] LEFTWARDS WAVE ARROW..UPWARDS TWO HEADED ARROW
+21A0          ; Common # Sm       RIGHTWARDS TWO HEADED ARROW
+21A1..21A2    ; Common # So   [2] DOWNWARDS TWO HEADED ARROW..LEFTWARDS ARROW WITH TAIL
+21A3          ; Common # Sm       RIGHTWARDS ARROW WITH TAIL
+21A4..21A5    ; Common # So   [2] LEFTWARDS ARROW FROM BAR..UPWARDS ARROW FROM BAR
+21A6          ; Common # Sm       RIGHTWARDS ARROW FROM BAR
+21A7..21AD    ; Common # So   [7] DOWNWARDS ARROW FROM BAR..LEFT RIGHT WAVE ARROW
+21AE          ; Common # Sm       LEFT RIGHT ARROW WITH STROKE
+21AF..21CD    ; Common # So  [31] DOWNWARDS ZIGZAG ARROW..LEFTWARDS DOUBLE ARROW WITH STROKE
+21CE..21CF    ; Common # Sm   [2] LEFT RIGHT DOUBLE ARROW WITH STROKE..RIGHTWARDS DOUBLE ARROW WITH STROKE
+21D0..21D1    ; Common # So   [2] LEFTWARDS DOUBLE ARROW..UPWARDS DOUBLE ARROW
+21D2          ; Common # Sm       RIGHTWARDS DOUBLE ARROW
+21D3          ; Common # So       DOWNWARDS DOUBLE ARROW
+21D4          ; Common # Sm       LEFT RIGHT DOUBLE ARROW
+21D5..21F3    ; Common # So  [31] UP DOWN DOUBLE ARROW..UP DOWN WHITE ARROW
+21F4..22FF    ; Common # Sm [268] RIGHT ARROW WITH SMALL CIRCLE..Z NOTATION BAG MEMBERSHIP
+2300..2307    ; Common # So   [8] DIAMETER SIGN..WAVY LINE
+2308..230B    ; Common # Sm   [4] LEFT CEILING..RIGHT FLOOR
+230C..231F    ; Common # So  [20] BOTTOM RIGHT CROP..BOTTOM RIGHT CORNER
+2320..2321    ; Common # Sm   [2] TOP HALF INTEGRAL..BOTTOM HALF INTEGRAL
+2322..2328    ; Common # So   [7] FROWN..KEYBOARD
+2329          ; Common # Ps       LEFT-POINTING ANGLE BRACKET
+232A          ; Common # Pe       RIGHT-POINTING ANGLE BRACKET
+232B..237B    ; Common # So  [81] ERASE TO THE LEFT..NOT CHECK MARK
+237C          ; Common # Sm       RIGHT ANGLE WITH DOWNWARDS ZIGZAG ARROW
+237D..239A    ; Common # So  [30] SHOULDERED OPEN BOX..CLEAR SCREEN SYMBOL
+239B..23B3    ; Common # Sm  [25] LEFT PARENTHESIS UPPER HOOK..SUMMATION BOTTOM
+23B4..23DB    ; Common # So  [40] TOP SQUARE BRACKET..FUSE
+23DC..23E1    ; Common # Sm   [6] TOP PARENTHESIS..BOTTOM TORTOISE SHELL BRACKET
+23E2..23E7    ; Common # So   [6] WHITE TRAPEZIUM..ELECTRICAL INTERSECTION
+2400..2426    ; Common # So  [39] SYMBOL FOR NULL..SYMBOL FOR SUBSTITUTE FORM TWO
+2440..244A    ; Common # So  [11] OCR HOOK..OCR DOUBLE BACKSLASH
+2460..249B    ; Common # No  [60] CIRCLED DIGIT ONE..NUMBER TWENTY FULL STOP
+249C..24E9    ; Common # So  [78] PARENTHESIZED LATIN SMALL LETTER A..CIRCLED LATIN SMALL LETTER Z
+24EA..24FF    ; Common # No  [22] CIRCLED DIGIT ZERO..NEGATIVE CIRCLED DIGIT ZERO
+2500..25B6    ; Common # So [183] BOX DRAWINGS LIGHT HORIZONTAL..BLACK RIGHT-POINTING TRIANGLE
+25B7          ; Common # Sm       WHITE RIGHT-POINTING TRIANGLE
+25B8..25C0    ; Common # So   [9] BLACK RIGHT-POINTING SMALL TRIANGLE..BLACK LEFT-POINTING TRIANGLE
+25C1          ; Common # Sm       WHITE LEFT-POINTING TRIANGLE
+25C2..25F7    ; Common # So  [54] BLACK LEFT-POINTING SMALL TRIANGLE..WHITE CIRCLE WITH UPPER RIGHT QUADRANT
+25F8..25FF    ; Common # Sm   [8] UPPER LEFT TRIANGLE..LOWER RIGHT TRIANGLE
+2600..266E    ; Common # So [111] BLACK SUN WITH RAYS..MUSIC NATURAL SIGN
+266F          ; Common # Sm       MUSIC SHARP SIGN
+2670..269D    ; Common # So  [46] WEST SYRIAC CROSS..OUTLINED WHITE STAR
+26A0..26BC    ; Common # So  [29] WARNING SIGN..SESQUIQUADRATE
+26C0..26C3    ; Common # So   [4] WHITE DRAUGHTS MAN..BLACK DRAUGHTS KING
+2701..2704    ; Common # So   [4] UPPER BLADE SCISSORS..WHITE SCISSORS
+2706..2709    ; Common # So   [4] TELEPHONE LOCATION SIGN..ENVELOPE
+270C..2727    ; Common # So  [28] VICTORY HAND..WHITE FOUR POINTED STAR
+2729..274B    ; Common # So  [35] STRESS OUTLINED WHITE STAR..HEAVY EIGHT TEARDROP-SPOKED PROPELLER ASTERISK
+274D          ; Common # So       SHADOWED WHITE CIRCLE
+274F..2752    ; Common # So   [4] LOWER RIGHT DROP-SHADOWED WHITE SQUARE..UPPER RIGHT SHADOWED WHITE SQUARE
+2756          ; Common # So       BLACK DIAMOND MINUS WHITE X
+2758..275E    ; Common # So   [7] LIGHT VERTICAL BAR..HEAVY DOUBLE COMMA QUOTATION MARK ORNAMENT
+2761..2767    ; Common # So   [7] CURVED STEM PARAGRAPH SIGN ORNAMENT..ROTATED FLORAL HEART BULLET
+2768          ; Common # Ps       MEDIUM LEFT PARENTHESIS ORNAMENT
+2769          ; Common # Pe       MEDIUM RIGHT PARENTHESIS ORNAMENT
+276A          ; Common # Ps       MEDIUM FLATTENED LEFT PARENTHESIS ORNAMENT
+276B          ; Common # Pe       MEDIUM FLATTENED RIGHT PARENTHESIS ORNAMENT
+276C          ; Common # Ps       MEDIUM LEFT-POINTING ANGLE BRACKET ORNAMENT
+276D          ; Common # Pe       MEDIUM RIGHT-POINTING ANGLE BRACKET ORNAMENT
+276E          ; Common # Ps       HEAVY LEFT-POINTING ANGLE QUOTATION MARK ORNAMENT
+276F          ; Common # Pe       HEAVY RIGHT-POINTING ANGLE QUOTATION MARK ORNAMENT
+2770          ; Common # Ps       HEAVY LEFT-POINTING ANGLE BRACKET ORNAMENT
+2771          ; Common # Pe       HEAVY RIGHT-POINTING ANGLE BRACKET ORNAMENT
+2772          ; Common # Ps       LIGHT LEFT TORTOISE SHELL BRACKET ORNAMENT
+2773          ; Common # Pe       LIGHT RIGHT TORTOISE SHELL BRACKET ORNAMENT
+2774          ; Common # Ps       MEDIUM LEFT CURLY BRACKET ORNAMENT
+2775          ; Common # Pe       MEDIUM RIGHT CURLY BRACKET ORNAMENT
+2776..2793    ; Common # No  [30] DINGBAT NEGATIVE CIRCLED DIGIT ONE..DINGBAT NEGATIVE CIRCLED SANS-SERIF NUMBER TEN
+2794          ; Common # So       HEAVY WIDE-HEADED RIGHTWARDS ARROW
+2798..27AF    ; Common # So  [24] HEAVY SOUTH EAST ARROW..NOTCHED LOWER RIGHT-SHADOWED WHITE RIGHTWARDS ARROW
+27B1..27BE    ; Common # So  [14] NOTCHED UPPER RIGHT-SHADOWED WHITE RIGHTWARDS ARROW..OPEN-OUTLINED RIGHTWARDS ARROW
+27C0..27C4    ; Common # Sm   [5] THREE DIMENSIONAL ANGLE..OPEN SUPERSET
+27C5          ; Common # Ps       LEFT S-SHAPED BAG DELIMITER
+27C6          ; Common # Pe       RIGHT S-SHAPED BAG DELIMITER
+27C7..27CA    ; Common # Sm   [4] OR WITH DOT INSIDE..VERTICAL BAR WITH HORIZONTAL STROKE
+27CC          ; Common # Sm       LONG DIVISION
+27D0..27E5    ; Common # Sm  [22] WHITE DIAMOND WITH CENTRED DOT..WHITE SQUARE WITH RIGHTWARDS TICK
+27E6          ; Common # Ps       MATHEMATICAL LEFT WHITE SQUARE BRACKET
+27E7          ; Common # Pe       MATHEMATICAL RIGHT WHITE SQUARE BRACKET
+27E8          ; Common # Ps       MATHEMATICAL LEFT ANGLE BRACKET
+27E9          ; Common # Pe       MATHEMATICAL RIGHT ANGLE BRACKET
+27EA          ; Common # Ps       MATHEMATICAL LEFT DOUBLE ANGLE BRACKET
+27EB          ; Common # Pe       MATHEMATICAL RIGHT DOUBLE ANGLE BRACKET
+27EC          ; Common # Ps       MATHEMATICAL LEFT WHITE TORTOISE SHELL BRACKET
+27ED          ; Common # Pe       MATHEMATICAL RIGHT WHITE TORTOISE SHELL BRACKET
+27EE          ; Common # Ps       MATHEMATICAL LEFT FLATTENED PARENTHESIS
+27EF          ; Common # Pe       MATHEMATICAL RIGHT FLATTENED PARENTHESIS
+27F0..27FF    ; Common # Sm  [16] UPWARDS QUADRUPLE ARROW..LONG RIGHTWARDS SQUIGGLE ARROW
+2900..2982    ; Common # Sm [131] RIGHTWARDS TWO-HEADED ARROW WITH VERTICAL STROKE..Z NOTATION TYPE COLON
+2983          ; Common # Ps       LEFT WHITE CURLY BRACKET
+2984          ; Common # Pe       RIGHT WHITE CURLY BRACKET
+2985          ; Common # Ps       LEFT WHITE PARENTHESIS
+2986          ; Common # Pe       RIGHT WHITE PARENTHESIS
+2987          ; Common # Ps       Z NOTATION LEFT IMAGE BRACKET
+2988          ; Common # Pe       Z NOTATION RIGHT IMAGE BRACKET
+2989          ; Common # Ps       Z NOTATION LEFT BINDING BRACKET
+298A          ; Common # Pe       Z NOTATION RIGHT BINDING BRACKET
+298B          ; Common # Ps       LEFT SQUARE BRACKET WITH UNDERBAR
+298C          ; Common # Pe       RIGHT SQUARE BRACKET WITH UNDERBAR
+298D          ; Common # Ps       LEFT SQUARE BRACKET WITH TICK IN TOP CORNER
+298E          ; Common # Pe       RIGHT SQUARE BRACKET WITH TICK IN BOTTOM CORNER
+298F          ; Common # Ps       LEFT SQUARE BRACKET WITH TICK IN BOTTOM CORNER
+2990          ; Common # Pe       RIGHT SQUARE BRACKET WITH TICK IN TOP CORNER
+2991          ; Common # Ps       LEFT ANGLE BRACKET WITH DOT
+2992          ; Common # Pe       RIGHT ANGLE BRACKET WITH DOT
+2993          ; Common # Ps       LEFT ARC LESS-THAN BRACKET
+2994          ; Common # Pe       RIGHT ARC GREATER-THAN BRACKET
+2995          ; Common # Ps       DOUBLE LEFT ARC GREATER-THAN BRACKET
+2996          ; Common # Pe       DOUBLE RIGHT ARC LESS-THAN BRACKET
+2997          ; Common # Ps       LEFT BLACK TORTOISE SHELL BRACKET
+2998          ; Common # Pe       RIGHT BLACK TORTOISE SHELL BRACKET
+2999..29D7    ; Common # Sm  [63] DOTTED FENCE..BLACK HOURGLASS
+29D8          ; Common # Ps       LEFT WIGGLY FENCE
+29D9          ; Common # Pe       RIGHT WIGGLY FENCE
+29DA          ; Common # Ps       LEFT DOUBLE WIGGLY FENCE
+29DB          ; Common # Pe       RIGHT DOUBLE WIGGLY FENCE
+29DC..29FB    ; Common # Sm  [32] INCOMPLETE INFINITY..TRIPLE PLUS
+29FC          ; Common # Ps       LEFT-POINTING CURVED ANGLE BRACKET
+29FD          ; Common # Pe       RIGHT-POINTING CURVED ANGLE BRACKET
+29FE..2AFF    ; Common # Sm [258] TINY..N-ARY WHITE VERTICAL BAR
+2B00..2B2F    ; Common # So  [48] NORTH EAST WHITE ARROW..WHITE VERTICAL ELLIPSE
+2B30..2B44    ; Common # Sm  [21] LEFT ARROW WITH SMALL CIRCLE..RIGHTWARDS ARROW THROUGH SUPERSET
+2B45..2B46    ; Common # So   [2] LEFTWARDS QUADRUPLE ARROW..RIGHTWARDS QUADRUPLE ARROW
+2B47..2B4C    ; Common # Sm   [6] REVERSE TILDE OPERATOR ABOVE RIGHTWARDS ARROW..RIGHTWARDS ARROW ABOVE REVERSE TILDE OPERATOR
+2B50..2B54    ; Common # So   [5] WHITE MEDIUM STAR..WHITE RIGHT-POINTING PENTAGON
+2E00..2E01    ; Common # Po   [2] RIGHT ANGLE SUBSTITUTION MARKER..RIGHT ANGLE DOTTED SUBSTITUTION MARKER
+2E02          ; Common # Pi       LEFT SUBSTITUTION BRACKET
+2E03          ; Common # Pf       RIGHT SUBSTITUTION BRACKET
+2E04          ; Common # Pi       LEFT DOTTED SUBSTITUTION BRACKET
+2E05          ; Common # Pf       RIGHT DOTTED SUBSTITUTION BRACKET
+2E06..2E08    ; Common # Po   [3] RAISED INTERPOLATION MARKER..DOTTED TRANSPOSITION MARKER
+2E09          ; Common # Pi       LEFT TRANSPOSITION BRACKET
+2E0A          ; Common # Pf       RIGHT TRANSPOSITION BRACKET
+2E0B          ; Common # Po       RAISED SQUARE
+2E0C          ; Common # Pi       LEFT RAISED OMISSION BRACKET
+2E0D          ; Common # Pf       RIGHT RAISED OMISSION BRACKET
+2E0E..2E16    ; Common # Po   [9] EDITORIAL CORONIS..DOTTED RIGHT-POINTING ANGLE
+2E17          ; Common # Pd       DOUBLE OBLIQUE HYPHEN
+2E18..2E19    ; Common # Po   [2] INVERTED INTERROBANG..PALM BRANCH
+2E1A          ; Common # Pd       HYPHEN WITH DIAERESIS
+2E1B          ; Common # Po       TILDE WITH RING ABOVE
+2E1C          ; Common # Pi       LEFT LOW PARAPHRASE BRACKET
+2E1D          ; Common # Pf       RIGHT LOW PARAPHRASE BRACKET
+2E1E..2E1F    ; Common # Po   [2] TILDE WITH DOT ABOVE..TILDE WITH DOT BELOW
+2E20          ; Common # Pi       LEFT VERTICAL BAR WITH QUILL
+2E21          ; Common # Pf       RIGHT VERTICAL BAR WITH QUILL
+2E22          ; Common # Ps       TOP LEFT HALF BRACKET
+2E23          ; Common # Pe       TOP RIGHT HALF BRACKET
+2E24          ; Common # Ps       BOTTOM LEFT HALF BRACKET
+2E25          ; Common # Pe       BOTTOM RIGHT HALF BRACKET
+2E26          ; Common # Ps       LEFT SIDEWAYS U BRACKET
+2E27          ; Common # Pe       RIGHT SIDEWAYS U BRACKET
+2E28          ; Common # Ps       LEFT DOUBLE PARENTHESIS
+2E29          ; Common # Pe       RIGHT DOUBLE PARENTHESIS
+2E2A..2E2E    ; Common # Po   [5] TWO DOTS OVER ONE DOT PUNCTUATION..REVERSED QUESTION MARK
+2E2F          ; Common # Lm       VERTICAL TILDE
+2E30          ; Common # Po       RING POINT
+2FF0..2FFB    ; Common # So  [12] IDEOGRAPHIC DESCRIPTION CHARACTER LEFT TO RIGHT..IDEOGRAPHIC DESCRIPTION CHARACTER OVERLAID
+3000          ; Common # Zs       IDEOGRAPHIC SPACE
+3001..3003    ; Common # Po   [3] IDEOGRAPHIC COMMA..DITTO MARK
+3004          ; Common # So       JAPANESE INDUSTRIAL STANDARD SYMBOL
+3006          ; Common # Lo       IDEOGRAPHIC CLOSING MARK
+3008          ; Common # Ps       LEFT ANGLE BRACKET
+3009          ; Common # Pe       RIGHT ANGLE BRACKET
+300A          ; Common # Ps       LEFT DOUBLE ANGLE BRACKET
+300B          ; Common # Pe       RIGHT DOUBLE ANGLE BRACKET
+300C          ; Common # Ps       LEFT CORNER BRACKET
+300D          ; Common # Pe       RIGHT CORNER BRACKET
+300E          ; Common # Ps       LEFT WHITE CORNER BRACKET
+300F          ; Common # Pe       RIGHT WHITE CORNER BRACKET
+3010          ; Common # Ps       LEFT BLACK LENTICULAR BRACKET
+3011          ; Common # Pe       RIGHT BLACK LENTICULAR BRACKET
+3012..3013    ; Common # So   [2] POSTAL MARK..GETA MARK
+3014          ; Common # Ps       LEFT TORTOISE SHELL BRACKET
+3015          ; Common # Pe       RIGHT TORTOISE SHELL BRACKET
+3016          ; Common # Ps       LEFT WHITE LENTICULAR BRACKET
+3017          ; Common # Pe       RIGHT WHITE LENTICULAR BRACKET
+3018          ; Common # Ps       LEFT WHITE TORTOISE SHELL BRACKET
+3019          ; Common # Pe       RIGHT WHITE TORTOISE SHELL BRACKET
+301A          ; Common # Ps       LEFT WHITE SQUARE BRACKET
+301B          ; Common # Pe       RIGHT WHITE SQUARE BRACKET
+301C          ; Common # Pd       WAVE DASH
+301D          ; Common # Ps       REVERSED DOUBLE PRIME QUOTATION MARK
+301E..301F    ; Common # Pe   [2] DOUBLE PRIME QUOTATION MARK..LOW DOUBLE PRIME QUOTATION MARK
+3020          ; Common # So       POSTAL MARK FACE
+3030          ; Common # Pd       WAVY DASH
+3031..3035    ; Common # Lm   [5] VERTICAL KANA REPEAT MARK..VERTICAL KANA REPEAT MARK LOWER HALF
+3036..3037    ; Common # So   [2] CIRCLED POSTAL MARK..IDEOGRAPHIC TELEGRAPH LINE FEED SEPARATOR SYMBOL
+303C          ; Common # Lo       MASU MARK
+303D          ; Common # Po       PART ALTERNATION MARK
+303E..303F    ; Common # So   [2] IDEOGRAPHIC VARIATION INDICATOR..IDEOGRAPHIC HALF FILL SPACE
+309B..309C    ; Common # Sk   [2] KATAKANA-HIRAGANA VOICED SOUND MARK..KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK
+30A0          ; Common # Pd       KATAKANA-HIRAGANA DOUBLE HYPHEN
+30FB          ; Common # Po       KATAKANA MIDDLE DOT
+30FC          ; Common # Lm       KATAKANA-HIRAGANA PROLONGED SOUND MARK
+3190..3191    ; Common # So   [2] IDEOGRAPHIC ANNOTATION LINKING MARK..IDEOGRAPHIC ANNOTATION REVERSE MARK
+3192..3195    ; Common # No   [4] IDEOGRAPHIC ANNOTATION ONE MARK..IDEOGRAPHIC ANNOTATION FOUR MARK
+3196..319F    ; Common # So  [10] IDEOGRAPHIC ANNOTATION TOP MARK..IDEOGRAPHIC ANNOTATION MAN MARK
+31C0..31E3    ; Common # So  [36] CJK STROKE T..CJK STROKE Q
+3220..3229    ; Common # No  [10] PARENTHESIZED IDEOGRAPH ONE..PARENTHESIZED IDEOGRAPH TEN
+322A..3243    ; Common # So  [26] PARENTHESIZED IDEOGRAPH MOON..PARENTHESIZED IDEOGRAPH REACH
+3250          ; Common # So       PARTNERSHIP SIGN
+3251..325F    ; Common # No  [15] CIRCLED NUMBER TWENTY ONE..CIRCLED NUMBER THIRTY FIVE
+327F          ; Common # So       KOREAN STANDARD SYMBOL
+3280..3289    ; Common # No  [10] CIRCLED IDEOGRAPH ONE..CIRCLED IDEOGRAPH TEN
+328A..32B0    ; Common # So  [39] CIRCLED IDEOGRAPH MOON..CIRCLED IDEOGRAPH NIGHT
+32B1..32BF    ; Common # No  [15] CIRCLED NUMBER THIRTY SIX..CIRCLED NUMBER FIFTY
+32C0..32CF    ; Common # So  [16] IDEOGRAPHIC TELEGRAPH SYMBOL FOR JANUARY..LIMITED LIABILITY SIGN
+3358..33FF    ; Common # So [168] IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR ZERO..SQUARE GAL
+4DC0..4DFF    ; Common # So  [64] HEXAGRAM FOR THE CREATIVE HEAVEN..HEXAGRAM FOR BEFORE COMPLETION
+A700..A716    ; Common # Sk  [23] MODIFIER LETTER CHINESE TONE YIN PING..MODIFIER LETTER EXTRA-LOW LEFT-STEM TONE BAR
+A717..A71F    ; Common # Lm   [9] MODIFIER LETTER DOT VERTICAL BAR..MODIFIER LETTER LOW INVERTED EXCLAMATION MARK
+A720..A721    ; Common # Sk   [2] MODIFIER LETTER STRESS AND HIGH TONE..MODIFIER LETTER STRESS AND LOW TONE
+A788          ; Common # Lm       MODIFIER LETTER LOW CIRCUMFLEX ACCENT
+A789..A78A    ; Common # Sk   [2] MODIFIER LETTER COLON..MODIFIER LETTER SHORT EQUALS SIGN
+FD3E          ; Common # Ps       ORNATE LEFT PARENTHESIS
+FD3F          ; Common # Pe       ORNATE RIGHT PARENTHESIS
+FDFD          ; Common # So       ARABIC LIGATURE BISMILLAH AR-RAHMAN AR-RAHEEM
+FE10..FE16    ; Common # Po   [7] PRESENTATION FORM FOR VERTICAL COMMA..PRESENTATION FORM FOR VERTICAL QUESTION MARK
+FE17          ; Common # Ps       PRESENTATION FORM FOR VERTICAL LEFT WHITE LENTICULAR BRACKET
+FE18          ; Common # Pe       PRESENTATION FORM FOR VERTICAL RIGHT WHITE LENTICULAR BRAKCET
+FE19          ; Common # Po       PRESENTATION FORM FOR VERTICAL HORIZONTAL ELLIPSIS
+FE30          ; Common # Po       PRESENTATION FORM FOR VERTICAL TWO DOT LEADER
+FE31..FE32    ; Common # Pd   [2] PRESENTATION FORM FOR VERTICAL EM DASH..PRESENTATION FORM FOR VERTICAL EN DASH
+FE33..FE34    ; Common # Pc   [2] PRESENTATION FORM FOR VERTICAL LOW LINE..PRESENTATION FORM FOR VERTICAL WAVY LOW LINE
+FE35          ; Common # Ps       PRESENTATION FORM FOR VERTICAL LEFT PARENTHESIS
+FE36          ; Common # Pe       PRESENTATION FORM FOR VERTICAL RIGHT PARENTHESIS
+FE37          ; Common # Ps       PRESENTATION FORM FOR VERTICAL LEFT CURLY BRACKET
+FE38          ; Common # Pe       PRESENTATION FORM FOR VERTICAL RIGHT CURLY BRACKET
+FE39          ; Common # Ps       PRESENTATION FORM FOR VERTICAL LEFT TORTOISE SHELL BRACKET
+FE3A          ; Common # Pe       PRESENTATION FORM FOR VERTICAL RIGHT TORTOISE SHELL BRACKET
+FE3B          ; Common # Ps       PRESENTATION FORM FOR VERTICAL LEFT BLACK LENTICULAR BRACKET
+FE3C          ; Common # Pe       PRESENTATION FORM FOR VERTICAL RIGHT BLACK LENTICULAR BRACKET
+FE3D          ; Common # Ps       PRESENTATION FORM FOR VERTICAL LEFT DOUBLE ANGLE BRACKET
+FE3E          ; Common # Pe       PRESENTATION FORM FOR VERTICAL RIGHT DOUBLE ANGLE BRACKET
+FE3F          ; Common # Ps       PRESENTATION FORM FOR VERTICAL LEFT ANGLE BRACKET
+FE40          ; Common # Pe       PRESENTATION FORM FOR VERTICAL RIGHT ANGLE BRACKET
+FE41          ; Common # Ps       PRESENTATION FORM FOR VERTICAL LEFT CORNER BRACKET
+FE42          ; Common # Pe       PRESENTATION FORM FOR VERTICAL RIGHT CORNER BRACKET
+FE43          ; Common # Ps       PRESENTATION FORM FOR VERTICAL LEFT WHITE CORNER BRACKET
+FE44          ; Common # Pe       PRESENTATION FORM FOR VERTICAL RIGHT WHITE CORNER BRACKET
+FE45..FE46    ; Common # Po   [2] SESAME DOT..WHITE SESAME DOT
+FE47          ; Common # Ps       PRESENTATION FORM FOR VERTICAL LEFT SQUARE BRACKET
+FE48          ; Common # Pe       PRESENTATION FORM FOR VERTICAL RIGHT SQUARE BRACKET
+FE49..FE4C    ; Common # Po   [4] DASHED OVERLINE..DOUBLE WAVY OVERLINE
+FE4D..FE4F    ; Common # Pc   [3] DASHED LOW LINE..WAVY LOW LINE
+FE50..FE52    ; Common # Po   [3] SMALL COMMA..SMALL FULL STOP
+FE54..FE57    ; Common # Po   [4] SMALL SEMICOLON..SMALL EXCLAMATION MARK
+FE58          ; Common # Pd       SMALL EM DASH
+FE59          ; Common # Ps       SMALL LEFT PARENTHESIS
+FE5A          ; Common # Pe       SMALL RIGHT PARENTHESIS
+FE5B          ; Common # Ps       SMALL LEFT CURLY BRACKET
+FE5C          ; Common # Pe       SMALL RIGHT CURLY BRACKET
+FE5D          ; Common # Ps       SMALL LEFT TORTOISE SHELL BRACKET
+FE5E          ; Common # Pe       SMALL RIGHT TORTOISE SHELL BRACKET
+FE5F..FE61    ; Common # Po   [3] SMALL NUMBER SIGN..SMALL ASTERISK
+FE62          ; Common # Sm       SMALL PLUS SIGN
+FE63          ; Common # Pd       SMALL HYPHEN-MINUS
+FE64..FE66    ; Common # Sm   [3] SMALL LESS-THAN SIGN..SMALL EQUALS SIGN
+FE68          ; Common # Po       SMALL REVERSE SOLIDUS
+FE69          ; Common # Sc       SMALL DOLLAR SIGN
+FE6A..FE6B    ; Common # Po   [2] SMALL PERCENT SIGN..SMALL COMMERCIAL AT
+FEFF          ; Common # Cf       ZERO WIDTH NO-BREAK SPACE
+FF01..FF03    ; Common # Po   [3] FULLWIDTH EXCLAMATION MARK..FULLWIDTH NUMBER SIGN
+FF04          ; Common # Sc       FULLWIDTH DOLLAR SIGN
+FF05..FF07    ; Common # Po   [3] FULLWIDTH PERCENT SIGN..FULLWIDTH APOSTROPHE
+FF08          ; Common # Ps       FULLWIDTH LEFT PARENTHESIS
+FF09          ; Common # Pe       FULLWIDTH RIGHT PARENTHESIS
+FF0A          ; Common # Po       FULLWIDTH ASTERISK
+FF0B          ; Common # Sm       FULLWIDTH PLUS SIGN
+FF0C          ; Common # Po       FULLWIDTH COMMA
+FF0D          ; Common # Pd       FULLWIDTH HYPHEN-MINUS
+FF0E..FF0F    ; Common # Po   [2] FULLWIDTH FULL STOP..FULLWIDTH SOLIDUS
+FF10..FF19    ; Common # Nd  [10] FULLWIDTH DIGIT ZERO..FULLWIDTH DIGIT NINE
+FF1A..FF1B    ; Common # Po   [2] FULLWIDTH COLON..FULLWIDTH SEMICOLON
+FF1C..FF1E    ; Common # Sm   [3] FULLWIDTH LESS-THAN SIGN..FULLWIDTH GREATER-THAN SIGN
+FF1F..FF20    ; Common # Po   [2] FULLWIDTH QUESTION MARK..FULLWIDTH COMMERCIAL AT
+FF3B          ; Common # Ps       FULLWIDTH LEFT SQUARE BRACKET
+FF3C          ; Common # Po       FULLWIDTH REVERSE SOLIDUS
+FF3D          ; Common # Pe       FULLWIDTH RIGHT SQUARE BRACKET
+FF3E          ; Common # Sk       FULLWIDTH CIRCUMFLEX ACCENT
+FF3F          ; Common # Pc       FULLWIDTH LOW LINE
+FF40          ; Common # Sk       FULLWIDTH GRAVE ACCENT
+FF5B          ; Common # Ps       FULLWIDTH LEFT CURLY BRACKET
+FF5C          ; Common # Sm       FULLWIDTH VERTICAL LINE
+FF5D          ; Common # Pe       FULLWIDTH RIGHT CURLY BRACKET
+FF5E          ; Common # Sm       FULLWIDTH TILDE
+FF5F          ; Common # Ps       FULLWIDTH LEFT WHITE PARENTHESIS
+FF60          ; Common # Pe       FULLWIDTH RIGHT WHITE PARENTHESIS
+FF61          ; Common # Po       HALFWIDTH IDEOGRAPHIC FULL STOP
+FF62          ; Common # Ps       HALFWIDTH LEFT CORNER BRACKET
+FF63          ; Common # Pe       HALFWIDTH RIGHT CORNER BRACKET
+FF64..FF65    ; Common # Po   [2] HALFWIDTH IDEOGRAPHIC COMMA..HALFWIDTH KATAKANA MIDDLE DOT
+FF70          ; Common # Lm       HALFWIDTH KATAKANA-HIRAGANA PROLONGED SOUND MARK
+FF9E..FF9F    ; Common # Lm   [2] HALFWIDTH KATAKANA VOICED SOUND MARK..HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK
+FFE0..FFE1    ; Common # Sc   [2] FULLWIDTH CENT SIGN..FULLWIDTH POUND SIGN
+FFE2          ; Common # Sm       FULLWIDTH NOT SIGN
+FFE3          ; Common # Sk       FULLWIDTH MACRON
+FFE4          ; Common # So       FULLWIDTH BROKEN BAR
+FFE5..FFE6    ; Common # Sc   [2] FULLWIDTH YEN SIGN..FULLWIDTH WON SIGN
+FFE8          ; Common # So       HALFWIDTH FORMS LIGHT VERTICAL
+FFE9..FFEC    ; Common # Sm   [4] HALFWIDTH LEFTWARDS ARROW..HALFWIDTH DOWNWARDS ARROW
+FFED..FFEE    ; Common # So   [2] HALFWIDTH BLACK SQUARE..HALFWIDTH WHITE CIRCLE
+FFF9..FFFB    ; Common # Cf   [3] INTERLINEAR ANNOTATION ANCHOR..INTERLINEAR ANNOTATION TERMINATOR
+FFFC..FFFD    ; Common # So   [2] OBJECT REPLACEMENT CHARACTER..REPLACEMENT CHARACTER
+10100..10101  ; Common # Po   [2] AEGEAN WORD SEPARATOR LINE..AEGEAN WORD SEPARATOR DOT
+10102         ; Common # So       AEGEAN CHECK MARK
+10107..10133  ; Common # No  [45] AEGEAN NUMBER ONE..AEGEAN NUMBER NINETY THOUSAND
+10137..1013F  ; Common # So   [9] AEGEAN WEIGHT BASE UNIT..AEGEAN MEASURE THIRD SUBUNIT
+10190..1019B  ; Common # So  [12] ROMAN SEXTANS SIGN..ROMAN CENTURIAL SIGN
+101D0..101FC  ; Common # So  [45] PHAISTOS DISC SIGN PEDESTRIAN..PHAISTOS DISC SIGN WAVY BAND
+1D000..1D0F5  ; Common # So [246] BYZANTINE MUSICAL SYMBOL PSILI..BYZANTINE MUSICAL SYMBOL GORGON NEO KATO
+1D100..1D126  ; Common # So  [39] MUSICAL SYMBOL SINGLE BARLINE..MUSICAL SYMBOL DRUM CLEF-2
+1D129..1D164  ; Common # So  [60] MUSICAL SYMBOL MULTIPLE MEASURE REST..MUSICAL SYMBOL ONE HUNDRED TWENTY-EIGHTH NOTE
+1D165..1D166  ; Common # Mc   [2] MUSICAL SYMBOL COMBINING STEM..MUSICAL SYMBOL COMBINING SPRECHGESANG STEM
+1D16A..1D16C  ; Common # So   [3] MUSICAL SYMBOL FINGERED TREMOLO-1..MUSICAL SYMBOL FINGERED TREMOLO-3
+1D16D..1D172  ; Common # Mc   [6] MUSICAL SYMBOL COMBINING AUGMENTATION DOT..MUSICAL SYMBOL COMBINING FLAG-5
+1D173..1D17A  ; Common # Cf   [8] MUSICAL SYMBOL BEGIN BEAM..MUSICAL SYMBOL END PHRASE
+1D183..1D184  ; Common # So   [2] MUSICAL SYMBOL ARPEGGIATO UP..MUSICAL SYMBOL ARPEGGIATO DOWN
+1D18C..1D1A9  ; Common # So  [30] MUSICAL SYMBOL RINFORZANDO..MUSICAL SYMBOL DEGREE SLASH
+1D1AE..1D1DD  ; Common # So  [48] MUSICAL SYMBOL PEDAL MARK..MUSICAL SYMBOL PES SUBPUNCTIS
+1D300..1D356  ; Common # So  [87] MONOGRAM FOR EARTH..TETRAGRAM FOR FOSTERING
+1D360..1D371  ; Common # No  [18] COUNTING ROD UNIT DIGIT ONE..COUNTING ROD TENS DIGIT NINE
+1D400..1D454  ; Common # L&  [85] MATHEMATICAL BOLD CAPITAL A..MATHEMATICAL ITALIC SMALL G
+1D456..1D49C  ; Common # L&  [71] MATHEMATICAL ITALIC SMALL I..MATHEMATICAL SCRIPT CAPITAL A
+1D49E..1D49F  ; Common # L&   [2] MATHEMATICAL SCRIPT CAPITAL C..MATHEMATICAL SCRIPT CAPITAL D
+1D4A2         ; Common # L&       MATHEMATICAL SCRIPT CAPITAL G
+1D4A5..1D4A6  ; Common # L&   [2] MATHEMATICAL SCRIPT CAPITAL J..MATHEMATICAL SCRIPT CAPITAL K
+1D4A9..1D4AC  ; Common # L&   [4] MATHEMATICAL SCRIPT CAPITAL N..MATHEMATICAL SCRIPT CAPITAL Q
+1D4AE..1D4B9  ; Common # L&  [12] MATHEMATICAL SCRIPT CAPITAL S..MATHEMATICAL SCRIPT SMALL D
+1D4BB         ; Common # L&       MATHEMATICAL SCRIPT SMALL F
+1D4BD..1D4C3  ; Common # L&   [7] MATHEMATICAL SCRIPT SMALL H..MATHEMATICAL SCRIPT SMALL N
+1D4C5..1D505  ; Common # L&  [65] MATHEMATICAL SCRIPT SMALL P..MATHEMATICAL FRAKTUR CAPITAL B
+1D507..1D50A  ; Common # L&   [4] MATHEMATICAL FRAKTUR CAPITAL D..MATHEMATICAL FRAKTUR CAPITAL G
+1D50D..1D514  ; Common # L&   [8] MATHEMATICAL FRAKTUR CAPITAL J..MATHEMATICAL FRAKTUR CAPITAL Q
+1D516..1D51C  ; Common # L&   [7] MATHEMATICAL FRAKTUR CAPITAL S..MATHEMATICAL FRAKTUR CAPITAL Y
+1D51E..1D539  ; Common # L&  [28] MATHEMATICAL FRAKTUR SMALL A..MATHEMATICAL DOUBLE-STRUCK CAPITAL B
+1D53B..1D53E  ; Common # L&   [4] MATHEMATICAL DOUBLE-STRUCK CAPITAL D..MATHEMATICAL DOUBLE-STRUCK CAPITAL G
+1D540..1D544  ; Common # L&   [5] MATHEMATICAL DOUBLE-STRUCK CAPITAL I..MATHEMATICAL DOUBLE-STRUCK CAPITAL M
+1D546         ; Common # L&       MATHEMATICAL DOUBLE-STRUCK CAPITAL O
+1D54A..1D550  ; Common # L&   [7] MATHEMATICAL DOUBLE-STRUCK CAPITAL S..MATHEMATICAL DOUBLE-STRUCK CAPITAL Y
+1D552..1D6A5  ; Common # L& [340] MATHEMATICAL DOUBLE-STRUCK SMALL A..MATHEMATICAL ITALIC SMALL DOTLESS J
+1D6A8..1D6C0  ; Common # L&  [25] MATHEMATICAL BOLD CAPITAL ALPHA..MATHEMATICAL BOLD CAPITAL OMEGA
+1D6C1         ; Common # Sm       MATHEMATICAL BOLD NABLA
+1D6C2..1D6DA  ; Common # L&  [25] MATHEMATICAL BOLD SMALL ALPHA..MATHEMATICAL BOLD SMALL OMEGA
+1D6DB         ; Common # Sm       MATHEMATICAL BOLD PARTIAL DIFFERENTIAL
+1D6DC..1D6FA  ; Common # L&  [31] MATHEMATICAL BOLD EPSILON SYMBOL..MATHEMATICAL ITALIC CAPITAL OMEGA
+1D6FB         ; Common # Sm       MATHEMATICAL ITALIC NABLA
+1D6FC..1D714  ; Common # L&  [25] MATHEMATICAL ITALIC SMALL ALPHA..MATHEMATICAL ITALIC SMALL OMEGA
+1D715         ; Common # Sm       MATHEMATICAL ITALIC PARTIAL DIFFERENTIAL
+1D716..1D734  ; Common # L&  [31] MATHEMATICAL ITALIC EPSILON SYMBOL..MATHEMATICAL BOLD ITALIC CAPITAL OMEGA
+1D735         ; Common # Sm       MATHEMATICAL BOLD ITALIC NABLA
+1D736..1D74E  ; Common # L&  [25] MATHEMATICAL BOLD ITALIC SMALL ALPHA..MATHEMATICAL BOLD ITALIC SMALL OMEGA
+1D74F         ; Common # Sm       MATHEMATICAL BOLD ITALIC PARTIAL DIFFERENTIAL
+1D750..1D76E  ; Common # L&  [31] MATHEMATICAL BOLD ITALIC EPSILON SYMBOL..MATHEMATICAL SANS-SERIF BOLD CAPITAL OMEGA
+1D76F         ; Common # Sm       MATHEMATICAL SANS-SERIF BOLD NABLA
+1D770..1D788  ; Common # L&  [25] MATHEMATICAL SANS-SERIF BOLD SMALL ALPHA..MATHEMATICAL SANS-SERIF BOLD SMALL OMEGA
+1D789         ; Common # Sm       MATHEMATICAL SANS-SERIF BOLD PARTIAL DIFFERENTIAL
+1D78A..1D7A8  ; Common # L&  [31] MATHEMATICAL SANS-SERIF BOLD EPSILON SYMBOL..MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL OMEGA
+1D7A9         ; Common # Sm       MATHEMATICAL SANS-SERIF BOLD ITALIC NABLA
+1D7AA..1D7C2  ; Common # L&  [25] MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL ALPHA..MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL OMEGA
+1D7C3         ; Common # Sm       MATHEMATICAL SANS-SERIF BOLD ITALIC PARTIAL DIFFERENTIAL
+1D7C4..1D7CB  ; Common # L&   [8] MATHEMATICAL SANS-SERIF BOLD ITALIC EPSILON SYMBOL..MATHEMATICAL BOLD SMALL DIGAMMA
+1D7CE..1D7FF  ; Common # Nd  [50] MATHEMATICAL BOLD DIGIT ZERO..MATHEMATICAL MONOSPACE DIGIT NINE
+1F000..1F02B  ; Common # So  [44] MAHJONG TILE EAST WIND..MAHJONG TILE BACK
+1F030..1F093  ; Common # So [100] DOMINO TILE HORIZONTAL BACK..DOMINO TILE VERTICAL-06-06
+E0001         ; Common # Cf       LANGUAGE TAG
+E0020..E007F  ; Common # Cf  [96] TAG SPACE..CANCEL TAG
+
+# Total code points: 5178
+
+# ================================================
+
+0041..005A    ; Latin # L&  [26] LATIN CAPITAL LETTER A..LATIN CAPITAL LETTER Z
+0061..007A    ; Latin # L&  [26] LATIN SMALL LETTER A..LATIN SMALL LETTER Z
+00AA          ; Latin # L&       FEMININE ORDINAL INDICATOR
+00BA          ; Latin # L&       MASCULINE ORDINAL INDICATOR
+00C0..00D6    ; Latin # L&  [23] LATIN CAPITAL LETTER A WITH GRAVE..LATIN CAPITAL LETTER O WITH DIAERESIS
+00D8..00F6    ; Latin # L&  [31] LATIN CAPITAL LETTER O WITH STROKE..LATIN SMALL LETTER O WITH DIAERESIS
+00F8..01BA    ; Latin # L& [195] LATIN SMALL LETTER O WITH STROKE..LATIN SMALL LETTER EZH WITH TAIL
+01BB          ; Latin # Lo       LATIN LETTER TWO WITH STROKE
+01BC..01BF    ; Latin # L&   [4] LATIN CAPITAL LETTER TONE FIVE..LATIN LETTER WYNN
+01C0..01C3    ; Latin # Lo   [4] LATIN LETTER DENTAL CLICK..LATIN LETTER RETROFLEX CLICK
+01C4..0293    ; Latin # L& [208] LATIN CAPITAL LETTER DZ WITH CARON..LATIN SMALL LETTER EZH WITH CURL
+0294          ; Latin # Lo       LATIN LETTER GLOTTAL STOP
+0295..02AF    ; Latin # L&  [27] LATIN LETTER PHARYNGEAL VOICED FRICATIVE..LATIN SMALL LETTER TURNED H WITH FISHHOOK AND TAIL
+02B0..02B8    ; Latin # Lm   [9] MODIFIER LETTER SMALL H..MODIFIER LETTER SMALL Y
+02E0..02E4    ; Latin # Lm   [5] MODIFIER LETTER SMALL GAMMA..MODIFIER LETTER SMALL REVERSED GLOTTAL STOP
+1D00..1D25    ; Latin # L&  [38] LATIN LETTER SMALL CAPITAL A..LATIN LETTER AIN
+1D2C..1D5C    ; Latin # Lm  [49] MODIFIER LETTER CAPITAL A..MODIFIER LETTER SMALL AIN
+1D62..1D65    ; Latin # L&   [4] LATIN SUBSCRIPT SMALL LETTER I..LATIN SUBSCRIPT SMALL LETTER V
+1D6B..1D77    ; Latin # L&  [13] LATIN SMALL LETTER UE..LATIN SMALL LETTER TURNED G
+1D79..1D9A    ; Latin # L&  [34] LATIN SMALL LETTER INSULAR G..LATIN SMALL LETTER EZH WITH RETROFLEX HOOK
+1D9B..1DBE    ; Latin # Lm  [36] MODIFIER LETTER SMALL TURNED ALPHA..MODIFIER LETTER SMALL EZH
+1E00..1EFF    ; Latin # L& [256] LATIN CAPITAL LETTER A WITH RING BELOW..LATIN SMALL LETTER Y WITH LOOP
+2071          ; Latin # L&       SUPERSCRIPT LATIN SMALL LETTER I
+207F          ; Latin # L&       SUPERSCRIPT LATIN SMALL LETTER N
+2090..2094    ; Latin # Lm   [5] LATIN SUBSCRIPT SMALL LETTER A..LATIN SUBSCRIPT SMALL LETTER SCHWA
+212A..212B    ; Latin # L&   [2] KELVIN SIGN..ANGSTROM SIGN
+2132          ; Latin # L&       TURNED CAPITAL F
+214E          ; Latin # L&       TURNED SMALL F
+2160..2182    ; Latin # Nl  [35] ROMAN NUMERAL ONE..ROMAN NUMERAL TEN THOUSAND
+2183..2184    ; Latin # L&   [2] ROMAN NUMERAL REVERSED ONE HUNDRED..LATIN SMALL LETTER REVERSED C
+2185..2188    ; Latin # Nl   [4] ROMAN NUMERAL SIX LATE FORM..ROMAN NUMERAL ONE HUNDRED THOUSAND
+2C60..2C6F    ; Latin # L&  [16] LATIN CAPITAL LETTER L WITH DOUBLE BAR..LATIN CAPITAL LETTER TURNED A
+2C71..2C7C    ; Latin # L&  [12] LATIN SMALL LETTER V WITH RIGHT HOOK..LATIN SUBSCRIPT SMALL LETTER J
+2C7D          ; Latin # Lm       MODIFIER LETTER CAPITAL V
+A722..A76F    ; Latin # L&  [78] LATIN CAPITAL LETTER EGYPTOLOGICAL ALEF..LATIN SMALL LETTER CON
+A770          ; Latin # Lm       MODIFIER LETTER US
+A771..A787    ; Latin # L&  [23] LATIN SMALL LETTER DUM..LATIN SMALL LETTER INSULAR T
+A78B..A78C    ; Latin # L&   [2] LATIN CAPITAL LETTER SALTILLO..LATIN SMALL LETTER SALTILLO
+A7FB..A7FF    ; Latin # Lo   [5] LATIN EPIGRAPHIC LETTER REVERSED F..LATIN EPIGRAPHIC LETTER ARCHAIC M
+FB00..FB06    ; Latin # L&   [7] LATIN SMALL LIGATURE FF..LATIN SMALL LIGATURE ST
+FF21..FF3A    ; Latin # L&  [26] FULLWIDTH LATIN CAPITAL LETTER A..FULLWIDTH LATIN CAPITAL LETTER Z
+FF41..FF5A    ; Latin # L&  [26] FULLWIDTH LATIN SMALL LETTER A..FULLWIDTH LATIN SMALL LETTER Z
+
+# Total code points: 1241
+
+# ================================================
+
+0370..0373    ; Greek # L&   [4] GREEK CAPITAL LETTER HETA..GREEK SMALL LETTER ARCHAIC SAMPI
+0375          ; Greek # Sk       GREEK LOWER NUMERAL SIGN
+0376..0377    ; Greek # L&   [2] GREEK CAPITAL LETTER PAMPHYLIAN DIGAMMA..GREEK SMALL LETTER PAMPHYLIAN DIGAMMA
+037A          ; Greek # Lm       GREEK YPOGEGRAMMENI
+037B..037D    ; Greek # L&   [3] GREEK SMALL REVERSED LUNATE SIGMA SYMBOL..GREEK SMALL REVERSED DOTTED LUNATE SIGMA SYMBOL
+0384          ; Greek # Sk       GREEK TONOS
+0386          ; Greek # L&       GREEK CAPITAL LETTER ALPHA WITH TONOS
+0388..038A    ; Greek # L&   [3] GREEK CAPITAL LETTER EPSILON WITH TONOS..GREEK CAPITAL LETTER IOTA WITH TONOS
+038C          ; Greek # L&       GREEK CAPITAL LETTER OMICRON WITH TONOS
+038E..03A1    ; Greek # L&  [20] GREEK CAPITAL LETTER UPSILON WITH TONOS..GREEK CAPITAL LETTER RHO
+03A3..03E1    ; Greek # L&  [63] GREEK CAPITAL LETTER SIGMA..GREEK SMALL LETTER SAMPI
+03F0..03F5    ; Greek # L&   [6] GREEK KAPPA SYMBOL..GREEK LUNATE EPSILON SYMBOL
+03F6          ; Greek # Sm       GREEK REVERSED LUNATE EPSILON SYMBOL
+03F7..03FF    ; Greek # L&   [9] GREEK CAPITAL LETTER SHO..GREEK CAPITAL REVERSED DOTTED LUNATE SIGMA SYMBOL
+1D26..1D2A    ; Greek # L&   [5] GREEK LETTER SMALL CAPITAL GAMMA..GREEK LETTER SMALL CAPITAL PSI
+1D5D..1D61    ; Greek # Lm   [5] MODIFIER LETTER SMALL BETA..MODIFIER LETTER SMALL CHI
+1D66..1D6A    ; Greek # L&   [5] GREEK SUBSCRIPT SMALL LETTER BETA..GREEK SUBSCRIPT SMALL LETTER CHI
+1DBF          ; Greek # Lm       MODIFIER LETTER SMALL THETA
+1F00..1F15    ; Greek # L&  [22] GREEK SMALL LETTER ALPHA WITH PSILI..GREEK SMALL LETTER EPSILON WITH DASIA AND OXIA
+1F18..1F1D    ; Greek # L&   [6] GREEK CAPITAL LETTER EPSILON WITH PSILI..GREEK CAPITAL LETTER EPSILON WITH DASIA AND OXIA
+1F20..1F45    ; Greek # L&  [38] GREEK SMALL LETTER ETA WITH PSILI..GREEK SMALL LETTER OMICRON WITH DASIA AND OXIA
+1F48..1F4D    ; Greek # L&   [6] GREEK CAPITAL LETTER OMICRON WITH PSILI..GREEK CAPITAL LETTER OMICRON WITH DASIA AND OXIA
+1F50..1F57    ; Greek # L&   [8] GREEK SMALL LETTER UPSILON WITH PSILI..GREEK SMALL LETTER UPSILON WITH DASIA AND PERISPOMENI
+1F59          ; Greek # L&       GREEK CAPITAL LETTER UPSILON WITH DASIA
+1F5B          ; Greek # L&       GREEK CAPITAL LETTER UPSILON WITH DASIA AND VARIA
+1F5D          ; Greek # L&       GREEK CAPITAL LETTER UPSILON WITH DASIA AND OXIA
+1F5F..1F7D    ; Greek # L&  [31] GREEK CAPITAL LETTER UPSILON WITH DASIA AND PERISPOMENI..GREEK SMALL LETTER OMEGA WITH OXIA
+1F80..1FB4    ; Greek # L&  [53] GREEK SMALL LETTER ALPHA WITH PSILI AND YPOGEGRAMMENI..GREEK SMALL LETTER ALPHA WITH OXIA AND YPOGEGRAMMENI
+1FB6..1FBC    ; Greek # L&   [7] GREEK SMALL LETTER ALPHA WITH PERISPOMENI..GREEK CAPITAL LETTER ALPHA WITH PROSGEGRAMMENI
+1FBD          ; Greek # Sk       GREEK KORONIS
+1FBE          ; Greek # L&       GREEK PROSGEGRAMMENI
+1FBF..1FC1    ; Greek # Sk   [3] GREEK PSILI..GREEK DIALYTIKA AND PERISPOMENI
+1FC2..1FC4    ; Greek # L&   [3] GREEK SMALL LETTER ETA WITH VARIA AND YPOGEGRAMMENI..GREEK SMALL LETTER ETA WITH OXIA AND YPOGEGRAMMENI
+1FC6..1FCC    ; Greek # L&   [7] GREEK SMALL LETTER ETA WITH PERISPOMENI..GREEK CAPITAL LETTER ETA WITH PROSGEGRAMMENI
+1FCD..1FCF    ; Greek # Sk   [3] GREEK PSILI AND VARIA..GREEK PSILI AND PERISPOMENI
+1FD0..1FD3    ; Greek # L&   [4] GREEK SMALL LETTER IOTA WITH VRACHY..GREEK SMALL LETTER IOTA WITH DIALYTIKA AND OXIA
+1FD6..1FDB    ; Greek # L&   [6] GREEK SMALL LETTER IOTA WITH PERISPOMENI..GREEK CAPITAL LETTER IOTA WITH OXIA
+1FDD..1FDF    ; Greek # Sk   [3] GREEK DASIA AND VARIA..GREEK DASIA AND PERISPOMENI
+1FE0..1FEC    ; Greek # L&  [13] GREEK SMALL LETTER UPSILON WITH VRACHY..GREEK CAPITAL LETTER RHO WITH DASIA
+1FED..1FEF    ; Greek # Sk   [3] GREEK DIALYTIKA AND VARIA..GREEK VARIA
+1FF2..1FF4    ; Greek # L&   [3] GREEK SMALL LETTER OMEGA WITH VARIA AND YPOGEGRAMMENI..GREEK SMALL LETTER OMEGA WITH OXIA AND YPOGEGRAMMENI
+1FF6..1FFC    ; Greek # L&   [7] GREEK SMALL LETTER OMEGA WITH PERISPOMENI..GREEK CAPITAL LETTER OMEGA WITH PROSGEGRAMMENI
+1FFD..1FFE    ; Greek # Sk   [2] GREEK OXIA..GREEK DASIA
+2126          ; Greek # L&       OHM SIGN
+10140..10174  ; Greek # Nl  [53] GREEK ACROPHONIC ATTIC ONE QUARTER..GREEK ACROPHONIC STRATIAN FIFTY MNAS
+10175..10178  ; Greek # No   [4] GREEK ONE HALF SIGN..GREEK THREE QUARTERS SIGN
+10179..10189  ; Greek # So  [17] GREEK YEAR SIGN..GREEK TRYBLION BASE SIGN
+1018A         ; Greek # No       GREEK ZERO SIGN
+1D200..1D241  ; Greek # So  [66] GREEK VOCAL NOTATION SYMBOL-1..GREEK INSTRUMENTAL NOTATION SYMBOL-54
+1D242..1D244  ; Greek # Mn   [3] COMBINING GREEK MUSICAL TRISEME..COMBINING GREEK MUSICAL PENTASEME
+1D245         ; Greek # So       GREEK MUSICAL LEIMMA
+
+# Total code points: 511
+
+# ================================================
+
+0400..0481    ; Cyrillic # L& [130] CYRILLIC CAPITAL LETTER IE WITH GRAVE..CYRILLIC SMALL LETTER KOPPA
+0482          ; Cyrillic # So       CYRILLIC THOUSANDS SIGN
+0483..0487    ; Cyrillic # Mn   [5] COMBINING CYRILLIC TITLO..COMBINING CYRILLIC POKRYTIE
+0488..0489    ; Cyrillic # Me   [2] COMBINING CYRILLIC HUNDRED THOUSANDS SIGN..COMBINING CYRILLIC MILLIONS SIGN
+048A..0523    ; Cyrillic # L& [154] CYRILLIC CAPITAL LETTER SHORT I WITH TAIL..CYRILLIC SMALL LETTER EN WITH MIDDLE HOOK
+1D2B          ; Cyrillic # L&       CYRILLIC LETTER SMALL CAPITAL EL
+1D78          ; Cyrillic # Lm       MODIFIER LETTER CYRILLIC EN
+2DE0..2DFF    ; Cyrillic # Mn  [32] COMBINING CYRILLIC LETTER BE..COMBINING CYRILLIC LETTER IOTIFIED BIG YUS
+A640..A65F    ; Cyrillic # L&  [32] CYRILLIC CAPITAL LETTER ZEMLYA..CYRILLIC SMALL LETTER YN
+A662..A66D    ; Cyrillic # L&  [12] CYRILLIC CAPITAL LETTER SOFT DE..CYRILLIC SMALL LETTER DOUBLE MONOCULAR O
+A66E          ; Cyrillic # Lo       CYRILLIC LETTER MULTIOCULAR O
+A66F          ; Cyrillic # Mn       COMBINING CYRILLIC VZMET
+A670..A672    ; Cyrillic # Me   [3] COMBINING CYRILLIC TEN MILLIONS SIGN..COMBINING CYRILLIC THOUSAND MILLIONS SIGN
+A673          ; Cyrillic # Po       SLAVONIC ASTERISK
+A67C..A67D    ; Cyrillic # Mn   [2] COMBINING CYRILLIC KAVYKA..COMBINING CYRILLIC PAYEROK
+A67E          ; Cyrillic # Po       CYRILLIC KAVYKA
+A67F          ; Cyrillic # Lm       CYRILLIC PAYEROK
+A680..A697    ; Cyrillic # L&  [24] CYRILLIC CAPITAL LETTER DWE..CYRILLIC SMALL LETTER SHWE
+
+# Total code points: 404
+
+# ================================================
+
+0531..0556    ; Armenian # L&  [38] ARMENIAN CAPITAL LETTER AYB..ARMENIAN CAPITAL LETTER FEH
+0559          ; Armenian # Lm       ARMENIAN MODIFIER LETTER LEFT HALF RING
+055A..055F    ; Armenian # Po   [6] ARMENIAN APOSTROPHE..ARMENIAN ABBREVIATION MARK
+0561..0587    ; Armenian # L&  [39] ARMENIAN SMALL LETTER AYB..ARMENIAN SMALL LIGATURE ECH YIWN
+058A          ; Armenian # Pd       ARMENIAN HYPHEN
+FB13..FB17    ; Armenian # L&   [5] ARMENIAN SMALL LIGATURE MEN NOW..ARMENIAN SMALL LIGATURE MEN XEH
+
+# Total code points: 90
+
+# ================================================
+
+0591..05BD    ; Hebrew # Mn  [45] HEBREW ACCENT ETNAHTA..HEBREW POINT METEG
+05BE          ; Hebrew # Pd       HEBREW PUNCTUATION MAQAF
+05BF          ; Hebrew # Mn       HEBREW POINT RAFE
+05C0          ; Hebrew # Po       HEBREW PUNCTUATION PASEQ
+05C1..05C2    ; Hebrew # Mn   [2] HEBREW POINT SHIN DOT..HEBREW POINT SIN DOT
+05C3          ; Hebrew # Po       HEBREW PUNCTUATION SOF PASUQ
+05C4..05C5    ; Hebrew # Mn   [2] HEBREW MARK UPPER DOT..HEBREW MARK LOWER DOT
+05C6          ; Hebrew # Po       HEBREW PUNCTUATION NUN HAFUKHA
+05C7          ; Hebrew # Mn       HEBREW POINT QAMATS QATAN
+05D0..05EA    ; Hebrew # Lo  [27] HEBREW LETTER ALEF..HEBREW LETTER TAV
+05F0..05F2    ; Hebrew # Lo   [3] HEBREW LIGATURE YIDDISH DOUBLE VAV..HEBREW LIGATURE YIDDISH DOUBLE YOD
+05F3..05F4    ; Hebrew # Po   [2] HEBREW PUNCTUATION GERESH..HEBREW PUNCTUATION GERSHAYIM
+FB1D          ; Hebrew # Lo       HEBREW LETTER YOD WITH HIRIQ
+FB1E          ; Hebrew # Mn       HEBREW POINT JUDEO-SPANISH VARIKA
+FB1F..FB28    ; Hebrew # Lo  [10] HEBREW LIGATURE YIDDISH YOD YOD PATAH..HEBREW LETTER WIDE TAV
+FB29          ; Hebrew # Sm       HEBREW LETTER ALTERNATIVE PLUS SIGN
+FB2A..FB36    ; Hebrew # Lo  [13] HEBREW LETTER SHIN WITH SHIN DOT..HEBREW LETTER ZAYIN WITH DAGESH
+FB38..FB3C    ; Hebrew # Lo   [5] HEBREW LETTER TET WITH DAGESH..HEBREW LETTER LAMED WITH DAGESH
+FB3E          ; Hebrew # Lo       HEBREW LETTER MEM WITH DAGESH
+FB40..FB41    ; Hebrew # Lo   [2] HEBREW LETTER NUN WITH DAGESH..HEBREW LETTER SAMEKH WITH DAGESH
+FB43..FB44    ; Hebrew # Lo   [2] HEBREW LETTER FINAL PE WITH DAGESH..HEBREW LETTER PE WITH DAGESH
+FB46..FB4F    ; Hebrew # Lo  [10] HEBREW LETTER TSADI WITH DAGESH..HEBREW LIGATURE ALEF LAMED
+
+# Total code points: 133
+
+# ================================================
+
+0606..0608    ; Arabic # Sm   [3] ARABIC-INDIC CUBE ROOT..ARABIC RAY
+0609..060A    ; Arabic # Po   [2] ARABIC-INDIC PER MILLE SIGN..ARABIC-INDIC PER TEN THOUSAND SIGN
+060B          ; Arabic # Sc       AFGHANI SIGN
+060D          ; Arabic # Po       ARABIC DATE SEPARATOR
+060E..060F    ; Arabic # So   [2] ARABIC POETIC VERSE SIGN..ARABIC SIGN MISRA
+0610..061A    ; Arabic # Mn  [11] ARABIC SIGN SALLALLAHOU ALAYHE WASSALLAM..ARABIC SMALL KASRA
+061E          ; Arabic # Po       ARABIC TRIPLE DOT PUNCTUATION MARK
+0621..063F    ; Arabic # Lo  [31] ARABIC LETTER HAMZA..ARABIC LETTER FARSI YEH WITH THREE DOTS ABOVE
+0641..064A    ; Arabic # Lo  [10] ARABIC LETTER FEH..ARABIC LETTER YEH
+0656..065E    ; Arabic # Mn   [9] ARABIC SUBSCRIPT ALEF..ARABIC FATHA WITH TWO DOTS
+066A..066D    ; Arabic # Po   [4] ARABIC PERCENT SIGN..ARABIC FIVE POINTED STAR
+066E..066F    ; Arabic # Lo   [2] ARABIC LETTER DOTLESS BEH..ARABIC LETTER DOTLESS QAF
+0671..06D3    ; Arabic # Lo  [99] ARABIC LETTER ALEF WASLA..ARABIC LETTER YEH BARREE WITH HAMZA ABOVE
+06D4          ; Arabic # Po       ARABIC FULL STOP
+06D5          ; Arabic # Lo       ARABIC LETTER AE
+06D6..06DC    ; Arabic # Mn   [7] ARABIC SMALL HIGH LIGATURE SAD WITH LAM WITH ALEF MAKSURA..ARABIC SMALL HIGH SEEN
+06DE          ; Arabic # Me       ARABIC START OF RUB EL HIZB
+06DF..06E4    ; Arabic # Mn   [6] ARABIC SMALL HIGH ROUNDED ZERO..ARABIC SMALL HIGH MADDA
+06E5..06E6    ; Arabic # Lm   [2] ARABIC SMALL WAW..ARABIC SMALL YEH
+06E7..06E8    ; Arabic # Mn   [2] ARABIC SMALL HIGH YEH..ARABIC SMALL HIGH NOON
+06E9          ; Arabic # So       ARABIC PLACE OF SAJDAH
+06EA..06ED    ; Arabic # Mn   [4] ARABIC EMPTY CENTRE LOW STOP..ARABIC SMALL LOW MEEM
+06EE..06EF    ; Arabic # Lo   [2] ARABIC LETTER DAL WITH INVERTED V..ARABIC LETTER REH WITH INVERTED V
+06F0..06F9    ; Arabic # Nd  [10] EXTENDED ARABIC-INDIC DIGIT ZERO..EXTENDED ARABIC-INDIC DIGIT NINE
+06FA..06FC    ; Arabic # Lo   [3] ARABIC LETTER SHEEN WITH DOT BELOW..ARABIC LETTER GHAIN WITH DOT BELOW
+06FD..06FE    ; Arabic # So   [2] ARABIC SIGN SINDHI AMPERSAND..ARABIC SIGN SINDHI POSTPOSITION MEN
+06FF          ; Arabic # Lo       ARABIC LETTER HEH WITH INVERTED V
+0750..077F    ; Arabic # Lo  [48] ARABIC LETTER BEH WITH THREE DOTS HORIZONTALLY BELOW..ARABIC LETTER KAF WITH TWO DOTS ABOVE
+FB50..FBB1    ; Arabic # Lo  [98] ARABIC LETTER ALEF WASLA ISOLATED FORM..ARABIC LETTER YEH BARREE WITH HAMZA ABOVE FINAL FORM
+FBD3..FD3D    ; Arabic # Lo [363] ARABIC LETTER NG ISOLATED FORM..ARABIC LIGATURE ALEF WITH FATHATAN ISOLATED FORM
+FD50..FD8F    ; Arabic # Lo  [64] ARABIC LIGATURE TEH WITH JEEM WITH MEEM INITIAL FORM..ARABIC LIGATURE MEEM WITH KHAH WITH MEEM INITIAL FORM
+FD92..FDC7    ; Arabic # Lo  [54] ARABIC LIGATURE MEEM WITH JEEM WITH KHAH INITIAL FORM..ARABIC LIGATURE NOON WITH JEEM WITH YEH FINAL FORM
+FDF0..FDFB    ; Arabic # Lo  [12] ARABIC LIGATURE SALLA USED AS KORANIC STOP SIGN ISOLATED FORM..ARABIC LIGATURE JALLAJALALOUHOU
+FDFC          ; Arabic # Sc       RIAL SIGN
+FE70..FE74    ; Arabic # Lo   [5] ARABIC FATHATAN ISOLATED FORM..ARABIC KASRATAN ISOLATED FORM
+FE76..FEFC    ; Arabic # Lo [135] ARABIC FATHA ISOLATED FORM..ARABIC LIGATURE LAM WITH ALEF FINAL FORM
+
+# Total code points: 999
+
+# ================================================
+
+0700..070D    ; Syriac # Po  [14] SYRIAC END OF PARAGRAPH..SYRIAC HARKLEAN ASTERISCUS
+070F          ; Syriac # Cf       SYRIAC ABBREVIATION MARK
+0710          ; Syriac # Lo       SYRIAC LETTER ALAPH
+0711          ; Syriac # Mn       SYRIAC LETTER SUPERSCRIPT ALAPH
+0712..072F    ; Syriac # Lo  [30] SYRIAC LETTER BETH..SYRIAC LETTER PERSIAN DHALATH
+0730..074A    ; Syriac # Mn  [27] SYRIAC PTHAHA ABOVE..SYRIAC BARREKH
+074D..074F    ; Syriac # Lo   [3] SYRIAC LETTER SOGDIAN ZHAIN..SYRIAC LETTER SOGDIAN FE
+
+# Total code points: 77
+
+# ================================================
+
+0780..07A5    ; Thaana # Lo  [38] THAANA LETTER HAA..THAANA LETTER WAAVU
+07A6..07B0    ; Thaana # Mn  [11] THAANA ABAFILI..THAANA SUKUN
+07B1          ; Thaana # Lo       THAANA LETTER NAA
+
+# Total code points: 50
+
+# ================================================
+
+0901..0902    ; Devanagari # Mn   [2] DEVANAGARI SIGN CANDRABINDU..DEVANAGARI SIGN ANUSVARA
+0903          ; Devanagari # Mc       DEVANAGARI SIGN VISARGA
+0904..0939    ; Devanagari # Lo  [54] DEVANAGARI LETTER SHORT A..DEVANAGARI LETTER HA
+093C          ; Devanagari # Mn       DEVANAGARI SIGN NUKTA
+093D          ; Devanagari # Lo       DEVANAGARI SIGN AVAGRAHA
+093E..0940    ; Devanagari # Mc   [3] DEVANAGARI VOWEL SIGN AA..DEVANAGARI VOWEL SIGN II
+0941..0948    ; Devanagari # Mn   [8] DEVANAGARI VOWEL SIGN U..DEVANAGARI VOWEL SIGN AI
+0949..094C    ; Devanagari # Mc   [4] DEVANAGARI VOWEL SIGN CANDRA O..DEVANAGARI VOWEL SIGN AU
+094D          ; Devanagari # Mn       DEVANAGARI SIGN VIRAMA
+0950          ; Devanagari # Lo       DEVANAGARI OM
+0953..0954    ; Devanagari # Mn   [2] DEVANAGARI GRAVE ACCENT..DEVANAGARI ACUTE ACCENT
+0958..0961    ; Devanagari # Lo  [10] DEVANAGARI LETTER QA..DEVANAGARI LETTER VOCALIC LL
+0962..0963    ; Devanagari # Mn   [2] DEVANAGARI VOWEL SIGN VOCALIC L..DEVANAGARI VOWEL SIGN VOCALIC LL
+0966..096F    ; Devanagari # Nd  [10] DEVANAGARI DIGIT ZERO..DEVANAGARI DIGIT NINE
+0971          ; Devanagari # Lm       DEVANAGARI SIGN HIGH SPACING DOT
+0972          ; Devanagari # Lo       DEVANAGARI LETTER CANDRA A
+097B..097F    ; Devanagari # Lo   [5] DEVANAGARI LETTER GGA..DEVANAGARI LETTER BBA
+
+# Total code points: 107
+
+# ================================================
+
+0981          ; Bengali # Mn       BENGALI SIGN CANDRABINDU
+0982..0983    ; Bengali # Mc   [2] BENGALI SIGN ANUSVARA..BENGALI SIGN VISARGA
+0985..098C    ; Bengali # Lo   [8] BENGALI LETTER A..BENGALI LETTER VOCALIC L
+098F..0990    ; Bengali # Lo   [2] BENGALI LETTER E..BENGALI LETTER AI
+0993..09A8    ; Bengali # Lo  [22] BENGALI LETTER O..BENGALI LETTER NA
+09AA..09B0    ; Bengali # Lo   [7] BENGALI LETTER PA..BENGALI LETTER RA
+09B2          ; Bengali # Lo       BENGALI LETTER LA
+09B6..09B9    ; Bengali # Lo   [4] BENGALI LETTER SHA..BENGALI LETTER HA
+09BC          ; Bengali # Mn       BENGALI SIGN NUKTA
+09BD          ; Bengali # Lo       BENGALI SIGN AVAGRAHA
+09BE..09C0    ; Bengali # Mc   [3] BENGALI VOWEL SIGN AA..BENGALI VOWEL SIGN II
+09C1..09C4    ; Bengali # Mn   [4] BENGALI VOWEL SIGN U..BENGALI VOWEL SIGN VOCALIC RR
+09C7..09C8    ; Bengali # Mc   [2] BENGALI VOWEL SIGN E..BENGALI VOWEL SIGN AI
+09CB..09CC    ; Bengali # Mc   [2] BENGALI VOWEL SIGN O..BENGALI VOWEL SIGN AU
+09CD          ; Bengali # Mn       BENGALI SIGN VIRAMA
+09CE          ; Bengali # Lo       BENGALI LETTER KHANDA TA
+09D7          ; Bengali # Mc       BENGALI AU LENGTH MARK
+09DC..09DD    ; Bengali # Lo   [2] BENGALI LETTER RRA..BENGALI LETTER RHA
+09DF..09E1    ; Bengali # Lo   [3] BENGALI LETTER YYA..BENGALI LETTER VOCALIC LL
+09E2..09E3    ; Bengali # Mn   [2] BENGALI VOWEL SIGN VOCALIC L..BENGALI VOWEL SIGN VOCALIC LL
+09E6..09EF    ; Bengali # Nd  [10] BENGALI DIGIT ZERO..BENGALI DIGIT NINE
+09F0..09F1    ; Bengali # Lo   [2] BENGALI LETTER RA WITH MIDDLE DIAGONAL..BENGALI LETTER RA WITH LOWER DIAGONAL
+09F2..09F3    ; Bengali # Sc   [2] BENGALI RUPEE MARK..BENGALI RUPEE SIGN
+09F4..09F9    ; Bengali # No   [6] BENGALI CURRENCY NUMERATOR ONE..BENGALI CURRENCY DENOMINATOR SIXTEEN
+09FA          ; Bengali # So       BENGALI ISSHAR
+
+# Total code points: 91
+
+# ================================================
+
+0A01..0A02    ; Gurmukhi # Mn   [2] GURMUKHI SIGN ADAK BINDI..GURMUKHI SIGN BINDI
+0A03          ; Gurmukhi # Mc       GURMUKHI SIGN VISARGA
+0A05..0A0A    ; Gurmukhi # Lo   [6] GURMUKHI LETTER A..GURMUKHI LETTER UU
+0A0F..0A10    ; Gurmukhi # Lo   [2] GURMUKHI LETTER EE..GURMUKHI LETTER AI
+0A13..0A28    ; Gurmukhi # Lo  [22] GURMUKHI LETTER OO..GURMUKHI LETTER NA
+0A2A..0A30    ; Gurmukhi # Lo   [7] GURMUKHI LETTER PA..GURMUKHI LETTER RA
+0A32..0A33    ; Gurmukhi # Lo   [2] GURMUKHI LETTER LA..GURMUKHI LETTER LLA
+0A35..0A36    ; Gurmukhi # Lo   [2] GURMUKHI LETTER VA..GURMUKHI LETTER SHA
+0A38..0A39    ; Gurmukhi # Lo   [2] GURMUKHI LETTER SA..GURMUKHI LETTER HA
+0A3C          ; Gurmukhi # Mn       GURMUKHI SIGN NUKTA
+0A3E..0A40    ; Gurmukhi # Mc   [3] GURMUKHI VOWEL SIGN AA..GURMUKHI VOWEL SIGN II
+0A41..0A42    ; Gurmukhi # Mn   [2] GURMUKHI VOWEL SIGN U..GURMUKHI VOWEL SIGN UU
+0A47..0A48    ; Gurmukhi # Mn   [2] GURMUKHI VOWEL SIGN EE..GURMUKHI VOWEL SIGN AI
+0A4B..0A4D    ; Gurmukhi # Mn   [3] GURMUKHI VOWEL SIGN OO..GURMUKHI SIGN VIRAMA
+0A51          ; Gurmukhi # Mn       GURMUKHI SIGN UDAAT
+0A59..0A5C    ; Gurmukhi # Lo   [4] GURMUKHI LETTER KHHA..GURMUKHI LETTER RRA
+0A5E          ; Gurmukhi # Lo       GURMUKHI LETTER FA
+0A66..0A6F    ; Gurmukhi # Nd  [10] GURMUKHI DIGIT ZERO..GURMUKHI DIGIT NINE
+0A70..0A71    ; Gurmukhi # Mn   [2] GURMUKHI TIPPI..GURMUKHI ADDAK
+0A72..0A74    ; Gurmukhi # Lo   [3] GURMUKHI IRI..GURMUKHI EK ONKAR
+0A75          ; Gurmukhi # Mn       GURMUKHI SIGN YAKASH
+
+# Total code points: 79
+
+# ================================================
+
+0A81..0A82    ; Gujarati # Mn   [2] GUJARATI SIGN CANDRABINDU..GUJARATI SIGN ANUSVARA
+0A83          ; Gujarati # Mc       GUJARATI SIGN VISARGA
+0A85..0A8D    ; Gujarati # Lo   [9] GUJARATI LETTER A..GUJARATI VOWEL CANDRA E
+0A8F..0A91    ; Gujarati # Lo   [3] GUJARATI LETTER E..GUJARATI VOWEL CANDRA O
+0A93..0AA8    ; Gujarati # Lo  [22] GUJARATI LETTER O..GUJARATI LETTER NA
+0AAA..0AB0    ; Gujarati # Lo   [7] GUJARATI LETTER PA..GUJARATI LETTER RA
+0AB2..0AB3    ; Gujarati # Lo   [2] GUJARATI LETTER LA..GUJARATI LETTER LLA
+0AB5..0AB9    ; Gujarati # Lo   [5] GUJARATI LETTER VA..GUJARATI LETTER HA
+0ABC          ; Gujarati # Mn       GUJARATI SIGN NUKTA
+0ABD          ; Gujarati # Lo       GUJARATI SIGN AVAGRAHA
+0ABE..0AC0    ; Gujarati # Mc   [3] GUJARATI VOWEL SIGN AA..GUJARATI VOWEL SIGN II
+0AC1..0AC5    ; Gujarati # Mn   [5] GUJARATI VOWEL SIGN U..GUJARATI VOWEL SIGN CANDRA E
+0AC7..0AC8    ; Gujarati # Mn   [2] GUJARATI VOWEL SIGN E..GUJARATI VOWEL SIGN AI
+0AC9          ; Gujarati # Mc       GUJARATI VOWEL SIGN CANDRA O
+0ACB..0ACC    ; Gujarati # Mc   [2] GUJARATI VOWEL SIGN O..GUJARATI VOWEL SIGN AU
+0ACD          ; Gujarati # Mn       GUJARATI SIGN VIRAMA
+0AD0          ; Gujarati # Lo       GUJARATI OM
+0AE0..0AE1    ; Gujarati # Lo   [2] GUJARATI LETTER VOCALIC RR..GUJARATI LETTER VOCALIC LL
+0AE2..0AE3    ; Gujarati # Mn   [2] GUJARATI VOWEL SIGN VOCALIC L..GUJARATI VOWEL SIGN VOCALIC LL
+0AE6..0AEF    ; Gujarati # Nd  [10] GUJARATI DIGIT ZERO..GUJARATI DIGIT NINE
+0AF1          ; Gujarati # Sc       GUJARATI RUPEE SIGN
+
+# Total code points: 83
+
+# ================================================
+
+0B01          ; Oriya # Mn       ORIYA SIGN CANDRABINDU
+0B02..0B03    ; Oriya # Mc   [2] ORIYA SIGN ANUSVARA..ORIYA SIGN VISARGA
+0B05..0B0C    ; Oriya # Lo   [8] ORIYA LETTER A..ORIYA LETTER VOCALIC L
+0B0F..0B10    ; Oriya # Lo   [2] ORIYA LETTER E..ORIYA LETTER AI
+0B13..0B28    ; Oriya # Lo  [22] ORIYA LETTER O..ORIYA LETTER NA
+0B2A..0B30    ; Oriya # Lo   [7] ORIYA LETTER PA..ORIYA LETTER RA
+0B32..0B33    ; Oriya # Lo   [2] ORIYA LETTER LA..ORIYA LETTER LLA
+0B35..0B39    ; Oriya # Lo   [5] ORIYA LETTER VA..ORIYA LETTER HA
+0B3C          ; Oriya # Mn       ORIYA SIGN NUKTA
+0B3D          ; Oriya # Lo       ORIYA SIGN AVAGRAHA
+0B3E          ; Oriya # Mc       ORIYA VOWEL SIGN AA
+0B3F          ; Oriya # Mn       ORIYA VOWEL SIGN I
+0B40          ; Oriya # Mc       ORIYA VOWEL SIGN II
+0B41..0B44    ; Oriya # Mn   [4] ORIYA VOWEL SIGN U..ORIYA VOWEL SIGN VOCALIC RR
+0B47..0B48    ; Oriya # Mc   [2] ORIYA VOWEL SIGN E..ORIYA VOWEL SIGN AI
+0B4B..0B4C    ; Oriya # Mc   [2] ORIYA VOWEL SIGN O..ORIYA VOWEL SIGN AU
+0B4D          ; Oriya # Mn       ORIYA SIGN VIRAMA
+0B56          ; Oriya # Mn       ORIYA AI LENGTH MARK
+0B57          ; Oriya # Mc       ORIYA AU LENGTH MARK
+0B5C..0B5D    ; Oriya # Lo   [2] ORIYA LETTER RRA..ORIYA LETTER RHA
+0B5F..0B61    ; Oriya # Lo   [3] ORIYA LETTER YYA..ORIYA LETTER VOCALIC LL
+0B62..0B63    ; Oriya # Mn   [2] ORIYA VOWEL SIGN VOCALIC L..ORIYA VOWEL SIGN VOCALIC LL
+0B66..0B6F    ; Oriya # Nd  [10] ORIYA DIGIT ZERO..ORIYA DIGIT NINE
+0B70          ; Oriya # So       ORIYA ISSHAR
+0B71          ; Oriya # Lo       ORIYA LETTER WA
+
+# Total code points: 84
+
+# ================================================
+
+0B82          ; Tamil # Mn       TAMIL SIGN ANUSVARA
+0B83          ; Tamil # Lo       TAMIL SIGN VISARGA
+0B85..0B8A    ; Tamil # Lo   [6] TAMIL LETTER A..TAMIL LETTER UU
+0B8E..0B90    ; Tamil # Lo   [3] TAMIL LETTER E..TAMIL LETTER AI
+0B92..0B95    ; Tamil # Lo   [4] TAMIL LETTER O..TAMIL LETTER KA
+0B99..0B9A    ; Tamil # Lo   [2] TAMIL LETTER NGA..TAMIL LETTER CA
+0B9C          ; Tamil # Lo       TAMIL LETTER JA
+0B9E..0B9F    ; Tamil # Lo   [2] TAMIL LETTER NYA..TAMIL LETTER TTA
+0BA3..0BA4    ; Tamil # Lo   [2] TAMIL LETTER NNA..TAMIL LETTER TA
+0BA8..0BAA    ; Tamil # Lo   [3] TAMIL LETTER NA..TAMIL LETTER PA
+0BAE..0BB9    ; Tamil # Lo  [12] TAMIL LETTER MA..TAMIL LETTER HA
+0BBE..0BBF    ; Tamil # Mc   [2] TAMIL VOWEL SIGN AA..TAMIL VOWEL SIGN I
+0BC0          ; Tamil # Mn       TAMIL VOWEL SIGN II
+0BC1..0BC2    ; Tamil # Mc   [2] TAMIL VOWEL SIGN U..TAMIL VOWEL SIGN UU
+0BC6..0BC8    ; Tamil # Mc   [3] TAMIL VOWEL SIGN E..TAMIL VOWEL SIGN AI
+0BCA..0BCC    ; Tamil # Mc   [3] TAMIL VOWEL SIGN O..TAMIL VOWEL SIGN AU
+0BCD          ; Tamil # Mn       TAMIL SIGN VIRAMA
+0BD0          ; Tamil # Lo       TAMIL OM
+0BD7          ; Tamil # Mc       TAMIL AU LENGTH MARK
+0BE6..0BEF    ; Tamil # Nd  [10] TAMIL DIGIT ZERO..TAMIL DIGIT NINE
+0BF0..0BF2    ; Tamil # No   [3] TAMIL NUMBER TEN..TAMIL NUMBER ONE THOUSAND
+0BF3..0BF8    ; Tamil # So   [6] TAMIL DAY SIGN..TAMIL AS ABOVE SIGN
+0BF9          ; Tamil # Sc       TAMIL RUPEE SIGN
+0BFA          ; Tamil # So       TAMIL NUMBER SIGN
+
+# Total code points: 72
+
+# ================================================
+
+0C01..0C03    ; Telugu # Mc   [3] TELUGU SIGN CANDRABINDU..TELUGU SIGN VISARGA
+0C05..0C0C    ; Telugu # Lo   [8] TELUGU LETTER A..TELUGU LETTER VOCALIC L
+0C0E..0C10    ; Telugu # Lo   [3] TELUGU LETTER E..TELUGU LETTER AI
+0C12..0C28    ; Telugu # Lo  [23] TELUGU LETTER O..TELUGU LETTER NA
+0C2A..0C33    ; Telugu # Lo  [10] TELUGU LETTER PA..TELUGU LETTER LLA
+0C35..0C39    ; Telugu # Lo   [5] TELUGU LETTER VA..TELUGU LETTER HA
+0C3D          ; Telugu # Lo       TELUGU SIGN AVAGRAHA
+0C3E..0C40    ; Telugu # Mn   [3] TELUGU VOWEL SIGN AA..TELUGU VOWEL SIGN II
+0C41..0C44    ; Telugu # Mc   [4] TELUGU VOWEL SIGN U..TELUGU VOWEL SIGN VOCALIC RR
+0C46..0C48    ; Telugu # Mn   [3] TELUGU VOWEL SIGN E..TELUGU VOWEL SIGN AI
+0C4A..0C4D    ; Telugu # Mn   [4] TELUGU VOWEL SIGN O..TELUGU SIGN VIRAMA
+0C55..0C56    ; Telugu # Mn   [2] TELUGU LENGTH MARK..TELUGU AI LENGTH MARK
+0C58..0C59    ; Telugu # Lo   [2] TELUGU LETTER TSA..TELUGU LETTER DZA
+0C60..0C61    ; Telugu # Lo   [2] TELUGU LETTER VOCALIC RR..TELUGU LETTER VOCALIC LL
+0C62..0C63    ; Telugu # Mn   [2] TELUGU VOWEL SIGN VOCALIC L..TELUGU VOWEL SIGN VOCALIC LL
+0C66..0C6F    ; Telugu # Nd  [10] TELUGU DIGIT ZERO..TELUGU DIGIT NINE
+0C78..0C7E    ; Telugu # No   [7] TELUGU FRACTION DIGIT ZERO FOR ODD POWERS OF FOUR..TELUGU FRACTION DIGIT THREE FOR EVEN POWERS OF FOUR
+0C7F          ; Telugu # So       TELUGU SIGN TUUMU
+
+# Total code points: 93
+
+# ================================================
+
+0C82..0C83    ; Kannada # Mc   [2] KANNADA SIGN ANUSVARA..KANNADA SIGN VISARGA
+0C85..0C8C    ; Kannada # Lo   [8] KANNADA LETTER A..KANNADA LETTER VOCALIC L
+0C8E..0C90    ; Kannada # Lo   [3] KANNADA LETTER E..KANNADA LETTER AI
+0C92..0CA8    ; Kannada # Lo  [23] KANNADA LETTER O..KANNADA LETTER NA
+0CAA..0CB3    ; Kannada # Lo  [10] KANNADA LETTER PA..KANNADA LETTER LLA
+0CB5..0CB9    ; Kannada # Lo   [5] KANNADA LETTER VA..KANNADA LETTER HA
+0CBC          ; Kannada # Mn       KANNADA SIGN NUKTA
+0CBD          ; Kannada # Lo       KANNADA SIGN AVAGRAHA
+0CBE          ; Kannada # Mc       KANNADA VOWEL SIGN AA
+0CBF          ; Kannada # Mn       KANNADA VOWEL SIGN I
+0CC0..0CC4    ; Kannada # Mc   [5] KANNADA VOWEL SIGN II..KANNADA VOWEL SIGN VOCALIC RR
+0CC6          ; Kannada # Mn       KANNADA VOWEL SIGN E
+0CC7..0CC8    ; Kannada # Mc   [2] KANNADA VOWEL SIGN EE..KANNADA VOWEL SIGN AI
+0CCA..0CCB    ; Kannada # Mc   [2] KANNADA VOWEL SIGN O..KANNADA VOWEL SIGN OO
+0CCC..0CCD    ; Kannada # Mn   [2] KANNADA VOWEL SIGN AU..KANNADA SIGN VIRAMA
+0CD5..0CD6    ; Kannada # Mc   [2] KANNADA LENGTH MARK..KANNADA AI LENGTH MARK
+0CDE          ; Kannada # Lo       KANNADA LETTER FA
+0CE0..0CE1    ; Kannada # Lo   [2] KANNADA LETTER VOCALIC RR..KANNADA LETTER VOCALIC LL
+0CE2..0CE3    ; Kannada # Mn   [2] KANNADA VOWEL SIGN VOCALIC L..KANNADA VOWEL SIGN VOCALIC LL
+0CE6..0CEF    ; Kannada # Nd  [10] KANNADA DIGIT ZERO..KANNADA DIGIT NINE
+
+# Total code points: 84
+
+# ================================================
+
+0D02..0D03    ; Malayalam # Mc   [2] MALAYALAM SIGN ANUSVARA..MALAYALAM SIGN VISARGA
+0D05..0D0C    ; Malayalam # Lo   [8] MALAYALAM LETTER A..MALAYALAM LETTER VOCALIC L
+0D0E..0D10    ; Malayalam # Lo   [3] MALAYALAM LETTER E..MALAYALAM LETTER AI
+0D12..0D28    ; Malayalam # Lo  [23] MALAYALAM LETTER O..MALAYALAM LETTER NA
+0D2A..0D39    ; Malayalam # Lo  [16] MALAYALAM LETTER PA..MALAYALAM LETTER HA
+0D3D          ; Malayalam # Lo       MALAYALAM SIGN AVAGRAHA
+0D3E..0D40    ; Malayalam # Mc   [3] MALAYALAM VOWEL SIGN AA..MALAYALAM VOWEL SIGN II
+0D41..0D44    ; Malayalam # Mn   [4] MALAYALAM VOWEL SIGN U..MALAYALAM VOWEL SIGN VOCALIC RR
+0D46..0D48    ; Malayalam # Mc   [3] MALAYALAM VOWEL SIGN E..MALAYALAM VOWEL SIGN AI
+0D4A..0D4C    ; Malayalam # Mc   [3] MALAYALAM VOWEL SIGN O..MALAYALAM VOWEL SIGN AU
+0D4D          ; Malayalam # Mn       MALAYALAM SIGN VIRAMA
+0D57          ; Malayalam # Mc       MALAYALAM AU LENGTH MARK
+0D60..0D61    ; Malayalam # Lo   [2] MALAYALAM LETTER VOCALIC RR..MALAYALAM LETTER VOCALIC LL
+0D62..0D63    ; Malayalam # Mn   [2] MALAYALAM VOWEL SIGN VOCALIC L..MALAYALAM VOWEL SIGN VOCALIC LL
+0D66..0D6F    ; Malayalam # Nd  [10] MALAYALAM DIGIT ZERO..MALAYALAM DIGIT NINE
+0D70..0D75    ; Malayalam # No   [6] MALAYALAM NUMBER TEN..MALAYALAM FRACTION THREE QUARTERS
+0D79          ; Malayalam # So       MALAYALAM DATE MARK
+0D7A..0D7F    ; Malayalam # Lo   [6] MALAYALAM LETTER CHILLU NN..MALAYALAM LETTER CHILLU K
+
+# Total code points: 95
+
+# ================================================
+
+0D82..0D83    ; Sinhala # Mc   [2] SINHALA SIGN ANUSVARAYA..SINHALA SIGN VISARGAYA
+0D85..0D96    ; Sinhala # Lo  [18] SINHALA LETTER AYANNA..SINHALA LETTER AUYANNA
+0D9A..0DB1    ; Sinhala # Lo  [24] SINHALA LETTER ALPAPRAANA KAYANNA..SINHALA LETTER DANTAJA NAYANNA
+0DB3..0DBB    ; Sinhala # Lo   [9] SINHALA LETTER SANYAKA DAYANNA..SINHALA LETTER RAYANNA
+0DBD          ; Sinhala # Lo       SINHALA LETTER DANTAJA LAYANNA
+0DC0..0DC6    ; Sinhala # Lo   [7] SINHALA LETTER VAYANNA..SINHALA LETTER FAYANNA
+0DCA          ; Sinhala # Mn       SINHALA SIGN AL-LAKUNA
+0DCF..0DD1    ; Sinhala # Mc   [3] SINHALA VOWEL SIGN AELA-PILLA..SINHALA VOWEL SIGN DIGA AEDA-PILLA
+0DD2..0DD4    ; Sinhala # Mn   [3] SINHALA VOWEL SIGN KETTI IS-PILLA..SINHALA VOWEL SIGN KETTI PAA-PILLA
+0DD6          ; Sinhala # Mn       SINHALA VOWEL SIGN DIGA PAA-PILLA
+0DD8..0DDF    ; Sinhala # Mc   [8] SINHALA VOWEL SIGN GAETTA-PILLA..SINHALA VOWEL SIGN GAYANUKITTA
+0DF2..0DF3    ; Sinhala # Mc   [2] SINHALA VOWEL SIGN DIGA GAETTA-PILLA..SINHALA VOWEL SIGN DIGA GAYANUKITTA
+0DF4          ; Sinhala # Po       SINHALA PUNCTUATION KUNDDALIYA
+
+# Total code points: 80
+
+# ================================================
+
+0E01..0E30    ; Thai # Lo  [48] THAI CHARACTER KO KAI..THAI CHARACTER SARA A
+0E31          ; Thai # Mn       THAI CHARACTER MAI HAN-AKAT
+0E32..0E33    ; Thai # Lo   [2] THAI CHARACTER SARA AA..THAI CHARACTER SARA AM
+0E34..0E3A    ; Thai # Mn   [7] THAI CHARACTER SARA I..THAI CHARACTER PHINTHU
+0E40..0E45    ; Thai # Lo   [6] THAI CHARACTER SARA E..THAI CHARACTER LAKKHANGYAO
+0E46          ; Thai # Lm       THAI CHARACTER MAIYAMOK
+0E47..0E4E    ; Thai # Mn   [8] THAI CHARACTER MAITAIKHU..THAI CHARACTER YAMAKKAN
+0E4F          ; Thai # Po       THAI CHARACTER FONGMAN
+0E50..0E59    ; Thai # Nd  [10] THAI DIGIT ZERO..THAI DIGIT NINE
+0E5A..0E5B    ; Thai # Po   [2] THAI CHARACTER ANGKHANKHU..THAI CHARACTER KHOMUT
+
+# Total code points: 86
+
+# ================================================
+
+0E81..0E82    ; Lao # Lo   [2] LAO LETTER KO..LAO LETTER KHO SUNG
+0E84          ; Lao # Lo       LAO LETTER KHO TAM
+0E87..0E88    ; Lao # Lo   [2] LAO LETTER NGO..LAO LETTER CO
+0E8A          ; Lao # Lo       LAO LETTER SO TAM
+0E8D          ; Lao # Lo       LAO LETTER NYO
+0E94..0E97    ; Lao # Lo   [4] LAO LETTER DO..LAO LETTER THO TAM
+0E99..0E9F    ; Lao # Lo   [7] LAO LETTER NO..LAO LETTER FO SUNG
+0EA1..0EA3    ; Lao # Lo   [3] LAO LETTER MO..LAO LETTER LO LING
+0EA5          ; Lao # Lo       LAO LETTER LO LOOT
+0EA7          ; Lao # Lo       LAO LETTER WO
+0EAA..0EAB    ; Lao # Lo   [2] LAO LETTER SO SUNG..LAO LETTER HO SUNG
+0EAD..0EB0    ; Lao # Lo   [4] LAO LETTER O..LAO VOWEL SIGN A
+0EB1          ; Lao # Mn       LAO VOWEL SIGN MAI KAN
+0EB2..0EB3    ; Lao # Lo   [2] LAO VOWEL SIGN AA..LAO VOWEL SIGN AM
+0EB4..0EB9    ; Lao # Mn   [6] LAO VOWEL SIGN I..LAO VOWEL SIGN UU
+0EBB..0EBC    ; Lao # Mn   [2] LAO VOWEL SIGN MAI KON..LAO SEMIVOWEL SIGN LO
+0EBD          ; Lao # Lo       LAO SEMIVOWEL SIGN NYO
+0EC0..0EC4    ; Lao # Lo   [5] LAO VOWEL SIGN E..LAO VOWEL SIGN AI
+0EC6          ; Lao # Lm       LAO KO LA
+0EC8..0ECD    ; Lao # Mn   [6] LAO TONE MAI EK..LAO NIGGAHITA
+0ED0..0ED9    ; Lao # Nd  [10] LAO DIGIT ZERO..LAO DIGIT NINE
+0EDC..0EDD    ; Lao # Lo   [2] LAO HO NO..LAO HO MO
+
+# Total code points: 65
+
+# ================================================
+
+0F00          ; Tibetan # Lo       TIBETAN SYLLABLE OM
+0F01..0F03    ; Tibetan # So   [3] TIBETAN MARK GTER YIG MGO TRUNCATED A..TIBETAN MARK GTER YIG MGO -UM GTER TSHEG MA
+0F04..0F12    ; Tibetan # Po  [15] TIBETAN MARK INITIAL YIG MGO MDUN MA..TIBETAN MARK RGYA GRAM SHAD
+0F13..0F17    ; Tibetan # So   [5] TIBETAN MARK CARET -DZUD RTAGS ME LONG CAN..TIBETAN ASTROLOGICAL SIGN SGRA GCAN -CHAR RTAGS
+0F18..0F19    ; Tibetan # Mn   [2] TIBETAN ASTROLOGICAL SIGN -KHYUD PA..TIBETAN ASTROLOGICAL SIGN SDONG TSHUGS
+0F1A..0F1F    ; Tibetan # So   [6] TIBETAN SIGN RDEL DKAR GCIG..TIBETAN SIGN RDEL DKAR RDEL NAG
+0F20..0F29    ; Tibetan # Nd  [10] TIBETAN DIGIT ZERO..TIBETAN DIGIT NINE
+0F2A..0F33    ; Tibetan # No  [10] TIBETAN DIGIT HALF ONE..TIBETAN DIGIT HALF ZERO
+0F34          ; Tibetan # So       TIBETAN MARK BSDUS RTAGS
+0F35          ; Tibetan # Mn       TIBETAN MARK NGAS BZUNG NYI ZLA
+0F36          ; Tibetan # So       TIBETAN MARK CARET -DZUD RTAGS BZHI MIG CAN
+0F37          ; Tibetan # Mn       TIBETAN MARK NGAS BZUNG SGOR RTAGS
+0F38          ; Tibetan # So       TIBETAN MARK CHE MGO
+0F39          ; Tibetan # Mn       TIBETAN MARK TSA -PHRU
+0F3A          ; Tibetan # Ps       TIBETAN MARK GUG RTAGS GYON
+0F3B          ; Tibetan # Pe       TIBETAN MARK GUG RTAGS GYAS
+0F3C          ; Tibetan # Ps       TIBETAN MARK ANG KHANG GYON
+0F3D          ; Tibetan # Pe       TIBETAN MARK ANG KHANG GYAS
+0F3E..0F3F    ; Tibetan # Mc   [2] TIBETAN SIGN YAR TSHES..TIBETAN SIGN MAR TSHES
+0F40..0F47    ; Tibetan # Lo   [8] TIBETAN LETTER KA..TIBETAN LETTER JA
+0F49..0F6C    ; Tibetan # Lo  [36] TIBETAN LETTER NYA..TIBETAN LETTER RRA
+0F71..0F7E    ; Tibetan # Mn  [14] TIBETAN VOWEL SIGN AA..TIBETAN SIGN RJES SU NGA RO
+0F7F          ; Tibetan # Mc       TIBETAN SIGN RNAM BCAD
+0F80..0F84    ; Tibetan # Mn   [5] TIBETAN VOWEL SIGN REVERSED I..TIBETAN MARK HALANTA
+0F85          ; Tibetan # Po       TIBETAN MARK PALUTA
+0F86..0F87    ; Tibetan # Mn   [2] TIBETAN SIGN LCI RTAGS..TIBETAN SIGN YANG RTAGS
+0F88..0F8B    ; Tibetan # Lo   [4] TIBETAN SIGN LCE TSA CAN..TIBETAN SIGN GRU MED RGYINGS
+0F90..0F97    ; Tibetan # Mn   [8] TIBETAN SUBJOINED LETTER KA..TIBETAN SUBJOINED LETTER JA
+0F99..0FBC    ; Tibetan # Mn  [36] TIBETAN SUBJOINED LETTER NYA..TIBETAN SUBJOINED LETTER FIXED-FORM RA
+0FBE..0FC5    ; Tibetan # So   [8] TIBETAN KU RU KHA..TIBETAN SYMBOL RDO RJE
+0FC6          ; Tibetan # Mn       TIBETAN SYMBOL PADMA GDAN
+0FC7..0FCC    ; Tibetan # So   [6] TIBETAN SYMBOL RDO RJE RGYA GRAM..TIBETAN SYMBOL NOR BU BZHI -KHYIL
+0FCE..0FCF    ; Tibetan # So   [2] TIBETAN SIGN RDEL NAG RDEL DKAR..TIBETAN SIGN RDEL NAG GSUM
+0FD0..0FD4    ; Tibetan # Po   [5] TIBETAN MARK BSKA- SHOG GI MGO RGYAN..TIBETAN MARK CLOSING BRDA RNYING YIG MGO SGAB MA
+
+# Total code points: 201
+
+# ================================================
+
+1000..102A    ; Myanmar # Lo  [43] MYANMAR LETTER KA..MYANMAR LETTER AU
+102B..102C    ; Myanmar # Mc   [2] MYANMAR VOWEL SIGN TALL AA..MYANMAR VOWEL SIGN AA
+102D..1030    ; Myanmar # Mn   [4] MYANMAR VOWEL SIGN I..MYANMAR VOWEL SIGN UU
+1031          ; Myanmar # Mc       MYANMAR VOWEL SIGN E
+1032..1037    ; Myanmar # Mn   [6] MYANMAR VOWEL SIGN AI..MYANMAR SIGN DOT BELOW
+1038          ; Myanmar # Mc       MYANMAR SIGN VISARGA
+1039..103A    ; Myanmar # Mn   [2] MYANMAR SIGN VIRAMA..MYANMAR SIGN ASAT
+103B..103C    ; Myanmar # Mc   [2] MYANMAR CONSONANT SIGN MEDIAL YA..MYANMAR CONSONANT SIGN MEDIAL RA
+103D..103E    ; Myanmar # Mn   [2] MYANMAR CONSONANT SIGN MEDIAL WA..MYANMAR CONSONANT SIGN MEDIAL HA
+103F          ; Myanmar # Lo       MYANMAR LETTER GREAT SA
+1040..1049    ; Myanmar # Nd  [10] MYANMAR DIGIT ZERO..MYANMAR DIGIT NINE
+104A..104F    ; Myanmar # Po   [6] MYANMAR SIGN LITTLE SECTION..MYANMAR SYMBOL GENITIVE
+1050..1055    ; Myanmar # Lo   [6] MYANMAR LETTER SHA..MYANMAR LETTER VOCALIC LL
+1056..1057    ; Myanmar # Mc   [2] MYANMAR VOWEL SIGN VOCALIC R..MYANMAR VOWEL SIGN VOCALIC RR
+1058..1059    ; Myanmar # Mn   [2] MYANMAR VOWEL SIGN VOCALIC L..MYANMAR VOWEL SIGN VOCALIC LL
+105A..105D    ; Myanmar # Lo   [4] MYANMAR LETTER MON NGA..MYANMAR LETTER MON BBE
+105E..1060    ; Myanmar # Mn   [3] MYANMAR CONSONANT SIGN MON MEDIAL NA..MYANMAR CONSONANT SIGN MON MEDIAL LA
+1061          ; Myanmar # Lo       MYANMAR LETTER SGAW KAREN SHA
+1062..1064    ; Myanmar # Mc   [3] MYANMAR VOWEL SIGN SGAW KAREN EU..MYANMAR TONE MARK SGAW KAREN KE PHO
+1065..1066    ; Myanmar # Lo   [2] MYANMAR LETTER WESTERN PWO KAREN THA..MYANMAR LETTER WESTERN PWO KAREN PWA
+1067..106D    ; Myanmar # Mc   [7] MYANMAR VOWEL SIGN WESTERN PWO KAREN EU..MYANMAR SIGN WESTERN PWO KAREN TONE-5
+106E..1070    ; Myanmar # Lo   [3] MYANMAR LETTER EASTERN PWO KAREN NNA..MYANMAR LETTER EASTERN PWO KAREN GHWA
+1071..1074    ; Myanmar # Mn   [4] MYANMAR VOWEL SIGN GEBA KAREN I..MYANMAR VOWEL SIGN KAYAH EE
+1075..1081    ; Myanmar # Lo  [13] MYANMAR LETTER SHAN KA..MYANMAR LETTER SHAN HA
+1082          ; Myanmar # Mn       MYANMAR CONSONANT SIGN SHAN MEDIAL WA
+1083..1084    ; Myanmar # Mc   [2] MYANMAR VOWEL SIGN SHAN AA..MYANMAR VOWEL SIGN SHAN E
+1085..1086    ; Myanmar # Mn   [2] MYANMAR VOWEL SIGN SHAN E ABOVE..MYANMAR VOWEL SIGN SHAN FINAL Y
+1087..108C    ; Myanmar # Mc   [6] MYANMAR SIGN SHAN TONE-2..MYANMAR SIGN SHAN COUNCIL TONE-3
+108D          ; Myanmar # Mn       MYANMAR SIGN SHAN COUNCIL EMPHATIC TONE
+108E          ; Myanmar # Lo       MYANMAR LETTER RUMAI PALAUNG FA
+108F          ; Myanmar # Mc       MYANMAR SIGN RUMAI PALAUNG TONE-5
+1090..1099    ; Myanmar # Nd  [10] MYANMAR SHAN DIGIT ZERO..MYANMAR SHAN DIGIT NINE
+109E..109F    ; Myanmar # So   [2] MYANMAR SYMBOL SHAN ONE..MYANMAR SYMBOL SHAN EXCLAMATION
+
+# Total code points: 156
+
+# ================================================
+
+10A0..10C5    ; Georgian # L&  [38] GEORGIAN CAPITAL LETTER AN..GEORGIAN CAPITAL LETTER HOE
+10D0..10FA    ; Georgian # Lo  [43] GEORGIAN LETTER AN..GEORGIAN LETTER AIN
+10FC          ; Georgian # Lm       MODIFIER LETTER GEORGIAN NAR
+2D00..2D25    ; Georgian # L&  [38] GEORGIAN SMALL LETTER AN..GEORGIAN SMALL LETTER HOE
+
+# Total code points: 120
+
+# ================================================
+
+1100..1159    ; Hangul # Lo  [90] HANGUL CHOSEONG KIYEOK..HANGUL CHOSEONG YEORINHIEUH
+115F..11A2    ; Hangul # Lo  [68] HANGUL CHOSEONG FILLER..HANGUL JUNGSEONG SSANGARAEA
+11A8..11F9    ; Hangul # Lo  [82] HANGUL JONGSEONG KIYEOK..HANGUL JONGSEONG YEORINHIEUH
+3131..318E    ; Hangul # Lo  [94] HANGUL LETTER KIYEOK..HANGUL LETTER ARAEAE
+3200..321E    ; Hangul # So  [31] PARENTHESIZED HANGUL KIYEOK..PARENTHESIZED KOREAN CHARACTER O HU
+3260..327E    ; Hangul # So  [31] CIRCLED HANGUL KIYEOK..CIRCLED HANGUL IEUNG U
+AC00..D7A3    ; Hangul # Lo [11172] HANGUL SYLLABLE GA..HANGUL SYLLABLE HIH
+FFA0..FFBE    ; Hangul # Lo  [31] HALFWIDTH HANGUL FILLER..HALFWIDTH HANGUL LETTER HIEUH
+FFC2..FFC7    ; Hangul # Lo   [6] HALFWIDTH HANGUL LETTER A..HALFWIDTH HANGUL LETTER E
+FFCA..FFCF    ; Hangul # Lo   [6] HALFWIDTH HANGUL LETTER YEO..HALFWIDTH HANGUL LETTER OE
+FFD2..FFD7    ; Hangul # Lo   [6] HALFWIDTH HANGUL LETTER YO..HALFWIDTH HANGUL LETTER YU
+FFDA..FFDC    ; Hangul # Lo   [3] HALFWIDTH HANGUL LETTER EU..HALFWIDTH HANGUL LETTER I
+
+# Total code points: 11620
+
+# ================================================
+
+1200..1248    ; Ethiopic # Lo  [73] ETHIOPIC SYLLABLE HA..ETHIOPIC SYLLABLE QWA
+124A..124D    ; Ethiopic # Lo   [4] ETHIOPIC SYLLABLE QWI..ETHIOPIC SYLLABLE QWE
+1250..1256    ; Ethiopic # Lo   [7] ETHIOPIC SYLLABLE QHA..ETHIOPIC SYLLABLE QHO
+1258          ; Ethiopic # Lo       ETHIOPIC SYLLABLE QHWA
+125A..125D    ; Ethiopic # Lo   [4] ETHIOPIC SYLLABLE QHWI..ETHIOPIC SYLLABLE QHWE
+1260..1288    ; Ethiopic # Lo  [41] ETHIOPIC SYLLABLE BA..ETHIOPIC SYLLABLE XWA
+128A..128D    ; Ethiopic # Lo   [4] ETHIOPIC SYLLABLE XWI..ETHIOPIC SYLLABLE XWE
+1290..12B0    ; Ethiopic # Lo  [33] ETHIOPIC SYLLABLE NA..ETHIOPIC SYLLABLE KWA
+12B2..12B5    ; Ethiopic # Lo   [4] ETHIOPIC SYLLABLE KWI..ETHIOPIC SYLLABLE KWE
+12B8..12BE    ; Ethiopic # Lo   [7] ETHIOPIC SYLLABLE KXA..ETHIOPIC SYLLABLE KXO
+12C0          ; Ethiopic # Lo       ETHIOPIC SYLLABLE KXWA
+12C2..12C5    ; Ethiopic # Lo   [4] ETHIOPIC SYLLABLE KXWI..ETHIOPIC SYLLABLE KXWE
+12C8..12D6    ; Ethiopic # Lo  [15] ETHIOPIC SYLLABLE WA..ETHIOPIC SYLLABLE PHARYNGEAL O
+12D8..1310    ; Ethiopic # Lo  [57] ETHIOPIC SYLLABLE ZA..ETHIOPIC SYLLABLE GWA
+1312..1315    ; Ethiopic # Lo   [4] ETHIOPIC SYLLABLE GWI..ETHIOPIC SYLLABLE GWE
+1318..135A    ; Ethiopic # Lo  [67] ETHIOPIC SYLLABLE GGA..ETHIOPIC SYLLABLE FYA
+135F          ; Ethiopic # Mn       ETHIOPIC COMBINING GEMINATION MARK
+1360          ; Ethiopic # So       ETHIOPIC SECTION MARK
+1361..1368    ; Ethiopic # Po   [8] ETHIOPIC WORDSPACE..ETHIOPIC PARAGRAPH SEPARATOR
+1369..137C    ; Ethiopic # No  [20] ETHIOPIC DIGIT ONE..ETHIOPIC NUMBER TEN THOUSAND
+1380..138F    ; Ethiopic # Lo  [16] ETHIOPIC SYLLABLE SEBATBEIT MWA..ETHIOPIC SYLLABLE PWE
+1390..1399    ; Ethiopic # So  [10] ETHIOPIC TONAL MARK YIZET..ETHIOPIC TONAL MARK KURT
+2D80..2D96    ; Ethiopic # Lo  [23] ETHIOPIC SYLLABLE LOA..ETHIOPIC SYLLABLE GGWE
+2DA0..2DA6    ; Ethiopic # Lo   [7] ETHIOPIC SYLLABLE SSA..ETHIOPIC SYLLABLE SSO
+2DA8..2DAE    ; Ethiopic # Lo   [7] ETHIOPIC SYLLABLE CCA..ETHIOPIC SYLLABLE CCO
+2DB0..2DB6    ; Ethiopic # Lo   [7] ETHIOPIC SYLLABLE ZZA..ETHIOPIC SYLLABLE ZZO
+2DB8..2DBE    ; Ethiopic # Lo   [7] ETHIOPIC SYLLABLE CCHA..ETHIOPIC SYLLABLE CCHO
+2DC0..2DC6    ; Ethiopic # Lo   [7] ETHIOPIC SYLLABLE QYA..ETHIOPIC SYLLABLE QYO
+2DC8..2DCE    ; Ethiopic # Lo   [7] ETHIOPIC SYLLABLE KYA..ETHIOPIC SYLLABLE KYO
+2DD0..2DD6    ; Ethiopic # Lo   [7] ETHIOPIC SYLLABLE XYA..ETHIOPIC SYLLABLE XYO
+2DD8..2DDE    ; Ethiopic # Lo   [7] ETHIOPIC SYLLABLE GYA..ETHIOPIC SYLLABLE GYO
+
+# Total code points: 461
+
+# ================================================
+
+13A0..13F4    ; Cherokee # Lo  [85] CHEROKEE LETTER A..CHEROKEE LETTER YV
+
+# Total code points: 85
+
+# ================================================
+
+1401..166C    ; Canadian_Aboriginal # Lo [620] CANADIAN SYLLABICS E..CANADIAN SYLLABICS CARRIER TTSA
+166D..166E    ; Canadian_Aboriginal # Po   [2] CANADIAN SYLLABICS CHI SIGN..CANADIAN SYLLABICS FULL STOP
+166F..1676    ; Canadian_Aboriginal # Lo   [8] CANADIAN SYLLABICS QAI..CANADIAN SYLLABICS NNGAA
+
+# Total code points: 630
+
+# ================================================
+
+1680          ; Ogham # Zs       OGHAM SPACE MARK
+1681..169A    ; Ogham # Lo  [26] OGHAM LETTER BEITH..OGHAM LETTER PEITH
+169B          ; Ogham # Ps       OGHAM FEATHER MARK
+169C          ; Ogham # Pe       OGHAM REVERSED FEATHER MARK
+
+# Total code points: 29
+
+# ================================================
+
+16A0..16EA    ; Runic # Lo  [75] RUNIC LETTER FEHU FEOH FE F..RUNIC LETTER X
+16EE..16F0    ; Runic # Nl   [3] RUNIC ARLAUG SYMBOL..RUNIC BELGTHOR SYMBOL
+
+# Total code points: 78
+
+# ================================================
+
+1780..17B3    ; Khmer # Lo  [52] KHMER LETTER KA..KHMER INDEPENDENT VOWEL QAU
+17B4..17B5    ; Khmer # Cf   [2] KHMER VOWEL INHERENT AQ..KHMER VOWEL INHERENT AA
+17B6          ; Khmer # Mc       KHMER VOWEL SIGN AA
+17B7..17BD    ; Khmer # Mn   [7] KHMER VOWEL SIGN I..KHMER VOWEL SIGN UA
+17BE..17C5    ; Khmer # Mc   [8] KHMER VOWEL SIGN OE..KHMER VOWEL SIGN AU
+17C6          ; Khmer # Mn       KHMER SIGN NIKAHIT
+17C7..17C8    ; Khmer # Mc   [2] KHMER SIGN REAHMUK..KHMER SIGN YUUKALEAPINTU
+17C9..17D3    ; Khmer # Mn  [11] KHMER SIGN MUUSIKATOAN..KHMER SIGN BATHAMASAT
+17D4..17D6    ; Khmer # Po   [3] KHMER SIGN KHAN..KHMER SIGN CAMNUC PII KUUH
+17D7          ; Khmer # Lm       KHMER SIGN LEK TOO
+17D8..17DA    ; Khmer # Po   [3] KHMER SIGN BEYYAL..KHMER SIGN KOOMUUT
+17DB          ; Khmer # Sc       KHMER CURRENCY SYMBOL RIEL
+17DC          ; Khmer # Lo       KHMER SIGN AVAKRAHASANYA
+17DD          ; Khmer # Mn       KHMER SIGN ATTHACAN
+17E0..17E9    ; Khmer # Nd  [10] KHMER DIGIT ZERO..KHMER DIGIT NINE
+17F0..17F9    ; Khmer # No  [10] KHMER SYMBOL LEK ATTAK SON..KHMER SYMBOL LEK ATTAK PRAM-BUON
+19E0..19FF    ; Khmer # So  [32] KHMER SYMBOL PATHAMASAT..KHMER SYMBOL DAP-PRAM ROC
+
+# Total code points: 146
+
+# ================================================
+
+1800..1801    ; Mongolian # Po   [2] MONGOLIAN BIRGA..MONGOLIAN ELLIPSIS
+1804          ; Mongolian # Po       MONGOLIAN COLON
+1806          ; Mongolian # Pd       MONGOLIAN TODO SOFT HYPHEN
+1807..180A    ; Mongolian # Po   [4] MONGOLIAN SIBE SYLLABLE BOUNDARY MARKER..MONGOLIAN NIRUGU
+180B..180D    ; Mongolian # Mn   [3] MONGOLIAN FREE VARIATION SELECTOR ONE..MONGOLIAN FREE VARIATION SELECTOR THREE
+180E          ; Mongolian # Zs       MONGOLIAN VOWEL SEPARATOR
+1810..1819    ; Mongolian # Nd  [10] MONGOLIAN DIGIT ZERO..MONGOLIAN DIGIT NINE
+1820..1842    ; Mongolian # Lo  [35] MONGOLIAN LETTER A..MONGOLIAN LETTER CHI
+1843          ; Mongolian # Lm       MONGOLIAN LETTER TODO LONG VOWEL SIGN
+1844..1877    ; Mongolian # Lo  [52] MONGOLIAN LETTER TODO E..MONGOLIAN LETTER MANCHU ZHA
+1880..18A8    ; Mongolian # Lo  [41] MONGOLIAN LETTER ALI GALI ANUSVARA ONE..MONGOLIAN LETTER MANCHU ALI GALI BHA
+18A9          ; Mongolian # Mn       MONGOLIAN LETTER ALI GALI DAGALGA
+18AA          ; Mongolian # Lo       MONGOLIAN LETTER MANCHU ALI GALI LHA
+
+# Total code points: 153
+
+# ================================================
+
+3041..3096    ; Hiragana # Lo  [86] HIRAGANA LETTER SMALL A..HIRAGANA LETTER SMALL KE
+309D..309E    ; Hiragana # Lm   [2] HIRAGANA ITERATION MARK..HIRAGANA VOICED ITERATION MARK
+309F          ; Hiragana # Lo       HIRAGANA DIGRAPH YORI
+
+# Total code points: 89
+
+# ================================================
+
+30A1..30FA    ; Katakana # Lo  [90] KATAKANA LETTER SMALL A..KATAKANA LETTER VO
+30FD..30FE    ; Katakana # Lm   [2] KATAKANA ITERATION MARK..KATAKANA VOICED ITERATION MARK
+30FF          ; Katakana # Lo       KATAKANA DIGRAPH KOTO
+31F0..31FF    ; Katakana # Lo  [16] KATAKANA LETTER SMALL KU..KATAKANA LETTER SMALL RO
+32D0..32FE    ; Katakana # So  [47] CIRCLED KATAKANA A..CIRCLED KATAKANA WO
+3300..3357    ; Katakana # So  [88] SQUARE APAATO..SQUARE WATTO
+FF66..FF6F    ; Katakana # Lo  [10] HALFWIDTH KATAKANA LETTER WO..HALFWIDTH KATAKANA LETTER SMALL TU
+FF71..FF9D    ; Katakana # Lo  [45] HALFWIDTH KATAKANA LETTER A..HALFWIDTH KATAKANA LETTER N
+
+# Total code points: 299
+
+# ================================================
+
+3105..312D    ; Bopomofo # Lo  [41] BOPOMOFO LETTER B..BOPOMOFO LETTER IH
+31A0..31B7    ; Bopomofo # Lo  [24] BOPOMOFO LETTER BU..BOPOMOFO FINAL LETTER H
+
+# Total code points: 65
+
+# ================================================
+
+2E80..2E99    ; Han # So  [26] CJK RADICAL REPEAT..CJK RADICAL RAP
+2E9B..2EF3    ; Han # So  [89] CJK RADICAL CHOKE..CJK RADICAL C-SIMPLIFIED TURTLE
+2F00..2FD5    ; Han # So [214] KANGXI RADICAL ONE..KANGXI RADICAL FLUTE
+3005          ; Han # Lm       IDEOGRAPHIC ITERATION MARK
+3007          ; Han # Nl       IDEOGRAPHIC NUMBER ZERO
+3021..3029    ; Han # Nl   [9] HANGZHOU NUMERAL ONE..HANGZHOU NUMERAL NINE
+3038..303A    ; Han # Nl   [3] HANGZHOU NUMERAL TEN..HANGZHOU NUMERAL THIRTY
+303B          ; Han # Lm       VERTICAL IDEOGRAPHIC ITERATION MARK
+3400..4DB5    ; Han # Lo [6582] CJK UNIFIED IDEOGRAPH-3400..CJK UNIFIED IDEOGRAPH-4DB5
+4E00..9FC3    ; Han # Lo [20932] CJK UNIFIED IDEOGRAPH-4E00..CJK UNIFIED IDEOGRAPH-9FC3
+F900..FA2D    ; Han # Lo [302] CJK COMPATIBILITY IDEOGRAPH-F900..CJK COMPATIBILITY IDEOGRAPH-FA2D
+FA30..FA6A    ; Han # Lo  [59] CJK COMPATIBILITY IDEOGRAPH-FA30..CJK COMPATIBILITY IDEOGRAPH-FA6A
+FA70..FAD9    ; Han # Lo [106] CJK COMPATIBILITY IDEOGRAPH-FA70..CJK COMPATIBILITY IDEOGRAPH-FAD9
+20000..2A6D6  ; Han # Lo [42711] CJK UNIFIED IDEOGRAPH-20000..CJK UNIFIED IDEOGRAPH-2A6D6
+2F800..2FA1D  ; Han # Lo [542] CJK COMPATIBILITY IDEOGRAPH-2F800..CJK COMPATIBILITY IDEOGRAPH-2FA1D
+
+# Total code points: 71578
+
+# ================================================
+
+A000..A014    ; Yi # Lo  [21] YI SYLLABLE IT..YI SYLLABLE E
+A015          ; Yi # Lm       YI SYLLABLE WU
+A016..A48C    ; Yi # Lo [1143] YI SYLLABLE BIT..YI SYLLABLE YYR
+A490..A4C6    ; Yi # So  [55] YI RADICAL QOT..YI RADICAL KE
+
+# Total code points: 1220
+
+# ================================================
+
+10300..1031E  ; Old_Italic # Lo  [31] OLD ITALIC LETTER A..OLD ITALIC LETTER UU
+10320..10323  ; Old_Italic # No   [4] OLD ITALIC NUMERAL ONE..OLD ITALIC NUMERAL FIFTY
+
+# Total code points: 35
+
+# ================================================
+
+10330..10340  ; Gothic # Lo  [17] GOTHIC LETTER AHSA..GOTHIC LETTER PAIRTHRA
+10341         ; Gothic # Nl       GOTHIC LETTER NINETY
+10342..10349  ; Gothic # Lo   [8] GOTHIC LETTER RAIDA..GOTHIC LETTER OTHAL
+1034A         ; Gothic # Nl       GOTHIC LETTER NINE HUNDRED
+
+# Total code points: 27
+
+# ================================================
+
+10400..1044F  ; Deseret # L&  [80] DESERET CAPITAL LETTER LONG I..DESERET SMALL LETTER EW
+
+# Total code points: 80
+
+# ================================================
+
+0300..036F    ; Inherited # Mn [112] COMBINING GRAVE ACCENT..COMBINING LATIN SMALL LETTER X
+064B..0655    ; Inherited # Mn  [11] ARABIC FATHATAN..ARABIC HAMZA BELOW
+0670          ; Inherited # Mn       ARABIC LETTER SUPERSCRIPT ALEF
+0951..0952    ; Inherited # Mn   [2] DEVANAGARI STRESS SIGN UDATTA..DEVANAGARI STRESS SIGN ANUDATTA
+1DC0..1DE6    ; Inherited # Mn  [39] COMBINING DOTTED GRAVE ACCENT..COMBINING LATIN SMALL LETTER Z
+1DFE..1DFF    ; Inherited # Mn   [2] COMBINING LEFT ARROWHEAD ABOVE..COMBINING RIGHT ARROWHEAD AND DOWN ARROWHEAD BELOW
+200C..200D    ; Inherited # Cf   [2] ZERO WIDTH NON-JOINER..ZERO WIDTH JOINER
+20D0..20DC    ; Inherited # Mn  [13] COMBINING LEFT HARPOON ABOVE..COMBINING FOUR DOTS ABOVE
+20DD..20E0    ; Inherited # Me   [4] COMBINING ENCLOSING CIRCLE..COMBINING ENCLOSING CIRCLE BACKSLASH
+20E1          ; Inherited # Mn       COMBINING LEFT RIGHT ARROW ABOVE
+20E2..20E4    ; Inherited # Me   [3] COMBINING ENCLOSING SCREEN..COMBINING ENCLOSING UPWARD POINTING TRIANGLE
+20E5..20F0    ; Inherited # Mn  [12] COMBINING REVERSE SOLIDUS OVERLAY..COMBINING ASTERISK ABOVE
+302A..302F    ; Inherited # Mn   [6] IDEOGRAPHIC LEVEL TONE MARK..HANGUL DOUBLE DOT TONE MARK
+3099..309A    ; Inherited # Mn   [2] COMBINING KATAKANA-HIRAGANA VOICED SOUND MARK..COMBINING KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK
+FE00..FE0F    ; Inherited # Mn  [16] VARIATION SELECTOR-1..VARIATION SELECTOR-16
+FE20..FE26    ; Inherited # Mn   [7] COMBINING LIGATURE LEFT HALF..COMBINING CONJOINING MACRON
+101FD         ; Inherited # Mn       PHAISTOS DISC SIGN COMBINING OBLIQUE STROKE
+1D167..1D169  ; Inherited # Mn   [3] MUSICAL SYMBOL COMBINING TREMOLO-1..MUSICAL SYMBOL COMBINING TREMOLO-3
+1D17B..1D182  ; Inherited # Mn   [8] MUSICAL SYMBOL COMBINING ACCENT..MUSICAL SYMBOL COMBINING LOURE
+1D185..1D18B  ; Inherited # Mn   [7] MUSICAL SYMBOL COMBINING DOIT..MUSICAL SYMBOL COMBINING TRIPLE TONGUE
+1D1AA..1D1AD  ; Inherited # Mn   [4] MUSICAL SYMBOL COMBINING DOWN BOW..MUSICAL SYMBOL COMBINING SNAP PIZZICATO
+E0100..E01EF  ; Inherited # Mn [240] VARIATION SELECTOR-17..VARIATION SELECTOR-256
+
+# Total code points: 496
+
+# ================================================
+
+1700..170C    ; Tagalog # Lo  [13] TAGALOG LETTER A..TAGALOG LETTER YA
+170E..1711    ; Tagalog # Lo   [4] TAGALOG LETTER LA..TAGALOG LETTER HA
+1712..1714    ; Tagalog # Mn   [3] TAGALOG VOWEL SIGN I..TAGALOG SIGN VIRAMA
+
+# Total code points: 20
+
+# ================================================
+
+1720..1731    ; Hanunoo # Lo  [18] HANUNOO LETTER A..HANUNOO LETTER HA
+1732..1734    ; Hanunoo # Mn   [3] HANUNOO VOWEL SIGN I..HANUNOO SIGN PAMUDPOD
+
+# Total code points: 21
+
+# ================================================
+
+1740..1751    ; Buhid # Lo  [18] BUHID LETTER A..BUHID LETTER HA
+1752..1753    ; Buhid # Mn   [2] BUHID VOWEL SIGN I..BUHID VOWEL SIGN U
+
+# Total code points: 20
+
+# ================================================
+
+1760..176C    ; Tagbanwa # Lo  [13] TAGBANWA LETTER A..TAGBANWA LETTER YA
+176E..1770    ; Tagbanwa # Lo   [3] TAGBANWA LETTER LA..TAGBANWA LETTER SA
+1772..1773    ; Tagbanwa # Mn   [2] TAGBANWA VOWEL SIGN I..TAGBANWA VOWEL SIGN U
+
+# Total code points: 18
+
+# ================================================
+
+1900..191C    ; Limbu # Lo  [29] LIMBU VOWEL-CARRIER LETTER..LIMBU LETTER HA
+1920..1922    ; Limbu # Mn   [3] LIMBU VOWEL SIGN A..LIMBU VOWEL SIGN U
+1923..1926    ; Limbu # Mc   [4] LIMBU VOWEL SIGN EE..LIMBU VOWEL SIGN AU
+1927..1928    ; Limbu # Mn   [2] LIMBU VOWEL SIGN E..LIMBU VOWEL SIGN O
+1929..192B    ; Limbu # Mc   [3] LIMBU SUBJOINED LETTER YA..LIMBU SUBJOINED LETTER WA
+1930..1931    ; Limbu # Mc   [2] LIMBU SMALL LETTER KA..LIMBU SMALL LETTER NGA
+1932          ; Limbu # Mn       LIMBU SMALL LETTER ANUSVARA
+1933..1938    ; Limbu # Mc   [6] LIMBU SMALL LETTER TA..LIMBU SMALL LETTER LA
+1939..193B    ; Limbu # Mn   [3] LIMBU SIGN MUKPHRENG..LIMBU SIGN SA-I
+1940          ; Limbu # So       LIMBU SIGN LOO
+1944..1945    ; Limbu # Po   [2] LIMBU EXCLAMATION MARK..LIMBU QUESTION MARK
+1946..194F    ; Limbu # Nd  [10] LIMBU DIGIT ZERO..LIMBU DIGIT NINE
+
+# Total code points: 66
+
+# ================================================
+
+1950..196D    ; Tai_Le # Lo  [30] TAI LE LETTER KA..TAI LE LETTER AI
+1970..1974    ; Tai_Le # Lo   [5] TAI LE LETTER TONE-2..TAI LE LETTER TONE-6
+
+# Total code points: 35
+
+# ================================================
+
+10000..1000B  ; Linear_B # Lo  [12] LINEAR B SYLLABLE B008 A..LINEAR B SYLLABLE B046 JE
+1000D..10026  ; Linear_B # Lo  [26] LINEAR B SYLLABLE B036 JO..LINEAR B SYLLABLE B032 QO
+10028..1003A  ; Linear_B # Lo  [19] LINEAR B SYLLABLE B060 RA..LINEAR B SYLLABLE B042 WO
+1003C..1003D  ; Linear_B # Lo   [2] LINEAR B SYLLABLE B017 ZA..LINEAR B SYLLABLE B074 ZE
+1003F..1004D  ; Linear_B # Lo  [15] LINEAR B SYLLABLE B020 ZO..LINEAR B SYLLABLE B091 TWO
+10050..1005D  ; Linear_B # Lo  [14] LINEAR B SYMBOL B018..LINEAR B SYMBOL B089
+10080..100FA  ; Linear_B # Lo [123] LINEAR B IDEOGRAM B100 MAN..LINEAR B IDEOGRAM VESSEL B305
+
+# Total code points: 211
+
+# ================================================
+
+10380..1039D  ; Ugaritic # Lo  [30] UGARITIC LETTER ALPA..UGARITIC LETTER SSU
+1039F         ; Ugaritic # Po       UGARITIC WORD DIVIDER
+
+# Total code points: 31
+
+# ================================================
+
+10450..1047F  ; Shavian # Lo  [48] SHAVIAN LETTER PEEP..SHAVIAN LETTER YEW
+
+# Total code points: 48
+
+# ================================================
+
+10480..1049D  ; Osmanya # Lo  [30] OSMANYA LETTER ALEF..OSMANYA LETTER OO
+104A0..104A9  ; Osmanya # Nd  [10] OSMANYA DIGIT ZERO..OSMANYA DIGIT NINE
+
+# Total code points: 40
+
+# ================================================
+
+10800..10805  ; Cypriot # Lo   [6] CYPRIOT SYLLABLE A..CYPRIOT SYLLABLE JA
+10808         ; Cypriot # Lo       CYPRIOT SYLLABLE JO
+1080A..10835  ; Cypriot # Lo  [44] CYPRIOT SYLLABLE KA..CYPRIOT SYLLABLE WO
+10837..10838  ; Cypriot # Lo   [2] CYPRIOT SYLLABLE XA..CYPRIOT SYLLABLE XE
+1083C         ; Cypriot # Lo       CYPRIOT SYLLABLE ZA
+1083F         ; Cypriot # Lo       CYPRIOT SYLLABLE ZO
+
+# Total code points: 55
+
+# ================================================
+
+2800..28FF    ; Braille # So [256] BRAILLE PATTERN BLANK..BRAILLE PATTERN DOTS-12345678
+
+# Total code points: 256
+
+# ================================================
+
+1A00..1A16    ; Buginese # Lo  [23] BUGINESE LETTER KA..BUGINESE LETTER HA
+1A17..1A18    ; Buginese # Mn   [2] BUGINESE VOWEL SIGN I..BUGINESE VOWEL SIGN U
+1A19..1A1B    ; Buginese # Mc   [3] BUGINESE VOWEL SIGN E..BUGINESE VOWEL SIGN AE
+1A1E..1A1F    ; Buginese # Po   [2] BUGINESE PALLAWA..BUGINESE END OF SECTION
+
+# Total code points: 30
+
+# ================================================
+
+03E2..03EF    ; Coptic # L&  [14] COPTIC CAPITAL LETTER SHEI..COPTIC SMALL LETTER DEI
+2C80..2CE4    ; Coptic # L& [101] COPTIC CAPITAL LETTER ALFA..COPTIC SYMBOL KAI
+2CE5..2CEA    ; Coptic # So   [6] COPTIC SYMBOL MI RO..COPTIC SYMBOL SHIMA SIMA
+2CF9..2CFC    ; Coptic # Po   [4] COPTIC OLD NUBIAN FULL STOP..COPTIC OLD NUBIAN VERSE DIVIDER
+2CFD          ; Coptic # No       COPTIC FRACTION ONE HALF
+2CFE..2CFF    ; Coptic # Po   [2] COPTIC FULL STOP..COPTIC MORPHOLOGICAL DIVIDER
+
+# Total code points: 128
+
+# ================================================
+
+1980..19A9    ; New_Tai_Lue # Lo  [42] NEW TAI LUE LETTER HIGH QA..NEW TAI LUE LETTER LOW XVA
+19B0..19C0    ; New_Tai_Lue # Mc  [17] NEW TAI LUE VOWEL SIGN VOWEL SHORTENER..NEW TAI LUE VOWEL SIGN IY
+19C1..19C7    ; New_Tai_Lue # Lo   [7] NEW TAI LUE LETTER FINAL V..NEW TAI LUE LETTER FINAL B
+19C8..19C9    ; New_Tai_Lue # Mc   [2] NEW TAI LUE TONE MARK-1..NEW TAI LUE TONE MARK-2
+19D0..19D9    ; New_Tai_Lue # Nd  [10] NEW TAI LUE DIGIT ZERO..NEW TAI LUE DIGIT NINE
+19DE..19DF    ; New_Tai_Lue # Po   [2] NEW TAI LUE SIGN LAE..NEW TAI LUE SIGN LAEV
+
+# Total code points: 80
+
+# ================================================
+
+2C00..2C2E    ; Glagolitic # L&  [47] GLAGOLITIC CAPITAL LETTER AZU..GLAGOLITIC CAPITAL LETTER LATINATE MYSLITE
+2C30..2C5E    ; Glagolitic # L&  [47] GLAGOLITIC SMALL LETTER AZU..GLAGOLITIC SMALL LETTER LATINATE MYSLITE
+
+# Total code points: 94
+
+# ================================================
+
+2D30..2D65    ; Tifinagh # Lo  [54] TIFINAGH LETTER YA..TIFINAGH LETTER YAZZ
+2D6F          ; Tifinagh # Lm       TIFINAGH MODIFIER LETTER LABIALIZATION MARK
+
+# Total code points: 55
+
+# ================================================
+
+A800..A801    ; Syloti_Nagri # Lo   [2] SYLOTI NAGRI LETTER A..SYLOTI NAGRI LETTER I
+A802          ; Syloti_Nagri # Mn       SYLOTI NAGRI SIGN DVISVARA
+A803..A805    ; Syloti_Nagri # Lo   [3] SYLOTI NAGRI LETTER U..SYLOTI NAGRI LETTER O
+A806          ; Syloti_Nagri # Mn       SYLOTI NAGRI SIGN HASANTA
+A807..A80A    ; Syloti_Nagri # Lo   [4] SYLOTI NAGRI LETTER KO..SYLOTI NAGRI LETTER GHO
+A80B          ; Syloti_Nagri # Mn       SYLOTI NAGRI SIGN ANUSVARA
+A80C..A822    ; Syloti_Nagri # Lo  [23] SYLOTI NAGRI LETTER CO..SYLOTI NAGRI LETTER HO
+A823..A824    ; Syloti_Nagri # Mc   [2] SYLOTI NAGRI VOWEL SIGN A..SYLOTI NAGRI VOWEL SIGN I
+A825..A826    ; Syloti_Nagri # Mn   [2] SYLOTI NAGRI VOWEL SIGN U..SYLOTI NAGRI VOWEL SIGN E
+A827          ; Syloti_Nagri # Mc       SYLOTI NAGRI VOWEL SIGN OO
+A828..A82B    ; Syloti_Nagri # So   [4] SYLOTI NAGRI POETRY MARK-1..SYLOTI NAGRI POETRY MARK-4
+
+# Total code points: 44
+
+# ================================================
+
+103A0..103C3  ; Old_Persian # Lo  [36] OLD PERSIAN SIGN A..OLD PERSIAN SIGN HA
+103C8..103CF  ; Old_Persian # Lo   [8] OLD PERSIAN SIGN AURAMAZDAA..OLD PERSIAN SIGN BUUMISH
+103D0         ; Old_Persian # Po       OLD PERSIAN WORD DIVIDER
+103D1..103D5  ; Old_Persian # Nl   [5] OLD PERSIAN NUMBER ONE..OLD PERSIAN NUMBER HUNDRED
+
+# Total code points: 50
+
+# ================================================
+
+10A00         ; Kharoshthi # Lo       KHAROSHTHI LETTER A
+10A01..10A03  ; Kharoshthi # Mn   [3] KHAROSHTHI VOWEL SIGN I..KHAROSHTHI VOWEL SIGN VOCALIC R
+10A05..10A06  ; Kharoshthi # Mn   [2] KHAROSHTHI VOWEL SIGN E..KHAROSHTHI VOWEL SIGN O
+10A0C..10A0F  ; Kharoshthi # Mn   [4] KHAROSHTHI VOWEL LENGTH MARK..KHAROSHTHI SIGN VISARGA
+10A10..10A13  ; Kharoshthi # Lo   [4] KHAROSHTHI LETTER KA..KHAROSHTHI LETTER GHA
+10A15..10A17  ; Kharoshthi # Lo   [3] KHAROSHTHI LETTER CA..KHAROSHTHI LETTER JA
+10A19..10A33  ; Kharoshthi # Lo  [27] KHAROSHTHI LETTER NYA..KHAROSHTHI LETTER TTTHA
+10A38..10A3A  ; Kharoshthi # Mn   [3] KHAROSHTHI SIGN BAR ABOVE..KHAROSHTHI SIGN DOT BELOW
+10A3F         ; Kharoshthi # Mn       KHAROSHTHI VIRAMA
+10A40..10A47  ; Kharoshthi # No   [8] KHAROSHTHI DIGIT ONE..KHAROSHTHI NUMBER ONE THOUSAND
+10A50..10A58  ; Kharoshthi # Po   [9] KHAROSHTHI PUNCTUATION DOT..KHAROSHTHI PUNCTUATION LINES
+
+# Total code points: 65
+
+# ================================================
+
+1B00..1B03    ; Balinese # Mn   [4] BALINESE SIGN ULU RICEM..BALINESE SIGN SURANG
+1B04          ; Balinese # Mc       BALINESE SIGN BISAH
+1B05..1B33    ; Balinese # Lo  [47] BALINESE LETTER AKARA..BALINESE LETTER HA
+1B34          ; Balinese # Mn       BALINESE SIGN REREKAN
+1B35          ; Balinese # Mc       BALINESE VOWEL SIGN TEDUNG
+1B36..1B3A    ; Balinese # Mn   [5] BALINESE VOWEL SIGN ULU..BALINESE VOWEL SIGN RA REPA
+1B3B          ; Balinese # Mc       BALINESE VOWEL SIGN RA REPA TEDUNG
+1B3C          ; Balinese # Mn       BALINESE VOWEL SIGN LA LENGA
+1B3D..1B41    ; Balinese # Mc   [5] BALINESE VOWEL SIGN LA LENGA TEDUNG..BALINESE VOWEL SIGN TALING REPA TEDUNG
+1B42          ; Balinese # Mn       BALINESE VOWEL SIGN PEPET
+1B43..1B44    ; Balinese # Mc   [2] BALINESE VOWEL SIGN PEPET TEDUNG..BALINESE ADEG ADEG
+1B45..1B4B    ; Balinese # Lo   [7] BALINESE LETTER KAF SASAK..BALINESE LETTER ASYURA SASAK
+1B50..1B59    ; Balinese # Nd  [10] BALINESE DIGIT ZERO..BALINESE DIGIT NINE
+1B5A..1B60    ; Balinese # Po   [7] BALINESE PANTI..BALINESE PAMENENG
+1B61..1B6A    ; Balinese # So  [10] BALINESE MUSICAL SYMBOL DONG..BALINESE MUSICAL SYMBOL DANG GEDE
+1B6B..1B73    ; Balinese # Mn   [9] BALINESE MUSICAL SYMBOL COMBINING TEGEH..BALINESE MUSICAL SYMBOL COMBINING GONG
+1B74..1B7C    ; Balinese # So   [9] BALINESE MUSICAL SYMBOL RIGHT-HAND OPEN DUG..BALINESE MUSICAL SYMBOL LEFT-HAND OPEN PING
+
+# Total code points: 121
+
+# ================================================
+
+12000..1236E  ; Cuneiform # Lo [879] CUNEIFORM SIGN A..CUNEIFORM SIGN ZUM
+12400..12462  ; Cuneiform # Nl  [99] CUNEIFORM NUMERIC SIGN TWO ASH..CUNEIFORM NUMERIC SIGN OLD ASSYRIAN ONE QUARTER
+12470..12473  ; Cuneiform # Po   [4] CUNEIFORM PUNCTUATION SIGN OLD ASSYRIAN WORD DIVIDER..CUNEIFORM PUNCTUATION SIGN DIAGONAL TRICOLON
+
+# Total code points: 982
+
+# ================================================
+
+10900..10915  ; Phoenician # Lo  [22] PHOENICIAN LETTER ALF..PHOENICIAN LETTER TAU
+10916..10919  ; Phoenician # No   [4] PHOENICIAN NUMBER ONE..PHOENICIAN NUMBER ONE HUNDRED
+1091F         ; Phoenician # Po       PHOENICIAN WORD SEPARATOR
+
+# Total code points: 27
+
+# ================================================
+
+A840..A873    ; Phags_Pa # Lo  [52] PHAGS-PA LETTER KA..PHAGS-PA LETTER CANDRABINDU
+A874..A877    ; Phags_Pa # Po   [4] PHAGS-PA SINGLE HEAD MARK..PHAGS-PA MARK DOUBLE SHAD
+
+# Total code points: 56
+
+# ================================================
+
+07C0..07C9    ; Nko # Nd  [10] NKO DIGIT ZERO..NKO DIGIT NINE
+07CA..07EA    ; Nko # Lo  [33] NKO LETTER A..NKO LETTER JONA RA
+07EB..07F3    ; Nko # Mn   [9] NKO COMBINING SHORT HIGH TONE..NKO COMBINING DOUBLE DOT ABOVE
+07F4..07F5    ; Nko # Lm   [2] NKO HIGH TONE APOSTROPHE..NKO LOW TONE APOSTROPHE
+07F6          ; Nko # So       NKO SYMBOL OO DENNEN
+07F7..07F9    ; Nko # Po   [3] NKO SYMBOL GBAKURUNEN..NKO EXCLAMATION MARK
+07FA          ; Nko # Lm       NKO LAJANYALAN
+
+# Total code points: 59
+
+# ================================================
+
+1B80..1B81    ; Sundanese # Mn   [2] SUNDANESE SIGN PANYECEK..SUNDANESE SIGN PANGLAYAR
+1B82          ; Sundanese # Mc       SUNDANESE SIGN PANGWISAD
+1B83..1BA0    ; Sundanese # Lo  [30] SUNDANESE LETTER A..SUNDANESE LETTER HA
+1BA1          ; Sundanese # Mc       SUNDANESE CONSONANT SIGN PAMINGKAL
+1BA2..1BA5    ; Sundanese # Mn   [4] SUNDANESE CONSONANT SIGN PANYAKRA..SUNDANESE VOWEL SIGN PANYUKU
+1BA6..1BA7    ; Sundanese # Mc   [2] SUNDANESE VOWEL SIGN PANAELAENG..SUNDANESE VOWEL SIGN PANOLONG
+1BA8..1BA9    ; Sundanese # Mn   [2] SUNDANESE VOWEL SIGN PAMEPET..SUNDANESE VOWEL SIGN PANEULEUNG
+1BAA          ; Sundanese # Mc       SUNDANESE SIGN PAMAAEH
+1BAE..1BAF    ; Sundanese # Lo   [2] SUNDANESE LETTER KHA..SUNDANESE LETTER SYA
+1BB0..1BB9    ; Sundanese # Nd  [10] SUNDANESE DIGIT ZERO..SUNDANESE DIGIT NINE
+
+# Total code points: 55
+
+# ================================================
+
+1C00..1C23    ; Lepcha # Lo  [36] LEPCHA LETTER KA..LEPCHA LETTER A
+1C24..1C2B    ; Lepcha # Mc   [8] LEPCHA SUBJOINED LETTER YA..LEPCHA VOWEL SIGN UU
+1C2C..1C33    ; Lepcha # Mn   [8] LEPCHA VOWEL SIGN E..LEPCHA CONSONANT SIGN T
+1C34..1C35    ; Lepcha # Mc   [2] LEPCHA CONSONANT SIGN NYIN-DO..LEPCHA CONSONANT SIGN KANG
+1C36..1C37    ; Lepcha # Mn   [2] LEPCHA SIGN RAN..LEPCHA SIGN NUKTA
+1C3B..1C3F    ; Lepcha # Po   [5] LEPCHA PUNCTUATION TA-ROL..LEPCHA PUNCTUATION TSHOOK
+1C40..1C49    ; Lepcha # Nd  [10] LEPCHA DIGIT ZERO..LEPCHA DIGIT NINE
+1C4D..1C4F    ; Lepcha # Lo   [3] LEPCHA LETTER TTA..LEPCHA LETTER DDA
+
+# Total code points: 74
+
+# ================================================
+
+1C50..1C59    ; Ol_Chiki # Nd  [10] OL CHIKI DIGIT ZERO..OL CHIKI DIGIT NINE
+1C5A..1C77    ; Ol_Chiki # Lo  [30] OL CHIKI LETTER LA..OL CHIKI LETTER OH
+1C78..1C7D    ; Ol_Chiki # Lm   [6] OL CHIKI MU TTUDDAG..OL CHIKI AHAD
+1C7E..1C7F    ; Ol_Chiki # Po   [2] OL CHIKI PUNCTUATION MUCAAD..OL CHIKI PUNCTUATION DOUBLE MUCAAD
+
+# Total code points: 48
+
+# ================================================
+
+A500..A60B    ; Vai # Lo [268] VAI SYLLABLE EE..VAI SYLLABLE NG
+A60C          ; Vai # Lm       VAI SYLLABLE LENGTHENER
+A60D..A60F    ; Vai # Po   [3] VAI COMMA..VAI QUESTION MARK
+A610..A61F    ; Vai # Lo  [16] VAI SYLLABLE NDOLE FA..VAI SYMBOL JONG
+A620..A629    ; Vai # Nd  [10] VAI DIGIT ZERO..VAI DIGIT NINE
+A62A..A62B    ; Vai # Lo   [2] VAI SYLLABLE NDOLE MA..VAI SYLLABLE NDOLE DO
+
+# Total code points: 300
+
+# ================================================
+
+A880..A881    ; Saurashtra # Mc   [2] SAURASHTRA SIGN ANUSVARA..SAURASHTRA SIGN VISARGA
+A882..A8B3    ; Saurashtra # Lo  [50] SAURASHTRA LETTER A..SAURASHTRA LETTER LLA
+A8B4..A8C3    ; Saurashtra # Mc  [16] SAURASHTRA CONSONANT SIGN HAARU..SAURASHTRA VOWEL SIGN AU
+A8C4          ; Saurashtra # Mn       SAURASHTRA SIGN VIRAMA
+A8CE..A8CF    ; Saurashtra # Po   [2] SAURASHTRA DANDA..SAURASHTRA DOUBLE DANDA
+A8D0..A8D9    ; Saurashtra # Nd  [10] SAURASHTRA DIGIT ZERO..SAURASHTRA DIGIT NINE
+
+# Total code points: 81
+
+# ================================================
+
+A900..A909    ; Kayah_Li # Nd  [10] KAYAH LI DIGIT ZERO..KAYAH LI DIGIT NINE
+A90A..A925    ; Kayah_Li # Lo  [28] KAYAH LI LETTER KA..KAYAH LI LETTER OO
+A926..A92D    ; Kayah_Li # Mn   [8] KAYAH LI VOWEL UE..KAYAH LI TONE CALYA PLOPHU
+A92E..A92F    ; Kayah_Li # Po   [2] KAYAH LI SIGN CWI..KAYAH LI SIGN SHYA
+
+# Total code points: 48
+
+# ================================================
+
+A930..A946    ; Rejang # Lo  [23] REJANG LETTER KA..REJANG LETTER A
+A947..A951    ; Rejang # Mn  [11] REJANG VOWEL SIGN I..REJANG CONSONANT SIGN R
+A952..A953    ; Rejang # Mc   [2] REJANG CONSONANT SIGN H..REJANG VIRAMA
+A95F          ; Rejang # Po       REJANG SECTION MARK
+
+# Total code points: 37
+
+# ================================================
+
+10280..1029C  ; Lycian # Lo  [29] LYCIAN LETTER A..LYCIAN LETTER X
+
+# Total code points: 29
+
+# ================================================
+
+102A0..102D0  ; Carian # Lo  [49] CARIAN LETTER A..CARIAN LETTER UUU3
+
+# Total code points: 49
+
+# ================================================
+
+10920..10939  ; Lydian # Lo  [26] LYDIAN LETTER A..LYDIAN LETTER C
+1093F         ; Lydian # Po       LYDIAN TRIANGULAR MARK
+
+# Total code points: 27
+
+# ================================================
+
+AA00..AA28    ; Cham # Lo  [41] CHAM LETTER A..CHAM LETTER HA
+AA29..AA2E    ; Cham # Mn   [6] CHAM VOWEL SIGN AA..CHAM VOWEL SIGN OE
+AA2F..AA30    ; Cham # Mc   [2] CHAM VOWEL SIGN O..CHAM VOWEL SIGN AI
+AA31..AA32    ; Cham # Mn   [2] CHAM VOWEL SIGN AU..CHAM VOWEL SIGN UE
+AA33..AA34    ; Cham # Mc   [2] CHAM CONSONANT SIGN YA..CHAM CONSONANT SIGN RA
+AA35..AA36    ; Cham # Mn   [2] CHAM CONSONANT SIGN LA..CHAM CONSONANT SIGN WA
+AA40..AA42    ; Cham # Lo   [3] CHAM LETTER FINAL K..CHAM LETTER FINAL NG
+AA43          ; Cham # Mn       CHAM CONSONANT SIGN FINAL NG
+AA44..AA4B    ; Cham # Lo   [8] CHAM LETTER FINAL CH..CHAM LETTER FINAL SS
+AA4C          ; Cham # Mn       CHAM CONSONANT SIGN FINAL M
+AA4D          ; Cham # Mc       CHAM CONSONANT SIGN FINAL H
+AA50..AA59    ; Cham # Nd  [10] CHAM DIGIT ZERO..CHAM DIGIT NINE
+AA5C..AA5F    ; Cham # Po   [4] CHAM PUNCTUATION SPIRAL..CHAM PUNCTUATION TRIPLE DANDA
+
+# Total code points: 83
+
+# EOF
diff --git a/extra/unicode/script/authors.txt b/extra/unicode/script/authors.txt
new file mode 100755 (executable)
index 0000000..504363d
--- /dev/null
@@ -0,0 +1 @@
+Daniel Ehrenberg\r
diff --git a/extra/unicode/script/script-docs.factor b/extra/unicode/script/script-docs.factor
new file mode 100755 (executable)
index 0000000..05828b7
--- /dev/null
@@ -0,0 +1,8 @@
+USING: help.syntax help.markup ;\r
+IN: unicode.script\r
+\r
+HELP: script-of\r
+{ $values { "char" "a code point" } { "script" "a symbol" } }\r
+{ $description "Gets a symbol representing the code point of a given character. The word name of the symbol is the same as the one " } ;\r
+\r
+ABOUT: script-of\r
diff --git a/extra/unicode/script/script-tests.factor b/extra/unicode/script/script-tests.factor
new file mode 100755 (executable)
index 0000000..9058371
--- /dev/null
@@ -0,0 +1,4 @@
+USING: unicode.script tools.test ;\r
+\r
+[ Latin ] [ CHAR: a script-of ] unit-test\r
+[ Common ] [ 0 script-of ] unit-test\r
diff --git a/extra/unicode/script/script.factor b/extra/unicode/script/script.factor
new file mode 100755 (executable)
index 0000000..d0bb4ac
--- /dev/null
@@ -0,0 +1,50 @@
+USING: unicode.syntax.backend kernel sequences assocs io.files
+io.encodings ascii math.ranges io splitting math.parser 
+namespaces byte-arrays locals math sets io.encodings.ascii
+words compiler.units arrays interval-maps ;
+IN: unicode.script
+
+<PRIVATE
+VALUE: script-table
+SYMBOL: interned
+
+: parse-script ( stream -- assoc )
+    ! assoc is code point/range => name
+    lines [ "#" split1 drop ] map [ empty? not ] filter [
+        ";" split1 [ [ blank? ] trim ] bi@
+    ] H{ } map>assoc ;
+
+: range, ( value key -- )
+    swap interned get
+    [ word-name = ] with find nip 2array , ;
+
+: expand-ranges ( assoc -- interval-map )
+    [
+        [
+            CHAR: . pick member? [
+                swap ".." split1 [ hex> ] bi@ 2array
+            ] [ swap hex> ] if range,
+        ] assoc-each
+    ] { } make <interval-map> ;
+
+: >symbols ( strings -- symbols )
+    [
+        [ "unicode.script" create dup define-symbol ] map
+    ] with-compilation-unit ;
+
+: process-script ( ranges -- )
+    dup values prune >symbols interned [
+        expand-ranges \ script-table set-value
+    ] with-variable ;
+
+: load-script ( -- )
+    "resource:extra/unicode/script/Scripts.txt"
+    ascii <file-reader> parse-script process-script ;
+
+load-script
+PRIVATE>
+
+SYMBOL: Unknown
+
+: script-of ( char -- script )
+    script-table interval-at [ Unknown ] unless* ;
diff --git a/extra/unicode/script/summary.txt b/extra/unicode/script/summary.txt
new file mode 100755 (executable)
index 0000000..a2de844
--- /dev/null
@@ -0,0 +1 @@
+Reads the UCD to get the script of a code point\r
index d80db44348f7f4133e191696c625d04a5ad94164..158dbeaddb7c3cd483bc7032e7121bc04982bfca 100755 (executable)
@@ -21,7 +21,9 @@ IN: unix
 : SO_SNDTIMEO HEX: 1005 ; inline
 : SO_RCVTIMEO HEX: 1006 ; inline
 
+: F_SETFD 2 ; inline
 : F_SETFL 4 ; inline
+: FD_CLOEXEC 1 ; inline
 : O_NONBLOCK 4 ; inline
 
 C-STRUCT: sockaddr-in
index 11db6cc862104dab9dbe59efdc45694fc96f20ad..74195fae36d14491eae17574a75584dc70696f09 100755 (executable)
@@ -24,6 +24,9 @@ USING: alien.syntax ;
 : SO_SNDTIMEO HEX: 15 ; inline
 : SO_RCVTIMEO HEX: 14 ; inline
 
+: F_SETFD 2 ; inline
+: FD_CLOEXEC 1 ; inline
+
 : F_SETFL 4 ; inline
 : O_NONBLOCK HEX: 800 ; inline
 
diff --git a/extra/update/backup/backup.factor b/extra/update/backup/backup.factor
new file mode 100644 (file)
index 0000000..bb6d17f
--- /dev/null
@@ -0,0 +1,25 @@
+
+USING: namespaces io.files bootstrap.image builder.util ;
+
+IN: update.backup
+
+: backup-boot-image ( -- )
+  my-boot-image-name
+  { "boot." my-arch "-" [ "datestamp" get ] ".image" } to-string  
+  move-file ;
+
+: backup-image ( -- )
+  "factor.image"
+  { "factor" "-" [ "datestamp" get ] ".image" } to-string
+  move-file ;
+
+: backup-vm ( -- )
+  "factor"
+  { "factor" "-" [ "datestamp" get ] } to-string
+  move-file ;
+
+: backup ( -- )
+  datestamp "datestamp" set
+  backup-boot-image
+  backup-image
+  backup-vm ;
diff --git a/extra/update/latest/latest.factor b/extra/update/latest/latest.factor
new file mode 100644 (file)
index 0000000..df05742
--- /dev/null
@@ -0,0 +1,53 @@
+
+USING: kernel namespaces system io.files bootstrap.image http.client
+       builder.util update update.backup ;
+
+IN: update.latest
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: git-pull-master ( -- )
+  image parent-directory
+    [
+      { "git" "pull" "git://factorcode.org/git/factor.git" "master" }
+      run-command
+    ]
+  with-directory ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: remote-latest-image ( -- url )
+  { "http://factorcode.org/images/latest/" my-boot-image-name } to-string ;
+
+: download-latest-image ( -- ) remote-latest-image download ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: rebuild-latest ( -- )
+  image parent-directory
+    [
+      backup
+      download-latest-image
+      make-clean
+      make
+      boot
+    ]
+  with-directory ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: update-latest ( -- )
+  image parent-directory
+    [
+      git-id
+      git-pull-master
+      git-id
+      = not
+        [ rebuild-latest ]
+      when
+    ]
+  with-directory ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+MAIN: update-latest
\ No newline at end of file
index 9846e7b20ce4e583386e853f37e109e621cd34f0..55721d7bef3c696f19d03b0c209e05d9b24aa77d 100644 (file)
@@ -43,6 +43,13 @@ a:hover, .link:hover {
        border: 1px dashed #ccc;
        background-color: #f5f5f5;
        padding: 5px;
-       font-size: 150%;
-       color: #000000;
+       color: #000;
+}
+
+.description p:first-child {
+       margin-top: 0px;
+}
+
+.description p:last-child {
+       margin-bottom: 0px;
 }
index e5a95d8908c4fbdebc7a993106f28abd79c7580b..d5b4ea8d3a0059c7f924dcdaaa8dfbb59cfb4874 100644 (file)
                <tr><th class="field-label">Date:    </th><td><t:view t:component="date"    /></td></tr>
        </table>
 
-       <div class="description">
-               <t:view t:component="contents" />
-       </div>
+       <pre class="description"><t:view t:component="contents" /></pre>
 
-       <t:form t:action="$pastebin/delete-annotation" class="inline">
-               <t:edit t:component="id" />
-               <t:edit t:component="aid" />
-               <button class="link-button link">Delete Annotation</button>
-       </t:form>
+       <t:button t:action="$pastebin/delete-annotation" t:for="aid" class="link-button link">Delete Annotation</t:button>
 
 </t:chloe>
index ad7152d20995736603151c0fe93b5f79b92cb87b..5d18860977fdcf84393da908964ca536129b1af7 100644 (file)
@@ -4,8 +4,7 @@
 
        <t:title>New Annotation</t:title>
 
-       <t:form t:action="$pastebin/annotate">
-               <t:edit t:component="id" />
+       <t:form t:action="$pastebin/annotate" t:for="id">
 
                <table>
                        <tr><th class="field-label">Summary: </th><td><t:edit t:component="summary" /></td></tr>
index eca46e254d714007eb64e26b28cab04398b05fcd..c751b110c09570f788662b5a78705812d5351b5d 100644 (file)
@@ -3,7 +3,7 @@
 <t:chloe xmlns:t="http://factorcode.org/chloe/1.0">
 
        <tr>
-               <td><t:a t:href="view-paste" query="id"><t:view t:component="summary" /></t:a></td>
+               <td><t:a t:href="$pastebin/view-paste" t:query="id"><t:view t:component="summary" /></t:a></td>
                <td><t:view t:component="author" /></td>
                <td><t:view t:component="date" /></td>
        </tr>
index 9db60bfcc321f22e21f771651cf3f3acd632173e..9141ee4ef1b8d3ba338792bf92fd75d565919a09 100644 (file)
@@ -2,9 +2,7 @@
 
 <t:chloe xmlns:t="http://factorcode.org/chloe/1.0">
 
-       <t:title>Pastebin</t:title>
-
-       <h2>Paste: <t:view t:component="summary" /></h2>
+       <t:title>Paste: <t:view t:component="summary" /></t:title>
 
        <table>
                <tr><th class="field-label">Author:  </th><td><t:view t:component="author"  /></td></tr>
 
        <pre class="description"><t:view t:component="contents" /></pre>
 
-       <t:form t:action="$pastebin/delete-paste" class="inline">
-               <t:edit t:component="id" />
-               <button class="link-button link">Delete Paste</button>
-       </t:form>
+       <t:button t:action="$pastebin/delete-paste" t:for="id" class="link-button link">Delete Paste</t:button>
        |
        <t:a t:href="$pastebin/annotate" t:query="id">Annotate</t:a>
 
index 144900d6ec8f392a25c1c6c25525f0962ad7e4b8..a18eb8147cedf6f086bd03eea47d373a8648457a 100644 (file)
@@ -207,12 +207,11 @@ annotation "ANNOTATION"
 
 :: <delete-annotation-action> ( ctor next -- action )
     <action>
-        { { "id" [ v-number ] } { "aid" [ v-number ] } } >>post-params
+        { { "aid" [ v-number ] } } >>post-params
 
         [
-            "id" get "aid" get ctor call delete-tuples
-
-            "id" get next <id-redirect>
+            f "aid" get ctor call select-tuple
+            [ delete-tuples ] [ id>> next <id-redirect> ] bi
         ] >>submit ;
 
 :: <new-paste-action> ( form ctor next -- action )
@@ -247,7 +246,7 @@ can-delete-pastes? define-capability
         <feed-action> "feed.xml" add-responder
         <paste-form> [ <paste> ] <view-paste-action> "view-paste" add-responder
         [ <paste> ] "$pastebin/list" <delete-paste-action> { can-delete-pastes? } <protected> "delete-paste" add-responder
-        [ <annotation> ] "$pastebin/view-paste" { can-delete-pastes? } <delete-annotation-action> <protected> "delete-annotation" add-responder
+        [ <annotation> ] "$pastebin/view-paste" <delete-annotation-action> { can-delete-pastes? } <protected> "delete-annotation" add-responder
         <paste-form> [ <paste> ]    <view-paste-action>     "$pastebin/view-paste"   add-responder
         <new-paste-form> [ <paste> now >>date ] "$pastebin/view-paste" <new-paste-action>     "new-paste"    add-responder
         <new-annotation-form> [ <annotation> now >>date ] "$pastebin/view-paste" <annotate-action> "annotate" add-responder
index 461a7be384b56058bcd532cfd36f1f811df1e554..7ca4c95f8e518b257fe85e5da8f3cb10d2c03b66 100644 (file)
                | <t:a t:href="$pastebin/new-paste">New Paste</t:a>
                | <t:a t:href="$pastebin/feed.xml">Atom Feed</t:a>
 
-               <t:if t:var="http.server.auth:logged-in-user">
+               <t:if t:code="http.server.sessions:uid">
 
                        <t:if t:code="http.server.auth.login:allow-edit-profile?">
                                | <t:a t:href="$login/edit-profile" t:flow="begin">Edit Profile</t:a>
                        </t:if>
 
-                       <t:form t:action="$login/logout" t:flow="begin" class="inline">
-                               | <button type="submit" class="link-button link">Logout</button>
-                       </t:form>
+                       | <t:button t:action="$login/logout" t:flow="begin" class="link-button link">Logout</t:button>
 
                </t:if>
 
index b2eab2b0b48d1565f3a6f01ba21395e712760252..ebfccc47de901e7584073f97c2ab309c04b012f9 100644 (file)
@@ -4,9 +4,7 @@
 
        <t:title>Edit Blog</t:title>
 
-       <t:form t:action="$planet-factor/admin/edit-blog">
-
-               <t:edit t:component="id" />
+       <t:form t:action="$planet-factor/admin/edit-blog" t:for="id">
 
                <table>
 
@@ -31,8 +29,5 @@
 
        </t:form>
 
-       <t:form t:action="$planet-factor/admin/delete-blog" class="inline">
-               <t:edit t:component="id" />
-               <button type="submit" class="link-button link">Delete</button>
-       </t:form>
+       <t:button t:action="$planet-factor/admin/delete-blog" t:for="id" class="link-button link">Delete</t:button>
 </t:chloe>
index 7f2b034366bb3ca9e51b8e70564dadb7b1bb09c4..29609e12ba6873829d1c980fe7c07399f2495bee 100644 (file)
@@ -9,14 +9,12 @@
                | <t:a t:href="$planet-factor/feed.xml">Atom Feed</t:a>
                | <t:a t:href="$planet-factor/admin">Admin</t:a>
 
-               <t:if t:var="http.server.auth:logged-in-user">
+               <t:if t:code="http.server.sessions:uid">
                        <t:if t:code="http.server.auth.login:allow-edit-profile?">
                                | <t:a t:href="$login/edit-profile" t:flow="begin">Edit Profile</t:a>
                        </t:if>
        
-                       <t:form t:action="$login/logout" t:flow="begin" class="inline">
-                               | <button type="submit" class="link-button link">Logout</button>
-                       </t:form>
+                       | <t:button t:action="$login/logout" t:flow="begin" class="link-button link">Logout</t:button>
                </t:if>
        </div>
 
index 9b7e9e667a0afe10100c000bff3d92607334e318..e1d4c40e236bb0a372f0c3aa98b8b4b601f4d7c1 100644 (file)
@@ -4,9 +4,7 @@
 
        <t:title>Edit Item</t:title>
 
-       <t:form t:action="$todo-list/edit">
-               <t:edit t:component="id" />
-
+       <t:form t:action="$todo-list/edit" t:for="id">
                <table>
                        <tr><th class="field-label">Summary: </th><td><t:edit t:component="summary" /></td></tr>
                        <tr><th class="field-label">Priority: </th><td><t:edit t:component="priority" /></td></tr>
                <input type="SUBMIT" value="Done" />
        </t:form>
 
-       <t:a t:href="$todo-list/view" t:query="id">View</t:a>
-       |
-       <t:form t:action="$todo-list/delete" t:class="inline">
-               <t:edit t:component="id" />
-               <button type="submit" class="link-button link">Delete</button>
-       </t:form>
+       <t:if t:value="id">
+       
+               <t:a t:href="$todo-list/view" t:query="id">View</t:a>
+               |
+               <t:button t:action="$todo-list/delete" t:for="id" class="link-button link">Delete</t:button>
+               
+       </t:if>
 
 </t:chloe>
index 3e6d3cfd44e5aaa5d9d2b8b0465f2825a4566141..651e29d867279af213a8d410d8c65cdc26cfb823 100644 (file)
@@ -12,9 +12,7 @@
                        | <t:a t:href="$login/edit-profile" t:flow="begin">Edit Profile</t:a>
                </t:if>
 
-               <t:form t:action="$login/logout" t:flow="begin" class="inline">
-                       | <button type="submit" class="link-button link">Logout</button>
-               </t:form>
+               <t:button t:action="$login/logout" t:flow="begin" class="link-button link">Logout</t:button>
        </div>
 
        <h1><t:write-title /></h1>
index 1bd73f48e1f0e271d6bfe663f0344af62d7def40..8c90ba9056bc7473164494ac81060d5649e76e60 100644 (file)
@@ -15,9 +15,6 @@
 
        <t:a t:href="$todo-list/edit" t:query="id">Edit</t:a>
        |
-       <t:form t:action="$todo-list/delete" class="inline">
-               <t:edit t:component="id" />
-               <button class="link-button link">Delete</button>
-       </t:form>
+       <t:button t:action="$todo-list/delete" t:for="id" class="link-button link">Delete</t:button>
 
 </t:chloe>
diff --git a/extra/xml/backend/backend.factor b/extra/xml/backend/backend.factor
new file mode 100644 (file)
index 0000000..5dee386
--- /dev/null
@@ -0,0 +1,6 @@
+! Copyright (C) 2008 Daniel Ehrenberg
+! See http://factorcode.org/license.txt for BSD license.
+IN: xml.backend
+
+! A stack of { tag children } pairs
+SYMBOL: xml-stack
diff --git a/extra/xml/errors/errors-tests.factor b/extra/xml/errors/errors-tests.factor
new file mode 100755 (executable)
index 0000000..402c76d
--- /dev/null
@@ -0,0 +1,28 @@
+USING: continuations xml xml.errors tools.test kernel arrays xml.data state-parser quotations ;
+IN: xml.errors.tests
+
+: xml-error-test ( expected-error xml-string -- )
+    [ string>xml ] curry swap [ = ] curry must-fail-with ;
+
+T{ no-entity f 1 10 "nbsp" } "<x>&nbsp;</x>" xml-error-test
+T{ mismatched f 1 8 T{ name f "" "x" "" } T{ name f "" "y" "" }
+} "<x></y>" xml-error-test
+T{ unclosed f 1 4 V{ T{ name f "" "x" "" } } } "<x>" xml-error-test
+T{ nonexist-ns f 1 5 "x" } "<x:y/>" xml-error-test
+T{ unopened f 1 5 } "</x>" xml-error-test
+T{ not-yes/no f 1 41 "maybe" } "<?xml version='1.0' standalone='maybe'?><x/>" xml-error-test
+T{ extra-attrs f 1 32 V{ T{ name f "" "foo" f } }
+} "<?xml version='1.1' foo='bar'?><x/>" xml-error-test
+T{ bad-version f 1 28 "5 million" } "<?xml version='5 million'?><x/>" xml-error-test
+T{ notags f 1 0 } "" xml-error-test
+T{ multitags } "<x/><y/>" xml-error-test
+T{ bad-prolog  f 1 26 T{ prolog f "1.0" "UTF-8" f }
+} "<x/><?xml version='1.0'?>" xml-error-test
+T{ capitalized-prolog f 1 6 "XmL" } "<?XmL version='1.0'?><x/>"
+xml-error-test
+T{ pre/post-content f "x" t } "x<y/>" xml-error-test
+T{ versionless-prolog f 1 8 } "<?xml?><x/>" xml-error-test
+T{ bad-instruction f 1 11 T{ instruction f "xsl" }
+} "<x><?xsl?></x>" xml-error-test
+T{ bad-directive f 1 15 T{ directive f "DOCTYPE" }
+} "<x/><!DOCTYPE>" xml-error-test
index 5b41a7ff9f1b6051415b9cd67b9845d64b0b870d..53f2046a544c77019cbc2c03ad56078e417ac3dc 100644 (file)
 ! Copyright (C) 2005, 2006 Daniel Ehrenberg
 ! See http://factorcode.org/license.txt for BSD license.
 USING: xml.data xml.writer kernel generic io prettyprint math 
-debugger sequences state-parser ;
+debugger sequences state-parser accessors inspector
+namespaces io.streams.string xml.backend ;
 IN: xml.errors
 
-TUPLE: no-entity thing ;
-: <no-entity> ( string -- error )
-    { set-no-entity-thing } no-entity construct-parsing-error ;
-M: no-entity error.
-    dup parsing-error.
-    "Entity does not exist: &" write no-entity-thing write ";" print ;
+TUPLE: multitags ;
+C: <multitags> multitags
+M: multitags summary ( obj -- str )
+    drop "XML document contains multiple main tags" ;
 
-TUPLE: xml-string-error string ; ! this should not exist
+TUPLE: pre/post-content string pre? ;
+C: <pre/post-content> pre/post-content
+M: pre/post-content summary ( obj -- str )
+    [
+        "The text string:" print
+        dup string>> .
+        "was used " write
+        pre?>> "before" "after" ? write
+        " the main tag." print
+    ] with-string-writer ;
+
+TUPLE: no-entity < parsing-error thing ;
+: <no-entity> ( string -- error )
+    \ no-entity parsing-error swap >>thing ;
+M: no-entity summary ( obj -- str )
+    [
+        dup call-next-method write
+        "Entity does not exist: &" write thing>> write ";" print
+    ] with-string-writer ;
+
+TUPLE: xml-string-error < parsing-error string ; ! this should not exist
 : <xml-string-error> ( string -- xml-string-error )
-    { set-xml-string-error-string }
-    xml-string-error construct-parsing-error ;
-M: xml-string-error error.
-    dup parsing-error.
-    xml-string-error-string print ;
-
-TUPLE: mismatched open close ;
+    \ xml-string-error parsing-error swap >>string ;
+M: xml-string-error summary ( obj -- str )
+    [
+        dup call-next-method write
+        string>> print
+    ] with-string-writer ;
+
+TUPLE: mismatched < parsing-error open close ;
 : <mismatched>
-    { set-mismatched-open set-mismatched-close }
-    mismatched construct-parsing-error ;
-M: mismatched error.
-    dup parsing-error.
-    "Mismatched tags" print
-    "Opening tag: <" write dup mismatched-open print-name ">" print
-    "Closing tag: </" write mismatched-close print-name ">" print ;
-
-TUPLE: unclosed tags ;
-! <unclosed> is ( -- unclosed ), see presentation.factor
-M: unclosed error.
-    "Unclosed tags" print
-    "Tags: " print
-    unclosed-tags [ "  <" write print-name ">" print ] each ;
-
-TUPLE: bad-uri string ;
+    \ mismatched parsing-error swap >>close swap >>open ;
+M: mismatched summary ( obj -- str )
+    [
+        dup call-next-method write
+        "Mismatched tags" print
+        "Opening tag: <" write dup open>> print-name ">" print
+        "Closing tag: </" write close>> print-name ">" print
+    ] with-string-writer ;
+
+TUPLE: unclosed < parsing-error tags ;
+: <unclosed> ( -- unclosed )
+    unclosed parsing-error
+        xml-stack get rest-slice [ first opener-name ] map >>tags ;
+M: unclosed summary ( obj -- str )
+    [
+        dup call-next-method write
+        "Unclosed tags" print
+        "Tags: " print
+        tags>> [ "  <" write print-name ">" print ] each
+    ] with-string-writer ;
+
+TUPLE: bad-uri < parsing-error string ;
 : <bad-uri> ( string -- bad-uri )
-    { set-bad-uri-string } bad-uri construct-parsing-error ;
-M: bad-uri error.
-    dup parsing-error.
-    "Bad URI:" print bad-uri-string . ;
-
-TUPLE: nonexist-ns name ;
+    \ bad-uri parsing-error swap >>string ;
+M: bad-uri summary ( obj -- str )
+    [
+        dup call-next-method write
+        "Bad URI:" print string>> .
+    ] with-string-writer ;
+
+TUPLE: nonexist-ns < parsing-error name ;
 : <nonexist-ns> ( name-string -- nonexist-ns )
-    { set-nonexist-ns-name }
-    nonexist-ns construct-parsing-error ;
-M: nonexist-ns error.
-    dup parsing-error.
-    "Namespace " write nonexist-ns-name write " has not been declared" print ;
-
-TUPLE: unopened ; ! this should give which tag was unopened
+    \ nonexist-ns parsing-error swap >>name ;
+M: nonexist-ns summary ( obj -- str )
+    [
+        dup call-next-method write
+        "Namespace " write name>> write " has not been declared" print
+    ] with-string-writer ;
+
+TUPLE: unopened < parsing-error ; ! this should give which tag was unopened
 : <unopened> ( -- unopened )
-    { } unopened construct-parsing-error ;
-M: unopened error.
-    parsing-error.
-    "Closed an unopened tag" print ;
-
-TUPLE: not-yes/no text ;
+    \ unopened parsing-error ;
+M: unopened summary ( obj -- str )
+    [
+        call-next-method write
+        "Closed an unopened tag" print
+    ] with-string-writer ;
+
+TUPLE: not-yes/no < parsing-error text ;
 : <not-yes/no> ( text -- not-yes/no )
-    { set-not-yes/no-text } not-yes/no construct-parsing-error ;
-M: not-yes/no error.
-    dup parsing-error.
-    "standalone must be either yes or no, not \"" write
-    not-yes/no-text write "\"." print ;
-
-TUPLE: extra-attrs attrs ; ! this should actually print the names
+    \ not-yes/no parsing-error swap >>text ;
+M: not-yes/no summary ( obj -- str )
+    [
+        dup call-next-method write
+        "standalone must be either yes or no, not \"" write
+        text>> write "\"." print
+    ] with-string-writer ;
+
+! this should actually print the names
+TUPLE: extra-attrs < parsing-error attrs ;
 : <extra-attrs> ( attrs -- extra-attrs )
-    { set-extra-attrs-attrs }
-    extra-attrs construct-parsing-error ;
-M: extra-attrs error.
-    dup parsing-error.
-    "Extra attributes included in xml version declaration:" print
-    extra-attrs-attrs . ;
-
-TUPLE: bad-version num ;
+    \ extra-attrs parsing-error swap >>attrs ;
+M: extra-attrs summary ( obj -- str )
+    [
+        dup call-next-method write
+        "Extra attributes included in xml version declaration:" print
+        attrs>> .
+    ] with-string-writer ;
+
+TUPLE: bad-version < parsing-error num ;
 : <bad-version>
-    { set-bad-version-num }
-    bad-version construct-parsing-error ;
-M: bad-version error.
-    "XML version must be \"1.0\" or \"1.1\". Version here was " write
-    bad-version-num . ;
+    \ bad-version parsing-error swap >>num ;
+M: bad-version summary ( obj -- str )
+    [
+        "XML version must be \"1.0\" or \"1.1\". Version here was " write
+        num>> .
+    ] with-string-writer ;
 
 TUPLE: notags ;
 C: <notags> notags
-M: notags error.
-    drop "XML document lacks a main tag" print ;
-
-TUPLE: multitags ;
-C: <multitags> multitags
-M: multitags error.
-    drop "XML document contains multiple main tags" print ;
+M: notags summary ( obj -- str )
+    drop "XML document lacks a main tag" ;
 
-TUPLE: bad-prolog prolog ;
+TUPLE: bad-prolog < parsing-error prolog ;
 : <bad-prolog> ( prolog -- bad-prolog )
-    { set-bad-prolog-prolog }
-    bad-prolog construct-parsing-error ;
-M: bad-prolog error.
-    dup parsing-error.
-    "Misplaced XML prolog" print
-    bad-prolog-prolog write-prolog nl ;
-
-TUPLE: capitalized-prolog name ;
+    \ bad-prolog parsing-error swap >>prolog ;
+M: bad-prolog summary ( obj -- str )
+    [
+        dup call-next-method write
+        "Misplaced XML prolog" print
+        prolog>> write-prolog nl
+    ] with-string-writer ;
+
+TUPLE: capitalized-prolog < parsing-error name ;
 : <capitalized-prolog> ( name -- capitalized-prolog )
-    { set-capitalized-prolog-name }
-    capitalized-prolog construct-parsing-error ;
-M: capitalized-prolog error.
-    dup parsing-error.
-    "XML prolog name was partially or totally capitalized, using" print
-    "<?" write capitalized-prolog-name write "...?>" write
-    " instead of <?xml...?>" print ;
-
-TUPLE: pre/post-content string pre? ;
-C: <pre/post-content> pre/post-content
-M: pre/post-content error.
-    "The text string:" print
-    dup pre/post-content-string .
-    "was used " write
-    pre/post-content-pre? "before" "after" ? write
-    " the main tag." print ;
-
-TUPLE: versionless-prolog ;
+    \ capitalized-prolog parsing-error swap >>name ;
+M: capitalized-prolog summary ( obj -- str )
+    [
+        dup call-next-method write
+        "XML prolog name was partially or totally capitalized, using" print
+        "<?" write name>> write "...?>" write
+        " instead of <?xml...?>" print
+    ] with-string-writer ;
+
+TUPLE: versionless-prolog < parsing-error ;
 : <versionless-prolog> ( -- versionless-prolog )
-    { } versionless-prolog construct-parsing-error ;
-M: versionless-prolog error.
-    parsing-error.
-    "XML prolog lacks a version declaration" print ;
-
-TUPLE: bad-instruction inst ;
+    \ versionless-prolog parsing-error ;
+M: versionless-prolog summary ( obj -- str )
+    [
+        call-next-method write
+        "XML prolog lacks a version declaration" print
+    ] with-string-writer ;
+
+TUPLE: bad-instruction < parsing-error instruction ;
 : <bad-instruction> ( instruction -- bad-instruction )
-    { set-bad-instruction-inst }
-    bad-instruction construct-parsing-error ;
-M: bad-instruction error.
-    dup parsing-error.
-    "Misplaced processor instruction:" print
-    bad-instruction-inst write-item nl ;
-
-TUPLE: bad-directive dir ;
+    \ bad-instruction parsing-error swap >>instruction ;
+M: bad-instruction summary ( obj -- str )
+    [
+        dup call-next-method write
+        "Misplaced processor instruction:" print
+        instruction>> write-item nl
+    ] with-string-writer ;
+
+TUPLE: bad-directive < parsing-error dir ;
 : <bad-directive> ( directive -- bad-directive )
-    { set-bad-directive-dir }
-    bad-directive construct-parsing-error ;
-M: bad-directive error.
-    dup parsing-error.
-    "Misplaced directive:" print
-    bad-directive-dir write-item nl ;
+    \ bad-directive parsing-error swap >>dir ;
+M: bad-directive summary ( obj -- str )
+    [
+        dup call-next-method write
+        "Misplaced directive:" print
+        bad-directive-dir write-item nl
+    ] with-string-writer ;
 
 UNION: xml-parse-error multitags notags extra-attrs nonexist-ns
        not-yes/no unclosed mismatched xml-string-error expected no-entity
diff --git a/extra/xml/tests/errors.factor b/extra/xml/tests/errors.factor
deleted file mode 100755 (executable)
index 6ba0b0d..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-USING: continuations xml xml.errors tools.test kernel arrays xml.data state-parser quotations ;
-IN: xml.tests
-
-: xml-error-test ( expected-error xml-string -- )
-    [ string>xml ] curry swap [ = ] curry must-fail-with ;
-
-T{ no-entity T{ parsing-error f 1 10 } "nbsp" } "<x>&nbsp;</x>" xml-error-test
-T{ mismatched T{ parsing-error f 1 8 } T{ name f "" "x" "" } T{ name f "" "y" "" }
-} "<x></y>" xml-error-test
-T{ unclosed f V{ T{ name f "" "x" "" } } } "<x>" xml-error-test
-T{ nonexist-ns T{ parsing-error f 1 5 } "x" } "<x:y/>" xml-error-test
-T{ unopened T{ parsing-error f 1 5 } } "</x>" xml-error-test
-T{ not-yes/no T{ parsing-error f 1 41 } "maybe" } "<?xml version='1.0' standalone='maybe'?><x/>" xml-error-test
-T{ extra-attrs T{ parsing-error f 1 32 } V{ T{ name f "" "foo" f } }
-} "<?xml version='1.1' foo='bar'?><x/>" xml-error-test
-T{ bad-version T{ parsing-error f 1 28 } "5 million" } "<?xml version='5 million'?><x/>" xml-error-test
-T{ notags f } "" xml-error-test
-T{ multitags f } "<x/><y/>" xml-error-test
-T{ bad-prolog T{ parsing-error f 1 26 } T{ prolog f "1.0" "UTF-8" f }
-} "<x/><?xml version='1.0'?>" xml-error-test
-T{ capitalized-prolog T{ parsing-error f 1 6 } "XmL" } "<?XmL version='1.0'?><x/>"
-xml-error-test
-T{ pre/post-content f "x" t } "x<y/>" xml-error-test
-T{ versionless-prolog T{ parsing-error f 1 8 } } "<?xml?><x/>" xml-error-test
-T{ bad-instruction T{ parsing-error f 1 11 } T{ instruction f "xsl" }
-} "<x><?xsl?></x>" xml-error-test
-T{ bad-directive T{ parsing-error f 1 15 } T{ directive f "DOCTYPE" }
-} "<x/><!DOCTYPE>" xml-error-test
index 775930025f0e7769f66f9fc405603b014407df85..c7452bb079f38c51c0c216e88959263bd0ad2b38 100755 (executable)
@@ -10,6 +10,6 @@ IN: xml.tests
     [ assemble-data ] map ;
 
 [ "http://www.foxnews.com/oreilly/" ] [
-    "extra/xml/tests/soap.xml" resource-path file>xml
+    "resource:extra/xml/tests/soap.xml" file>xml
     parse-result first first
 ] unit-test
index d85345b3c72d87fca3ea4f0a974796df10ff9bb9..77949301440ddfad9c97863030bed8342709957f 100644 (file)
@@ -9,7 +9,7 @@ USING: kernel xml tools.test io namespaces sequences xml.errors xml.entities
 \ read-xml must-infer
 
 SYMBOL: xml-file
-[ ] [ "extra/xml/tests/test.xml" resource-path
+[ ] [ "resource:extra/xml/tests/test.xml"
     [ file>xml ] with-html-entities xml-file set ] unit-test
 [ "1.0" ] [ xml-file get xml-prolog prolog-version ] unit-test
 [ f ] [ xml-file get xml-prolog prolog-standalone ] unit-test
index dd77d7c7665dd2e23ffb01c215d0ec52abc9dd1f..6a2ff1109ec67c8cc076dafa8ee7f15cac06a2af 100644 (file)
@@ -42,17 +42,17 @@ HELP: xml-reprint
 \r
 HELP: write-xml\r
 { $values { "xml" "an XML document" } }\r
-{ $description "prints the contents of an XML document (" { $link xml } ") to stdio" }\r
+{ $description "prints the contents of an XML document (" { $link xml } ") to " { $link output-stream } "." }\r
 { $notes "does not preserve what type of quotes were used or what data was omitted from version declaration" } ;\r
 \r
 HELP: print-xml\r
 { $values { "xml" "an XML document" } }\r
-{ $description "prints the contents of an XML document (" { $link xml } ") to stdio, followed by a newline" }\r
+{ $description "prints the contents of an XML document (" { $link xml } ") to " { $link output-stream } ", followed by a newline" }\r
 { $notes "does not preserve what type of quotes were used or what data was omitted from version declaration" } ;\r
 \r
 HELP: pprint-xml\r
 { $values { "xml" "an XML document" } }\r
-{ $description "prints the contents of an XML document (" { $link xml } ") to stdio in a prettyprinted form." }\r
+{ $description "prints the contents of an XML document (" { $link xml } ") to " { $link output-stream } " in a prettyprinted form." }\r
 { $notes "does not preserve what type of quotes were used or what data was omitted from version declaration" } ;\r
 \r
 HELP: pprint-xml-but\r
@@ -226,7 +226,7 @@ HELP: pull-xml
 \r
 HELP: <pull-xml>\r
 { $values { "pull-xml" "a pull-xml tuple" } }\r
-{ $description "creates an XML pull-based parser which reads from the " { $link stdio } " stream, executing all initial XML commands to set up the parser." }\r
+{ $description "creates an XML pull-based parser which reads from " { $link input-stream } ", executing all initial XML commands to set up the parser." }\r
 { $see-also pull-xml pull-elem pull-event } ;\r
 \r
 HELP: pull-elem\r
@@ -241,12 +241,12 @@ HELP: pull-event
 \r
 HELP: write-item\r
 { $values { "object" "an XML element" } }\r
-{ $description "writes an XML element to the " { $link stdio } " stream." }\r
+{ $description "writes an XML element to " { $link output-stream } "." }\r
 { $see-also write-chunk write-xml } ;\r
 \r
 HELP: write-chunk\r
 { $values { "seq" "an XML document fragment" } }\r
-{ $description "writes an XML document fragment, ie a sequence of XML elements, to the " { $link stdio } " stream." }\r
+{ $description "writes an XML document fragment, ie a sequence of XML elements, to " { $link output-stream } "." }\r
 { $see-also write-item write-xml } ;\r
 \r
 HELP: deep-tag-named\r
index 2d7c8c8ff8e2a2abb8d4d6eca69dc505053963b5..4e2ad7a67231c7234a0af8ecc5f5910dc070e1f8 100644 (file)
@@ -3,18 +3,12 @@
 USING: io io.streams.string io.files kernel math namespaces
 prettyprint sequences arrays generic strings vectors
 xml.char-classes xml.data xml.errors xml.tokenize xml.writer
-xml.utilities state-parser assocs ascii io.encodings.utf8 ;
+xml.utilities state-parser assocs ascii io.encodings.utf8
+accessors xml.backend ;
 IN: xml
 
 !   -- Overall parser with data tree
 
-! A stack of { tag children } pairs
-SYMBOL: xml-stack
-
-: <unclosed> ( -- unclosed )
-    xml-stack get rest-slice [ first opener-name ] map
-    { set-unclosed-tags } unclosed construct ;
-
 : add-child ( object -- )
     xml-stack get peek second push ;
 
@@ -104,7 +98,7 @@ SYMBOL: text-now?
 TUPLE: pull-xml scope ;
 : <pull-xml> ( -- pull-xml )
     [
-        stdio [ ] change ! bring stdio var in this scope
+        input-stream [ ] change ! bring var in this scope
         init-parser reset-prolog init-ns-stack
         text-now? on
     ] H{ } make-assoc
index 22d3217ee69c89b3e94514ee2a88a8bdb9a65682..277439c0cdb1bf3241b9693b569c387be9406fda 100755 (executable)
@@ -24,7 +24,7 @@ TAGS>
     ] keep ;
 
 : load-catalog ( -- modes )
-    "extra/xmode/modes/catalog" resource-path
+    "resource:extra/xmode/modes/catalog"
     file>xml parse-modes-tag ;
 
 : modes ( -- assoc )
@@ -38,8 +38,8 @@ TAGS>
 MEMO: (load-mode) ( name -- rule-sets )
     modes at [
         mode-file
-        "extra/xmode/modes/" prepend
-        resource-path utf8 <file-reader> parse-mode
+        "resource:extra/xmode/modes/" prepend
+        utf8 <file-reader> parse-mode
     ] [
         "text" (load-mode)
     ] if* ;
index a13e412afe4366e5d61bbdb5685f513c8f95b001..3977f4277c37a7f0bd9b33881560c59b8c90e319 100755 (executable)
@@ -20,8 +20,8 @@ IN: xmode.code2html
 
 : default-stylesheet ( -- )
     <style>
-        "extra/xmode/code2html/stylesheet.css"
-        resource-path utf8 file-contents write
+        "resource:extra/xmode/code2html/stylesheet.css"
+        utf8 file-contents write
     </style> ;
 
 : htmlize-stream ( path stream -- )
@@ -42,8 +42,7 @@ IN: xmode.code2html
 
 : htmlize-file ( path -- )
     dup utf8 [
-        stdio get
-        over ".html" append utf8 [
-            htmlize-stream
+        dup ".html" append utf8 [
+            input-stream get htmlize-stream
         ] with-file-writer
     ] with-file-reader ;
index 99689d88191fb72566ea93aa080d34dcf9acf194..a2183edbc9f936c88ec0c59a44903fac2ea423d8 100755 (executable)
@@ -48,6 +48,6 @@ TAGS>
         "This is a great company"
     }
 ] [
-    "extra/xmode/utilities/test.xml"
-    resource-path file>xml parse-company-tag
+    "resource:extra/xmode/utilities/test.xml"
+    file>xml parse-company-tag
 ] unit-test
index 197fa4900b3cd68473f158dfa8c39986d8877778..46d05ce720212d02c28526d92c77a12d6a3d1d92 100644 (file)
@@ -6,6 +6,6 @@ USING: tools.test yahoo kernel io.files xml sequences ;
     "Official Foo Fighters"
     "http://www.foofighters.com/"
     "Official site with news, tour dates, discography, store, community, and more."
-} ] [ "extra/yahoo/test-results.xml" resource-path file>xml parse-yahoo first ] unit-test
+} ] [ "resource:extra/yahoo/test-results.xml" file>xml parse-yahoo first ] unit-test
 
 [ "http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=Factor-search&query=hi&results=1" ] [ "hi" 1 query ] unit-test
index 03394b933c04cb7da3b6aae31336b5b808e69179..1bf9a17aa6c26a7e0f83b9b0f33bb4a9a30a3dfa 100644 (file)
@@ -29,7 +29,7 @@
                        <key>begin</key>
                        <string>&lt;%\s</string>
                        <key>end</key>
-                       <string>\s%&gt;</string>
+                       <string>(?&lt;=\s)%&gt;</string>
                        <key>name</key>
                        <string>source.factor.embedded.html</string>
                        <key>patterns</key>
diff --git a/unmaintained/openssl/authors.txt b/unmaintained/openssl/authors.txt
new file mode 100644 (file)
index 0000000..7c29e7c
--- /dev/null
@@ -0,0 +1 @@
+Elie Chaftari
diff --git a/unmaintained/openssl/libcrypto/libcrypto.factor b/unmaintained/openssl/libcrypto/libcrypto.factor
new file mode 100755 (executable)
index 0000000..312c7b0
--- /dev/null
@@ -0,0 +1,131 @@
+! Copyright (C) 2007 Elie CHAFTARI
+! See http://factorcode.org/license.txt for BSD license.
+!
+! Tested with OpenSSL 0.9.8a_0 on Mac OS X 10.4.9 PowerPC
+!
+! export LD_LIBRARY_PATH=/opt/local/lib
+
+USING: alien alien.syntax combinators kernel system ;
+
+IN: openssl.libcrypto
+
+<<
+"libcrypto" {
+    { [ os winnt? ]  [ "libeay32.dll" "cdecl" ] }
+    { [ os macosx? ] [ "libcrypto.dylib" "cdecl" ] }
+    { [ os unix? ]   [ "libcrypto.so" "cdecl" ] }
+} cond add-library
+>>
+
+C-STRUCT: bio-method
+    { "int" "type" }
+    { "void*" "name" }
+    { "void*" "bwrite" }
+    { "void*" "bread" }
+    { "void*" "bputs" }
+    { "void*" "bgets" }
+    { "void*" "ctrl" }
+    { "void*" "create" }
+    { "void*" "destroy" }
+    { "void*" "callback-ctrl" } ;
+
+C-STRUCT: bio
+    { "void*" "method" }
+    { "void*" "callback" }
+    { "void*" "cb-arg" }
+    { "int" "init" }
+    { "int" "shutdown" }
+    { "int" "flags" }
+    { "int" "retry-reason" }
+    { "int" "num" }
+    { "void*" "ptr" }
+    { "void*" "next-bio" }
+    { "void*" "prev-bio" }
+    { "int" "references" } 
+    { "ulong" "num-read" }
+    { "ulong" "num-write" } 
+    { "void*" "crypto-ex-data-stack" }
+    { "int" "crypto-ex-data-dummy" } ;
+
+: BIO_NOCLOSE       HEX: 00 ; inline
+: BIO_CLOSE         HEX: 01 ; inline
+
+: RSA_3             HEX: 3 ; inline
+: RSA_F4            HEX: 10001 ; inline
+
+: BIO_C_SET_SSL     109 ; inline
+: BIO_C_GET_SSL     110 ; inline
+
+LIBRARY: libcrypto
+
+! ===============================================
+! bio.h
+! ===============================================
+
+FUNCTION: bio* BIO_new_file ( char* filename, char* mode ) ;
+
+FUNCTION: int BIO_printf ( bio* bio, char* format ) ;
+
+FUNCTION: long BIO_ctrl ( void* bio, int cmd, long larg, void* parg ) ;
+
+FUNCTION: void* BIO_new_socket ( int fd, int close-flag ) ;
+
+FUNCTION: void* BIO_new ( void* method ) ;
+
+FUNCTION: int BIO_set ( void* bio, void* method ) ;
+
+FUNCTION: int BIO_free ( void* bio ) ;
+
+FUNCTION: void* BIO_push ( void* bio, void* append ) ;
+
+FUNCTION: int BIO_read ( void* b, void* buf, int len ) ;
+
+FUNCTION: int BIO_gets ( void* b, char* buf, int size ) ;
+
+FUNCTION: int BIO_write ( void* b, void* buf, int len ) ;
+
+FUNCTION: int BIO_puts ( void* bp, char* buf ) ;
+
+FUNCTION: ulong ERR_get_error (  ) ;
+
+FUNCTION: char* ERR_error_string ( ulong e, void* buf ) ;
+
+FUNCTION: void* BIO_f_buffer (  ) ;
+
+! ===============================================
+! evp.h
+! ===============================================
+
+! Initialize ciphers and digest tables
+FUNCTION: void OpenSSL_add_all_ciphers (  ) ;
+
+FUNCTION: void OpenSSL_add_all_digests (  ) ;
+
+! Clean them up before exiting
+FUNCTION: void EVP_cleanup (  ) ;
+
+FUNCTION: void* EVP_get_digestbyname ( char* name ) ;
+
+FUNCTION: void EVP_MD_CTX_init ( void* ctx ) ;
+
+FUNCTION: void* PEM_read_bio_DHparams ( void* bp, void* x, void* cb,
+                                        void* u ) ;
+
+! ===============================================
+! md5.h
+! ===============================================
+
+FUNCTION: uchar* MD5 ( uchar* d, ulong n, uchar* md ) ;
+
+! ===============================================
+! rsa.h
+! ===============================================
+
+FUNCTION: void* RSA_generate_key ( int num, ulong e, void* callback,
+                                   void* cb_arg ) ;
+
+FUNCTION: int RSA_check_key ( void* rsa ) ;
+
+FUNCTION: void RSA_free ( void* rsa ) ;
+
+FUNCTION: int RSA_print_fp ( void* fp, void* x, int offset ) ;
diff --git a/unmaintained/openssl/libssl/libssl.factor b/unmaintained/openssl/libssl/libssl.factor
new file mode 100755 (executable)
index 0000000..0f2e7b3
--- /dev/null
@@ -0,0 +1,174 @@
+! Copyright (C) 2007 Elie CHAFTARI
+! See http://factorcode.org/license.txt for BSD license.
+!
+! Tested with OpenSSL 0.9.8a_0 on Mac OS X 10.4.9 PowerPC
+!
+! export LD_LIBRARY_PATH=/opt/local/lib
+
+USING: alien alien.syntax combinators kernel system ;
+
+IN: openssl.libssl
+
+<< "libssl" {
+    { [ os winnt? ]  [ "ssleay32.dll" "cdecl" ] }
+    { [ os macosx? ] [ "libssl.dylib" "cdecl" ] }
+    { [ os unix? ]   [ "libssl.so" "cdecl" ] }
+} cond add-library >>
+
+: X509_FILETYPE_PEM       1 ; inline
+: X509_FILETYPE_ASN1      2 ; inline
+: X509_FILETYPE_DEFAULT   3 ; inline
+
+: SSL_FILETYPE_ASN1  X509_FILETYPE_ASN1 ; inline
+: SSL_FILETYPE_PEM   X509_FILETYPE_PEM ; inline
+
+: SSL_CTRL_NEED_TMP_RSA      1 ; inline
+: SSL_CTRL_SET_TMP_RSA       2 ; inline
+: SSL_CTRL_SET_TMP_DH        3 ; inline
+: SSL_CTRL_SET_TMP_RSA_CB    4 ; inline
+: SSL_CTRL_SET_TMP_DH_CB     5 ; inline
+
+: SSL_ERROR_NONE             0 ; inline
+: SSL_ERROR_SSL              1 ; inline
+: SSL_ERROR_WANT_READ        2 ; inline
+: SSL_ERROR_WANT_WRITE       3 ; inline
+: SSL_ERROR_WANT_X509_LOOKUP 4 ; inline
+: SSL_ERROR_SYSCALL          5 ; inline ! consult errno for details
+: SSL_ERROR_ZERO_RETURN      6 ; inline
+: SSL_ERROR_WANT_CONNECT     7 ; inline
+: SSL_ERROR_WANT_ACCEPT      8 ; inline
+
+! Error messages table
+: error-messages ( -- hash )
+    H{
+        { 0  "SSL_ERROR_NONE" }
+        { 1  "SSL_ERROR_SSL" }
+        { 2  "SSL_ERROR_WANT_READ" }
+        { 3  "SSL_ERROR_WANT_WRITE" }
+        { 4  "SSL_ERROR_WANT_X509_LOOKUP" }
+        { 5  "SSL_ERROR_SYSCALL" }
+        { 6  "SSL_ERROR_ZERO_RETURN" }
+        { 7  "SSL_ERROR_WANT_CONNECT" }
+        { 8  "SSL_ERROR_WANT_ACCEPT" }
+    } ;
+
+TYPEDEF: void* ssl-method
+TYPEDEF: void* ssl-ctx
+TYPEDEF: void* ssl-pointer
+
+LIBRARY: libssl
+
+! ===============================================
+! ssl.h
+! ===============================================
+
+FUNCTION: char* SSL_get_version ( ssl-pointer ssl ) ;
+
+! Maps OpenSSL errors to strings
+FUNCTION: void SSL_load_error_strings (  ) ;
+
+! Must be called before any other action takes place
+FUNCTION: int SSL_library_init (  ) ;
+
+! Sets the default SSL version
+FUNCTION: ssl-method SSLv2_client_method (  ) ;
+
+FUNCTION: ssl-method SSLv23_client_method (  ) ;
+
+FUNCTION: ssl-method SSLv23_server_method (  ) ;
+
+FUNCTION: ssl-method SSLv23_method (  ) ; ! SSLv3 but can rollback to v2
+
+FUNCTION: ssl-method SSLv3_client_method (  ) ;
+
+FUNCTION: ssl-method SSLv3_server_method (  ) ;
+
+FUNCTION: ssl-method SSLv3_method (  ) ;
+
+FUNCTION: ssl-method TLSv1_client_method (  ) ;
+
+FUNCTION: ssl-method TLSv1_server_method (  ) ;
+
+FUNCTION: ssl-method TLSv1_method (  ) ;
+
+! Creates the context
+FUNCTION: ssl-ctx SSL_CTX_new ( ssl-method method ) ;
+
+! Load the certificates and private keys into the SSL_CTX
+FUNCTION: int SSL_CTX_use_certificate_chain_file ( ssl-ctx ctx,
+                                                   char* file ) ; ! PEM type
+FUNCTION: ssl-pointer SSL_new ( ssl-ctx ctx ) ;
+
+FUNCTION: int SSL_set_fd ( ssl-pointer ssl, int fd ) ;
+
+FUNCTION: void SSL_set_bio ( ssl-pointer ssl, void* rbio, void* wbio ) ;
+
+FUNCTION: int SSL_get_error ( ssl-pointer ssl, int ret ) ;
+
+FUNCTION: void SSL_set_connect_state ( ssl-pointer ssl ) ;
+
+FUNCTION: void SSL_set_accept_state ( ssl-pointer ssl ) ;
+
+FUNCTION: int SSL_connect ( ssl-pointer ssl ) ;
+
+FUNCTION: int SSL_accept ( ssl-pointer ssl ) ;
+
+FUNCTION: int SSL_write ( ssl-pointer ssl, void* buf, int num ) ;
+
+FUNCTION: int SSL_read ( ssl-pointer ssl, void* buf, int num ) ;
+
+FUNCTION: void SSL_shutdown ( ssl-pointer ssl ) ;
+
+FUNCTION: void SSL_free ( ssl-pointer ssl ) ;
+
+FUNCTION: void SSL_CTX_free ( ssl-ctx ctx ) ;
+
+FUNCTION: void RAND_seed ( void* buf, int num ) ;
+
+FUNCTION: int SSL_set_cipher_list ( ssl-pointer ssl, char* str ) ;
+
+FUNCTION: int SSL_use_RSAPrivateKey_file ( ssl-pointer ssl, char* str ) ;
+
+FUNCTION: int SSL_CTX_use_RSAPrivateKey_file ( ssl-ctx ctx, int type ) ;
+
+FUNCTION: int SSL_use_certificate_file ( ssl-pointer ssl,
+                                         char* str, int type ) ;
+
+FUNCTION: int SSL_CTX_load_verify_locations ( ssl-ctx ctx, char* CAfile,
+                                              char* CApath ) ;
+
+FUNCTION: void SSL_CTX_set_client_CA_list ( ssl-ctx ctx, ssl-pointer list ) ;
+
+FUNCTION: ssl-pointer SSL_load_client_CA_file ( char* file ) ;
+
+! Used to manipulate settings of the SSL_CTX and SSL objects.
+! This function should never be called directly
+FUNCTION: long SSL_CTX_ctrl ( ssl-ctx ctx, int cmd, long larg, void* parg ) ;
+
+FUNCTION: void SSL_CTX_set_default_passwd_cb ( ssl-ctx ctx, void* cb ) ;
+
+FUNCTION: void SSL_CTX_set_default_passwd_cb_userdata ( ssl-ctx ctx,
+                                                        void* u ) ;
+
+FUNCTION: int SSL_CTX_use_PrivateKey_file ( ssl-ctx ctx, char* file,
+                                            int type ) ;
+
+! Sets the maximum depth for the allowed ctx certificate chain verification 
+FUNCTION: void SSL_CTX_set_verify_depth ( ssl-ctx ctx, int depth ) ;
+
+! Sets DH parameters to be used to be dh.
+! The key is inherited by all ssl objects created from ctx
+FUNCTION: void SSL_CTX_set_tmp_dh_callback ( ssl-ctx ctx, void* dh ) ;
+
+FUNCTION: void SSL_CTX_set_tmp_rsa_callback ( ssl-ctx ctx, void* rsa ) ;
+
+FUNCTION: void* BIO_f_ssl (  ) ;
+
+! ===============================================
+! sha.h
+! ===============================================
+
+! For a high level interface to message digests
+! use the EVP digest routines in libcrypto.factor
+
+FUNCTION: uchar* SHA1 ( uchar* d, ulong n, uchar* md ) ;
diff --git a/unmaintained/openssl/openssl-docs.factor b/unmaintained/openssl/openssl-docs.factor
new file mode 100644 (file)
index 0000000..dd31bfd
--- /dev/null
@@ -0,0 +1,10 @@
+
+USING: help.syntax help.markup ;
+
+IN: openssl
+
+ARTICLE: "openssl" "OpenSSL"
+
+"Factor on Windows has been tested with this version of OpenSSL: "
+
+{ $url "http://www.openssl.org/related/binaries.html" } ;
\ No newline at end of file
diff --git a/unmaintained/openssl/openssl-tests.factor b/unmaintained/openssl/openssl-tests.factor
new file mode 100755 (executable)
index 0000000..2b840bd
--- /dev/null
@@ -0,0 +1,146 @@
+USING: alien alien.c-types alien.strings assocs bit-arrays
+hashtables io io.files io.encodings.ascii io.sockets kernel
+mirrors openssl.libcrypto openssl.libssl namespaces math
+math.parser openssl prettyprint sequences tools.test ;
+
+! =========================================================
+! Some crypto functions (still to be turned into words)
+! =========================================================
+
+[
+    B{ 201 238 222 100 92 200 182 188 138 255 129 163 115 88 240 136 }
+]
+[ "Hello world from the openssl binding" >md5 ] unit-test
+
+! Not found on netbsd, windows -- why?
+! [
+    ! B{ 63 113 237 255 181 5 152 241 136 181 43 95 160 105 44 87 49
+    ! 82 115 0 }
+! ]
+! [ "Hello world from the openssl binding" >sha1 ] unit-test
+
+! =========================================================
+! Initialize context
+! =========================================================
+
+[ ] [ init load-error-strings ] unit-test
+
+[ ] [ ssl-v23 new-ctx ] unit-test
+
+[ ] [ get-ctx "resource:extra/openssl/test/server.pem" use-cert-chain ] unit-test
+
+! TODO: debug 'Memory protection fault at address 6c'
+! get-ctx 1024 "char" malloc-array 1024 0 f password-cb set-default-passwd
+
+[ ] [ get-ctx "password" ascii string>alien set-default-passwd-userdata ] unit-test
+
+! Enter PEM pass phrase: password
+[ ] [ get-ctx "resource:extra/openssl/test/server.pem"
+SSL_FILETYPE_PEM use-private-key ] unit-test
+
+[ ] [ get-ctx "resource:extra/openssl/test/root.pem" f
+verify-load-locations ] unit-test
+
+[ ] [ get-ctx 1 set-verify-depth ] unit-test
+
+! =========================================================
+! Load Diffie-Hellman parameters
+! =========================================================
+
+[ ] [ "resource:extra/openssl/test/dh1024.pem" "r" bio-new-file ] unit-test
+
+[ ] [ get-bio f f f read-pem-dh-params ] unit-test
+
+[ ] [ get-bio bio-free ] unit-test
+
+! TODO: debug SSL_CTX_set_tmp_dh 'No such symbol'
+[ ] [ get-ctx get-dh set-tmp-dh-callback ] unit-test
+
+! Workaround (this function should never be called directly)
+! [ ] [ get-ctx SSL_CTRL_SET_TMP_DH 0 get-dh set-ctx-ctrl ] unit-test
+
+! =========================================================
+! Generate ephemeral RSA key
+! =========================================================
+
+[ ] [ 512 RSA_F4 f f generate-rsa-key ] unit-test
+
+! TODO: debug SSL_CTX_set_tmp_rsa 'No such symbol'
+! get-ctx get-rsa set-tmp-rsa-callback
+
+! Workaround (this function should never be called directly)
+[ ] [ get-ctx SSL_CTRL_SET_TMP_RSA 0 get-rsa set-ctx-ctrl ] unit-test
+
+[ ] [ get-rsa free-rsa ] unit-test
+
+! =========================================================
+! Listen and accept on socket
+! =========================================================
+
+! SYMBOL: sock
+! SYMBOL: fdset
+! SYMBOL: acset
+! SYMBOL: sbio
+! SYMBOL: ssl
+! 
+! : is-set ( seq -- newseq )
+!     <enum> >alist [ nip ] assoc-filter >hashtable keys ;
+! 
+! ! 1234 server-socket sock set
+! "127.0.0.1" 1234 <inet4> SOCK_STREAM server-fd sock set
+! 
+! FD_SETSIZE 8 * <bit-array> fdset set
+! 
+! FD_SETSIZE 8 * <bit-array> t 8 rot [ set-nth ] keep fdset set
+! 
+! fdset get is-set .
+
+! : loop ( -- )
+!     sock get f f accept
+!     dup -1 = [ drop ] [
+!         dup number>string print flush
+!         ! BIO_NOCLOSE bio-new-socket sbio set
+!         [ get-ctx new-ssl ssl set ] keep
+!         ssl get swap set-ssl-fd
+!         ! ssl get sbio get dup set-ssl-bio
+!         ! ssl get ssl-accept
+!         ! dup 0 <= [ 
+!         !     ssl get swap ssl-get-error 
+!         ! ] [ drop ] if
+!     ] if
+!     loop ;
+
+! { } acset set
+! 
+! : loop ( -- )
+!     ! FD_SETSIZE fdset get f f f select . flush
+!     FD_SETSIZE fdset get f f 10000 make-timeval select 
+!     0 <= [ acset get [ close ] each "timeout" print ] [
+!         fdset get is-set sock get swap member? [ 
+!              sock get f f accept dup . flush 
+!              acset get swap add acset set
+!     ] [ ] if
+!         loop
+!     ] if ;
+! 
+! loop
+! 
+! sock get close
+
+! =========================================================
+! Dump errors to file
+! =========================================================
+
+[ ] [ "resource:extra/openssl/test/errors.txt" "w" bio-new-file ] unit-test
+
+[ 6 ] [ get-bio "Hello\n" bio-print ] unit-test
+
+[ ] [ get-bio bio-free ] unit-test
+
+! =========================================================
+! Clean-up
+! =========================================================
+
+! sock get close
+
+get-ctx destroy-ctx
diff --git a/unmaintained/openssl/openssl.factor b/unmaintained/openssl/openssl.factor
new file mode 100755 (executable)
index 0000000..9b23774
--- /dev/null
@@ -0,0 +1,154 @@
+! Copyright (C) 2007 Elie CHAFTARI
+! See http://factorcode.org/license.txt for BSD license.
+!
+! Tested with OpenSSL 0.9.8a_0 on Mac OS X 10.4.9 PowerPC
+
+USING: alien alien.c-types alien.strings assocs kernel libc
+namespaces openssl.libcrypto openssl.libssl sequences
+io.encodings.ascii ;
+
+IN: openssl
+
+SYMBOL: bio
+SYMBOL: ssl-bio
+
+SYMBOL: ctx
+SYMBOL: dh
+SYMBOL: rsa
+
+! =========================================================
+! Callback routines
+! =========================================================
+
+: password-cb ( -- alien )
+    "int" { "char*" "int" "int" "void*" } "cdecl"
+    [ 3drop "password" ascii string>alien 1023 memcpy
+    "password" length ] alien-callback ;
+
+! =========================================================
+! Error-handling routines
+! =========================================================
+
+: get-error ( -- num )
+    ERR_get_error ;
+
+: error-string ( num -- str )
+    f ERR_error_string ;
+
+: check-result ( result -- )
+    1 = [  ] [
+        get-error error-string throw
+    ] if ;
+
+: ssl-get-error ( ssl ret -- )
+    SSL_get_error error-messages at throw ;
+
+! Write errors to a file
+: bio-new-file ( path mode -- )
+    BIO_new_file bio set ;
+
+: bio-print ( bio str -- n )
+    BIO_printf ;
+
+: bio-free ( bio -- )
+    BIO_free check-result ;
+
+! =========================================================
+! Initialization routines
+! =========================================================
+
+: init ( -- )
+    SSL_library_init drop ; ! always returns 1
+
+: load-error-strings ( -- )
+    SSL_load_error_strings ;
+
+: ssl-v23 ( -- method )
+    SSLv23_method ;
+
+: new-ctx ( method -- )
+    SSL_CTX_new ctx set ;
+
+: use-cert-chain ( ctx file -- )
+    SSL_CTX_use_certificate_chain_file check-result ;
+
+: set-default-passwd ( ctx cb -- )
+    SSL_CTX_set_default_passwd_cb ;
+
+: set-default-passwd-userdata ( ctx passwd -- )
+    SSL_CTX_set_default_passwd_cb_userdata ;
+
+: use-private-key ( ctx file type -- )
+    SSL_CTX_use_PrivateKey_file check-result ;
+
+: verify-load-locations ( ctx file path -- )
+    SSL_CTX_load_verify_locations check-result ;
+
+: set-verify-depth ( ctx depth -- )
+    SSL_CTX_set_verify_depth ;
+
+: read-pem-dh-params ( bio x cb u -- )
+    PEM_read_bio_DHparams dh set ;
+
+: set-tmp-dh-callback ( ctx dh -- )
+    SSL_CTX_set_tmp_dh_callback ;
+
+: set-ctx-ctrl ( ctx cmd larg parg -- )
+    SSL_CTX_ctrl check-result ;
+
+: generate-rsa-key ( n e cb cbarg -- )
+    RSA_generate_key rsa set ;
+
+: set-tmp-rsa-callback ( ctx rsa -- )
+    SSL_CTX_set_tmp_rsa_callback ;
+
+: free-rsa ( rsa -- )
+    RSA_free ;
+
+: bio-new-socket ( fd flag -- sbio )
+    BIO_new_socket ;
+
+: new-ssl ( ctx -- ssl )
+    SSL_new ;
+
+: set-ssl-bio ( ssl bio bio -- )
+    SSL_set_bio ;
+
+: set-ssl-fd ( ssl fd -- )
+    SSL_set_fd check-result ;
+
+: ssl-accept ( ssl -- result )
+    SSL_accept ;
+
+! =========================================================
+! Clean-up and termination routines
+! =========================================================
+
+: destroy-ctx ( ctx -- )
+    SSL_CTX_free ;
+
+! =========================================================
+! Public routines
+! =========================================================
+
+: get-bio ( -- bio )
+    bio get ;
+
+: get-ssl-bio ( -- bio )
+    ssl-bio get ;
+
+: get-ctx ( -- ctx )
+    ctx get ;
+
+: get-dh ( -- dh )
+    dh get ;
+
+: get-rsa ( -- rsa )
+    rsa get ;
+
+: >md5 ( str -- byte-array )
+    dup length 16 "uchar" <c-array> [ MD5 ] keep nip ;
+
+: >sha1 ( str -- byte-array )
+    dup length 20 "uchar" <c-array> [ SHA1 ] keep nip ;
+
diff --git a/unmaintained/openssl/summary.txt b/unmaintained/openssl/summary.txt
new file mode 100755 (executable)
index 0000000..42db29f
--- /dev/null
@@ -0,0 +1 @@
+OpenSSL binding
diff --git a/unmaintained/openssl/tags.txt b/unmaintained/openssl/tags.txt
new file mode 100644 (file)
index 0000000..93e252c
--- /dev/null
@@ -0,0 +1,3 @@
+enterprise
+network
+bindings
diff --git a/unmaintained/openssl/test/dh1024.pem b/unmaintained/openssl/test/dh1024.pem
new file mode 100644 (file)
index 0000000..aa68d98
--- /dev/null
@@ -0,0 +1,5 @@
+-----BEGIN DH PARAMETERS-----
+MIGHAoGBANmAnfkETuKHOCWaE+W+F3kM/e7z5A8hZb7OqwGMQrUOaBEAr4BWeZBn
+G/87hhwZgNP69/KUchm714qd/PpOspCaUJ20x6PcmKujpAgca/f19HGMBjRawQMk
+R9oaBwazuQT0l0rTTKmvpMEcrQQIcVWii3CZI56I56oqF8biGPD7AgEC
+-----END DH PARAMETERS-----
diff --git a/unmaintained/openssl/test/errors.txt b/unmaintained/openssl/test/errors.txt
new file mode 100644 (file)
index 0000000..e965047
--- /dev/null
@@ -0,0 +1 @@
+Hello
diff --git a/unmaintained/openssl/test/root.pem b/unmaintained/openssl/test/root.pem
new file mode 100644 (file)
index 0000000..db0c59f
--- /dev/null
@@ -0,0 +1,14 @@
+-----BEGIN CERTIFICATE-----
+MIICIjCCAYugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJVUzET
+MBEGA1UEChMKUlRGTSwgSW5jLjEZMBcGA1UECxMQV2lkZ2V0cyBEaXZpc2lvbjEY
+MBYGA1UEAxMPVGVzdCBDQTIwMDEwNTE3MB4XDTAxMDUxNzE2MDExNFoXDTA2MTIy
+NTE2MDExNFowVzELMAkGA1UEBhMCVVMxEzARBgNVBAoTClJURk0sIEluYy4xGTAX
+BgNVBAsTEFdpZGdldHMgRGl2aXNpb24xGDAWBgNVBAMTD1Rlc3QgQ0EyMDAxMDUx
+NzCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAmkX40warmH0+lnwD9YjsJhRz
+ZX6qXadFry0y2trZ6gMs8Mv33IKPwOu8TE7V+3PESEtjI2wr8juV9OkbIPOm+td5
+M8+6vXyIW+JBo3ch99i0QMTf5/jTgsW+3IjV8yEdiGcZFp2NWKLRvZPq2VRbuF7R
+1pvgcaRuBJ0wGOohwnsCAwEAATANBgkqhkiG9w0BAQQFAAOBgQCUB8zMKIlX5io8
+TalbzH9Qke7BcvFAL+wp/5w1ToVsWkNrINSWKv6bl/jcqOD3aPhK7qhaeOU8ZWKL
+PoPPCnRl9Wo+1JtsOO3qIgJP79Bl9ooLGahixF2v/gea5qNISjQvwYllLSa//APP
+6kXHngO0RIRbiTBYHSkAzm6hDdsvVA==
+-----END CERTIFICATE-----
diff --git a/unmaintained/openssl/test/server.pem b/unmaintained/openssl/test/server.pem
new file mode 100644 (file)
index 0000000..87376db
--- /dev/null
@@ -0,0 +1,32 @@
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,5772A2A7BE34B611
+
+1yJ+xAn4MudcIfXXy7ElYngJ9EohIh8yvcyVLmE4kVd0xeaL/Bqhvk25BjYCK5d9
+k1K8cjgnKEBjbC++0xtJxFSbUhwoKTLwn+sBoJDcFzMKkmJXXDbSTOaNr1sVwiAR
+SnB4lhUcHguYoV5zlRJn53ft7t1mjB6RwGH+d1Zx6t95OqM1lnKqwekwmotVAWHj
+ncu3N8qhmoPMppmzEv0fOo2/pK2WohcJykSeN5zBrZCUxoO0NBNEZkFUcVjR+KsA
+1ZeI1mU60szqg+AoU/XtFcow8RtG1QZKQbbXzyfbwaG+6LqkHaWYKHQEI1546yWK
+us1HJ734uUkZoyyyazG6PiGCYV2u/aY0i3qdmyDqTvmVIvve7E4glBrtDS9h7D40
+nPShIvOatoPzIK4Y0QSvrI3G1vTsIZT3IOZto4AWuOkLNfYS2ce7prOreF0KjhV0
+3tggw9pHdDmTjHTiIkXqheZxZ7TVu+pddZW+CuB62I8lCBGPW7os1f21e3eOD/oY
+YPCI44aJvgP+zUORuZBWqaSJ0AAIuVW9S83Yzkz/tlSFHViOebyd8Cug4TlxK1VI
+q6hbSafh4C8ma7YzlvqjMzqFifcIolcbx+1A6ot0UiayJTUra4d6Uc4Rbc9RIiG0
+jfDWC6aii9YkAgRl9WqSd31yASge/HDqVXFwR48qdlYQ57rcHviqxyrwRDnfw/lX
+Mf6LPiDKEco4MKej7SR2kK2c2AgxUzpGZeAY6ePyhxbdhA0eY21nDeFd/RbwSc5s
+eTiCCMr41OB4hfBFXKDKqsM3K7klhoz6D5WsgE6u3lDoTdz76xOSTg==
+-----END RSA PRIVATE KEY-----
+-----BEGIN CERTIFICATE-----
+MIICGDCCAYECAgEBMA0GCSqGSIb3DQEBBAUAMFcxCzAJBgNVBAYTAlVTMRMwEQYD
+VQQKEwpSVEZNLCBJbmMuMRkwFwYDVQQLExBXaWRnZXRzIERpdmlzaW9uMRgwFgYD
+VQQDEw9UZXN0IENBMjAwMTA1MTcwHhcNMDEwNTE3MTYxMDU5WhcNMDQwMzA2MTYx
+MDU5WjBRMQswCQYDVQQGEwJVUzETMBEGA1UEChMKUlRGTSwgSW5jLjEZMBcGA1UE
+CxMQV2lkZ2V0cyBEaXZpc2lvbjESMBAGA1UEAxMJbG9jYWxob3N0MIGfMA0GCSqG
+SIb3DQEBAQUAA4GNADCBiQKBgQCiWhMjNOPlPLNW4DJFBiL2fFEIkHuRor0pKw25
+J0ZYHW93lHQ4yxA6afQr99ayRjMY0D26pH41f0qjDgO4OXskBsaYOFzapSZtQMbT
+97OCZ7aHtK8z0ZGNW/cslu+1oOLomgRxJomIFgW1RyUUkQP1n0hemtUdCLOLlO7Q
+CPqZLQIDAQABMA0GCSqGSIb3DQEBBAUAA4GBAIumUwl1OoWuyN2xfoBHYAs+lRLY
+KmFLoI5+iMcGxWIsksmA+b0FLRAN43wmhPnums8eXgYbDCrKLv2xWcvKDP3mps7m
+AMivwtu/eFpYz6J8Mo1fsV4Ys08A/uPXkT23jyKo2hMu8mywkqXCXYF2e+7pEeBr
+dsbmkWK5NgoMl8eM
+-----END CERTIFICATE-----