From b022dfd1d914d5a7a01de8b1efc62fe4673d311e Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 13 Jun 2005 01:20:00 +0000 Subject: [PATCH] fixed typo in socket code --- TODO.FACTOR.txt | 1 - library/tools/interpreter.factor | 14 +++++++------- library/unix/io.factor | 2 +- library/unix/sockets.factor | 8 +++++--- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 71e8932725..af3e9616bf 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -8,7 +8,6 @@ if write returns -1 and errno == EINTR then it's not a real error, you can try again - single-stepper and variable access: wrong namespace? -- investigate if COPYING_GEN needs a fix - http keep alive, and range get - sleep word - fix i/o on generic x86/ppc unix diff --git a/library/tools/interpreter.factor b/library/tools/interpreter.factor index c641d6c533..30443ef8c7 100644 --- a/library/tools/interpreter.factor +++ b/library/tools/interpreter.factor @@ -29,7 +29,7 @@ SYMBOL: meta-executing 10 meta-r set 10 meta-d set namestack meta-n set - f meta-c set + catchstack meta-c set f meta-cf set f meta-executing set ; @@ -51,7 +51,11 @@ SYMBOL: meta-executing #! swap in the old stacks. This is so messy. push-d datastack push-d meta-d get set-datastack + catchstack >r meta-c set-catchstack + namestack >r meta-n set-namestack >r execute datastack r> tuck push + r> set-namestack + r> set-catchstack set-datastack meta-d set ; : meta-call ( quot -- ) @@ -82,14 +86,10 @@ SYMBOL: meta-executing \ datastack [ meta-d get clone push-d ] set-meta-word \ set-datastack [ pop-d clone meta-d set ] set-meta-word -\ >r [ pop-d push-r ] set-meta-word -\ r> [ pop-r push-d ] set-meta-word +\ >r [ pop-d push-r ] set-meta-word +\ r> [ pop-r push-d ] set-meta-word \ callstack [ meta-r get clone push-d ] set-meta-word \ set-callstack [ pop-d clone meta-r set ] set-meta-word -\ namestack [ meta-n get push-d ] set-meta-word -\ set-namestack [ pop-d meta-n set ] set-meta-word -\ catchstack [ meta-c get push-d ] set-meta-word -\ set-catchstack [ pop-d meta-c set ] set-meta-word \ call [ pop-d meta-call ] set-meta-word \ execute [ pop-d meta-word ] set-meta-word \ ifte [ pop-d pop-d pop-d [ nip ] [ drop ] ifte meta-call ] set-meta-word diff --git a/library/unix/io.factor b/library/unix/io.factor index ac43997a15..620f30b8c4 100644 --- a/library/unix/io.factor +++ b/library/unix/io.factor @@ -13,7 +13,7 @@ USING: namespaces ; : (io-error) errno strerror throw ; -: check-null ( n -- ) dup 0 = [ (io-error) ] when ; +: check-null ( n -- ) 0 = [ (io-error) ] when ; : io-error ( n -- ) 0 < [ (io-error) ] when ; diff --git a/library/unix/sockets.factor b/library/unix/sockets.factor index 099f38ce42..7c7714fba1 100644 --- a/library/unix/sockets.factor +++ b/library/unix/sockets.factor @@ -4,7 +4,7 @@ ! We need to fiddle with the exact search order here, since ! unix-internals::accept shadows streams::accept. IN: io-internals -USING: namespaces streams threads unparser ; +USING: errors namespaces streams threads unparser ; USING: alien generic kernel math unix-internals ; : init-sockaddr ( port -- sockaddr ) @@ -15,8 +15,10 @@ USING: alien generic kernel math unix-internals ; : client-sockaddr ( host port -- sockaddr ) #! Error handling here init-sockaddr [ - >r gethostbyname dup [ "Host lookup failed" ] unless - hostent-addr dup check-null r> set-sockaddr-in-addr + >r gethostbyname dup [ + "Host lookup failed" throw + ] unless hostent-addr dup check-null + r> set-sockaddr-in-addr ] keep ; : socket-fd ( -- socket )