stringio 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of stringio might be problematic. Click here for more details.

Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/ext/stringio/stringio.c +16 -12
  3. metadata +7 -35
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 41c6ce121bb7eb707f594272b5665080732c7eb7d5ae868f95bb633dc83711ae
4
- data.tar.gz: d7c1e9260fa0095a95a31e7170264d0d40b4e0093b6bccd0ee84fc80e3c4f005
3
+ metadata.gz: 709966f48107a3b3ab9c8b6195ffc21e7e887b7e02c139e4608b20e265ce63c5
4
+ data.tar.gz: '087dda134d3df50928ebb2a941032a4b5a94fafb1a2dc15057a801a3bfff2d65'
5
5
  SHA512:
6
- metadata.gz: c19e3fa54ab666fe1ac76a398637e7181ca7e5948bb3576a2504e3a79253ab995dbf515bbaa52f01a6aec112f28102c002353038eced204ddeba0b15ea930544
7
- data.tar.gz: 3d67ea8a7975013bdf361bf8ab80cd208187b6f4396a118fd16f1d6e9134ab0b596d4b7453b5bdaa0a7f232e08c0103ae3da638258f98baf2e4bd5bcaf5e35f8
6
+ metadata.gz: 38f467c080782fdca0e76f32c75aac445457d653eea491bd3219f412682889e6613c363062700901948cc372af9227dceba622cc77a84b01455fd6af38247c69
7
+ data.tar.gz: f17f06857188c5f7cac5810fb6c98cbf2615832a785ea0b19e3e91d6754d9136498694da628e61ba4a5ceb39ba7b7afad63d443c473c49364f423d08d0e19e75
@@ -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 "3.0.0"
15
+ #define STRINGIO_VERSION "3.0.1"
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,11 +829,11 @@ 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
  }
@@ -1064,11 +1072,7 @@ strio_each_codepoint(VALUE self)
1064
1072
 
1065
1073
  ptr = readable(self);
1066
1074
  enc = get_enc(ptr);
1067
- for (;;) {
1068
- if (ptr->pos >= RSTRING_LEN(ptr->string)) {
1069
- return self;
1070
- }
1071
-
1075
+ while ((ptr = strio_to_read(self)) != NULL) {
1072
1076
  c = rb_enc_codepoint_len(RSTRING_PTR(ptr->string)+ptr->pos,
1073
1077
  RSTRING_END(ptr->string), &n, enc);
1074
1078
  ptr->pos += n;
@@ -1755,7 +1759,7 @@ Init_stringio(void)
1755
1759
  rb_ext_ractor_safe(true);
1756
1760
  #endif
1757
1761
 
1758
- VALUE StringIO = rb_define_class("StringIO", rb_cData);
1762
+ VALUE StringIO = rb_define_class("StringIO", rb_cObject);
1759
1763
 
1760
1764
  rb_define_const(StringIO, "VERSION", rb_str_new_cstr(STRINGIO_VERSION));
1761
1765
 
metadata CHANGED
@@ -1,43 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stringio
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nobu Nakada
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-18 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'
27
- - !ruby/object:Gem::Dependency
28
- name: test-unit
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
11
+ date: 2021-10-21 00:00:00.000000000 Z
12
+ dependencies: []
41
13
  description: Pseudo `IO` class from/to `String`.
42
14
  email: nobu@ruby-lang.org
43
15
  executables: []
@@ -53,7 +25,7 @@ licenses:
53
25
  - Ruby
54
26
  - BSD-2-Clause
55
27
  metadata: {}
56
- post_install_message:
28
+ post_install_message:
57
29
  rdoc_options: []
58
30
  require_paths:
59
31
  - lib
@@ -68,8 +40,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
40
  - !ruby/object:Gem::Version
69
41
  version: '2.6'
70
42
  requirements: []
71
- rubygems_version: 3.1.4
72
- signing_key:
43
+ rubygems_version: 3.3.0.dev
44
+ signing_key:
73
45
  specification_version: 4
74
46
  summary: Pseudo IO on String
75
47
  test_files: []