From 7f24b0aabd4e1f6d0ff058a944508575a08eaa65 Mon Sep 17 00:00:00 2001 From: hsbt Date: Tue, 12 Sep 2017 11:52:23 +0000 Subject: [PATCH] Merge fiddle-1.0.0.beta2 from upstream. * ext/fiddle/closure.c: use directly declaration for standalone gem without internal.h. * Specify frozen string literal is true. * Update gemspec configuration for release version. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59854 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/fiddle/closure.c | 3 ++- ext/fiddle/extconf.rb | 8 ++++---- ext/fiddle/fiddle.gemspec | 5 ++--- ext/fiddle/lib/fiddle.rb | 2 +- ext/fiddle/lib/fiddle/closure.rb | 2 +- ext/fiddle/lib/fiddle/cparser.rb | 2 +- ext/fiddle/lib/fiddle/function.rb | 2 +- ext/fiddle/lib/fiddle/import.rb | 2 +- ext/fiddle/lib/fiddle/pack.rb | 4 ++-- ext/fiddle/lib/fiddle/struct.rb | 2 +- ext/fiddle/lib/fiddle/types.rb | 2 +- ext/fiddle/lib/fiddle/value.rb | 2 +- ext/fiddle/win32/libffi-config.rb | 2 +- test/fiddle/helper.rb | 2 +- test/fiddle/test_c_struct_entry.rb | 2 +- test/fiddle/test_c_union_entity.rb | 2 +- test/fiddle/test_closure.rb | 2 +- test/fiddle/test_cparser.rb | 2 +- test/fiddle/test_fiddle.rb | 2 +- test/fiddle/test_func.rb | 4 ++-- test/fiddle/test_function.rb | 2 +- test/fiddle/test_handle.rb | 6 +++--- test/fiddle/test_import.rb | 2 +- test/fiddle/test_pointer.rb | 2 +- 24 files changed, 33 insertions(+), 33 deletions(-) diff --git a/ext/fiddle/closure.c b/ext/fiddle/closure.c index f19091b29b..1a80b2b02a 100644 --- a/ext/fiddle/closure.c +++ b/ext/fiddle/closure.c @@ -1,6 +1,7 @@ #include #include -#include "internal.h" /* rb_thread_has_gvl_p */ + +int ruby_thread_has_gvl_p(void); /* from internal.h */ VALUE cFiddleClosure; diff --git a/ext/fiddle/extconf.rb b/ext/fiddle/extconf.rb index 9e244ed27d..2c333001e5 100644 --- a/ext/fiddle/extconf.rb +++ b/ext/fiddle/extconf.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'mkmf' # :stopdoc: @@ -41,12 +41,12 @@ begin libffi.lib = "#{libffi.builddir}/.libs" libffi.a = "#{libffi.lib}/libffi_convenience.#{$LIBEXT}" nowarn = CONFIG.merge("warnflags"=>"") - libffi.cflags = RbConfig.expand("$(CFLAGS)", nowarn) + libffi.cflags = RbConfig.expand("$(CFLAGS)".dup, nowarn) ver = ver[/libffi-(.*)/, 1] FileUtils.mkdir_p(libffi.dir) libffi.opt = CONFIG['configure_args'][/'(-C)'/, 1] - libffi.ldflags = RbConfig.expand("$(LDFLAGS) #{libpathflag([relative_from($topdir, "..")])} #{$LIBRUBYARG}") + libffi.ldflags = RbConfig.expand("$(LDFLAGS) #{libpathflag([relative_from($topdir, "..")])} #{$LIBRUBYARG}".dup) libffi.arch = RbConfig::CONFIG['host'] if $mswin unless find_executable(as = /x64/ =~ libffi.arch ? "ml64" : "ml") @@ -77,7 +77,7 @@ begin args << libffi.opt if libffi.opt args.concat %W[ CC=#{cc} CFLAGS=#{libffi.cflags} - CXX=#{cxx} CXXFLAGS=#{RbConfig.expand("$(CXXFLAGS)", nowarn)} + CXX=#{cxx} CXXFLAGS=#{RbConfig.expand("$(CXXFLAGS)".dup, nowarn)} LD=#{ld} LDFLAGS=#{libffi.ldflags} ] diff --git a/ext/fiddle/fiddle.gemspec b/ext/fiddle/fiddle.gemspec index 3e54f47f96..054d7c06ec 100644 --- a/ext/fiddle/fiddle.gemspec +++ b/ext/fiddle/fiddle.gemspec @@ -1,14 +1,14 @@ # frozen_string_literal: true Gem::Specification.new do |spec| spec.name = "fiddle" - spec.version = '1.0.0.beta1' + spec.version = '1.0.0.beta2' spec.authors = ["Aaron Patterson", "SHIBATA Hiroshi"] spec.email = ["aaron@tenderlovemaking.com", "hsbt@ruby-lang.org"] spec.summary = %q{A libffi wrapper for Ruby.} spec.description = %q{A libffi wrapper for Ruby.} spec.homepage = "https://github.com/ruby/fiddle" - spec.license = "MIT" + spec.license = "BSD-2-Clause" spec.files = [".gitignore", ".travis.yml", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "ext/fiddle/closure.c", "ext/fiddle/closure.h", "ext/fiddle/conversions.c", "ext/fiddle/conversions.h", "ext/fiddle/extconf.rb", "ext/fiddle/extlibs", "ext/fiddle/fiddle.c", "ext/fiddle/fiddle.h", "ext/fiddle/function.c", "ext/fiddle/function.h", "ext/fiddle/handle.c", "ext/fiddle/pointer.c", "ext/fiddle/win32/fficonfig.h", "ext/fiddle/win32/libffi-3.2.1-mswin.patch", "ext/fiddle/win32/libffi-config.rb", "ext/fiddle/win32/libffi.mk.tmpl", "fiddle.gemspec", "lib/fiddle.rb", "lib/fiddle/closure.rb", "lib/fiddle/cparser.rb", "lib/fiddle/function.rb", "lib/fiddle/import.rb", "lib/fiddle/pack.rb", "lib/fiddle/struct.rb", "lib/fiddle/types.rb", "lib/fiddle/value.rb"] spec.bindir = "exe" @@ -17,6 +17,5 @@ Gem::Specification.new do |spec| spec.add_development_dependency "bundler" spec.add_development_dependency "rake" - spec.add_development_dependency "minitest", "~> 4.0" spec.add_development_dependency "rake-compiler" end diff --git a/ext/fiddle/lib/fiddle.rb b/ext/fiddle/lib/fiddle.rb index 5208eb9328..e9aa7e50ae 100644 --- a/ext/fiddle/lib/fiddle.rb +++ b/ext/fiddle/lib/fiddle.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'fiddle.so' require 'fiddle/function' require 'fiddle/closure' diff --git a/ext/fiddle/lib/fiddle/closure.rb b/ext/fiddle/lib/fiddle/closure.rb index 0b9adbb60a..c865a63c20 100644 --- a/ext/fiddle/lib/fiddle/closure.rb +++ b/ext/fiddle/lib/fiddle/closure.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true module Fiddle class Closure diff --git a/ext/fiddle/lib/fiddle/cparser.rb b/ext/fiddle/lib/fiddle/cparser.rb index 6b9da9fa7c..d3b450b85f 100644 --- a/ext/fiddle/lib/fiddle/cparser.rb +++ b/ext/fiddle/lib/fiddle/cparser.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true module Fiddle # A mixin that provides methods for parsing C struct and prototype signatures. # diff --git a/ext/fiddle/lib/fiddle/function.rb b/ext/fiddle/lib/fiddle/function.rb index fcd90dfd26..dd5e04e417 100644 --- a/ext/fiddle/lib/fiddle/function.rb +++ b/ext/fiddle/lib/fiddle/function.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true module Fiddle class Function # The ABI of the Function. diff --git a/ext/fiddle/lib/fiddle/import.rb b/ext/fiddle/lib/fiddle/import.rb index 09429f6631..59ab3ee6f7 100644 --- a/ext/fiddle/lib/fiddle/import.rb +++ b/ext/fiddle/lib/fiddle/import.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'fiddle' require 'fiddle/struct' require 'fiddle/cparser' diff --git a/ext/fiddle/lib/fiddle/pack.rb b/ext/fiddle/lib/fiddle/pack.rb index 6301068450..3c9e3c8ad7 100644 --- a/ext/fiddle/lib/fiddle/pack.rb +++ b/ext/fiddle/lib/fiddle/pack.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'fiddle' module Fiddle @@ -101,7 +101,7 @@ module Fiddle private def parse_types(types) - @template = "" + @template = "".dup addr = 0 types.each{|t| orig_addr = addr diff --git a/ext/fiddle/lib/fiddle/struct.rb b/ext/fiddle/lib/fiddle/struct.rb index 233a987269..7c0dedb39f 100644 --- a/ext/fiddle/lib/fiddle/struct.rb +++ b/ext/fiddle/lib/fiddle/struct.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'fiddle' require 'fiddle/value' require 'fiddle/pack' diff --git a/ext/fiddle/lib/fiddle/types.rb b/ext/fiddle/lib/fiddle/types.rb index 8a72635a69..8dc811d3e4 100644 --- a/ext/fiddle/lib/fiddle/types.rb +++ b/ext/fiddle/lib/fiddle/types.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true module Fiddle # Adds Windows type aliases to the including class for use with # Fiddle::Importer. diff --git a/ext/fiddle/lib/fiddle/value.rb b/ext/fiddle/lib/fiddle/value.rb index ac318cf2c4..a043b9b066 100644 --- a/ext/fiddle/lib/fiddle/value.rb +++ b/ext/fiddle/lib/fiddle/value.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'fiddle' module Fiddle diff --git a/ext/fiddle/win32/libffi-config.rb b/ext/fiddle/win32/libffi-config.rb index 7a32a91517..6abc9b2c02 100755 --- a/ext/fiddle/win32/libffi-config.rb +++ b/ext/fiddle/win32/libffi-config.rb @@ -1,5 +1,5 @@ #!/usr/bin/ruby -# frozen_string_literal: false +# frozen_string_literal: true require 'fileutils' basedir = File.dirname(__FILE__) diff --git a/test/fiddle/helper.rb b/test/fiddle/helper.rb index d1bbe24b74..4aaa55ea78 100644 --- a/test/fiddle/helper.rb +++ b/test/fiddle/helper.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'test/unit' require 'fiddle' diff --git a/test/fiddle/test_c_struct_entry.rb b/test/fiddle/test_c_struct_entry.rb index 39b7aeff99..8ece438f54 100644 --- a/test/fiddle/test_c_struct_entry.rb +++ b/test/fiddle/test_c_struct_entry.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true begin require_relative 'helper' require 'fiddle/struct' diff --git a/test/fiddle/test_c_union_entity.rb b/test/fiddle/test_c_union_entity.rb index 3c4d538ff1..5727a20e3b 100644 --- a/test/fiddle/test_c_union_entity.rb +++ b/test/fiddle/test_c_union_entity.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true begin require_relative 'helper' require 'fiddle/struct' diff --git a/test/fiddle/test_closure.rb b/test/fiddle/test_closure.rb index 0dbdcb3138..2de0660725 100644 --- a/test/fiddle/test_closure.rb +++ b/test/fiddle/test_closure.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true begin require_relative 'helper' rescue LoadError diff --git a/test/fiddle/test_cparser.rb b/test/fiddle/test_cparser.rb index c1527bf85d..c053706e13 100644 --- a/test/fiddle/test_cparser.rb +++ b/test/fiddle/test_cparser.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true begin require_relative 'helper' require 'fiddle/cparser' diff --git a/test/fiddle/test_fiddle.rb b/test/fiddle/test_fiddle.rb index cf4839af86..8751d96920 100644 --- a/test/fiddle/test_fiddle.rb +++ b/test/fiddle/test_fiddle.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true begin require_relative 'helper' rescue LoadError diff --git a/test/fiddle/test_func.rb b/test/fiddle/test_func.rb index 70e1b9e333..8f7b0c2874 100644 --- a/test/fiddle/test_func.rb +++ b/test/fiddle/test_func.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true begin require_relative 'helper' rescue LoadError @@ -16,7 +16,7 @@ module Fiddle assert_raise(SecurityError) do Thread.new { $SAFE = 1 - f.call("uname -rs".taint) + f.call("uname -rs".dup.taint) }.join end end diff --git a/test/fiddle/test_function.rb b/test/fiddle/test_function.rb index 3cce95a540..477b6a86dc 100644 --- a/test/fiddle/test_function.rb +++ b/test/fiddle/test_function.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true begin require_relative 'helper' rescue LoadError diff --git a/test/fiddle/test_handle.rb b/test/fiddle/test_handle.rb index 233e8b0aa4..444ac55da3 100644 --- a/test/fiddle/test_handle.rb +++ b/test/fiddle/test_handle.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true begin require_relative 'helper' rescue LoadError @@ -11,7 +11,7 @@ module Fiddle def test_safe_handle_open t = Thread.new do $SAFE = 1 - Fiddle::Handle.new(LIBC_SO.taint) + Fiddle::Handle.new(LIBC_SO.dup.taint) end assert_raise(SecurityError) { t.value } end @@ -20,7 +20,7 @@ module Fiddle t = Thread.new do h = Fiddle::Handle.new(LIBC_SO) $SAFE = 1 - h["qsort".taint] + h["qsort".dup.taint] end assert_raise(SecurityError) { t.value } end diff --git a/test/fiddle/test_import.rb b/test/fiddle/test_import.rb index b637e4fadd..0cd5e76a80 100644 --- a/test/fiddle/test_import.rb +++ b/test/fiddle/test_import.rb @@ -1,5 +1,5 @@ # coding: US-ASCII -# frozen_string_literal: false +# frozen_string_literal: true begin require_relative 'helper' require 'fiddle/import' diff --git a/test/fiddle/test_pointer.rb b/test/fiddle/test_pointer.rb index 80b64b04db..27a8a6cb06 100644 --- a/test/fiddle/test_pointer.rb +++ b/test/fiddle/test_pointer.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true begin require_relative 'helper' rescue LoadError