Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: eb2eb019e42b
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c1191bd01aad
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Dec 15, 2016

  1. Copy the full SHA
    d2e9138 View commit details
  2. Copy the full SHA
    c1191bd View commit details
Showing with 8 additions and 19 deletions.
  1. +3 −12 truffle/src/main/ruby/core/env.rb
  2. +5 −7 truffle/src/main/ruby/core/library.rb
15 changes: 3 additions & 12 deletions truffle/src/main/ruby/core/env.rb
Original file line number Diff line number Diff line change
@@ -36,17 +36,8 @@
# Interface to process environment variables.

module Rubinius
module EnvironmentAccess
extend FFI::Library

attach_function :getenv, [:string], :string
attach_function :setenv, [:string, :string, :int], :int
attach_function :unsetenv, [:string], :int
end

class EnvironmentVariables
include Enumerable
include Rubinius::EnvironmentAccess

def initialize
vars = Truffle::System.initial_environment_variables
@@ -58,7 +49,7 @@ def size
end

def [](key)
value = getenv(StringValue(key))
value = Truffle::POSIX.getenv(StringValue(key))
if value
value = set_encoding(value)
end
@@ -68,10 +59,10 @@ def [](key)
def []=(key, value)
key = StringValue(key)
if value.nil?
unsetenv(key)
Truffle::POSIX.unsetenv(key)
@variables.delete(key)
else
if setenv(key, StringValue(value), 1) != 0
if Truffle::POSIX.setenv(key, StringValue(value), 1) != 0
Errno.handle("setenv")
end
unless @variables.include?(key)
12 changes: 5 additions & 7 deletions truffle/src/main/ruby/core/library.rb
Original file line number Diff line number Diff line change
@@ -46,15 +46,13 @@ def attach_function(name, _, _, _=nil, _=nil)

caller = Truffle::Boot.source_of_caller

suffixes = ['ruby/truffle/rubysl/rubysl-socket/lib/rubysl/socket.rb', 'core/env.rb']
suffixes = ['ruby/truffle/rubysl/rubysl-socket/lib/rubysl/socket.rb']

suffixes.each do |suffix|
if caller[-suffix.length, suffix.length] == suffix
if Truffle::POSIX.respond_to? mname
define_method mname, &Truffle::POSIX.method(mname)
module_function mname
return
end
if caller.end_with?(suffix) and Truffle::POSIX.respond_to?(mname)
define_method mname, &Truffle::POSIX.method(mname)
module_function mname
return
end
end