From 1682a5512ac7027f49c18ec9d536eeeba03101d4 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Thu, 12 Feb 2009 22:26:44 -0600 Subject: [PATCH 1/3] Minor docs fix and cleanup in http.server.static --- basis/http/server/static/static-docs.factor | 2 +- basis/http/server/static/static.factor | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/basis/http/server/static/static-docs.factor b/basis/http/server/static/static-docs.factor index fbe20b5fcd..bbad56a6f1 100644 --- a/basis/http/server/static/static-docs.factor +++ b/basis/http/server/static/static-docs.factor @@ -38,7 +38,7 @@ $nl "If all you want to do is serve files from a directory, the following phrase does the trick:" { $code "USING: namespaces http.server http.server.static ;" - "/var/www/mysite.com/ main-responder set" + "\"/var/www/mysite.com/\" main-responder set" "8080 httpd" } { $subsection "http.server.static.extend" } ; diff --git a/basis/http/server/static/static.factor b/basis/http/server/static/static.factor index 53d3d4f917..5d5ad7d2b8 100644 --- a/basis/http/server/static/static.factor +++ b/basis/http/server/static/static.factor @@ -45,9 +45,8 @@ TUPLE: file-responder root hook special allow-listings ; [ file-responder get hook>> call ] [ 2drop <304> ] if ; : serving-path ( filename -- filename ) - file-responder get root>> trim-tail-separators - "/" - rot "" or trim-head-separators 3append ; + [ file-responder get root>> trim-tail-separators "/" ] dip + "" or trim-head-separators 3append ; : serve-file ( filename -- response ) dup mime-type From c6680eee60a3bbd432750ab4733f039c98ab9d73 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Fri, 13 Feb 2009 15:10:34 -0600 Subject: [PATCH 2/3] Making xml-undo words private; adding bytes>xml word --- basis/xml/syntax/syntax.factor | 4 ++++ basis/xml/tests/test.factor | 12 +++++++++--- basis/xml/xml-docs.factor | 9 +++++++-- basis/xml/xml.factor | 5 ++++- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/basis/xml/syntax/syntax.factor b/basis/xml/syntax/syntax.factor index 8e6bebfe6b..067bb9ec11 100644 --- a/basis/xml/syntax/syntax.factor +++ b/basis/xml/syntax/syntax.factor @@ -174,6 +174,8 @@ PRIVATE> : [XML "XML]" [ string>chunk ] parse-def ; parsing +enum ] ; \ interpolate-xml 1 [ undo-xml ] define-pop-inverse + +PRIVATE> diff --git a/basis/xml/tests/test.factor b/basis/xml/tests/test.factor index b1f6cf002f..0372132736 100644 --- a/basis/xml/tests/test.factor +++ b/basis/xml/tests/test.factor @@ -3,7 +3,7 @@ IN: xml.tests USING: kernel xml tools.test io namespaces make sequences xml.errors xml.entities.html parser strings xml.data io.files -xml.traversal continuations assocs +xml.traversal continuations assocs io.encodings.binary sequences.deep accessors io.streams.string ; ! This is insufficient @@ -12,8 +12,14 @@ sequences.deep accessors io.streams.string ; \ string>xml must-infer SYMBOL: xml-file -[ ] [ "resource:basis/xml/tests/test.xml" - [ file>xml ] with-html-entities xml-file set ] unit-test +[ ] [ + "resource:basis/xml/tests/test.xml" + [ file>xml ] with-html-entities xml-file set +] unit-test +[ t ] [ + "resource:basis/xml/tests/test.xml" binary file-contents + [ bytes>xml ] with-html-entities xml-file get = +] unit-test [ "1.0" ] [ xml-file get prolog>> version>> ] unit-test [ f ] [ xml-file get prolog>> standalone>> ] unit-test [ "a" ] [ xml-file get space>> ] unit-test diff --git a/basis/xml/xml-docs.factor b/basis/xml/xml-docs.factor index 024b086ef9..77969c55cd 100644 --- a/basis/xml/xml-docs.factor +++ b/basis/xml/xml-docs.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2005, 2009 Daniel Ehrenberg ! See http://factorcode.org/license.txt for BSD license. -USING: help.markup help.syntax xml.data io strings ; +USING: help.markup help.syntax xml.data io strings byte-arrays ; IN: xml HELP: string>xml @@ -16,7 +16,11 @@ HELP: file>xml { $values { "filename" string } { "xml" xml } } { $description "Opens the given file, reads it in as XML, closes the file and returns the corresponding XML tree. The encoding is automatically detected." } ; -{ string>xml read-xml file>xml } related-words +HELP: bytes>xml +{ $values { "byte-array" byte-array } { "xml" xml } } +{ $description "Parses a byte array as an XML document. The encoding is automatically detected." } ; + +{ string>xml read-xml file>xml bytes>xml } related-words HELP: read-xml-chunk { $values { "stream" "an input stream" } { "seq" "a sequence of elements" } } @@ -68,6 +72,7 @@ ARTICLE: { "xml" "reading" } "Reading XML" { $subsection read-xml-chunk } { $subsection string>xml-chunk } { $subsection file>xml } + { $subsection bytes>xml } "To read a DTD:" { $subsection read-dtd } { $subsection file>dtd } diff --git a/basis/xml/xml.factor b/basis/xml/xml.factor index 57c1b6dbd3..073f46cbae 100755 --- a/basis/xml/xml.factor +++ b/basis/xml/xml.factor @@ -4,7 +4,7 @@ USING: accessors arrays io io.encodings.binary io.files io.streams.string kernel namespaces sequences strings io.encodings.utf8 xml.data xml.errors xml.elements ascii xml.entities xml.writer xml.state xml.autoencoding assocs xml.tokenize -combinators.short-circuit xml.name splitting ; +combinators.short-circuit xml.name splitting io.streams.byte-array ; IN: xml : file>xml ( filename -- xml ) binary read-xml ; +: bytes>xml ( byte-array -- xml ) + binary read-xml ; + : read-dtd ( stream -- dtd ) [ H{ } clone extra-entities set From 0ce47f84c607b594da2c4854cfc3db3c9a1457f5 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Fri, 13 Feb 2009 15:14:09 -0600 Subject: [PATCH 3/3] use decode instead of >string in images.tiff --- basis/images/tiff/tiff.factor | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/basis/images/tiff/tiff.factor b/basis/images/tiff/tiff.factor index 674188992a..f57f15ae20 100755 --- a/basis/images/tiff/tiff.factor +++ b/basis/images/tiff/tiff.factor @@ -1,9 +1,11 @@ ! Copyright (C) 2009 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors combinators io io.encodings.binary io.files kernel -pack endian constructors sequences arrays math.order math.parser -prettyprint classes io.binary assocs math math.bitwise byte-arrays -grouping images compression.lzw fry strings ; +USING: accessors arrays assocs byte-arrays classes combinators +compression.lzw constructors endian fry grouping images io +io.binary io.encodings.ascii io.encodings.binary +io.encodings.string io.encodings.utf8 io.files kernel math +math.bitwise math.order math.parser pack prettyprint sequences +strings ; IN: images.tiff TUPLE: tiff-image < image ; @@ -249,13 +251,13 @@ ERROR: bad-small-ifd-type n ; { 283 [ first y-resolution ] } { 284 [ planar-configuration ] } { 296 [ lookup-resolution-unit resolution-unit ] } - { 305 [ >string software ] } - { 306 [ >string date-time ] } + { 305 [ ascii decode software ] } + { 306 [ ascii decode date-time ] } { 317 [ lookup-predictor predictor ] } { 330 [ sub-ifd ] } { 338 [ lookup-extra-samples extra-samples ] } { 339 [ lookup-sample-format sample-format ] } - { 700 [ >string xmp ] } + { 700 [ utf8 decode xmp ] } { 34377 [ photoshop ] } { 34665 [ exif-ifd ] } { 33723 [ iptc ] }