strscan 3.1.5 → 3.1.6

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: 74de6150a7cbeca1382c754e79ae54cc6adc16eb3073952b0d8ef5f2f0fe0c90
4
- data.tar.gz: d3abc5e2e3a84aec4b0bd7f4748cbe5c5c5a66826220d60b850a5a49082f6ad3
3
+ metadata.gz: 8a20ded1eb483c2517db5c99febea87c52f108b1b8fb1077d6e66d3512b69a8c
4
+ data.tar.gz: 4cc83ff72dba80c66f05c0dc1ba31669a0d8b41cd3d4d36fad8fceb4b04a7e84
5
5
  SHA512:
6
- metadata.gz: abf7dfce1540a7cbd710740c0269b84bba5b33bbb51d6434da84a860b75526f906b8bbc211f35678cf57d33cabc50f42fc2c578d2b9eb5ce5b6f81374b02ff4d
7
- data.tar.gz: 03c301039437aece9be7ecb739a22d02aa2e143e706dc57ce14eeea57a3f8f77f5d7ba1a8f6b4e1aec2e378e5af6f2d64a56b31ab51b3d79eb30aa5240e42450
6
+ metadata.gz: 9890e1ba7ac3c7fd26f4e8c3b0e6a40a3473bc6e87b472eee4e6f18c4299fa0291eadbf222c19db68c6913277f7147f7609ee001711bcd5c454c6a9cd8f070c1
7
+ data.tar.gz: ceea0c6918412705091741a0154b8c3b0752cd2c1130da4932ecaff33c4fa8690775b046aea8157dc539ff28a873b8f2dff41bee67c0fc458095845a340f328d
data/.rdoc_options CHANGED
@@ -1,3 +1,5 @@
1
1
  ---
2
2
  rdoc_include:
3
3
  - doc
4
+ main_page: README.md
5
+ op_dir: html
@@ -37,7 +37,7 @@ Some examples here assume that certain helper methods are defined:
37
37
  - `match_values_cleared?(scanner)`:
38
38
  Returns whether the scanner's [match values][9] are cleared.
39
39
 
40
- See examples [here][ext/strscan/helper_methods_md.html].
40
+ See examples at [helper methods](helper_methods.md).
41
41
 
42
42
  ## The `StringScanner` \Object
43
43
 
@@ -204,7 +204,7 @@ put_situation(scanner)
204
204
 
205
205
  ## Target Substring
206
206
 
207
- The target substring is the the part of the [stored string][1]
207
+ The target substring is the part of the [stored string][1]
208
208
  that extends from the current [byte position][2] to the end of the stored string;
209
209
  it is always either:
210
210
 
@@ -417,7 +417,7 @@ Each of these methods returns a captured match value:
417
417
  | Method | Return After Match | Return After No Match |
418
418
  |-----------------|-----------------------------------------|-----------------------|
419
419
  | #size | Count of captured substrings. | +nil+. |
420
- | #[](n) | <tt>n</tt>th captured substring. | +nil+. |
420
+ | #\[\](n) | <tt>n</tt>th captured substring. | +nil+. |
421
421
  | #captures | Array of all captured substrings. | +nil+. |
422
422
  | #values_at(*n) | Array of specified captured substrings. | +nil+. |
423
423
  | #named_captures | Hash of named captures. | <tt>{}</tt>. |
@@ -2,8 +2,9 @@
2
2
  require 'mkmf'
3
3
  if RUBY_ENGINE == 'ruby'
4
4
  $INCFLAGS << " -I$(top_srcdir)" if $extmk
5
- have_func("onig_region_memsize", "ruby.h")
6
- have_func("rb_reg_onig_match", "ruby.h")
5
+ have_func("onig_region_memsize(NULL)")
6
+ have_func("rb_reg_onig_match", "ruby/re.h")
7
+ have_func("rb_deprecate_constant")
7
8
  create_makefile 'strscan'
8
9
  else
9
10
  File.write('Makefile', dummy_makefile("").join)
@@ -22,7 +22,15 @@ extern size_t onig_region_memsize(const struct re_registers *regs);
22
22
 
23
23
  #include <stdbool.h>
24
24
 
25
- #define STRSCAN_VERSION "3.1.5"
25
+ #define STRSCAN_VERSION "3.1.6"
26
+
27
+
28
+ #ifdef HAVE_RB_DEPRECATE_CONSTANT
29
+ /* In ruby 3.0, defined but exposed in external headers */
30
+ extern void rb_deprecate_constant(VALUE mod, const char *name);
31
+ #else
32
+ # define rb_deprecate_constant(mod, name) ((void)0)
33
+ #endif
26
34
 
27
35
  /* =======================================================================
28
36
  Data Type Definitions
@@ -30,7 +38,6 @@ extern size_t onig_region_memsize(const struct re_registers *regs);
30
38
 
31
39
  static VALUE StringScanner;
32
40
  static VALUE ScanError;
33
- static ID id_byteslice;
34
41
 
35
42
  static int usascii_encindex, utf8_encindex, binary_encindex;
36
43
 
@@ -97,7 +104,6 @@ static VALUE strscan_init_copy _((VALUE vself, VALUE vorig));
97
104
 
98
105
  static VALUE strscan_s_mustc _((VALUE self));
99
106
  static VALUE strscan_terminate _((VALUE self));
100
- static VALUE strscan_clear _((VALUE self));
101
107
  static VALUE strscan_get_string _((VALUE self));
102
108
  static VALUE strscan_set_string _((VALUE self, VALUE str));
103
109
  static VALUE strscan_concat _((VALUE self, VALUE str));
@@ -119,14 +125,11 @@ static VALUE strscan_search_full _((VALUE self, VALUE re,
119
125
  static void adjust_registers_to_matched _((struct strscanner *p));
120
126
  static VALUE strscan_getch _((VALUE self));
121
127
  static VALUE strscan_get_byte _((VALUE self));
122
- static VALUE strscan_getbyte _((VALUE self));
123
128
  static VALUE strscan_peek _((VALUE self, VALUE len));
124
- static VALUE strscan_peep _((VALUE self, VALUE len));
125
129
  static VALUE strscan_scan_base10_integer _((VALUE self));
126
130
  static VALUE strscan_unscan _((VALUE self));
127
131
  static VALUE strscan_bol_p _((VALUE self));
128
132
  static VALUE strscan_eos_p _((VALUE self));
129
- static VALUE strscan_empty_p _((VALUE self));
130
133
  static VALUE strscan_rest_p _((VALUE self));
131
134
  static VALUE strscan_matched_p _((VALUE self));
132
135
  static VALUE strscan_matched _((VALUE self));
@@ -209,7 +212,7 @@ strscan_memsize(const void *ptr)
209
212
  static const rb_data_type_t strscanner_type = {
210
213
  "StringScanner",
211
214
  {strscan_mark, strscan_free, strscan_memsize},
212
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
215
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
213
216
  };
214
217
 
215
218
  static VALUE
@@ -273,7 +276,7 @@ strscan_initialize(int argc, VALUE *argv, VALUE self)
273
276
  p->fixed_anchor_p = false;
274
277
  }
275
278
  StringValue(str);
276
- p->str = str;
279
+ RB_OBJ_WRITE(self, &p->str, str);
277
280
 
278
281
  return self;
279
282
  }
@@ -303,7 +306,7 @@ strscan_init_copy(VALUE vself, VALUE vorig)
303
306
  orig = check_strscan(vorig);
304
307
  if (self != orig) {
305
308
  self->flags = orig->flags;
306
- self->str = orig->str;
309
+ RB_OBJ_WRITE(vself, &self->str, orig->str);
307
310
  self->prev = orig->prev;
308
311
  self->curr = orig->curr;
309
312
  if (rb_reg_region_copy(&self->regs, &orig->regs))
@@ -385,21 +388,6 @@ strscan_terminate(VALUE self)
385
388
  return self;
386
389
  }
387
390
 
388
- /*
389
- * call-seq:
390
- * clear -> self
391
- *
392
- * This method is obsolete; use the equivalent method StringScanner#terminate.
393
- */
394
-
395
- /* :nodoc: */
396
- static VALUE
397
- strscan_clear(VALUE self)
398
- {
399
- rb_warning("StringScanner#clear is obsolete; use #terminate instead");
400
- return strscan_terminate(self);
401
- }
402
-
403
391
  /*
404
392
  * :markup: markdown
405
393
  * :include: strscan/link_refs.txt
@@ -467,7 +455,7 @@ strscan_set_string(VALUE self, VALUE str)
467
455
  struct strscanner *p = check_strscan(self);
468
456
 
469
457
  StringValue(str);
470
- p->str = str;
458
+ RB_OBJ_WRITE(self, &p->str, str);
471
459
  p->curr = 0;
472
460
  CLEAR_MATCH_STATUS(p);
473
461
  return str;
@@ -712,7 +700,7 @@ strscan_do_scan(VALUE self, VALUE pattern, int succptr, int getstr, int headonly
712
700
 
713
701
  if (RB_TYPE_P(pattern, T_REGEXP)) {
714
702
  OnigPosition ret;
715
- p->regex = pattern;
703
+ RB_OBJ_WRITE(self, &p->regex, pattern);
716
704
  ret = rb_reg_onig_match(p->regex,
717
705
  p->str,
718
706
  headonly ? strscan_match : strscan_search,
@@ -1218,22 +1206,6 @@ strscan_get_byte(VALUE self)
1218
1206
  adjust_register_position(p, p->regs.end[0]));
1219
1207
  }
1220
1208
 
1221
- /*
1222
- * call-seq:
1223
- * getbyte
1224
- *
1225
- * Equivalent to #get_byte.
1226
- * This method is obsolete; use #get_byte instead.
1227
- */
1228
-
1229
- /* :nodoc: */
1230
- static VALUE
1231
- strscan_getbyte(VALUE self)
1232
- {
1233
- rb_warning("StringScanner#getbyte is obsolete; use #get_byte instead");
1234
- return strscan_get_byte(self);
1235
- }
1236
-
1237
1209
  /*
1238
1210
  * :markup: markdown
1239
1211
  * :include: strscan/link_refs.txt
@@ -1269,22 +1241,6 @@ strscan_peek(VALUE self, VALUE vlen)
1269
1241
  return extract_beg_len(p, p->curr, len);
1270
1242
  }
1271
1243
 
1272
- /*
1273
- * call-seq:
1274
- * peep
1275
- *
1276
- * Equivalent to #peek.
1277
- * This method is obsolete; use #peek instead.
1278
- */
1279
-
1280
- /* :nodoc: */
1281
- static VALUE
1282
- strscan_peep(VALUE self, VALUE vlen)
1283
- {
1284
- rb_warning("StringScanner#peep is obsolete; use #peek instead");
1285
- return strscan_peek(self, vlen);
1286
- }
1287
-
1288
1244
  static VALUE
1289
1245
  strscan_parse_integer(struct strscanner *p, int base, long len)
1290
1246
  {
@@ -1322,11 +1278,12 @@ strscan_must_ascii_compat(VALUE str)
1322
1278
  rb_must_asciicompat(str);
1323
1279
  }
1324
1280
 
1281
+ /* :nodoc: */
1325
1282
  static VALUE
1326
1283
  strscan_scan_base10_integer(VALUE self)
1327
1284
  {
1328
1285
  char *ptr;
1329
- long len = 0;
1286
+ long len = 0, remaining_len;
1330
1287
  struct strscanner *p;
1331
1288
 
1332
1289
  GET_SCANNER(self, p);
@@ -1336,7 +1293,7 @@ strscan_scan_base10_integer(VALUE self)
1336
1293
 
1337
1294
  ptr = CURPTR(p);
1338
1295
 
1339
- long remaining_len = S_RESTLEN(p);
1296
+ remaining_len = S_RESTLEN(p);
1340
1297
 
1341
1298
  if (remaining_len <= 0) {
1342
1299
  return Qnil;
@@ -1359,11 +1316,12 @@ strscan_scan_base10_integer(VALUE self)
1359
1316
  return strscan_parse_integer(p, 10, len);
1360
1317
  }
1361
1318
 
1319
+ /* :nodoc: */
1362
1320
  static VALUE
1363
1321
  strscan_scan_base16_integer(VALUE self)
1364
1322
  {
1365
1323
  char *ptr;
1366
- long len = 0;
1324
+ long len = 0, remaining_len;
1367
1325
  struct strscanner *p;
1368
1326
 
1369
1327
  GET_SCANNER(self, p);
@@ -1373,7 +1331,7 @@ strscan_scan_base16_integer(VALUE self)
1373
1331
 
1374
1332
  ptr = CURPTR(p);
1375
1333
 
1376
- long remaining_len = S_RESTLEN(p);
1334
+ remaining_len = S_RESTLEN(p);
1377
1335
 
1378
1336
  if (remaining_len <= 0) {
1379
1337
  return Qnil;
@@ -1524,28 +1482,11 @@ strscan_eos_p(VALUE self)
1524
1482
  return EOS_P(p) ? Qtrue : Qfalse;
1525
1483
  }
1526
1484
 
1527
- /*
1528
- * call-seq:
1529
- * empty?
1530
- *
1531
- * Equivalent to #eos?.
1532
- * This method is obsolete, use #eos? instead.
1533
- */
1534
-
1535
- /* :nodoc: */
1536
- static VALUE
1537
- strscan_empty_p(VALUE self)
1538
- {
1539
- rb_warning("StringScanner#empty? is obsolete; use #eos? instead");
1540
- return strscan_eos_p(self);
1541
- }
1542
-
1543
1485
  /*
1544
1486
  * call-seq:
1545
1487
  * rest?
1546
1488
  *
1547
1489
  * Returns true if and only if there is more data in the string. See #eos?.
1548
- * This method is obsolete; use #eos? instead.
1549
1490
  *
1550
1491
  * s = StringScanner.new('test string')
1551
1492
  * # These two are opposites
@@ -1673,7 +1614,7 @@ name_to_backref_number(struct re_registers *regs, VALUE regexp, const char* name
1673
1614
  (const unsigned char* )name_end,
1674
1615
  regs);
1675
1616
  if (num >= 1) {
1676
- return num;
1617
+ return num;
1677
1618
  }
1678
1619
  }
1679
1620
  rb_enc_raise(enc, rb_eIndexError, "undefined group name reference: %.*s",
@@ -2053,22 +1994,6 @@ strscan_rest_size(VALUE self)
2053
1994
  return INT2FIX(i);
2054
1995
  }
2055
1996
 
2056
- /*
2057
- * call-seq:
2058
- * restsize
2059
- *
2060
- * <tt>s.restsize</tt> is equivalent to <tt>s.rest_size</tt>.
2061
- * This method is obsolete; use #rest_size instead.
2062
- */
2063
-
2064
- /* :nodoc: */
2065
- static VALUE
2066
- strscan_restsize(VALUE self)
2067
- {
2068
- rb_warning("StringScanner#restsize is obsolete; use #rest_size instead");
2069
- return strscan_rest_size(self);
2070
- }
2071
-
2072
1997
  #define INSPECT_LENGTH 5
2073
1998
 
2074
1999
  /*
@@ -2267,6 +2192,13 @@ strscan_named_captures(VALUE self)
2267
2192
  Ruby Interface
2268
2193
  ======================================================================= */
2269
2194
 
2195
+ /*
2196
+ * Document-class: StringScanner::Error
2197
+ *
2198
+ * The error class for StringScanner.
2199
+ * See StringScanner#unscan.
2200
+ */
2201
+
2270
2202
  /*
2271
2203
  * Document-class: StringScanner
2272
2204
  *
@@ -2287,8 +2219,6 @@ Init_strscan(void)
2287
2219
  ID id_scanerr = rb_intern("ScanError");
2288
2220
  VALUE tmp;
2289
2221
 
2290
- id_byteslice = rb_intern("byteslice");
2291
-
2292
2222
  usascii_encindex = rb_usascii_encindex();
2293
2223
  utf8_encindex = rb_utf8_encindex();
2294
2224
  binary_encindex = rb_ascii8bit_encindex();
@@ -2297,6 +2227,7 @@ Init_strscan(void)
2297
2227
  ScanError = rb_define_class_under(StringScanner, "Error", rb_eStandardError);
2298
2228
  if (!rb_const_defined(rb_cObject, id_scanerr)) {
2299
2229
  rb_const_set(rb_cObject, id_scanerr, ScanError);
2230
+ rb_deprecate_constant(rb_cObject, "ScanError");
2300
2231
  }
2301
2232
  tmp = rb_str_new2(STRSCAN_VERSION);
2302
2233
  rb_obj_freeze(tmp);
@@ -2304,6 +2235,7 @@ Init_strscan(void)
2304
2235
  tmp = rb_str_new2("$Id$");
2305
2236
  rb_obj_freeze(tmp);
2306
2237
  rb_const_set(StringScanner, rb_intern("Id"), tmp);
2238
+ rb_deprecate_constant(StringScanner, "Id");
2307
2239
 
2308
2240
  rb_define_alloc_func(StringScanner, strscan_s_allocate);
2309
2241
  rb_define_private_method(StringScanner, "initialize", strscan_initialize, -1);
@@ -2311,7 +2243,6 @@ Init_strscan(void)
2311
2243
  rb_define_singleton_method(StringScanner, "must_C_version", strscan_s_mustc, 0);
2312
2244
  rb_define_method(StringScanner, "reset", strscan_reset, 0);
2313
2245
  rb_define_method(StringScanner, "terminate", strscan_terminate, 0);
2314
- rb_define_method(StringScanner, "clear", strscan_clear, 0);
2315
2246
  rb_define_method(StringScanner, "string", strscan_get_string, 0);
2316
2247
  rb_define_method(StringScanner, "string=", strscan_set_string, 1);
2317
2248
  rb_define_method(StringScanner, "concat", strscan_concat, 1);
@@ -2336,11 +2267,9 @@ Init_strscan(void)
2336
2267
 
2337
2268
  rb_define_method(StringScanner, "getch", strscan_getch, 0);
2338
2269
  rb_define_method(StringScanner, "get_byte", strscan_get_byte, 0);
2339
- rb_define_method(StringScanner, "getbyte", strscan_getbyte, 0);
2340
2270
  rb_define_method(StringScanner, "scan_byte", strscan_scan_byte, 0);
2341
2271
  rb_define_method(StringScanner, "peek", strscan_peek, 1);
2342
2272
  rb_define_method(StringScanner, "peek_byte", strscan_peek_byte, 0);
2343
- rb_define_method(StringScanner, "peep", strscan_peep, 1);
2344
2273
 
2345
2274
  rb_define_private_method(StringScanner, "scan_base10_integer", strscan_scan_base10_integer, 0);
2346
2275
  rb_define_private_method(StringScanner, "scan_base16_integer", strscan_scan_base16_integer, 0);
@@ -2350,7 +2279,6 @@ Init_strscan(void)
2350
2279
  rb_define_method(StringScanner, "beginning_of_line?", strscan_bol_p, 0);
2351
2280
  rb_alias(StringScanner, rb_intern("bol?"), rb_intern("beginning_of_line?"));
2352
2281
  rb_define_method(StringScanner, "eos?", strscan_eos_p, 0);
2353
- rb_define_method(StringScanner, "empty?", strscan_empty_p, 0);
2354
2282
  rb_define_method(StringScanner, "rest?", strscan_rest_p, 0);
2355
2283
 
2356
2284
  rb_define_method(StringScanner, "matched?", strscan_matched_p, 0);
@@ -2365,7 +2293,6 @@ Init_strscan(void)
2365
2293
 
2366
2294
  rb_define_method(StringScanner, "rest", strscan_rest, 0);
2367
2295
  rb_define_method(StringScanner, "rest_size", strscan_rest_size, 0);
2368
- rb_define_method(StringScanner, "restsize", strscan_restsize, 0);
2369
2296
 
2370
2297
  rb_define_method(StringScanner, "inspect", strscan_inspect, 0);
2371
2298
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strscan
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.5
4
+ version: 3.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minero Aoki
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  requirements: []
77
- rubygems_version: 3.6.7
77
+ rubygems_version: 3.6.9
78
78
  specification_version: 4
79
79
  summary: Provides lexical scanning operations on a String.
80
80
  test_files: []