Skip to content

Commit 8814d48

Browse files
aardvark179eregon
authored andcommitted
Patch the tk gem to use rb_hash_foreach.
1 parent 95f5f97 commit 8814d48

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

lib/truffle/truffle/cext_preprocessor.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
require_relative 'patches/nokogiri_patches'
1111
require_relative 'patches/oci8_patches'
1212
require_relative 'patches/pg_patches'
13+
require_relative 'patches/tk_patches'
1314

1415
module Truffle
1516
module CExt
@@ -39,12 +40,13 @@ def self.add_gem_patches(patch_hash, gem_patches)
3940
add_gem_patches(PATCHED_FILES, ::NokogiriPatches::PATCHES)
4041
add_gem_patches(PATCHED_FILES, ::OCI8Patches::PATCHES)
4142
add_gem_patches(PATCHED_FILES, ::PgPatches::PATCHES)
43+
add_gem_patches(PATCHED_FILES, ::TkPatches::PATCHES)
4244

4345
def self.makefile_matcher(command1, command2)
4446
file_list = Hash.new { |h,k| h[k] = [] }
4547
PATCHED_FILES.each_pair do |file, patch|
4648
dir = if patch[:ext_dir]
47-
File.join(patch[:gem], 'ext', patch[:ext_dir])
49+
File.join('ext', patch[:ext_dir])
4850
else
4951
"/#{patch[:gem]}"
5052
end
@@ -85,7 +87,7 @@ def self.makefile_matcher(command1, command2)
8587
def self.patch(file, contents, directory)
8688
if patched_file = PATCHED_FILES[File.basename(file)]
8789
matched = if patched_file[:ext_dir]
88-
directory.end_with?(File.join(patched_file[:gem], 'ext', patched_file[:ext_dir]))
90+
directory.end_with?('ext', patched_file[:ext_dir])
8991
else
9092
regexp = /^#{Regexp.escape(patched_file[:gem])}\b/
9193
directory.split('/').last(3).any? { |part| part =~ regexp } || file.split('/').last(2).any? { |part| part =~ regexp }
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. This
2+
# code is released under a tri EPL/GPL/LGPL license. You can use it,
3+
# redistribute it and/or modify it under the terms of the:
4+
#
5+
# Eclipse Public License version 2.0, or
6+
# GNU General Public License version 2, or
7+
# GNU Lesser General Public License version 2.1.
8+
9+
# Tested with tk version 0.4.0
10+
class TkPatches
11+
12+
PATCHES = {
13+
gem: 'tk',
14+
patches: {
15+
['tk/tkutil', 'tkutil.c'] => [
16+
{
17+
match: 'st_foreach_check(RHASH_TBL(keys), to_strkey, new_keys, Qundef)',
18+
replacement: 'rb_hash_foreach(keys, to_strkey, new_keys)'
19+
},
20+
{
21+
match: 'st_foreach_check(RHASH_TBL(hash), push_kv, args, Qundef)',
22+
replacement: 'rb_hash_foreach(hash, push_kv, args)'
23+
},
24+
{
25+
match: 'st_foreach_check(RHASH_TBL(hash), push_kv_enc, args, Qundef)',
26+
replacement: 'rb_hash_foreach(hash, push_kv_enc, args)'
27+
},
28+
]
29+
}
30+
}
31+
32+
end

0 commit comments

Comments
 (0)