Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move Rubinius::Terminal constant to kernel, wire up IO#tty? to suppor…

…t it.

Environment::set_rubinius_constants() is now gone, as it is not needed.
  • Loading branch information...
commit c11533d567062775d1d9177e99309e874a529bd3 1 parent d58394d
@drbrain drbrain authored
View
4 kernel/common/io.rb
@@ -1339,8 +1339,6 @@ def to_io
self
end
- alias_method :prim_tty?, :tty?
-
##
# Returns true if ios is associated with a terminal device (tty), false otherwise.
#
@@ -1348,7 +1346,7 @@ def to_io
# File.new("/dev/tty").isatty #=> true
def tty?
raise IOError, "closed stream" if closed?
- prim_tty?
+ Platform::POSIX.isatty(@descriptor) == 1
end
alias_method :isatty, :tty?
View
7 kernel/delta/io.rb
@@ -7,3 +7,10 @@ class IO::BidirectionalPipe
undef_method method
end
end
+
+# Re-setup all the stdio channels, to pull in new ivars
+
+STDOUT.setup
+STDIN.setup
+STDERR.setup
+
View
6 kernel/delta/rubinius.rb
@@ -0,0 +1,6 @@
+# depends on: io.rb
+
+module Rubinius
+ Terminal = STDIN.tty?
+end
+
View
8 kernel/loader.rb
@@ -1,11 +1,5 @@
# Contained first is the system startup code.
-# Re-setup all the stdio channels, to pull in new ivars
-
-STDOUT.setup
-STDIN.setup
-STDERR.setup
-
begin
ENV = EnvironmentVariables.new
@@ -110,7 +104,7 @@
puts RBS_USAGE
exit 1
when "-v"
- puts "rubinius #{RBX_VERSION} (ruby #{RUBY_VERSION} compatible) (#{Rubinius::BUILDREV[0..8]}) (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
+ puts "rubinius #{Rubinius::RBX_VERSION} (ruby #{RUBY_VERSION} compatible) (#{Rubinius::BUILDREV[0..8]}) (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
$VERBOSE = true
exit 0 if ARGV.empty?
when "-w"
View
3  kernel/platform/posix.rb
@@ -70,7 +70,8 @@ module Platform::POSIX
attach_function 'clearerr', [:pointer], :void
attach_function 'fseek', [:pointer, :int, :int], :int
attach_function 'ftell', [:pointer], :int
- attach_function 'lseek', [:int, :int, :int], :int
+ attach_function 'lseek', [:int, :int, :int], :int
+ attach_function 'isatty', [:int], :int
# reading
attach_function 'fread', [:string, :size_t, :size_t, :pointer], :size_t
View
11 rakelib/configure.rake
@@ -6,11 +6,12 @@ file 'lib/rbconfig.rb' do
write_rbconfig
end
-file 'kernel/bootstrap/rubinius_config.rb' => 'rakelib/configuration.rb' do |task, args|
+file 'kernel/bootstrap/rubinius_config.rb' =>
+ %w[rakelib/configuration.rb rakelib/configure.rake] do |task, args|
open task.name, 'w' do |io|
io << <<-EOF
#--
-# This file was generated from rakelib/configur.rake
+# This file was generated from rakelib/configure.rake
#++
module Rubinius
@@ -20,15 +21,17 @@ module Rubinius
RBA_PATH = #{RBX_RBA_PATH.inspect}
RBX_VERSION = #{RBX_VERSION.inspect}
end
+
EOF
end
end
-file 'kernel/bootstrap/ruby_config.rb' => 'rakelib/configuration.rb' do |task, args|
+file 'kernel/bootstrap/ruby_config.rb' =>
+ %w[rakelib/configuration.rb rakelib/configure.rake] do |task, args|
open task.name, 'w' do |io|
io << <<-EOF
#--
-# This file was generated from rakelib/configur.rake
+# This file was generated from rakelib/configure.rake
#++
PLATFORM = #{RBX_HOST.inspect}
View
1  vm/drivers/cli.cpp
@@ -45,7 +45,6 @@ int main(int argc, char** argv) {
}
std::string root = std::string(e);
- env.set_rubinius_constants();
std::cout << "Loading platform.conf: " << root << "\n";
env.load_platform_conf(root);
View
12 vm/environment.cpp
@@ -97,16 +97,4 @@ namespace rubinius {
}
}
- /*
- * HACK hook this up to a config file
- */
- void Environment::set_rubinius_constants() {
- Module* rubinius = GO(rubinius).get();
-
- if(isatty(fileno(stdin))) {
- rubinius->set_const(state, "Terminal", Qtrue);
- } else {
- rubinius->set_const(state, "Terminal", Qfalse);
- }
- }
}
View
2  vm/environment.hpp
@@ -19,8 +19,8 @@ namespace rubinius {
void load_directory(std::string dir);
void load_platform_conf(std::string dir);
void run_file(std::string path);
- void set_rubinius_constants();
};
+
}
#endif
Please sign in to comment.
Something went wrong with that request. Please try again.