From 9dbafadbf37b2815aea5fa3b2edcdfca152fbec4 Mon Sep 17 00:00:00 2001 From: ueno Date: Fri, 12 Aug 2005 00:42:26 +0000 Subject: [PATCH] * server.rb: Don't bind @err in execution environment. --- lisp/ChangeLog | 4 ++++ lisp/server.rb | 23 +++++++++++------------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 1329beb..31e4822 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2005-08-12 Daiki Ueno + + * server.rb: Don't bind @err in execution environment. + 2005-08-11 Daiki Ueno * server.rb: Connect $stdout and $stderr to StringIO objects. diff --git a/lisp/server.rb b/lisp/server.rb index 2619dcf..24f65ee 100644 --- a/lisp/server.rb +++ b/lisp/server.rb @@ -4,22 +4,11 @@ require 'thread' require 'stringio' class Server - module B - def output(s) - @out.puts("# output #{Thread.current[:rubyserv_name]} #{s}\r\n") - end - module_function :output - end - def initialize @out = $stdout @err = $stderr $stdout = StringIO.new $stderr = StringIO.new - out, err = @out, @err - B.module_eval do - @out, @err = out, err - end @buf = '' @que = Queue.new @@ -85,9 +74,19 @@ class Server @out.puts("S name #{name}\r\n") @out.puts("OK\r\n") Thread.current[:rubyserv_name] = name + out = @out + e = Module.new + e.module_eval do + @out = out + + def output(s) + @out.puts("# output #{Thread.current[:rubyserv_name]} #{s}\r\n") + end + module_function :output + end begin Thread.current[:rubyserv_error] = false - Thread.current[:rubyserv_response] = eval(r, B.module_eval('binding()')) + Thread.current[:rubyserv_response] = eval(r, e.module_eval('binding()')) rescue Exception => e Thread.current[:rubyserv_error] = true Thread.current[:rubyserv_response] = e.to_s.sub(/\A.*?\n/, '') -- 1.7.10.4