static_holmes 0.7.7 → 0.7.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e35947554b465d48dc970a60031dcca03df441bd829b4464dba2ecf0bc792bb
4
- data.tar.gz: 4cdfaff28364c07fc96a0a77a62d2fb5dbccc130859a4268065084e5abdff449
3
+ metadata.gz: d44feed3f25dc6342272d68eda9bedda3b3e5fa7a8ddd3eceabd439391702991
4
+ data.tar.gz: 99a711e297e7082271707217b9b8d220a7299399b4a855294d2e08af4d53b96a
5
5
  SHA512:
6
- metadata.gz: 3007aa5b2d53c6046dc65086cb74881ea10f48fda3de2c89a053a42a820f5045b20ce2b716ce9ac0d51f3e6b704a85e9659958cf70c9631e74593637dfbae486
7
- data.tar.gz: 13ad7377a3525419518ef4c20ce6c4763a8fc9e8b5cabaa30495d5d79cb8bf0b239e2238a4dcea5bc181572cec4356be3c2d65bf599c440a74a9f398881a6ec5
6
+ metadata.gz: c943b95a7cab86ddc69d02231eb1273ade055263b3e7e8a20fc2d0671f1ea6d44dbbcf58697b9c5e7ec8e498643c5b067b8dc60d1a3cfb2388d12ab92a15cf99
7
+ data.tar.gz: 0be53f5049292086423382ac269586e5b381ec5f6bf27b13b52ca8a36129a2a7f398ceba77c7d42b4f52272faee15ab03ee1adf67b266fb000a3b3acc6f6b84b
@@ -38,4 +38,19 @@ static inline VALUE charlock_new_str2(const char *str)
38
38
  #endif
39
39
  }
40
40
 
41
+
42
+ #ifdef __cplusplus
43
+ extern "C"
44
+ {
45
+ #endif
46
+
47
+ extern void Init_charlock_holmes();
48
+ extern void _init_charlock_encoding_detector();
49
+ extern void _init_charlock_converter();
50
+ extern void _init_charlock_transliterator();
51
+
52
+ #ifdef __cplusplus
53
+ }
54
+ #endif
55
+
41
56
  #endif
@@ -29,7 +29,7 @@ static VALUE rb_converter_convert(VALUE self, VALUE rb_txt, VALUE rb_src_enc, VA
29
29
  if (status != U_BUFFER_OVERFLOW_ERROR) {
30
30
  rb_raise(rb_eArgError, "%s", u_errorName(status));
31
31
  }
32
- out_buf = malloc(out_len);
32
+ out_buf = (char *) malloc(out_len);
33
33
 
34
34
  // now do the actual conversion
35
35
  status = U_ZERO_ERROR;
@@ -352,7 +352,7 @@ static VALUE rb_encdec__alloc(VALUE klass)
352
352
  UErrorCode status = U_ZERO_ERROR;
353
353
  VALUE obj;
354
354
 
355
- detector = calloc(1, sizeof(charlock_detector_t));
355
+ detector = (charlock_detector_t *) calloc(1, sizeof(charlock_detector_t));
356
356
  obj = Data_Wrap_Struct(klass, NULL, rb_encdec__free, (void *)detector);
357
357
 
358
358
  detector->csd = ucsdet_open(&status);
@@ -1,9 +1,5 @@
1
1
  #include "common.h"
2
2
 
3
- extern void _init_charlock_encoding_detector();
4
- extern void _init_charlock_converter();
5
- extern void _init_charlock_transliterator();
6
-
7
3
  VALUE rb_mCharlockHolmes;
8
4
 
9
5
  void Init_charlock_holmes() {
@@ -12,4 +8,4 @@ void Init_charlock_holmes() {
12
8
  _init_charlock_encoding_detector();
13
9
  _init_charlock_converter();
14
10
  _init_charlock_transliterator();
15
- }
11
+ }
@@ -34,8 +34,6 @@ pkg_config("icu-i18n")
34
34
  pkg_config("icu-io")
35
35
  pkg_config("icu-uc")
36
36
 
37
- $CXXFLAGS << ' -std=c++11' unless $CXXFLAGS.include?("-std=")
38
-
39
37
  unless have_library 'icui18n' and have_header 'unicode/ucnv.h'
40
38
  STDERR.puts "\n\n"
41
39
  STDERR.puts "***************************************************************************************"
@@ -51,6 +49,32 @@ have_library 'icudata' or abort 'libicudata missing'
51
49
  $CFLAGS << ' -Wall -funroll-loops'
52
50
  $CFLAGS << ' -Wextra -O0 -ggdb3' if ENV['DEBUG']
53
51
 
52
+ minimal_program = <<~SRC
53
+ #include <unicode/translit.h>
54
+ int main() { return 0; }
55
+ SRC
56
+
57
+ # Pass -x c++ to force gcc to compile the test program
58
+ # as C++ (as it will end in .c by default).
59
+ compile_options = +"-x c++"
60
+
61
+ icu_requires_version_flag = checking_for("icu that requires explicit C++ version flag") do
62
+ !try_compile(minimal_program, compile_options)
63
+ end
64
+
65
+ if icu_requires_version_flag
66
+ abort "Cannot compile icu with your compiler: recent versions require C++17 support." unless %w[c++20 c++17 c++11 c++0x].any? do |std|
67
+ checking_for("icu that compiles with #{std} standard") do
68
+ flags = compile_options + " -std=#{std}"
69
+ if try_compile(minimal_program, flags)
70
+ $CPPFLAGS << flags
71
+
72
+ true
73
+ end
74
+ end
75
+ end
76
+ end
77
+
54
78
  def libflag_to_filename(ldflag)
55
79
  case ldflag
56
80
  when /\A-l(.+)/
@@ -69,6 +93,21 @@ def resolve_static_library(libflag, dirs)
69
93
  end
70
94
 
71
95
  def substitute_static_libs(packages)
96
+ packages.each do |pkg|
97
+ unless pkg_config(pkg)
98
+ message = <<~MSG
99
+ Unable to run `pkg-config #{pkg}`.
100
+
101
+ Check that PKG_CONFIG_PATH includes #{pkg}.pc (or unset it if it's already set).
102
+
103
+ Current environment:
104
+ PKG_CONFIG_PATH=#{ENV['PKG_CONFIG_PATH']}
105
+ MSG
106
+
107
+ raise message
108
+ end
109
+ end
110
+
72
111
  # First, find all the -l<lib> flags added by pkg-config. We want to drop
73
112
  # these dynamically linked libraries and substitute them with the static libraries.
74
113
  libflags = packages.map do |pkg|
@@ -79,7 +118,7 @@ def substitute_static_libs(packages)
79
118
  # library paths given by the -L flag from pkg-config.
80
119
  lib_paths = packages.map do |pkg|
81
120
  include_path = pkg_config(pkg, 'libs-only-L')&.strip
82
- include_path&.split(' ').map { |lib| lib.gsub(/^-L/, '') }
121
+ include_path&.split(' ')&.map { |lib| lib.gsub(/^-L/, '') }
83
122
  end.flatten.uniq
84
123
 
85
124
  # Drop the -l<lib> flags and add in the static libraries.
@@ -1,3 +1,3 @@
1
1
  module CharlockHolmes
2
- VERSION = "0.7.7"
2
+ VERSION = "0.7.11"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: static_holmes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.7
4
+ version: 0.7.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Lopez
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-03-23 00:00:00.000000000 Z
12
+ date: 2024-07-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake-compiler
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  - !ruby/object:Gem::Version
92
92
  version: '0'
93
93
  requirements: []
94
- rubygems_version: 3.5.6
94
+ rubygems_version: 3.5.14
95
95
  signing_key:
96
96
  specification_version: 4
97
97
  summary: Character encoding detection, brought to you by ICU