stringio 3.0.0 → 3.0.1.1

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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/ext/stringio/stringio.c +17 -13
  3. metadata +4 -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: 7c86f86172a6b8f70ac2b4263064b3b27f2919e4114a412a7a6bbbc20664886d
4
+ data.tar.gz: cf5ad5b78b3e544195c11a5280cfee89c1c97ecdf1c1cc8c9f8470e4f2758a87
5
5
  SHA512:
6
- metadata.gz: c19e3fa54ab666fe1ac76a398637e7181ca7e5948bb3576a2504e3a79253ab995dbf515bbaa52f01a6aec112f28102c002353038eced204ddeba0b15ea930544
7
- data.tar.gz: 3d67ea8a7975013bdf361bf8ab80cd208187b6f4396a118fd16f1d6e9134ab0b596d4b7453b5bdaa0a7f232e08c0103ae3da638258f98baf2e4bd5bcaf5e35f8
6
+ metadata.gz: 340c0a775cd3f3622942b87e7bfc3a7887f259e01370a8aefa18ae383a672e8ee5df3b1e5666e9b7cab4a02a898bcbaf99e49ab5ad9b74a9e65c882459b44c6b
7
+ data.tar.gz: c8a2cf3a58fa211c76ac63f17827beead45c6f53dffd1e68f024d88ae6329d353d78f30d902735afd802624a334683c6739e5e265301c3282301c4181face1d5
@@ -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.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
  }
@@ -976,7 +984,7 @@ strio_unget_bytes(struct StringIO *ptr, const char *cp, long cl)
976
984
  len = RSTRING_LEN(str);
977
985
  rest = pos - len;
978
986
  if (cl > pos) {
979
- long ex = (rest < 0 ? cl-pos : cl+rest);
987
+ long ex = cl - (rest < 0 ? pos : len);
980
988
  rb_str_modify_expand(str, ex);
981
989
  rb_str_set_len(str, len + ex);
982
990
  s = RSTRING_PTR(str);
@@ -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,14 @@
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.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nobu Nakada
8
- autorequire:
9
8
  bindir: bin
10
9
  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'
10
+ date: 2024-03-19 00:00:00.000000000 Z
11
+ dependencies: []
41
12
  description: Pseudo `IO` class from/to `String`.
42
13
  email: nobu@ruby-lang.org
43
14
  executables: []
@@ -53,7 +24,6 @@ licenses:
53
24
  - Ruby
54
25
  - BSD-2-Clause
55
26
  metadata: {}
56
- post_install_message:
57
27
  rdoc_options: []
58
28
  require_paths:
59
29
  - lib
@@ -68,8 +38,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
38
  - !ruby/object:Gem::Version
69
39
  version: '2.6'
70
40
  requirements: []
71
- rubygems_version: 3.1.4
72
- signing_key:
41
+ rubygems_version: 3.6.0.dev
73
42
  specification_version: 4
74
43
  summary: Pseudo IO on String
75
44
  test_files: []