nkf 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d91d0012de880dc327a501e8cbcf616c0bf94f3631a7ffcfe7d312df4ee234d3
4
- data.tar.gz: '0305883ba08acedfca7e3ecfbedd6046519130091e297e84b31f2c164cd557a1'
3
+ metadata.gz: 99fe300695064529e277ba99c695e957548f0e636b2901e7eba88a4a62ac5c6c
4
+ data.tar.gz: 74a4a2835c227cb45348608c0bb2a206ff8462dfae5df7b803638e254e05572d
5
5
  SHA512:
6
- metadata.gz: 1e4d3a3a8d83b61eb5cd2800ffa606f288af719d09b936ed5357a84d2913f33629e2a752a03bb3bf53f59f3bdd5a0e9e1311110266aba448d873e54a34ce03d6
7
- data.tar.gz: fc812b17abfdf9aea0e9eeacb62721e42974ba39749c5625be1022e743e030c2888f160101f79bcf02bd3a260bbc5007336802bba7fd32fd493a26a8cd64f6da
6
+ metadata.gz: c7f58fd74f820302552e7c83271857e63df0d0e622f950570fd1c934efb6f334cc23cf69e8195a26ad79310721a0bb0a06461e098c073c2fefe5be664ae36072
7
+ data.tar.gz: 54289152cd0158f6f07d5cbfac794175aa75b510ca20ab7f7d6b13b9a01b76eb78e02d81ae2498ddae5be3565f90f175da0b1686945c6a24f19211ea65f697f6
@@ -0,0 +1,7 @@
1
+ # This is a file used by GitHub to ignore the following commits on `git blame`.
2
+ #
3
+ # You can also do the same thing in your local repository with:
4
+ # $ git config --local blame.ignoreRevsFile .git-blame-ignore-revs
5
+
6
+ # Expand tabs
7
+ 564b86c8de70b636d94df815c77c5989a7a45c3b
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: 'github-actions'
4
+ directory: '/'
5
+ schedule:
6
+ interval: 'weekly'
@@ -11,7 +11,7 @@ jobs:
11
11
  os: [ ubuntu-latest, macos-latest ]
12
12
  runs-on: ${{ matrix.os }}
13
13
  steps:
14
- - uses: actions/checkout@v2
14
+ - uses: actions/checkout@v3
15
15
  - name: Set up Ruby
16
16
  uses: ruby/setup-ruby@v1
17
17
  with:
@@ -144,7 +144,7 @@ static void w_oconv(nkf_char c2, nkf_char c1);
144
144
  static void w_oconv16(nkf_char c2, nkf_char c1);
145
145
  static void w_oconv32(nkf_char c2, nkf_char c1);
146
146
 
147
- typedef struct {
147
+ typedef const struct {
148
148
  const char *name;
149
149
  nkf_char (*iconv)(nkf_char c2, nkf_char c1, nkf_char c0);
150
150
  void (*oconv)(nkf_char c2, nkf_char c1);
@@ -158,10 +158,10 @@ nkf_native_encoding NkfEncodingUTF_8 = { "UTF-8", w_iconv, w_oconv };
158
158
  nkf_native_encoding NkfEncodingUTF_16 = { "UTF-16", w_iconv16, w_oconv16 };
159
159
  nkf_native_encoding NkfEncodingUTF_32 = { "UTF-32", w_iconv32, w_oconv32 };
160
160
 
161
- typedef struct {
162
- const int id;
161
+ typedef const struct {
162
+ int id;
163
163
  const char *name;
164
- const nkf_native_encoding *base_encoding;
164
+ nkf_native_encoding *base_encoding;
165
165
  } nkf_encoding;
166
166
 
167
167
  nkf_encoding nkf_encoding_table[] = {
@@ -204,9 +204,9 @@ nkf_encoding nkf_encoding_table[] = {
204
204
  {-1, NULL, NULL}
205
205
  };
206
206
 
207
- struct {
207
+ static const struct {
208
208
  const char *name;
209
- const int id;
209
+ int id;
210
210
  } encoding_name_to_id_table[] = {
211
211
  {"US-ASCII", ASCII},
212
212
  {"ASCII", ASCII},
@@ -4286,7 +4286,7 @@ static const unsigned char *mime_pattern[] = {
4286
4286
 
4287
4287
 
4288
4288
  /* $B3:Ev$9$k%3!<%I$NM%@hEY$r>e$2$k$?$a$NL\0u(B */
4289
- nkf_char (*mime_priority_func[])(nkf_char c2, nkf_char c1, nkf_char c0) = {
4289
+ static nkf_char (*const mime_priority_func[])(nkf_char c2, nkf_char c1, nkf_char c0) = {
4290
4290
  e_iconv, s_iconv, 0, 0, 0, 0, 0,
4291
4291
  #if defined(UTF8_INPUT_ENABLE)
4292
4292
  w_iconv, w_iconv,
data/ext/nkf/nkf.c CHANGED
@@ -9,6 +9,7 @@
9
9
 
10
10
  #define RUBY_NKF_REVISION "$Revision$"
11
11
  #define RUBY_NKF_VERSION NKF_VERSION " (" NKF_RELEASE_DATE ")"
12
+ #define NKF_GEM_VERSION "0.1.3"
12
13
 
13
14
  #include "ruby/ruby.h"
14
15
  #include "ruby/encoding.h"
@@ -65,11 +66,11 @@ rb_encoding* rb_nkf_enc_get(const char *name)
65
66
  {
66
67
  int idx = rb_enc_find_index(name);
67
68
  if (idx < 0) {
68
- nkf_encoding *nkf_enc = nkf_enc_find(name);
69
- idx = rb_enc_find_index(nkf_enc_name(nkf_enc_to_base_encoding(nkf_enc)));
70
- if (idx < 0) {
71
- idx = rb_define_dummy_encoding(name);
72
- }
69
+ nkf_encoding *nkf_enc = nkf_enc_find(name);
70
+ idx = rb_enc_find_index(nkf_enc_name(nkf_enc_to_base_encoding(nkf_enc)));
71
+ if (idx < 0) {
72
+ idx = rb_define_dummy_encoding(name);
73
+ }
73
74
  }
74
75
  return rb_enc_from_index(idx);
75
76
  }
@@ -83,40 +84,40 @@ int nkf_split_options(const char *arg)
83
84
  int is_single_quoted = FALSE;
84
85
  int is_double_quoted = FALSE;
85
86
  for(i = 0; arg[i]; i++){
86
- if(j == 255){
87
- return -1;
88
- }else if(is_single_quoted){
89
- if(arg[i] == '\''){
90
- is_single_quoted = FALSE;
91
- }else{
92
- option[j++] = arg[i];
93
- }
94
- }else if(is_escaped){
95
- is_escaped = FALSE;
96
- option[j++] = arg[i];
97
- }else if(arg[i] == '\\'){
98
- is_escaped = TRUE;
99
- }else if(is_double_quoted){
100
- if(arg[i] == '"'){
101
- is_double_quoted = FALSE;
102
- }else{
103
- option[j++] = arg[i];
104
- }
105
- }else if(arg[i] == '\''){
106
- is_single_quoted = TRUE;
107
- }else if(arg[i] == '"'){
108
- is_double_quoted = TRUE;
109
- }else if(arg[i] == ' '){
110
- option[j] = '\0';
111
- options(option);
112
- j = 0;
113
- }else{
114
- option[j++] = arg[i];
115
- }
87
+ if(j == 255){
88
+ return -1;
89
+ }else if(is_single_quoted){
90
+ if(arg[i] == '\''){
91
+ is_single_quoted = FALSE;
92
+ }else{
93
+ option[j++] = arg[i];
94
+ }
95
+ }else if(is_escaped){
96
+ is_escaped = FALSE;
97
+ option[j++] = arg[i];
98
+ }else if(arg[i] == '\\'){
99
+ is_escaped = TRUE;
100
+ }else if(is_double_quoted){
101
+ if(arg[i] == '"'){
102
+ is_double_quoted = FALSE;
103
+ }else{
104
+ option[j++] = arg[i];
105
+ }
106
+ }else if(arg[i] == '\''){
107
+ is_single_quoted = TRUE;
108
+ }else if(arg[i] == '"'){
109
+ is_double_quoted = TRUE;
110
+ }else if(arg[i] == ' '){
111
+ option[j] = '\0';
112
+ options(option);
113
+ j = 0;
114
+ }else{
115
+ option[j++] = arg[i];
116
+ }
116
117
  }
117
118
  if(j){
118
- option[j] = '\0';
119
- options(option);
119
+ option[j] = '\0';
120
+ options(option);
120
121
  }
121
122
  return count;
122
123
  }
@@ -170,9 +171,9 @@ rb_nkf_convert(VALUE obj, VALUE opt, VALUE src)
170
171
  rb_str_set_len(tmp, output_ctr);
171
172
 
172
173
  if (mimeout_f)
173
- rb_enc_associate(tmp, rb_usascii_encoding());
174
+ rb_enc_associate(tmp, rb_usascii_encoding());
174
175
  else
175
- rb_enc_associate(tmp, rb_nkf_enc_get(nkf_enc_name(output_encoding)));
176
+ rb_enc_associate(tmp, rb_nkf_enc_get(nkf_enc_name(output_encoding)));
176
177
 
177
178
  return tmp;
178
179
  }
@@ -274,7 +275,7 @@ rb_nkf_guess(VALUE obj, VALUE src)
274
275
  *
275
276
  * {de/en}crypt ROT13/47
276
277
  *
277
- * === -h[123] --hiragana --katakana --katakana-hiragana
278
+ * === \-h[123] --hiragana --katakana --katakana-hiragana
278
279
  *
279
280
  * [-h1 --hiragana] Katakana to Hiragana conversion.
280
281
  *
@@ -299,7 +300,7 @@ rb_nkf_guess(VALUE obj, VALUE src)
299
300
  *
300
301
  * New line preserving line folding.
301
302
  *
302
- * === -Z[0-3]
303
+ * === \-Z[0-3]
303
304
  *
304
305
  * Convert X0208 alphabet (Fullwidth Alphabets) to ASCII.
305
306
  *
@@ -318,7 +319,7 @@ rb_nkf_guess(VALUE obj, VALUE src)
318
319
  * With <b>-x</b>, try to preserve X0208 kana and do not convert X0201 kana to X0208.
319
320
  * In JIS output, ESC-(-I is used. In EUC output, SSO is used.
320
321
  *
321
- * === -B[0-2]
322
+ * === \-B[0-2]
322
323
  *
323
324
  * Assume broken JIS-Kanji input, which lost ESC.
324
325
  * Useful when your site is using old B-News Nihongo patch.
@@ -336,7 +337,7 @@ rb_nkf_guess(VALUE obj, VALUE src)
336
337
  *
337
338
  * Delete \r in line feed, Add \r in line feed.
338
339
  *
339
- * === -m[BQN0]
340
+ * === \-m[BQN0]
340
341
  *
341
342
  * MIME ISO-2022-JP/ISO8859-1 decode. (DEFAULT)
342
343
  * To see ISO8859-1 (Latin-1) -l is necessary.
@@ -358,14 +359,14 @@ rb_nkf_guess(VALUE obj, VALUE src)
358
359
  *
359
360
  * [-MB] MIME encode Base64 stream.
360
361
  *
361
- * [-MQ] Perfome quoted encoding.
362
+ * [-MQ] Perform quoted encoding.
362
363
  *
363
364
  * === -l
364
365
  *
365
366
  * Input and output code is ISO8859-1 (Latin-1) and ISO-2022-JP.
366
367
  * <b>-s</b>, <b>-e</b> and <b>-x</b> are not compatible with this option.
367
368
  *
368
- * === -L[uwm]
369
+ * === \-L[uwm]
369
370
  *
370
371
  * new line mode
371
372
  * Without this option, nkf doesn't convert line breaks.
@@ -500,4 +501,6 @@ Init_nkf(void)
500
501
  rb_define_const(mNKF, "NKF_VERSION", rb_str_new2(NKF_VERSION));
501
502
  /* Release date of nkf */
502
503
  rb_define_const(mNKF, "NKF_RELEASE_DATE", rb_str_new2(NKF_RELEASE_DATE));
504
+ /* Version of nkf library */
505
+ rb_define_const(mNKF, "GEM_VERSION", rb_str_new_cstr(NKF_GEM_VERSION));
503
506
  }
data/nkf.gemspec CHANGED
@@ -1,6 +1,16 @@
1
+ source_version = ["", "ext/nkf/"].find do |dir|
2
+ begin
3
+ break File.open(File.join(__dir__, "#{dir}nkf.c")) {|f|
4
+ f.gets("\n#define NKF_GEM_VERSION ")
5
+ f.gets[/\s*"(.+)"/, 1]
6
+ }
7
+ rescue Errno::ENOENT
8
+ end
9
+ end
10
+
1
11
  Gem::Specification.new do |spec|
2
12
  spec.name = "nkf"
3
- spec.version = "0.1.1"
13
+ spec.version = source_version
4
14
  spec.authors = ["NARUSE Yui"]
5
15
  spec.email = ["naruse@airemix.jp"]
6
16
 
@@ -21,4 +31,5 @@ Gem::Specification.new do |spec|
21
31
  spec.bindir = "exe"
22
32
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
33
  spec.require_paths = ["lib"]
34
+ spec.extensions = ["ext/nkf/extconf.rb"]
24
35
  end
metadata CHANGED
@@ -1,22 +1,25 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nkf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - NARUSE Yui
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-14 00:00:00.000000000 Z
11
+ date: 2023-05-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby extension for Network Kanji Filter
14
14
  email:
15
15
  - naruse@airemix.jp
16
16
  executables: []
17
- extensions: []
17
+ extensions:
18
+ - ext/nkf/extconf.rb
18
19
  extra_rdoc_files: []
19
20
  files:
21
+ - ".git-blame-ignore-revs"
22
+ - ".github/dependabot.yml"
20
23
  - ".github/workflows/test.yml"
21
24
  - ".gitignore"
22
25
  - Gemfile
@@ -56,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
59
  - !ruby/object:Gem::Version
57
60
  version: '0'
58
61
  requirements: []
59
- rubygems_version: 3.2.22
62
+ rubygems_version: 3.5.0.dev
60
63
  signing_key:
61
64
  specification_version: 4
62
65
  summary: Ruby extension for Network Kanji Filter