summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml2
-rw-r--r--Rakefile4
-rw-r--r--ext/ffi_c/AbstractMemory.c2
-rw-r--r--ext/ffi_c/Buffer.c2
-rw-r--r--ext/ffi_c/MethodHandle.c4
-rw-r--r--ext/ffi_c/Pointer.c6
-rw-r--r--lib/ffi/library.rb15
-rw-r--r--lib/ffi/struct.rb2
-rw-r--r--spec/ffi/struct_spec.rb8
9 files changed, 30 insertions, 15 deletions
diff --git a/.travis.yml b/.travis.yml
index 9b38679..ac176d6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,11 +12,13 @@ rvm:
- "2.2"
- "ruby-head"
- "rbx"
+ - "system"
env:
- CC=gcc
- CC=clang
matrix:
allow_failures:
+ - rvm: system
- os: osx
rvm: "2.2"
- os: osx
diff --git a/Rakefile b/Rakefile
index 10839e2..14bfc61 100644
--- a/Rakefile
+++ b/Rakefile
@@ -138,7 +138,7 @@ end
task 'spec:run' => TEST_DEPS
task 'spec:specdoc' => TEST_DEPS
-task :default => :specs
+task :default => :spec
namespace 'java' do
@@ -175,7 +175,7 @@ if USE_RAKE_COMPILER
ext.cross_platform = %w[i386-mingw32 x64-mingw32] # forces the Windows platform instead of the default one
end
- ENV['RUBY_CC_VERSION'] ||= '1.8.7:1.9.3:2.0.0:2.1.5:2.2.1'
+ ENV['RUBY_CC_VERSION'] ||= '1.8.7:1.9.3:2.0.0:2.1.6:2.2.2'
# To reduce the gem file size strip mingw32 dlls before packaging
ENV['RUBY_CC_VERSION'].to_s.split(':').each do |ruby_version|
diff --git a/ext/ffi_c/AbstractMemory.c b/ext/ffi_c/AbstractMemory.c
index 156d7cf..144199c 100644
--- a/ext/ffi_c/AbstractMemory.c
+++ b/ext/ffi_c/AbstractMemory.c
@@ -497,7 +497,7 @@ memory_put_bytes(int argc, VALUE* argv, VALUE self)
off = NUM2LONG(offset);
idx = nargs > 2 ? NUM2LONG(rbIndex) : 0;
if (idx < 0) {
- rb_raise(rb_eRangeError, "index canot be less than zero");
+ rb_raise(rb_eRangeError, "index cannot be less than zero");
return Qnil;
}
len = nargs > 3 ? NUM2LONG(rbLength) : (RSTRING_LEN(str) - idx);
diff --git a/ext/ffi_c/Buffer.c b/ext/ffi_c/Buffer.c
index 8ae3a59..faf4834 100644
--- a/ext/ffi_c/Buffer.c
+++ b/ext/ffi_c/Buffer.c
@@ -253,7 +253,7 @@ buffer_inspect(VALUE self)
* @overload order(order)
* @param [:big, :little, :network] order
* @return [self]
- * Set endinaness of Buffer (+:network+ is an alias for +:big+).
+ * Set endianness of Buffer (+:network+ is an alias for +:big+).
*/
static VALUE
buffer_order(int argc, VALUE* argv, VALUE self)
diff --git a/ext/ffi_c/MethodHandle.c b/ext/ffi_c/MethodHandle.c
index cee1df5..bbf99a2 100644
--- a/ext/ffi_c/MethodHandle.c
+++ b/ext/ffi_c/MethodHandle.c
@@ -243,10 +243,10 @@ static VALUE custom_trampoline(caddr_t args, Closure*);
#define TRAMPOLINE_FUN_MAGIC (0xbeefcafe)
/*
- * This is a hand-coded trampoline to speedup entry from ruby to the FFI translation
+ * This is a hand-coded trampoline to speed-up entry from ruby to the FFI translation
* layer for i386 arches.
*
- * This does not make a discernable difference vs a raw closure, so for now,
+ * This does not make a discernible difference vs a raw closure, so for now,
* it is not enabled.
*/
__asm__(
diff --git a/ext/ffi_c/Pointer.c b/ext/ffi_c/Pointer.c
index edd931c..1eee790 100644
--- a/ext/ffi_c/Pointer.c
+++ b/ext/ffi_c/Pointer.c
@@ -89,7 +89,7 @@ ptr_allocate(VALUE klass)
* @overload initialize(type, address)
* @param [Type] type type for pointer
* @param [Integer] address base address for pointer
- * Create a new pointer from a {Type} and a base adresse
+ * Create a new pointer from a {Type} and a base address
* @return [self]
* A new instance of Pointer.
*/
@@ -146,11 +146,11 @@ ptr_initialize(int argc, VALUE* argv, VALUE self)
* call-seq: ptr.initialize_copy(other)
* @param [Pointer] other source for cloning or dupping
* @return [self]
- * @raise {RuntimeError} if +other+ is an unbounded memory area, or is unreable/unwritable
+ * @raise {RuntimeError} if +other+ is an unbounded memory area, or is unreadable/unwritable
* @raise {NoMemError} if failed to allocate memory for new object
* DO NOT CALL THIS METHOD.
*
- * This method is internally used by #dup and #clone. Memory contents is copied from +other+.
+ * This method is internally used by #dup and #clone. Memory content is copied from +other+.
*/
static VALUE
ptr_initialize_copy(VALUE self, VALUE other)
diff --git a/lib/ffi/library.rb b/lib/ffi/library.rb
index 9849a3a..93d617e 100644
--- a/lib/ffi/library.rb
+++ b/lib/ffi/library.rb
@@ -109,6 +109,7 @@ module FFI
libnames.each do |libname|
begin
+ orig = libname
lib = FFI::DynamicLibrary.open(libname, lib_flags)
break if lib
@@ -121,10 +122,22 @@ module FFI
end
end
+ # TODO better library lookup logic
+ unless libname.start_with?("/")
+ path = ['/usr/lib/','/usr/local/lib/'].find do |pth|
+ File.exist?(pth + libname)
+ end
+ if path
+ libname = path + libname
+ retry
+ end
+ end
+
if ldscript
retry
else
- errors[libname] = ex
+ libr = (orig == libname ? orig : "#{orig} #{libname}")
+ errors[libr] = ex
end
end
end
diff --git a/lib/ffi/struct.rb b/lib/ffi/struct.rb
index 89231ba..0896d35 100644
--- a/lib/ffi/struct.rb
+++ b/lib/ffi/struct.rb
@@ -341,7 +341,7 @@ module FFI
# @raise if Ruby 1.8
# Add hash +spec+ to +builder+.
def hash_layout(builder, spec)
- raise "Ruby version not supported" if RUBY_VERSION =~ /1\.8\.*/
+ raise "Ruby version not supported" if RUBY_VERSION =~ /^1\.8\..*/
spec[0].each do |name, type|
builder.add name, find_field_type(type), nil
end
diff --git a/spec/ffi/struct_spec.rb b/spec/ffi/struct_spec.rb
index 1728758..9110d92 100644
--- a/spec/ffi/struct_spec.rb
+++ b/spec/ffi/struct_spec.rb
@@ -7,7 +7,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
describe "Struct aligns fields correctly" do
it "char, followed by an int" do
- pending("not supported in 1.8") if RUBY_VERSION =~ /1.8.*/
+ pending("not supported in 1.8") if RUBY_VERSION =~ /^1\.8\..*/
class CIStruct < FFI::Struct
layout :c => :char, :i => :int
end
@@ -15,7 +15,7 @@ describe "Struct aligns fields correctly" do
end
it "short, followed by an int" do
- pending("not supported in 1.8") if RUBY_VERSION =~ /1.8.*/
+ pending("not supported in 1.8") if RUBY_VERSION =~ /^1\.8\..*/
class SIStruct < FFI::Struct
layout :s => :short, :i => :int
end
@@ -23,7 +23,7 @@ describe "Struct aligns fields correctly" do
end
it "int, followed by an int" do
- pending("not supported in 1.8") if RUBY_VERSION =~ /1.8.*/
+ pending("not supported in 1.8") if RUBY_VERSION =~ /^1\.8\..*/
class IIStruct < FFI::Struct
layout :i1 => :int, :i => :int
end
@@ -31,7 +31,7 @@ describe "Struct aligns fields correctly" do
end
it "long long, followed by an int" do
- pending("not supported in 1.8") if RUBY_VERSION =~ /1.8.*/
+ pending("not supported in 1.8") if RUBY_VERSION =~ /^1\.8\..*/
class LLIStruct < FFI::Struct
layout :l => :long_long, :i => :int
end