Skip to content

Instantly share code, notes, and snippets.

View kronos's full-sized avatar
👨‍💻

Ivan Samsonov kronos

👨‍💻
View GitHub Profile
diff --git a/kernel/common/module.rb b/kernel/common/module.rb
index 5f98a67..f4b661a 100644
--- a/kernel/common/module.rb
+++ b/kernel/common/module.rb
@@ -69,6 +69,13 @@ class Module
class_variable_defined? verify_class_variable_name(name)
end
+ def remove_class_variable(name)
+ Ruby.primitive :module_cvar_remove
# This is a sample configuration file suited for a development environment.
# Setting output for logging. You can use :stdout, :stderr or the name of log
# file. Defaults to :stdout.
#
# Ex:
# config.logger[:output] = :stdout
# config.logger[:output] = :stderr
# config.logger[:output] = "development.log" # or the name of log file.
#
ruby 1.9.1p376 (2009-12-07 revision 26041) [i386-darwin10]
kronos:engine kronos$ irb
irb(main):001:0> c = Class.new { @@mvar = :mvar }
=> #<Class:0x0000010105d8c0>
irb(main):002:0> c.send(:remove_class_variable, :@@mvar)
=> :mvar
irb(main):003:0> exit
kronos:engine kronos$ rvm use 1.8.7
Now using ruby 1.8.7 p248
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#remove_class_variable" do
it "removes class variable" do
m = ModuleSpecs::MVars.dup
m.send(:remove_class_variable, :@@mvar)
m.class_variable_defined?(:@@mvar).should == false
end
diff --git a/kernel/common/string.rb b/kernel/common/string.rb
index 28bd362..62f4fe9 100644
--- a/kernel/common/string.rb
+++ b/kernel/common/string.rb
@@ -1992,7 +1992,7 @@ class String
bits = Type.coerce_to bits, Integer, :to_int unless bits.__kind_of__ Fixnum
i, sum = -1, 0
sum += @data[i] while (i += 1) < @num_bytes
- sum & ((1 << bits) - 1)
+ bits > 0 ? sum & ((1 << bits) - 1) : sum
require 'timeout'
begin
r0, w0 = IO.pipe
pid = fork {
trap(:USR1, "EXIT")
w0.close
# Thread.start { Thread.pass }
# r0.sysread(4096)
}
sleep 0.1
diff --git a/kernel/common/process.rb b/kernel/common/process.rb
index 3220098..1f8c276 100644
--- a/kernel/common/process.rb
+++ b/kernel/common/process.rb
@@ -71,6 +71,7 @@ module Process
def self.kill(sig, pid)
use_process_group = false
+ sig = sig.to_s if sig.kind_of?(Symbol)
if sig.kind_of?(String)
diff --git a/kernel/common/process.rb b/kernel/common/process.rb
index 3220098..7c9abaf 100644
--- a/kernel/common/process.rb
+++ b/kernel/common/process.rb
@@ -71,8 +71,9 @@ module Process
def self.kill(sig, pid)
use_process_group = false
+ sig = sig.to_s if sig.kind_of?(Symbol)
if sig.kind_of?(String)
require 'benchmark'
#
# TIMES = 1
#
s = "a string"*100000
Benchmark.bmbm do |x|
x.report("delete!") do
s.delete!(" ")
end
r, w = IO.pipe
w.close
s = "x"
r.read(10, s)
p s == ""