stringio 3.0.4 → 3.0.5
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 +4 -4
- data/README.md +2 -1
- data/ext/stringio/stringio.c +29 -28
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd5cdd012959f081ba2717eb15a3a6f3ca015ec48bba03ef1bf318686007dac2
|
4
|
+
data.tar.gz: 57842131091d3f2a38c03abfb8e294c51361c844b0777086126c034a1a904537
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cb53aa9936ad5464a40268c1b4477f06dcde9f4a456107aeb897812c1a1b52859bbe88a90e8d82dd8b30819444cb5c2b05193ab40c2ccb43a04e03002183b2d
|
7
|
+
data.tar.gz: aefe614e34d66c31b2ddc0c78788e85fba60279c081b65645786cbcaf936e20a42edaa5ef5615dcf4aff6eb10258a1823eee99e89c81f5ed0e01348692bfeb38
|
data/README.md
CHANGED
@@ -12,6 +12,7 @@ This library is based on MoonWolf version written in Ruby. Thanks a lot.
|
|
12
12
|
|
13
13
|
* `fileno` raises `NotImplementedError`.
|
14
14
|
* encoding conversion is not implemented, and ignored silently.
|
15
|
+
* there is no `#to_io` method because this is not an `IO.
|
15
16
|
|
16
17
|
## Installation
|
17
18
|
|
@@ -31,7 +32,7 @@ Or install it yourself as:
|
|
31
32
|
|
32
33
|
## Development
|
33
34
|
|
34
|
-
|
35
|
+
Run `bundle install` to install dependencies and then `bundle exec rake test` to run the tests.
|
35
36
|
|
36
37
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
37
38
|
|
data/ext/stringio/stringio.c
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
**********************************************************************/
|
14
14
|
|
15
|
-
#define STRINGIO_VERSION "3.0.
|
15
|
+
#define STRINGIO_VERSION "3.0.5"
|
16
16
|
|
17
17
|
#include "ruby.h"
|
18
18
|
#include "ruby/io.h"
|
@@ -263,7 +263,7 @@ strio_s_allocate(VALUE klass)
|
|
263
263
|
* Note that +mode+ defaults to <tt>'r'</tt> if +string+ is frozen.
|
264
264
|
*
|
265
265
|
* Returns a new \StringIO instance formed from +string+ and +mode+;
|
266
|
-
* see {Access Modes}[
|
266
|
+
* see {Access Modes}[rdoc-ref:File@Access+Modes]:
|
267
267
|
*
|
268
268
|
* strio = StringIO.new # => #<StringIO>
|
269
269
|
* strio.close
|
@@ -409,7 +409,7 @@ strio_finalize(VALUE self)
|
|
409
409
|
* Note that +mode+ defaults to <tt>'r'</tt> if +string+ is frozen.
|
410
410
|
*
|
411
411
|
* Creates a new \StringIO instance formed from +string+ and +mode+;
|
412
|
-
* see {Access Modes}[
|
412
|
+
* see {Access Modes}[rdoc-ref:File@Access+Modes].
|
413
413
|
*
|
414
414
|
* With no block, returns the new instance:
|
415
415
|
*
|
@@ -682,7 +682,7 @@ strio_to_read(VALUE self)
|
|
682
682
|
* eof? -> true or false
|
683
683
|
*
|
684
684
|
* Returns +true+ if positioned at end-of-stream, +false+ otherwise;
|
685
|
-
* see {Position}[
|
685
|
+
* see {Position}[rdoc-ref:File@Position].
|
686
686
|
*
|
687
687
|
* Raises IOError if the stream is not opened for reading.
|
688
688
|
*
|
@@ -719,7 +719,7 @@ strio_copy(VALUE copy, VALUE orig)
|
|
719
719
|
* lineno -> current_line_number
|
720
720
|
*
|
721
721
|
* Returns the current line number in +self+;
|
722
|
-
* see {Line Number}[
|
722
|
+
* see {Line Number}[rdoc-ref:IO@Line+Number].
|
723
723
|
*/
|
724
724
|
static VALUE
|
725
725
|
strio_get_lineno(VALUE self)
|
@@ -732,7 +732,7 @@ strio_get_lineno(VALUE self)
|
|
732
732
|
* lineno = new_line_number -> new_line_number
|
733
733
|
*
|
734
734
|
* Sets the current line number in +self+ to the given +new_line_number+;
|
735
|
-
* see {Line Number}[
|
735
|
+
* see {Line Number}[rdoc-ref:IO@Line+Number].
|
736
736
|
*/
|
737
737
|
static VALUE
|
738
738
|
strio_set_lineno(VALUE self, VALUE lineno)
|
@@ -746,7 +746,7 @@ strio_set_lineno(VALUE self, VALUE lineno)
|
|
746
746
|
* binmode -> self
|
747
747
|
*
|
748
748
|
* Sets the data mode in +self+ to binary mode;
|
749
|
-
* see {Data Mode}[
|
749
|
+
* see {Data Mode}[rdoc-ref:File@Data+Mode].
|
750
750
|
*
|
751
751
|
*/
|
752
752
|
static VALUE
|
@@ -807,7 +807,7 @@ strio_reopen(int argc, VALUE *argv, VALUE self)
|
|
807
807
|
* pos -> stream_position
|
808
808
|
*
|
809
809
|
* Returns the current position (in bytes);
|
810
|
-
* see {Position}[
|
810
|
+
* see {Position}[rdoc-ref:IO@Position].
|
811
811
|
*
|
812
812
|
* StringIO#tell is an alias for StringIO#pos.
|
813
813
|
*/
|
@@ -822,7 +822,7 @@ strio_get_pos(VALUE self)
|
|
822
822
|
* pos = new_position -> new_position
|
823
823
|
*
|
824
824
|
* Sets the current position (in bytes);
|
825
|
-
* see {Position}[
|
825
|
+
* see {Position}[rdoc-ref:IO@Position].
|
826
826
|
*/
|
827
827
|
static VALUE
|
828
828
|
strio_set_pos(VALUE self, VALUE pos)
|
@@ -841,8 +841,8 @@ strio_set_pos(VALUE self, VALUE pos)
|
|
841
841
|
* rewind -> 0
|
842
842
|
*
|
843
843
|
* Sets the current position and line number to zero;
|
844
|
-
* see {Position}[
|
845
|
-
* and {Line Number}[
|
844
|
+
* see {Position}[rdoc-ref:IO@Position]
|
845
|
+
* and {Line Number}[rdoc-ref:IO@Line+Number].
|
846
846
|
*/
|
847
847
|
static VALUE
|
848
848
|
strio_rewind(VALUE self)
|
@@ -859,7 +859,7 @@ strio_rewind(VALUE self)
|
|
859
859
|
*
|
860
860
|
* Sets the current position to the given integer +offset+ (in bytes),
|
861
861
|
* with respect to a given constant +whence+;
|
862
|
-
* see {Position}[
|
862
|
+
* see {Position}[rdoc-ref:IO@Position].
|
863
863
|
*/
|
864
864
|
static VALUE
|
865
865
|
strio_seek(int argc, VALUE *argv, VALUE self)
|
@@ -915,7 +915,7 @@ strio_get_sync(VALUE self)
|
|
915
915
|
* each_byte {|byte| ... } -> self
|
916
916
|
*
|
917
917
|
* With a block given, calls the block with each remaining byte in the stream;
|
918
|
-
* see {Byte IO}[
|
918
|
+
* see {Byte IO}[rdoc-ref:IO@Byte+IO].
|
919
919
|
*
|
920
920
|
* With no block given, returns an enumerator.
|
921
921
|
*/
|
@@ -938,7 +938,7 @@ strio_each_byte(VALUE self)
|
|
938
938
|
* getc -> character or nil
|
939
939
|
*
|
940
940
|
* Reads and returns the next character from the stream;
|
941
|
-
* see {Character IO}[
|
941
|
+
* see {Character IO}[rdoc-ref:IO@Character+IO].
|
942
942
|
*/
|
943
943
|
static VALUE
|
944
944
|
strio_getc(VALUE self)
|
@@ -964,7 +964,7 @@ strio_getc(VALUE self)
|
|
964
964
|
* getbyte -> byte or nil
|
965
965
|
*
|
966
966
|
* Reads and returns the next 8-bit byte from the stream;
|
967
|
-
* see {Byte IO}[
|
967
|
+
* see {Byte IO}[rdoc-ref:IO@Byte+IO].
|
968
968
|
*/
|
969
969
|
static VALUE
|
970
970
|
strio_getbyte(VALUE self)
|
@@ -1003,7 +1003,7 @@ strio_extend(struct StringIO *ptr, long pos, long len)
|
|
1003
1003
|
* ungetc(character) -> nil
|
1004
1004
|
*
|
1005
1005
|
* Pushes back ("unshifts") a character or integer onto the stream;
|
1006
|
-
* see {Character IO}[
|
1006
|
+
* see {Character IO}[rdoc-ref:IO@Character+IO].
|
1007
1007
|
*/
|
1008
1008
|
static VALUE
|
1009
1009
|
strio_ungetc(VALUE self, VALUE c)
|
@@ -1041,7 +1041,7 @@ strio_ungetc(VALUE self, VALUE c)
|
|
1041
1041
|
* ungetbyte(byte) -> nil
|
1042
1042
|
*
|
1043
1043
|
* Pushes back ("unshifts") an 8-bit byte onto the stream;
|
1044
|
-
* see {Byte IO}[
|
1044
|
+
* see {Byte IO}[rdoc-ref:IO@Byte+IO].
|
1045
1045
|
*/
|
1046
1046
|
static VALUE
|
1047
1047
|
strio_ungetbyte(VALUE self, VALUE c)
|
@@ -1104,7 +1104,7 @@ strio_unget_bytes(struct StringIO *ptr, const char *cp, long cl)
|
|
1104
1104
|
* readchar -> string
|
1105
1105
|
*
|
1106
1106
|
* Like +getc+, but raises an exception if already at end-of-stream;
|
1107
|
-
* see {Character IO}[
|
1107
|
+
* see {Character IO}[rdoc-ref:IO@Character+IO].
|
1108
1108
|
*/
|
1109
1109
|
static VALUE
|
1110
1110
|
strio_readchar(VALUE self)
|
@@ -1119,7 +1119,7 @@ strio_readchar(VALUE self)
|
|
1119
1119
|
* readbyte -> byte
|
1120
1120
|
*
|
1121
1121
|
* Like +getbyte+, but raises an exception if already at end-of-stream;
|
1122
|
-
* see {Byte IO}[
|
1122
|
+
* see {Byte IO}[rdoc-ref:IO@Byte+IO].
|
1123
1123
|
*/
|
1124
1124
|
static VALUE
|
1125
1125
|
strio_readbyte(VALUE self)
|
@@ -1134,7 +1134,7 @@ strio_readbyte(VALUE self)
|
|
1134
1134
|
* each_char {|c| ... } -> self
|
1135
1135
|
*
|
1136
1136
|
* With a block given, calls the block with each remaining character in the stream;
|
1137
|
-
* see {Character IO}[
|
1137
|
+
* see {Character IO}[rdoc-ref:IO@Character+IO].
|
1138
1138
|
*
|
1139
1139
|
* With no block given, returns an enumerator.
|
1140
1140
|
*/
|
@@ -1156,7 +1156,7 @@ strio_each_char(VALUE self)
|
|
1156
1156
|
* each_codepoint {|codepoint| ... } -> self
|
1157
1157
|
*
|
1158
1158
|
* With a block given, calls the block with each remaining codepoint in the stream;
|
1159
|
-
* see {Codepoint IO}[
|
1159
|
+
* see {Codepoint IO}[rdoc-ref:IO@Codepoint+IO].
|
1160
1160
|
*
|
1161
1161
|
* With no block given, returns an enumerator.
|
1162
1162
|
*/
|
@@ -1340,8 +1340,9 @@ strio_getline(struct getline_arg *arg, struct StringIO *ptr)
|
|
1340
1340
|
str = strio_substr(ptr, ptr->pos, e - s - w, enc);
|
1341
1341
|
}
|
1342
1342
|
else {
|
1343
|
-
if (n < e - s) {
|
1344
|
-
|
1343
|
+
if (n < e - s + arg->chomp) {
|
1344
|
+
/* unless chomping, RS at the end does not matter */
|
1345
|
+
if (e - s < 1024 || n == e - s) {
|
1345
1346
|
for (p = s; p + n <= e; ++p) {
|
1346
1347
|
if (MEMCMP(p, RSTRING_PTR(str), char, n) == 0) {
|
1347
1348
|
e = p + n;
|
@@ -1374,7 +1375,7 @@ strio_getline(struct getline_arg *arg, struct StringIO *ptr)
|
|
1374
1375
|
*
|
1375
1376
|
* Reads and returns a line from the stream;
|
1376
1377
|
* assigns the return value to <tt>$_</tt>;
|
1377
|
-
* see {Line IO}[
|
1378
|
+
* see {Line IO}[rdoc-ref:IO@Line+IO].
|
1378
1379
|
*/
|
1379
1380
|
static VALUE
|
1380
1381
|
strio_gets(int argc, VALUE *argv, VALUE self)
|
@@ -1399,7 +1400,7 @@ strio_gets(int argc, VALUE *argv, VALUE self)
|
|
1399
1400
|
* readline(sep, limit, chomp: false) -> string
|
1400
1401
|
*
|
1401
1402
|
* Reads a line as with IO#gets, but raises EOFError if already at end-of-file;
|
1402
|
-
* see {Line IO}[
|
1403
|
+
* see {Line IO}[rdoc-ref:IO@Line+IO].
|
1403
1404
|
*/
|
1404
1405
|
static VALUE
|
1405
1406
|
strio_readline(int argc, VALUE *argv, VALUE self)
|
@@ -1418,7 +1419,7 @@ strio_readline(int argc, VALUE *argv, VALUE self)
|
|
1418
1419
|
* Calls the block with each remaining line read from the stream;
|
1419
1420
|
* does nothing if already at end-of-file;
|
1420
1421
|
* returns +self+.
|
1421
|
-
* See {Line IO}[
|
1422
|
+
* See {Line IO}[rdoc-ref:IO@Line+IO].
|
1422
1423
|
*
|
1423
1424
|
* StringIO#each is an alias for StringIO#each_line.
|
1424
1425
|
*/
|
@@ -1849,8 +1850,8 @@ strio_set_encoding_by_bom(VALUE self)
|
|
1849
1850
|
|
1850
1851
|
/*
|
1851
1852
|
* \IO streams for strings, with access similar to
|
1852
|
-
* {IO}[
|
1853
|
-
* see {IO}[
|
1853
|
+
* {IO}[rdoc-ref:IO];
|
1854
|
+
* see {IO}[rdoc-ref:IO].
|
1854
1855
|
*
|
1855
1856
|
* === About the Examples
|
1856
1857
|
*
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stringio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nobu Nakada
|
8
8
|
- Charles Oliver Nutter
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-02-03 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Pseudo `IO` class from/to `String`.
|
15
15
|
email:
|
@@ -28,7 +28,7 @@ licenses:
|
|
28
28
|
- Ruby
|
29
29
|
- BSD-2-Clause
|
30
30
|
metadata: {}
|
31
|
-
post_install_message:
|
31
|
+
post_install_message:
|
32
32
|
rdoc_options: []
|
33
33
|
require_paths:
|
34
34
|
- lib
|
@@ -43,8 +43,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
43
43
|
- !ruby/object:Gem::Version
|
44
44
|
version: '2.6'
|
45
45
|
requirements: []
|
46
|
-
rubygems_version: 3.
|
47
|
-
signing_key:
|
46
|
+
rubygems_version: 3.4.1
|
47
|
+
signing_key:
|
48
48
|
specification_version: 4
|
49
49
|
summary: Pseudo IO on String
|
50
50
|
test_files: []
|