From 8f916c061fffb4005c96610e39114772a0879e32 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 7 Mar 2009 19:38:51 -0600 Subject: [PATCH 01/11] Update README.txt --- README.txt | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/README.txt b/README.txt index dfe70c00f4..bd9da0ab2b 100755 --- a/README.txt +++ b/README.txt @@ -24,7 +24,7 @@ The Factor runtime is written in GNU C99, and is built with GNU make and gcc. Factor supports various platforms. For an up-to-date list, see -. +. Factor requires gcc 3.4 or later. @@ -36,17 +36,6 @@ arguments for make. Run 'make' ('gmake' on *BSD) with no parameters to build the Factor VM. -Compilation will yield an executable named 'factor' on Unix, -'factor.exe' on Windows XP/Vista, and 'factor-ce.exe' on Windows CE. - -* Libraries needed for compilation - -For X11 support, you need recent development libraries for libc, -Freetype, X11, OpenGL and GLUT. On a Debian-derived Linux distribution -(like Ubuntu), you can use the following line to grab everything: - - sudo apt-get install libc6-dev libfreetype6-dev libx11-dev glutg3-dev - * Bootstrapping the Factor image Once you have compiled the Factor runtime, you must bootstrap the Factor @@ -69,6 +58,12 @@ machines. On Unix, Factor can either run a graphical user interface using X11, or a terminal listener. +For X11 support, you need recent development libraries for libc, +Pango, X11, OpenGL and GLUT. On a Debian-derived Linux distribution +(like Ubuntu), you can use the following line to grab everything: + + sudo apt-get install libc6-dev libpango-1.0-dev libx11-dev glutg3-dev + If your DISPLAY environment variable is set, the UI will start automatically: @@ -78,14 +73,6 @@ To run an interactive terminal listener: ./factor -run=listener -If you're inside a terminal session, you can start the UI with one of -the following two commands: - - ui - [ ui ] in-thread - -The latter keeps the terminal listener running. - * Running Factor on Mac OS X - Cocoa UI On Mac OS X, a Cocoa UI is available in addition to the terminal @@ -110,7 +97,7 @@ When compiling Factor, pass the X11=1 parameter: Then bootstrap with the following switches: - ./factor -i=boot..image -ui-backend=x11 + ./factor -i=boot..image -ui-backend=x11 -ui-text-backend=pango Now if $DISPLAY is set, running ./factor will start the UI. @@ -126,6 +113,12 @@ the command prompt using the console application: factor.com -i=boot..image +Before bootstrapping, you will need to download the DLLs for the Pango +text rendering library. The required DLLs are listed in +build-support/dlls.txt and are available from the following location: + + + Once bootstrapped, double-clicking factor.exe or factor.com starts the Factor UI. @@ -135,7 +128,9 @@ To run the listener in the command prompt: * The Factor FAQ -The Factor FAQ is available at . +The Factor FAQ is available at the following location: + + * Command line usage From c2bc2c07052f362ed43bfa4cd9210cfaa544715d Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 7 Mar 2009 19:39:11 -0600 Subject: [PATCH 02/11] Updating deploy tool, mason.child and factor.sh for new Windows DLLs --- basis/tools/deploy/backend/backend.factor | 11 +++++--- basis/tools/deploy/unix/unix.factor | 2 +- basis/tools/deploy/windows/windows.factor | 15 +++++------ build-support/dlls.txt | 12 +++++++++ build-support/factor.sh | 32 +++++------------------ extra/mason/child/child.factor | 17 ++++++------ 6 files changed, 43 insertions(+), 46 deletions(-) create mode 100644 build-support/dlls.txt diff --git a/basis/tools/deploy/backend/backend.factor b/basis/tools/deploy/backend/backend.factor index 7d8f357240..28a32790dc 100755 --- a/basis/tools/deploy/backend/backend.factor +++ b/basis/tools/deploy/backend/backend.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2007, 2008 Slava Pestov. +! Copyright (C) 2007, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: namespaces make continuations.private kernel.private init assocs kernel vocabs words sequences memory io system arrays @@ -14,9 +14,14 @@ IN: tools.deploy.backend : copy-vm ( executable bundle-name -- vm ) prepend-path vm over copy-file ; -: copy-fonts ( name dir -- ) +CONSTANT: theme-path "basis/ui/gadgets/theme/" + +: copy-theme ( name dir -- ) deploy-ui? get [ - append-path "resource:fonts/" swap copy-tree-into + append-path + theme-path append-path + [ make-directories ] + [ theme-path "resource:" prepend swap copy-tree ] bi ] [ 2drop ] if ; : image-name ( vocab bundle-name -- str ) diff --git a/basis/tools/deploy/unix/unix.factor b/basis/tools/deploy/unix/unix.factor index c9bf308357..f88cf06ef7 100755 --- a/basis/tools/deploy/unix/unix.factor +++ b/basis/tools/deploy/unix/unix.factor @@ -7,7 +7,7 @@ tools.deploy.config.editor assocs hashtables prettyprint ; IN: tools.deploy.unix : create-app-dir ( vocab bundle-name -- vm ) - dup "" copy-fonts + dup "" copy-theme copy-vm dup OCT: 755 set-file-permissions ; diff --git a/basis/tools/deploy/windows/windows.factor b/basis/tools/deploy/windows/windows.factor index 0e9146b26e..bfa096ad2f 100755 --- a/basis/tools/deploy/windows/windows.factor +++ b/basis/tools/deploy/windows/windows.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2007, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: io io.files io.pathnames io.directories kernel namespaces +USING: io io.files io.pathnames io.directories io.encodings.ascii kernel namespaces sequences locals system splitting tools.deploy.backend tools.deploy.config tools.deploy.config.editor assocs hashtables prettyprint combinators windows.shell32 windows.user32 ; @@ -9,11 +9,10 @@ IN: tools.deploy.windows : copy-dll ( bundle-name -- ) "resource:factor.dll" swap copy-file-into ; -: copy-freetype ( bundle-name -- ) - { - "resource:freetype6.dll" - "resource:zlib1.dll" - } swap copy-files-into ; +: copy-pango ( bundle-name -- ) + "resource:build-support/dlls.txt" ascii file-lines + [ "resource:" prepend-path ] map + swap copy-files-into ; :: copy-vm ( executable bundle-name extension -- vm ) vm "." split1-last drop extension append @@ -23,8 +22,8 @@ IN: tools.deploy.windows : create-exe-dir ( vocab bundle-name -- vm ) dup copy-dll deploy-ui? get [ - [ copy-freetype ] - [ "" copy-fonts ] + [ copy-pango ] + [ "" copy-theme ] [ ".exe" copy-vm ] tri ] [ ".com" copy-vm ] if ; diff --git a/build-support/dlls.txt b/build-support/dlls.txt new file mode 100644 index 0000000000..97d0cf6e9c --- /dev/null +++ b/build-support/dlls.txt @@ -0,0 +1,12 @@ +libcairo-2.dll +libgio-2.0-0.dll +libglib-2.0-0.dll +libgmodule-2.0-0.dll +libgobject-2.0-0.dll +libgthread-2.0-0.dll +libpango-1.0-0.dll +libpangocairo-1.0-0.dll +libpangowin32-1.0-0.dll +libpng12-0.dll +libtiff3.dll +zlib1.dll diff --git a/build-support/factor.sh b/build-support/factor.sh index 3517d8f4ba..cf6aacb84f 100755 --- a/build-support/factor.sh +++ b/build-support/factor.sh @@ -447,31 +447,11 @@ get_url() { maybe_download_dlls() { if [[ $OS == winnt ]] ; then - get_url http://factorcode.org/dlls/freetype6.dll - get_url http://factorcode.org/dlls/zlib1.dll - get_url http://factorcode.org/dlls/OpenAL32.dll - get_url http://factorcode.org/dlls/alut.dll - get_url http://factorcode.org/dlls/comerr32.dll - get_url http://factorcode.org/dlls/gssapi32.dll - get_url http://factorcode.org/dlls/iconv.dll - get_url http://factorcode.org/dlls/k5sprt32.dll - get_url http://factorcode.org/dlls/krb5_32.dll - get_url http://factorcode.org/dlls/libcairo-2.dll - get_url http://factorcode.org/dlls/libeay32.dll - get_url http://factorcode.org/dlls/libiconv2.dll - get_url http://factorcode.org/dlls/libintl3.dll - get_url http://factorcode.org/dlls/libpq.dll - get_url http://factorcode.org/dlls/libxml2.dll - get_url http://factorcode.org/dlls/libxslt.dll - get_url http://factorcode.org/dlls/msvcr71.dll - get_url http://factorcode.org/dlls/ogg.dll - get_url http://factorcode.org/dlls/pgaevent.dll - get_url http://factorcode.org/dlls/sqlite3.dll - get_url http://factorcode.org/dlls/ssleay32.dll - get_url http://factorcode.org/dlls/theora.dll - get_url http://factorcode.org/dlls/vorbis.dll - chmod 777 *.dll - check_ret chmod + for file in `cat build-support/dlls.txt`; do + get_url http://factorcode.org/dlls/$file + chmod 777 *.dll + check_ret chmod + done fi } @@ -522,7 +502,7 @@ make_boot_image() { } install_build_system_apt() { - sudo apt-get --yes install libc6-dev libfreetype6-dev libx11-dev xorg-dev glutg3-dev wget git-core git-doc rlwrap gcc make + sudo apt-get --yes install libc6-dev libpango-1.0-dev libx11-dev xorg-dev glutg3-dev wget git-core git-doc rlwrap gcc make check_ret sudo } diff --git a/extra/mason/child/child.factor b/extra/mason/child/child.factor index 087ed2c3cb..1999c76d83 100644 --- a/extra/mason/child/child.factor +++ b/extra/mason/child/child.factor @@ -1,21 +1,22 @@ -! Copyright (C) 2008 Eduardo Cavazos, Slava Pestov. +! Copyright (C) 2008, 2009 Eduardo Cavazos, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays calendar combinators.short-circuit -continuations debugger http.client io.directories io.files -io.launcher io.pathnames kernel make mason.common mason.config +continuations debugger http.client io.directories io.files io.launcher +io.pathnames io.encodings.ascii kernel make mason.common mason.config mason.platform mason.report mason.email namespaces sequences ; IN: mason.child : make-cmd ( -- args ) gnu-make platform 2array ; +: dll-url ( -- url ) + "http://factorcode.org/dlls/" + target-cpu get "x86.64" = [ "64/" append ] when ; + : download-dlls ( -- ) target-os get "winnt" = [ - "http://factorcode.org/dlls/" - target-cpu get "x86.64" = [ "64/" append ] when - [ "freetype6.dll" append ] - [ "zlib1.dll" append ] bi - [ download ] bi@ + dll-url "build-support/dlls.txt" ascii file-lines + [ append download ] with each ] when ; : make-vm ( -- ) From a28bf0b9189ad59df0bfde5d6fb018054db2bf6d Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 7 Mar 2009 20:02:57 -0600 Subject: [PATCH 03/11] Fix nofollow in farkup --- basis/farkup/farkup.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/farkup/farkup.factor b/basis/farkup/farkup.factor index 50ee938659..6e41461c8d 100755 --- a/basis/farkup/farkup.factor +++ b/basis/farkup/farkup.factor @@ -169,8 +169,8 @@ CONSTANT: invalid-url "javascript:alert('Invalid URL in farkup');" } cond url-encode ; : write-link ( href text -- xml ) - [ check-url link-no-follow? get "true" and ] dip - [XML nofollow=<->><-> XML] ; + [ check-url link-no-follow? get "nofollow" and ] dip + [XML rel=<->><-> XML] ; : write-image-link ( href text -- xml ) disable-images? get [ From 4f81b6750f830b2de077d0e935c00611d690b19f Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 7 Mar 2009 20:32:07 -0600 Subject: [PATCH 04/11] Make cookie header parser more lenient --- basis/http/http-tests.factor | 6 ------ basis/http/parsers/parsers-tests.factor | 16 ++++++++++++++++ basis/http/parsers/parsers.factor | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 basis/http/parsers/parsers-tests.factor diff --git a/basis/http/http-tests.factor b/basis/http/http-tests.factor index 229d05615e..2b9cd100f7 100644 --- a/basis/http/http-tests.factor +++ b/basis/http/http-tests.factor @@ -11,12 +11,6 @@ IN: http.tests [ "application/octet-stream" binary ] [ "application/octet-stream" parse-content-type ] unit-test -[ { } ] [ "" parse-cookie ] unit-test -[ { } ] [ "" parse-set-cookie ] unit-test - -! Make sure that totally invalid cookies don't confuse us -[ { } ] [ "hello world; how are you" parse-cookie ] unit-test - : lf>crlf "\n" split "\r\n" join ; STRING: read-request-test-1 diff --git a/basis/http/parsers/parsers-tests.factor b/basis/http/parsers/parsers-tests.factor new file mode 100644 index 0000000000..f87ed47f00 --- /dev/null +++ b/basis/http/parsers/parsers-tests.factor @@ -0,0 +1,16 @@ +IN: http.parsers.tests +USING: http http.parsers tools.test ; + +[ { } ] [ "" parse-cookie ] unit-test +[ { } ] [ "" parse-set-cookie ] unit-test + +! Make sure that totally invalid cookies don't confuse us +[ { } ] [ "hello world; how are you" parse-cookie ] unit-test + +[ { T{ cookie { name "__s" } { value "12345567" } } } ] +[ "__s=12345567" parse-cookie ] +unit-test + +[ { T{ cookie { name "__s" } { value "12345567" } } } ] +[ "__s=12345567;" parse-cookie ] +unit-test \ No newline at end of file diff --git a/basis/http/parsers/parsers.factor b/basis/http/parsers/parsers.factor index d72147b381..2520c35acb 100644 --- a/basis/http/parsers/parsers.factor +++ b/basis/http/parsers/parsers.factor @@ -162,7 +162,7 @@ PEG: (parse-set-cookie) ( string -- alist ) 'value' , 'space' , ] seq* - [ ";,=" member? not ] satisfy repeat1 [ drop f ] action + [ ";,=" member? not ] satisfy repeat0 [ drop f ] action 2choice ; PEG: (parse-cookie) ( string -- alist ) From 8a7d877ec60731c5342a49a6cdcc3b6247c974b8 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 7 Mar 2009 20:55:55 -0600 Subject: [PATCH 05/11] Fix simple-flat-file --- basis/simple-flat-file/simple-flat-file.factor | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/basis/simple-flat-file/simple-flat-file.factor b/basis/simple-flat-file/simple-flat-file.factor index 721f4986a0..403fc4d14b 100644 --- a/basis/simple-flat-file/simple-flat-file.factor +++ b/basis/simple-flat-file/simple-flat-file.factor @@ -7,10 +7,13 @@ IN: simple-flat-file [ "#" split1 drop ] map harvest ; : split-column ( line -- columns ) - " \t" split harvest 2 head ; + " \t" split harvest 2 short head 2 f pad-tail ; : parse-hex ( s -- n ) - 2 short tail hex> ; + dup [ + "0x" ?head [ "U+" ?head [ "Missing 0x or U+" throw ] unless ] unless + hex> + ] when ; : parse-line ( line -- code-unicode ) split-column [ parse-hex ] map ; From c28370d3567f67be190b04b83d6c01231a4e6620 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 7 Mar 2009 21:24:32 -0600 Subject: [PATCH 06/11] Allow headers containing " to fix problem reported by doublec --- basis/http/http.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/http/http.factor b/basis/http/http.factor index a64a11690c..c7f10a789d 100755 --- a/basis/http/http.factor +++ b/basis/http/http.factor @@ -34,7 +34,7 @@ IN: http : check-header-string ( str -- str ) #! http://en.wikipedia.org/wiki/HTTP_Header_Injection - dup "\r\n\"" intersects? + dup "\r\n" intersects? [ "Header injection attack" throw ] when ; : write-header ( assoc -- ) From dfb55736c54bc8471d50e980e32e1f90a7cc858e Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 7 Mar 2009 21:35:44 -0600 Subject: [PATCH 07/11] show-browser command now just switches to an existing browser instead of pointing it at the documentation front page --- basis/ui/tools/browser/browser.factor | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/basis/ui/tools/browser/browser.factor b/basis/ui/tools/browser/browser.factor index 8fcd14c95f..078ece6546 100644 --- a/basis/ui/tools/browser/browser.factor +++ b/basis/ui/tools/browser/browser.factor @@ -86,7 +86,9 @@ M: browser-gadget focusable-child* search-field>> ; [ [ raise-window ] [ gadget-child show-help ] bi ] [ (browser-window) ] if* ; -: show-browser ( -- ) "handbook" com-browse ; +: show-browser ( -- ) + [ browser-gadget? ] find-window + [ raise-window ] [ browser-window ] if* ; \ show-browser H{ { +nullary+ t } } define-command From cf5e14a52fb83ae8d5c454d65621a36375b69a6d Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 7 Mar 2009 21:47:06 -0600 Subject: [PATCH 08/11] Don't escape absolute URLs in Farkup --- basis/farkup/farkup-tests.factor | 1 + basis/farkup/farkup.factor | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/basis/farkup/farkup-tests.factor b/basis/farkup/farkup-tests.factor index 60a9f785e6..246da48b32 100644 --- a/basis/farkup/farkup-tests.factor +++ b/basis/farkup/farkup-tests.factor @@ -99,6 +99,7 @@ link-no-follow? off [ "

\"teh

" ] [ "[[image:lol.jpg|teh lol]]" convert-farkup ] unit-test [ "

http://lol.com

" ] [ "[[http://lol.com]]" convert-farkup ] unit-test [ "

haha

" ] [ "[[http://lol.com|haha]]" convert-farkup ] unit-test +[ "

haha

" ] [ "[[http://lol.com/search?q=sex|haha]]" convert-farkup ] unit-test [ "

Bar

" ] [ "[[Foo/Bar]]" convert-farkup ] unit-test "/wiki/view/" relative-link-prefix [ diff --git a/basis/farkup/farkup.factor b/basis/farkup/farkup.factor index 6e41461c8d..4041d92773 100755 --- a/basis/farkup/farkup.factor +++ b/basis/farkup/farkup.factor @@ -165,8 +165,8 @@ CONSTANT: invalid-url "javascript:alert('Invalid URL in farkup');" { [ dup [ 127 > ] any? ] [ drop invalid-url ] } { [ dup first "/\\" member? ] [ drop invalid-url ] } { [ CHAR: : over member? ] [ dup absolute-url? [ drop invalid-url ] unless ] } - [ relative-link-prefix get prepend "" like ] - } cond url-encode ; + [ relative-link-prefix get prepend "" like url-encode ] + } cond ; : write-link ( href text -- xml ) [ check-url link-no-follow? get "nofollow" and ] dip From f3c2d32d2614194619b37668fa1a281a66b7d1d2 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 7 Mar 2009 21:50:23 -0600 Subject: [PATCH 09/11] Add Atom link to Planet Factor --- extra/webapps/planet/planet.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extra/webapps/planet/planet.xml b/extra/webapps/planet/planet.xml index 412f42c64e..08cf07d4ce 100644 --- a/extra/webapps/planet/planet.xml +++ b/extra/webapps/planet/planet.xml @@ -2,6 +2,8 @@ + [ planet-factor ] + [ planet-factor ] From 63302727604cfb311010ccea183eb2b9e3dd0a70 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 7 Mar 2009 22:09:57 -0600 Subject: [PATCH 10/11] Fix CGI --- basis/http/server/cgi/cgi.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/http/server/cgi/cgi.factor b/basis/http/server/cgi/cgi.factor index a64fe9af3c..d2f453034a 100644 --- a/basis/http/server/cgi/cgi.factor +++ b/basis/http/server/cgi/cgi.factor @@ -53,9 +53,9 @@ IN: http.server.cgi "CGI output follows" >>message swap '[ binary encode-output - _ output-stream get swap binary [ + output-stream get _ binary [ post-request? [ request get post-data>> data>> write flush ] when - '[ _ write ] each-block + '[ _ stream-write ] each-block ] with-stream ] >>body ; From 2e158b2e08f0c2040f9a0f7016ada9f8ebffc3f8 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 8 Mar 2009 01:13:53 -0600 Subject: [PATCH 11/11] Fix compile error on FreeBSD --- basis/unix/bsd/freebsd/freebsd.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/unix/bsd/freebsd/freebsd.factor b/basis/unix/bsd/freebsd/freebsd.factor index 4536c532bf..05642b5065 100644 --- a/basis/unix/bsd/freebsd/freebsd.factor +++ b/basis/unix/bsd/freebsd/freebsd.factor @@ -1,7 +1,7 @@ USING: alien.syntax ; IN: unix -: FD_SETSIZE 1024 ; +CONSTANT: FD_SETSIZE 1024 C-STRUCT: addrinfo { "int" "flags" }