stringio 0.1.4 → 3.0.2.pre1

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -1
  3. data/ext/stringio/stringio.c +21 -64
  4. metadata +12 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0bc5f299743ea72087d1219832a5b08a885520180c1b01e4f8305e263577c022
4
- data.tar.gz: cffe5c63c091abd02cd87f6e09ecd88b83818b8d1f465f4b32f9cf69aab1edde
3
+ metadata.gz: 485b4a853f043d25f1c1a3ece1a7f1e8a1720ee7157bcde9df858ac0f9b61701
4
+ data.tar.gz: f6f24d32282461b5c3b97d1576a7a510def637d0c9dc98834876e5ecbd2792b0
5
5
  SHA512:
6
- metadata.gz: 2c5fed3bca803311561c9e27deaebfc62e764bdd37699ae677e2780ae3664de2dd47471535db0aa78446dc8ee2f1f67791aa99c189a7c1df51aff0b0b880f303
7
- data.tar.gz: f5186918ceaaeef2528227195a750084e89046502011070905e219671714109fcd10a3ae7ba090e7143f30e62dcc3ebe13cf036997b034c8f39e055d13f1c06f
6
+ metadata.gz: e2c05da950d38ff21f3b4d4836be02dd7f9c479daff89fb648f84ccfb857a8611bfa2a0ab716f03316887790c70802d83b9a8867705b5aaddbadc9906f23b3a8
7
+ data.tar.gz: c9eb88894bc04413f3ed136b0d5801439913bc9721cf6e8daa5c77cdd118ea2aadab3830d0522949d1147294eda81db09f0e5a43d5ff68d5d49f37c8d305d532
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # StringIO
2
2
 
3
- [![Build Status](https://travis-ci.org/ruby/stringio.svg?branch=master)](https://travis-ci.org/ruby/stringio)
3
+ ![ubuntu](https://github.com/ruby/stringio/workflows/ubuntu/badge.svg?branch=master&event=push)
4
+ ![macos](https://github.com/ruby/stringio/workflows/macos/badge.svg?branch=master&event=push)
5
+ ![windows](https://github.com/ruby/stringio/workflows/windows/badge.svg?branch=master&event=push)
4
6
 
5
7
  Pseudo `IO` class from/to `String`.
6
8
 
@@ -1,3 +1,4 @@
1
+ /* -*- mode: c; indent-tabs-mode: t -*- */
1
2
  /**********************************************************************
2
3
 
3
4
  stringio.c -
@@ -11,7 +12,7 @@
11
12
 
12
13
  **********************************************************************/
13
14
 
14
- #define STRINGIO_VERSION "0.1.4"
15
+ #define STRINGIO_VERSION "3.0.2.pre1"
15
16
 
16
17
  #include "ruby.h"
17
18
  #include "ruby/io.h"
@@ -64,7 +65,7 @@ strio_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash,
64
65
  n = strchr(n, '|');
65
66
  }
66
67
  e = strchr(++n, ':');
67
- len = e ? e - n : strlen(n);
68
+ len = e ? e - n : (long)strlen(n);
68
69
  if (len > 0 && len <= ENCODING_MAXNAMELEN) {
69
70
  if (e) {
70
71
  memcpy(encname, n, len);
@@ -599,6 +600,14 @@ strio_closed_write(VALUE self)
599
600
  return Qtrue;
600
601
  }
601
602
 
603
+ static struct StringIO *
604
+ strio_to_read(VALUE self)
605
+ {
606
+ struct StringIO *ptr = readable(self);
607
+ if (ptr->pos < RSTRING_LEN(ptr->string)) return ptr;
608
+ return NULL;
609
+ }
610
+
602
611
  /*
603
612
  * call-seq:
604
613
  * strio.eof -> true or false
@@ -610,8 +619,7 @@ strio_closed_write(VALUE self)
610
619
  static VALUE
611
620
  strio_eof(VALUE self)
612
621
  {
613
- struct StringIO *ptr = readable(self);
614
- if (ptr->pos < RSTRING_LEN(ptr->string)) return Qfalse;
622
+ if (strio_to_read(self)) return Qfalse;
615
623
  return Qtrue;
616
624
  }
617
625
 
@@ -821,29 +829,17 @@ strio_get_sync(VALUE self)
821
829
  static VALUE
822
830
  strio_each_byte(VALUE self)
823
831
  {
824
- struct StringIO *ptr = readable(self);
832
+ struct StringIO *ptr;
825
833
 
826
834
  RETURN_ENUMERATOR(self, 0, 0);
827
835
 
828
- while (ptr->pos < RSTRING_LEN(ptr->string)) {
836
+ while ((ptr = strio_to_read(self)) != NULL) {
829
837
  char c = RSTRING_PTR(ptr->string)[ptr->pos++];
830
838
  rb_yield(CHR2FIX(c));
831
839
  }
832
840
  return self;
833
841
  }
834
842
 
835
- /*
836
- * This is a deprecated alias for #each_byte.
837
- */
838
- static VALUE
839
- strio_bytes(VALUE self)
840
- {
841
- rb_warn("StringIO#bytes is deprecated; use #each_byte instead");
842
- if (!rb_block_given_p())
843
- return rb_enumeratorize(self, ID2SYM(rb_intern("each_byte")), 0, 0);
844
- return strio_each_byte(self);
845
- }
846
-
847
843
  /*
848
844
  * call-seq:
849
845
  * strio.getc -> string or nil
@@ -1057,18 +1053,6 @@ strio_each_char(VALUE self)
1057
1053
  return self;
1058
1054
  }
1059
1055
 
1060
- /*
1061
- * This is a deprecated alias for #each_char.
1062
- */
1063
- static VALUE
1064
- strio_chars(VALUE self)
1065
- {
1066
- rb_warn("StringIO#chars is deprecated; use #each_char instead");
1067
- if (!rb_block_given_p())
1068
- return rb_enumeratorize(self, ID2SYM(rb_intern("each_char")), 0, 0);
1069
- return strio_each_char(self);
1070
- }
1071
-
1072
1056
  /*
1073
1057
  * call-seq:
1074
1058
  * strio.each_codepoint {|c| block } -> strio
@@ -1088,11 +1072,7 @@ strio_each_codepoint(VALUE self)
1088
1072
 
1089
1073
  ptr = readable(self);
1090
1074
  enc = get_enc(ptr);
1091
- for (;;) {
1092
- if (ptr->pos >= RSTRING_LEN(ptr->string)) {
1093
- return self;
1094
- }
1095
-
1075
+ while ((ptr = strio_to_read(self)) != NULL) {
1096
1076
  c = rb_enc_codepoint_len(RSTRING_PTR(ptr->string)+ptr->pos,
1097
1077
  RSTRING_END(ptr->string), &n, enc);
1098
1078
  ptr->pos += n;
@@ -1101,18 +1081,6 @@ strio_each_codepoint(VALUE self)
1101
1081
  return self;
1102
1082
  }
1103
1083
 
1104
- /*
1105
- * This is a deprecated alias for #each_codepoint.
1106
- */
1107
- static VALUE
1108
- strio_codepoints(VALUE self)
1109
- {
1110
- rb_warn("StringIO#codepoints is deprecated; use #each_codepoint instead");
1111
- if (!rb_block_given_p())
1112
- return rb_enumeratorize(self, ID2SYM(rb_intern("each_codepoint")), 0, 0);
1113
- return strio_each_codepoint(self);
1114
- }
1115
-
1116
1084
  /* Boyer-Moore search: copied from regex.c */
1117
1085
  static void
1118
1086
  bm_init_skip(long *skip, const char *pat, long m)
@@ -1363,18 +1331,6 @@ strio_each(int argc, VALUE *argv, VALUE self)
1363
1331
  return self;
1364
1332
  }
1365
1333
 
1366
- /*
1367
- * This is a deprecated alias for #each_line.
1368
- */
1369
- static VALUE
1370
- strio_lines(int argc, VALUE *argv, VALUE self)
1371
- {
1372
- rb_warn("StringIO#lines is deprecated; use #each_line instead");
1373
- if (!rb_block_given_p())
1374
- return rb_enumeratorize(self, ID2SYM(rb_intern("each_line")), argc, argv);
1375
- return strio_each(argc, argv, self);
1376
- }
1377
-
1378
1334
  /*
1379
1335
  * call-seq:
1380
1336
  * strio.readlines(sep=$/, chomp: false) -> array
@@ -1798,7 +1754,12 @@ void
1798
1754
  Init_stringio(void)
1799
1755
  {
1800
1756
  #undef rb_intern
1801
- VALUE StringIO = rb_define_class("StringIO", rb_cData);
1757
+
1758
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
1759
+ rb_ext_ractor_safe(true);
1760
+ #endif
1761
+
1762
+ VALUE StringIO = rb_define_class("StringIO", rb_cObject);
1802
1763
 
1803
1764
  rb_define_const(StringIO, "VERSION", rb_str_new_cstr(STRINGIO_VERSION));
1804
1765
 
@@ -1843,13 +1804,9 @@ Init_stringio(void)
1843
1804
 
1844
1805
  rb_define_method(StringIO, "each", strio_each, -1);
1845
1806
  rb_define_method(StringIO, "each_line", strio_each, -1);
1846
- rb_define_method(StringIO, "lines", strio_lines, -1);
1847
1807
  rb_define_method(StringIO, "each_byte", strio_each_byte, 0);
1848
- rb_define_method(StringIO, "bytes", strio_bytes, 0);
1849
1808
  rb_define_method(StringIO, "each_char", strio_each_char, 0);
1850
- rb_define_method(StringIO, "chars", strio_chars, 0);
1851
1809
  rb_define_method(StringIO, "each_codepoint", strio_each_codepoint, 0);
1852
- rb_define_method(StringIO, "codepoints", strio_codepoints, 0);
1853
1810
  rb_define_method(StringIO, "getc", strio_getc, 0);
1854
1811
  rb_define_method(StringIO, "ungetc", strio_ungetc, 1);
1855
1812
  rb_define_method(StringIO, "ungetbyte", strio_ungetbyte, 1);
metadata CHANGED
@@ -1,31 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stringio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 3.0.2.pre1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nobu Nakada
8
- autorequire:
8
+ - Charles Oliver Nutter
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2020-08-27 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rake-compiler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
12
+ date: 2022-04-15 00:00:00.000000000 Z
13
+ dependencies: []
27
14
  description: Pseudo `IO` class from/to `String`.
28
- email: nobu@ruby-lang.org
15
+ email:
16
+ - nobu@ruby-lang.org
17
+ - headius@headius.com
29
18
  executables: []
30
19
  extensions:
31
20
  - ext/stringio/extconf.rb
@@ -36,9 +25,10 @@ files:
36
25
  - ext/stringio/stringio.c
37
26
  homepage: https://github.com/ruby/stringio
38
27
  licenses:
28
+ - Ruby
39
29
  - BSD-2-Clause
40
30
  metadata: {}
41
- post_install_message:
31
+ post_install_message:
42
32
  rdoc_options: []
43
33
  require_paths:
44
34
  - lib
@@ -53,8 +43,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
53
43
  - !ruby/object:Gem::Version
54
44
  version: '2.6'
55
45
  requirements: []
56
- rubygems_version: 3.2.0.rc.1
57
- signing_key:
46
+ rubygems_version: 3.3.7
47
+ signing_key:
58
48
  specification_version: 4
59
49
  summary: Pseudo IO on String
60
50
  test_files: []