cybrid_api_id_ruby 0.56.9 → 0.56.11
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/Gemfile.lock +3 -3
- data/README.md +5 -5
- data/cybrid_api_id_ruby.gemspec +1 -1
- data/lib/cybrid_api_id_ruby/api/bank_applications_idp_api.rb +1 -1
- data/lib/cybrid_api_id_ruby/api/customer_tokens_idp_api.rb +1 -1
- data/lib/cybrid_api_id_ruby/api/organization_applications_idp_api.rb +1 -1
- data/lib/cybrid_api_id_ruby/api_client.rb +1 -1
- data/lib/cybrid_api_id_ruby/api_error.rb +1 -1
- data/lib/cybrid_api_id_ruby/configuration.rb +1 -1
- data/lib/cybrid_api_id_ruby/models/application_idp_model.rb +1 -1
- data/lib/cybrid_api_id_ruby/models/application_list_idp_model.rb +1 -1
- data/lib/cybrid_api_id_ruby/models/application_with_secret_all_of_idp_model.rb +1 -1
- data/lib/cybrid_api_id_ruby/models/application_with_secret_idp_model.rb +1 -1
- data/lib/cybrid_api_id_ruby/models/customer_token_idp_model.rb +1 -1
- data/lib/cybrid_api_id_ruby/models/post_bank_application_idp_model.rb +1 -1
- data/lib/cybrid_api_id_ruby/models/post_customer_token_idp_model.rb +1 -1
- data/lib/cybrid_api_id_ruby/models/post_organization_application_idp_model.rb +1 -1
- data/lib/cybrid_api_id_ruby/version.rb +2 -2
- data/lib/cybrid_api_id_ruby.rb +1 -1
- data/spec/api/bank_applications_idp_api_spec.rb +1 -1
- data/spec/api/customer_tokens_idp_api_spec.rb +1 -1
- data/spec/api/organization_applications_idp_api_spec.rb +1 -1
- data/spec/api_client_spec.rb +1 -1
- data/spec/configuration_spec.rb +1 -1
- data/spec/models/application_idp_model_spec.rb +1 -1
- data/spec/models/application_list_idp_model_spec.rb +1 -1
- data/spec/models/application_with_secret_all_of_idp_model_spec.rb +1 -1
- data/spec/models/application_with_secret_idp_model_spec.rb +1 -1
- data/spec/models/customer_token_idp_model_spec.rb +1 -1
- data/spec/models/post_bank_application_idp_model_spec.rb +1 -1
- data/spec/models/post_customer_token_idp_model_spec.rb +1 -1
- data/spec/models/post_organization_application_idp_model_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/vendor/bundle/ruby/3.1.0/cache/psych-5.0.1.gem +0 -0
- data/vendor/bundle/ruby/3.1.0/cache/stringio-3.0.3.gem +0 -0
- data/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0/byebug-11.1.3/gem_make.out +4 -4
- data/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0/ffi-1.15.5/gem_make.out +4 -4
- data/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0/jaro_winkler-1.5.4/gem_make.out +4 -4
- data/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0/{psych-5.0.0 → psych-5.0.1}/gem.build_complete +0 -0
- data/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0/{psych-5.0.0 → psych-5.0.1}/gem_make.out +14 -14
- data/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0/{psych-5.0.0 → psych-5.0.1}/mkmf.log +0 -0
- data/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0/{psych-5.0.0 → psych-5.0.1}/psych.so +0 -0
- data/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0/{stringio-3.0.2 → stringio-3.0.3}/gem.build_complete +0 -0
- data/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0/{stringio-3.0.2 → stringio-3.0.3}/gem_make.out +14 -14
- data/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0/{stringio-3.0.2 → stringio-3.0.3}/mkmf.log +0 -0
- data/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0/stringio-3.0.3/stringio.so +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/.gitignore +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/Gemfile +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/LICENSE +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/Mavenfile +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/README.md +6 -5
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/Rakefile +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/bin/console +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/bin/setup +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/ext/psych/.sitearchdir.time +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/ext/psych/Makefile +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/ext/psych/depend +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/ext/psych/extconf.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/ext/psych/psych.c +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/ext/psych/psych.h +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/ext/psych/psych.o +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/ext/psych/psych.so +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/ext/psych/psych_emitter.c +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/ext/psych/psych_emitter.h +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/ext/psych/psych_emitter.o +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/ext/psych/psych_parser.c +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/ext/psych/psych_parser.h +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/ext/psych/psych_parser.o +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/ext/psych/psych_to_ruby.c +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/ext/psych/psych_to_ruby.h +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/ext/psych/psych_to_ruby.o +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/ext/psych/psych_yaml_tree.c +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/ext/psych/psych_yaml_tree.h +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/ext/psych/psych_yaml_tree.o +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/class_loader.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/coder.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/core_ext.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/exception.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/handler.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/handlers/document_stream.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/handlers/recorder.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/json/ruby_events.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/json/stream.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/json/tree_builder.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/json/yaml_events.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/nodes/alias.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/nodes/document.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/nodes/mapping.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/nodes/node.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/nodes/scalar.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/nodes/sequence.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/nodes/stream.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/nodes.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/omap.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/parser.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/scalar_scanner.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/set.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/stream.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/streaming.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/syntax_error.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/tree_builder.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/versions.rb +1 -1
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/visitors/depth_first.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/visitors/emitter.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/visitors/json_tree.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/visitors/to_ruby.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/visitors/visitor.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/visitors/yaml_tree.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/visitors.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych/y.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/lib/psych.so +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{psych-5.0.0 → psych-5.0.1}/psych.gemspec +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{stringio-3.0.2 → stringio-3.0.3}/README.md +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{stringio-3.0.2 → stringio-3.0.3}/ext/stringio/.sitearchdir.time +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{stringio-3.0.2 → stringio-3.0.3}/ext/stringio/Makefile +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{stringio-3.0.2 → stringio-3.0.3}/ext/stringio/extconf.rb +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/{stringio-3.0.2 → stringio-3.0.3}/ext/stringio/stringio.c +241 -132
- data/vendor/bundle/ruby/3.1.0/gems/stringio-3.0.3/ext/stringio/stringio.o +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/stringio-3.0.3/ext/stringio/stringio.so +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/stringio-3.0.3/lib/stringio.so +0 -0
- data/vendor/bundle/ruby/3.1.0/specifications/{psych-5.0.0.gemspec → psych-5.0.1.gemspec} +3 -3
- data/vendor/bundle/ruby/3.1.0/specifications/{stringio-3.0.2.gemspec → stringio-3.0.3.gemspec} +3 -3
- metadata +89 -89
- data/vendor/bundle/ruby/3.1.0/cache/psych-5.0.0.gem +0 -0
- data/vendor/bundle/ruby/3.1.0/cache/stringio-3.0.2.gem +0 -0
- data/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0/stringio-3.0.2/stringio.so +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/stringio-3.0.2/ext/stringio/stringio.o +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/stringio-3.0.2/ext/stringio/stringio.so +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/stringio-3.0.2/lib/stringio.so +0 -0
data/vendor/bundle/ruby/3.1.0/gems/{stringio-3.0.2 → stringio-3.0.3}/ext/stringio/stringio.c
RENAMED
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
**********************************************************************/
|
14
14
|
|
15
|
-
#define STRINGIO_VERSION "3.0.
|
15
|
+
#define STRINGIO_VERSION "3.0.3"
|
16
16
|
|
17
17
|
#include "ruby.h"
|
18
18
|
#include "ruby/io.h"
|
@@ -67,15 +67,20 @@ strio_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash,
|
|
67
67
|
e = strchr(++n, ':');
|
68
68
|
len = e ? e - n : (long)strlen(n);
|
69
69
|
if (len > 0 && len <= ENCODING_MAXNAMELEN) {
|
70
|
+
rb_encoding *enc;
|
70
71
|
if (e) {
|
71
72
|
memcpy(encname, n, len);
|
72
73
|
encname[len] = '\0';
|
73
74
|
n = encname;
|
74
75
|
}
|
75
|
-
|
76
|
+
enc = rb_enc_find(n);
|
77
|
+
if (e)
|
78
|
+
convconfig_p->enc2 = enc;
|
79
|
+
else
|
80
|
+
convconfig_p->enc = enc;
|
76
81
|
}
|
77
82
|
if (e && (len = strlen(++e)) > 0 && len <= ENCODING_MAXNAMELEN) {
|
78
|
-
convconfig_p->
|
83
|
+
convconfig_p->enc = rb_enc_find(e);
|
79
84
|
}
|
80
85
|
}
|
81
86
|
}
|
@@ -252,9 +257,20 @@ strio_s_allocate(VALUE klass)
|
|
252
257
|
}
|
253
258
|
|
254
259
|
/*
|
255
|
-
* call-seq:
|
260
|
+
* call-seq:
|
261
|
+
* StringIO.new(string = '', mode = 'r+') -> new_stringio
|
262
|
+
*
|
263
|
+
* Note that +mode+ defaults to <tt>'r'</tt> if +string+ is frozen.
|
264
|
+
*
|
265
|
+
* Returns a new \StringIO instance formed from +string+ and +mode+;
|
266
|
+
* see {Access Modes}[https://docs.ruby-lang.org/en/master/File.html#class-File-label-Access+Modes]:
|
256
267
|
*
|
257
|
-
*
|
268
|
+
* strio = StringIO.new # => #<StringIO>
|
269
|
+
* strio.close
|
270
|
+
*
|
271
|
+
* The instance should be closed when no longer needed.
|
272
|
+
*
|
273
|
+
* Related: StringIO.open (accepts block; closes automatically).
|
258
274
|
*/
|
259
275
|
static VALUE
|
260
276
|
strio_initialize(int argc, VALUE *argv, VALUE self)
|
@@ -387,11 +403,26 @@ strio_finalize(VALUE self)
|
|
387
403
|
}
|
388
404
|
|
389
405
|
/*
|
390
|
-
* call-seq:
|
406
|
+
* call-seq:
|
407
|
+
* StringIO.open(string = '', mode = 'r+') {|strio| ... }
|
408
|
+
*
|
409
|
+
* Note that +mode+ defaults to <tt>'r'</tt> if +string+ is frozen.
|
410
|
+
*
|
411
|
+
* Creates a new \StringIO instance formed from +string+ and +mode+;
|
412
|
+
* see {Access Modes}[https://docs.ruby-lang.org/en/master/File.html#class-File-label-Access+Modes].
|
413
|
+
*
|
414
|
+
* With no block, returns the new instance:
|
415
|
+
*
|
416
|
+
* strio = StringIO.open # => #<StringIO>
|
417
|
+
*
|
418
|
+
* With a block, calls the block with the new instance
|
419
|
+
* and returns the block's value;
|
420
|
+
* closes the instance on block exit.
|
391
421
|
*
|
392
|
-
*
|
393
|
-
*
|
394
|
-
*
|
422
|
+
* StringIO.open {|strio| p strio }
|
423
|
+
* # => #<StringIO>
|
424
|
+
*
|
425
|
+
* Related: StringIO.new.
|
395
426
|
*/
|
396
427
|
static VALUE
|
397
428
|
strio_s_open(int argc, VALUE *argv, VALUE klass)
|
@@ -477,9 +508,23 @@ strio_unimpl(int argc, VALUE *argv, VALUE self)
|
|
477
508
|
}
|
478
509
|
|
479
510
|
/*
|
480
|
-
* call-seq:
|
511
|
+
* call-seq:
|
512
|
+
* string -> string
|
513
|
+
*
|
514
|
+
* Returns underlying string:
|
515
|
+
*
|
516
|
+
* StringIO.open('foo') do |strio|
|
517
|
+
* p strio.string
|
518
|
+
* strio.string = 'bar'
|
519
|
+
* p strio.string
|
520
|
+
* end
|
521
|
+
*
|
522
|
+
* Output:
|
523
|
+
*
|
524
|
+
* "foo"
|
525
|
+
* "bar"
|
481
526
|
*
|
482
|
-
*
|
527
|
+
* Related: StringIO#string= (assigns the underlying string).
|
483
528
|
*/
|
484
529
|
static VALUE
|
485
530
|
strio_get_string(VALUE self)
|
@@ -489,9 +534,23 @@ strio_get_string(VALUE self)
|
|
489
534
|
|
490
535
|
/*
|
491
536
|
* call-seq:
|
492
|
-
*
|
537
|
+
* string = other_string -> other_string
|
493
538
|
*
|
494
|
-
*
|
539
|
+
* Assigns the underlying string as +other_string+, and sets position to zero;
|
540
|
+
* returns +other_string+:
|
541
|
+
*
|
542
|
+
* StringIO.open('foo') do |strio|
|
543
|
+
* p strio.string
|
544
|
+
* strio.string = 'bar'
|
545
|
+
* p strio.string
|
546
|
+
* end
|
547
|
+
*
|
548
|
+
* Output:
|
549
|
+
*
|
550
|
+
* "foo"
|
551
|
+
* "bar"
|
552
|
+
*
|
553
|
+
* Related: StringIO#string (returns the underlying string).
|
495
554
|
*/
|
496
555
|
static VALUE
|
497
556
|
strio_set_string(VALUE self, VALUE string)
|
@@ -509,10 +568,13 @@ strio_set_string(VALUE self, VALUE string)
|
|
509
568
|
|
510
569
|
/*
|
511
570
|
* call-seq:
|
512
|
-
*
|
571
|
+
* close -> nil
|
572
|
+
*
|
573
|
+
* Closes +self+ for both reading and writing.
|
513
574
|
*
|
514
|
-
*
|
515
|
-
*
|
575
|
+
* Raises IOError if reading or writing is attempted.
|
576
|
+
*
|
577
|
+
* Related: StringIO#close_read, StringIO#close_write.
|
516
578
|
*/
|
517
579
|
static VALUE
|
518
580
|
strio_close(VALUE self)
|
@@ -524,10 +586,13 @@ strio_close(VALUE self)
|
|
524
586
|
|
525
587
|
/*
|
526
588
|
* call-seq:
|
527
|
-
*
|
589
|
+
* close_read -> nil
|
590
|
+
*
|
591
|
+
* Closes +self+ for reading; closed-write setting remains unchanged.
|
592
|
+
*
|
593
|
+
* Raises IOError if reading is attempted.
|
528
594
|
*
|
529
|
-
*
|
530
|
-
* receiver is not readable.
|
595
|
+
* Related: StringIO#close, StringIO#close_write.
|
531
596
|
*/
|
532
597
|
static VALUE
|
533
598
|
strio_close_read(VALUE self)
|
@@ -542,10 +607,13 @@ strio_close_read(VALUE self)
|
|
542
607
|
|
543
608
|
/*
|
544
609
|
* call-seq:
|
545
|
-
*
|
610
|
+
* close_write -> nil
|
546
611
|
*
|
547
|
-
* Closes
|
548
|
-
*
|
612
|
+
* Closes +self+ for writing; closed-read setting remains unchanged.
|
613
|
+
*
|
614
|
+
* Raises IOError if writing is attempted.
|
615
|
+
*
|
616
|
+
* Related: StringIO#close, StringIO#close_read.
|
549
617
|
*/
|
550
618
|
static VALUE
|
551
619
|
strio_close_write(VALUE self)
|
@@ -560,9 +628,10 @@ strio_close_write(VALUE self)
|
|
560
628
|
|
561
629
|
/*
|
562
630
|
* call-seq:
|
563
|
-
*
|
631
|
+
* closed? -> true or false
|
564
632
|
*
|
565
|
-
* Returns +true+ if
|
633
|
+
* Returns +true+ if +self+ is closed for both reading and writing,
|
634
|
+
* +false+ otherwise.
|
566
635
|
*/
|
567
636
|
static VALUE
|
568
637
|
strio_closed(VALUE self)
|
@@ -574,9 +643,9 @@ strio_closed(VALUE self)
|
|
574
643
|
|
575
644
|
/*
|
576
645
|
* call-seq:
|
577
|
-
*
|
646
|
+
* closed_read? -> true or false
|
578
647
|
*
|
579
|
-
* Returns +true+ if
|
648
|
+
* Returns +true+ if +self+ is closed for reading, +false+ otherwise.
|
580
649
|
*/
|
581
650
|
static VALUE
|
582
651
|
strio_closed_read(VALUE self)
|
@@ -588,9 +657,9 @@ strio_closed_read(VALUE self)
|
|
588
657
|
|
589
658
|
/*
|
590
659
|
* call-seq:
|
591
|
-
*
|
660
|
+
* closed_write? -> true or false
|
592
661
|
*
|
593
|
-
* Returns +true+ if
|
662
|
+
* Returns +true+ if +self+ is closed for writing, +false+ otherwise.
|
594
663
|
*/
|
595
664
|
static VALUE
|
596
665
|
strio_closed_write(VALUE self)
|
@@ -610,11 +679,14 @@ strio_to_read(VALUE self)
|
|
610
679
|
|
611
680
|
/*
|
612
681
|
* call-seq:
|
613
|
-
*
|
614
|
-
*
|
682
|
+
* eof? -> true or false
|
683
|
+
*
|
684
|
+
* Returns +true+ if positioned at end-of-stream, +false+ otherwise;
|
685
|
+
* see {Position}[https://docs.ruby-lang.org/en/master/File.html#class-File-label-Position].
|
615
686
|
*
|
616
|
-
*
|
617
|
-
*
|
687
|
+
* Raises IOError if the stream is not opened for reading.
|
688
|
+
*
|
689
|
+
* StreamIO#eof is an alias for StreamIO#eof?.
|
618
690
|
*/
|
619
691
|
static VALUE
|
620
692
|
strio_eof(VALUE self)
|
@@ -644,13 +716,10 @@ strio_copy(VALUE copy, VALUE orig)
|
|
644
716
|
|
645
717
|
/*
|
646
718
|
* call-seq:
|
647
|
-
*
|
719
|
+
* lineno -> current_line_number
|
648
720
|
*
|
649
|
-
* Returns the current line number
|
650
|
-
*
|
651
|
-
* called, rather than the number of newlines encountered. The two
|
652
|
-
* values will differ if +gets+ is called with a separator other than
|
653
|
-
* newline. See also the <code>$.</code> variable.
|
721
|
+
* Returns the current line number in +self+;
|
722
|
+
* see {Line Number}[https://docs.ruby-lang.org/en/master/IO.html#label-Line+Number].
|
654
723
|
*/
|
655
724
|
static VALUE
|
656
725
|
strio_get_lineno(VALUE self)
|
@@ -660,10 +729,10 @@ strio_get_lineno(VALUE self)
|
|
660
729
|
|
661
730
|
/*
|
662
731
|
* call-seq:
|
663
|
-
*
|
732
|
+
* lineno = new_line_number -> new_line_number
|
664
733
|
*
|
665
|
-
*
|
666
|
-
*
|
734
|
+
* Sets the current line number in +self+ to the given +new_line_number+;
|
735
|
+
* see {Line Number}[https://docs.ruby-lang.org/en/master/IO.html#label-Line+Number].
|
667
736
|
*/
|
668
737
|
static VALUE
|
669
738
|
strio_set_lineno(VALUE self, VALUE lineno)
|
@@ -674,9 +743,10 @@ strio_set_lineno(VALUE self, VALUE lineno)
|
|
674
743
|
|
675
744
|
/*
|
676
745
|
* call-seq:
|
677
|
-
*
|
746
|
+
* binmode -> self
|
678
747
|
*
|
679
|
-
*
|
748
|
+
* Sets the data mode in +self+ to binary mode;
|
749
|
+
* see {Data Mode}[https://docs.ruby-lang.org/en/master/File.html#class-File-label-Data+Mode].
|
680
750
|
*
|
681
751
|
*/
|
682
752
|
static VALUE
|
@@ -700,11 +770,27 @@ strio_binmode(VALUE self)
|
|
700
770
|
|
701
771
|
/*
|
702
772
|
* call-seq:
|
703
|
-
*
|
704
|
-
*
|
773
|
+
* reopen(other, mode = 'r+') -> self
|
774
|
+
*
|
775
|
+
* Reinitializes the stream with the given +other+ (string or StringIO) and +mode+;
|
776
|
+
* see IO.new:
|
777
|
+
*
|
778
|
+
* StringIO.open('foo') do |strio|
|
779
|
+
* p strio.string
|
780
|
+
* strio.reopen('bar')
|
781
|
+
* p strio.string
|
782
|
+
* other_strio = StringIO.new('baz')
|
783
|
+
* strio.reopen(other_strio)
|
784
|
+
* p strio.string
|
785
|
+
* other_strio.close
|
786
|
+
* end
|
787
|
+
*
|
788
|
+
* Output:
|
789
|
+
*
|
790
|
+
* "foo"
|
791
|
+
* "bar"
|
792
|
+
* "baz"
|
705
793
|
*
|
706
|
-
* Reinitializes the stream with the given <i>other_StrIO</i> or _string_
|
707
|
-
* and _mode_ (see StringIO#new).
|
708
794
|
*/
|
709
795
|
static VALUE
|
710
796
|
strio_reopen(int argc, VALUE *argv, VALUE self)
|
@@ -718,10 +804,12 @@ strio_reopen(int argc, VALUE *argv, VALUE self)
|
|
718
804
|
|
719
805
|
/*
|
720
806
|
* call-seq:
|
721
|
-
*
|
722
|
-
* strio.tell -> integer
|
807
|
+
* pos -> stream_position
|
723
808
|
*
|
724
|
-
* Returns the current
|
809
|
+
* Returns the current position (in bytes);
|
810
|
+
* see {Position}[https://docs.ruby-lang.org/en/master/IO.html#label-Position].
|
811
|
+
*
|
812
|
+
* StringIO#tell is an alias for StringIO#pos.
|
725
813
|
*/
|
726
814
|
static VALUE
|
727
815
|
strio_get_pos(VALUE self)
|
@@ -731,9 +819,10 @@ strio_get_pos(VALUE self)
|
|
731
819
|
|
732
820
|
/*
|
733
821
|
* call-seq:
|
734
|
-
*
|
822
|
+
* pos = new_position -> new_position
|
735
823
|
*
|
736
|
-
*
|
824
|
+
* Sets the current position (in bytes);
|
825
|
+
* see {Position}[https://docs.ruby-lang.org/en/master/IO.html#label-Position].
|
737
826
|
*/
|
738
827
|
static VALUE
|
739
828
|
strio_set_pos(VALUE self, VALUE pos)
|
@@ -749,10 +838,11 @@ strio_set_pos(VALUE self, VALUE pos)
|
|
749
838
|
|
750
839
|
/*
|
751
840
|
* call-seq:
|
752
|
-
*
|
841
|
+
* rewind -> 0
|
753
842
|
*
|
754
|
-
*
|
755
|
-
*
|
843
|
+
* Sets the current position and line number to zero;
|
844
|
+
* see {Position}[https://docs.ruby-lang.org/en/master/IO.html#label-Position]
|
845
|
+
* and {Line Number}[https://docs.ruby-lang.org/en/master/IO.html#label-Line+Number].
|
756
846
|
*/
|
757
847
|
static VALUE
|
758
848
|
strio_rewind(VALUE self)
|
@@ -765,10 +855,11 @@ strio_rewind(VALUE self)
|
|
765
855
|
|
766
856
|
/*
|
767
857
|
* call-seq:
|
768
|
-
*
|
858
|
+
* seek(offset, whence = SEEK_SET) -> 0
|
769
859
|
*
|
770
|
-
*
|
771
|
-
*
|
860
|
+
* Sets the current position to the given integer +offset+ (in bytes),
|
861
|
+
* with respect to a given constant +whence+;
|
862
|
+
* see {Position}[https://docs.ruby-lang.org/en/master/IO.html#label-Position].
|
772
863
|
*/
|
773
864
|
static VALUE
|
774
865
|
strio_seek(int argc, VALUE *argv, VALUE self)
|
@@ -804,9 +895,9 @@ strio_seek(int argc, VALUE *argv, VALUE self)
|
|
804
895
|
|
805
896
|
/*
|
806
897
|
* call-seq:
|
807
|
-
*
|
898
|
+
* sync -> true
|
808
899
|
*
|
809
|
-
* Returns +true
|
900
|
+
* Returns +true+; implemented only for compatibility with other stream classes.
|
810
901
|
*/
|
811
902
|
static VALUE
|
812
903
|
strio_get_sync(VALUE self)
|
@@ -821,10 +912,12 @@ strio_get_sync(VALUE self)
|
|
821
912
|
|
822
913
|
/*
|
823
914
|
* call-seq:
|
824
|
-
*
|
825
|
-
*
|
915
|
+
* each_byte {|byte| ... } -> self
|
916
|
+
*
|
917
|
+
* With a block given, calls the block with each remaining byte in the stream;
|
918
|
+
* see {Byte IO}[https://docs.ruby-lang.org/en/master/IO.html#label-Byte+IO].
|
826
919
|
*
|
827
|
-
*
|
920
|
+
* With no block given, returns an enumerator.
|
828
921
|
*/
|
829
922
|
static VALUE
|
830
923
|
strio_each_byte(VALUE self)
|
@@ -842,9 +935,10 @@ strio_each_byte(VALUE self)
|
|
842
935
|
|
843
936
|
/*
|
844
937
|
* call-seq:
|
845
|
-
*
|
938
|
+
* getc -> character or nil
|
846
939
|
*
|
847
|
-
*
|
940
|
+
* Reads and returns the next character from the stream;
|
941
|
+
* see {Character IO}[https://docs.ruby-lang.org/en/master/IO.html#label-Character+IO].
|
848
942
|
*/
|
849
943
|
static VALUE
|
850
944
|
strio_getc(VALUE self)
|
@@ -867,9 +961,10 @@ strio_getc(VALUE self)
|
|
867
961
|
|
868
962
|
/*
|
869
963
|
* call-seq:
|
870
|
-
*
|
964
|
+
* getbyte -> byte or nil
|
871
965
|
*
|
872
|
-
*
|
966
|
+
* Reads and returns the next 8-bit byte from the stream;
|
967
|
+
* see {Byte IO}[https://docs.ruby-lang.org/en/master/IO.html#label-Byte+IO].
|
873
968
|
*/
|
874
969
|
static VALUE
|
875
970
|
strio_getbyte(VALUE self)
|
@@ -905,12 +1000,10 @@ strio_extend(struct StringIO *ptr, long pos, long len)
|
|
905
1000
|
|
906
1001
|
/*
|
907
1002
|
* call-seq:
|
908
|
-
*
|
1003
|
+
* ungetc(character) -> nil
|
909
1004
|
*
|
910
|
-
* Pushes back
|
911
|
-
*
|
912
|
-
* limitation for multiple pushbacks including pushing back behind the
|
913
|
-
* beginning of the buffer string.
|
1005
|
+
* Pushes back ("unshifts") a character or integer onto the stream;
|
1006
|
+
* see {Character IO}[https://docs.ruby-lang.org/en/master/IO.html#label-Character+IO].
|
914
1007
|
*/
|
915
1008
|
static VALUE
|
916
1009
|
strio_ungetc(VALUE self, VALUE c)
|
@@ -945,9 +1038,10 @@ strio_ungetc(VALUE self, VALUE c)
|
|
945
1038
|
|
946
1039
|
/*
|
947
1040
|
* call-seq:
|
948
|
-
*
|
1041
|
+
* ungetbyte(byte) -> nil
|
949
1042
|
*
|
950
|
-
*
|
1043
|
+
* Pushes back ("unshifts") an 8-bit byte onto the stream;
|
1044
|
+
* see {Byte IO}[https://docs.ruby-lang.org/en/master/IO.html#label-Byte+IO].
|
951
1045
|
*/
|
952
1046
|
static VALUE
|
953
1047
|
strio_ungetbyte(VALUE self, VALUE c)
|
@@ -984,7 +1078,7 @@ strio_unget_bytes(struct StringIO *ptr, const char *cp, long cl)
|
|
984
1078
|
len = RSTRING_LEN(str);
|
985
1079
|
rest = pos - len;
|
986
1080
|
if (cl > pos) {
|
987
|
-
long ex = (rest < 0 ?
|
1081
|
+
long ex = cl - (rest < 0 ? pos : len);
|
988
1082
|
rb_str_modify_expand(str, ex);
|
989
1083
|
rb_str_set_len(str, len + ex);
|
990
1084
|
s = RSTRING_PTR(str);
|
@@ -1007,9 +1101,10 @@ strio_unget_bytes(struct StringIO *ptr, const char *cp, long cl)
|
|
1007
1101
|
|
1008
1102
|
/*
|
1009
1103
|
* call-seq:
|
1010
|
-
*
|
1104
|
+
* readchar -> string
|
1011
1105
|
*
|
1012
|
-
*
|
1106
|
+
* Like +getc+, but raises an exception if already at end-of-stream;
|
1107
|
+
* see {Character IO}[https://docs.ruby-lang.org/en/master/IO.html#label-Character+IO].
|
1013
1108
|
*/
|
1014
1109
|
static VALUE
|
1015
1110
|
strio_readchar(VALUE self)
|
@@ -1021,9 +1116,10 @@ strio_readchar(VALUE self)
|
|
1021
1116
|
|
1022
1117
|
/*
|
1023
1118
|
* call-seq:
|
1024
|
-
*
|
1119
|
+
* readbyte -> byte
|
1025
1120
|
*
|
1026
|
-
*
|
1121
|
+
* Like +getbyte+, but raises an exception if already at end-of-stream;
|
1122
|
+
* see {Byte IO}[https://docs.ruby-lang.org/en/master/IO.html#label-Byte+IO].
|
1027
1123
|
*/
|
1028
1124
|
static VALUE
|
1029
1125
|
strio_readbyte(VALUE self)
|
@@ -1035,10 +1131,12 @@ strio_readbyte(VALUE self)
|
|
1035
1131
|
|
1036
1132
|
/*
|
1037
1133
|
* call-seq:
|
1038
|
-
*
|
1039
|
-
*
|
1134
|
+
* each_char {|c| ... } -> self
|
1135
|
+
*
|
1136
|
+
* With a block given, calls the block with each remaining character in the stream;
|
1137
|
+
* see {Character IO}[https://docs.ruby-lang.org/en/master/IO.html#label-Character+IO].
|
1040
1138
|
*
|
1041
|
-
*
|
1139
|
+
* With no block given, returns an enumerator.
|
1042
1140
|
*/
|
1043
1141
|
static VALUE
|
1044
1142
|
strio_each_char(VALUE self)
|
@@ -1055,10 +1153,12 @@ strio_each_char(VALUE self)
|
|
1055
1153
|
|
1056
1154
|
/*
|
1057
1155
|
* call-seq:
|
1058
|
-
*
|
1059
|
-
* strio.each_codepoint -> anEnumerator
|
1156
|
+
* each_codepoint {|codepoint| ... } -> self
|
1060
1157
|
*
|
1061
|
-
*
|
1158
|
+
* With a block given, calls the block with each remaining codepoint in the stream;
|
1159
|
+
* see {Codepoint IO}[https://docs.ruby-lang.org/en/master/IO.html#label-Codepoint+IO].
|
1160
|
+
*
|
1161
|
+
* With no block given, returns an enumerator.
|
1062
1162
|
*/
|
1063
1163
|
static VALUE
|
1064
1164
|
strio_each_codepoint(VALUE self)
|
@@ -1125,8 +1225,10 @@ prepare_getline_args(struct getline_arg *arg, int argc, VALUE *argv)
|
|
1125
1225
|
{
|
1126
1226
|
VALUE str, lim, opts;
|
1127
1227
|
long limit = -1;
|
1228
|
+
int respect_chomp;
|
1128
1229
|
|
1129
1230
|
argc = rb_scan_args(argc, argv, "02:", &str, &lim, &opts);
|
1231
|
+
respect_chomp = argc == 0 || !NIL_P(str);
|
1130
1232
|
switch (argc) {
|
1131
1233
|
case 0:
|
1132
1234
|
str = rb_rs;
|
@@ -1160,7 +1262,9 @@ prepare_getline_args(struct getline_arg *arg, int argc, VALUE *argv)
|
|
1160
1262
|
keywords[0] = rb_intern_const("chomp");
|
1161
1263
|
}
|
1162
1264
|
rb_get_kwargs(opts, keywords, 0, 1, &vchomp);
|
1163
|
-
|
1265
|
+
if (respect_chomp) {
|
1266
|
+
arg->chomp = (vchomp != Qundef) && RTEST(vchomp);
|
1267
|
+
}
|
1164
1268
|
}
|
1165
1269
|
return arg;
|
1166
1270
|
}
|
@@ -1181,7 +1285,7 @@ strio_getline(struct getline_arg *arg, struct StringIO *ptr)
|
|
1181
1285
|
const char *s, *e, *p;
|
1182
1286
|
long n, limit = arg->limit;
|
1183
1287
|
VALUE str = arg->rs;
|
1184
|
-
|
1288
|
+
long w = 0;
|
1185
1289
|
rb_encoding *enc = get_enc(ptr);
|
1186
1290
|
|
1187
1291
|
if (ptr->pos >= (n = RSTRING_LEN(ptr->string))) {
|
@@ -1200,6 +1304,7 @@ strio_getline(struct getline_arg *arg, struct StringIO *ptr)
|
|
1200
1304
|
str = strio_substr(ptr, ptr->pos, e - s - w, enc);
|
1201
1305
|
}
|
1202
1306
|
else if ((n = RSTRING_LEN(str)) == 0) {
|
1307
|
+
const char *paragraph_end = NULL;
|
1203
1308
|
p = s;
|
1204
1309
|
while (p[(p + 1 < e) && (*p == '\r') && 0] == '\n') {
|
1205
1310
|
p += *p == '\r';
|
@@ -1209,19 +1314,21 @@ strio_getline(struct getline_arg *arg, struct StringIO *ptr)
|
|
1209
1314
|
}
|
1210
1315
|
s = p;
|
1211
1316
|
while ((p = memchr(p, '\n', e - p)) && (p != e)) {
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1317
|
+
p++;
|
1318
|
+
if (!((p < e && *p == '\n') ||
|
1319
|
+
(p + 1 < e && *p == '\r' && *(p+1) == '\n'))) {
|
1320
|
+
continue;
|
1321
|
+
}
|
1322
|
+
paragraph_end = p - ((*(p-2) == '\r') ? 2 : 1);
|
1323
|
+
while ((p < e && *p == '\n') ||
|
1324
|
+
(p + 1 < e && *p == '\r' && *(p+1) == '\n')) {
|
1325
|
+
p += (*p == '\r') ? 2 : 1;
|
1326
|
+
}
|
1327
|
+
e = p;
|
1328
|
+
break;
|
1222
1329
|
}
|
1223
|
-
if (
|
1224
|
-
w =
|
1330
|
+
if (arg->chomp && paragraph_end) {
|
1331
|
+
w = e - paragraph_end;
|
1225
1332
|
}
|
1226
1333
|
str = strio_substr(ptr, s - RSTRING_PTR(ptr->string), e - s - w, enc);
|
1227
1334
|
}
|
@@ -1237,7 +1344,8 @@ strio_getline(struct getline_arg *arg, struct StringIO *ptr)
|
|
1237
1344
|
if (e - s < 1024) {
|
1238
1345
|
for (p = s; p + n <= e; ++p) {
|
1239
1346
|
if (MEMCMP(p, RSTRING_PTR(str), char, n) == 0) {
|
1240
|
-
e = p +
|
1347
|
+
e = p + n;
|
1348
|
+
w = (arg->chomp ? n : 0);
|
1241
1349
|
break;
|
1242
1350
|
}
|
1243
1351
|
}
|
@@ -1260,11 +1368,13 @@ strio_getline(struct getline_arg *arg, struct StringIO *ptr)
|
|
1260
1368
|
|
1261
1369
|
/*
|
1262
1370
|
* call-seq:
|
1263
|
-
*
|
1264
|
-
*
|
1265
|
-
*
|
1371
|
+
* gets(sep = $/, chomp: false) -> string or nil
|
1372
|
+
* gets(limit, chomp: false) -> string or nil
|
1373
|
+
* gets(sep, limit, chomp: false) -> string or nil
|
1266
1374
|
*
|
1267
|
-
*
|
1375
|
+
* Reads and returns a line from the stream;
|
1376
|
+
* assigns the return value to <tt>$_</tt>;
|
1377
|
+
* see {Line IO}[https://docs.ruby-lang.org/en/master/IO.html#label-Line+IO].
|
1268
1378
|
*/
|
1269
1379
|
static VALUE
|
1270
1380
|
strio_gets(int argc, VALUE *argv, VALUE self)
|
@@ -1284,11 +1394,12 @@ strio_gets(int argc, VALUE *argv, VALUE self)
|
|
1284
1394
|
|
1285
1395
|
/*
|
1286
1396
|
* call-seq:
|
1287
|
-
*
|
1288
|
-
*
|
1289
|
-
*
|
1397
|
+
* readline(sep = $/, chomp: false) -> string
|
1398
|
+
* readline(limit, chomp: false) -> string
|
1399
|
+
* readline(sep, limit, chomp: false) -> string
|
1290
1400
|
*
|
1291
|
-
*
|
1401
|
+
* Reads a line as with IO#gets, but raises EOFError if already at end-of-file;
|
1402
|
+
* see {Line IO}[https://docs.ruby-lang.org/en/master/IO.html#label-Line+IO].
|
1292
1403
|
*/
|
1293
1404
|
static VALUE
|
1294
1405
|
strio_readline(int argc, VALUE *argv, VALUE self)
|
@@ -1300,17 +1411,16 @@ strio_readline(int argc, VALUE *argv, VALUE self)
|
|
1300
1411
|
|
1301
1412
|
/*
|
1302
1413
|
* call-seq:
|
1303
|
-
*
|
1304
|
-
*
|
1305
|
-
*
|
1306
|
-
* strio.each(...) -> anEnumerator
|
1414
|
+
* each_line(sep = $/, chomp: false) {|line| ... } -> self
|
1415
|
+
* each_line(limit, chomp: false) {|line| ... } -> self
|
1416
|
+
* each_line(sep, limit, chomp: false) {|line| ... } -> self
|
1307
1417
|
*
|
1308
|
-
*
|
1309
|
-
*
|
1310
|
-
*
|
1311
|
-
*
|
1418
|
+
* Calls the block with each remaining line read from the stream;
|
1419
|
+
* does nothing if already at end-of-file;
|
1420
|
+
* returns +self+.
|
1421
|
+
* See {Line IO}[https://docs.ruby-lang.org/en/master/IO.html#label-Line+IO].
|
1312
1422
|
*
|
1313
|
-
*
|
1423
|
+
* StringIO#each is an alias for StringIO#each_line.
|
1314
1424
|
*/
|
1315
1425
|
static VALUE
|
1316
1426
|
strio_each(int argc, VALUE *argv, VALUE self)
|
@@ -1655,7 +1765,7 @@ strio_truncate(VALUE self, VALUE len)
|
|
1655
1765
|
if (plen < l) {
|
1656
1766
|
MEMZERO(RSTRING_PTR(string) + plen, char, l - plen);
|
1657
1767
|
}
|
1658
|
-
return
|
1768
|
+
return INT2FIX(0);
|
1659
1769
|
}
|
1660
1770
|
|
1661
1771
|
/*
|
@@ -1711,7 +1821,14 @@ strio_set_encoding(int argc, VALUE *argv, VALUE self)
|
|
1711
1821
|
enc = rb_default_external_encoding();
|
1712
1822
|
}
|
1713
1823
|
else {
|
1714
|
-
enc =
|
1824
|
+
enc = rb_find_encoding(ext_enc);
|
1825
|
+
if (!enc) {
|
1826
|
+
struct rb_io_enc_t convconfig;
|
1827
|
+
int oflags, fmode;
|
1828
|
+
VALUE vmode = rb_str_append(rb_str_new_cstr("r:"), ext_enc);
|
1829
|
+
rb_io_extract_modeenc(&vmode, 0, Qnil, &oflags, &fmode, &convconfig);
|
1830
|
+
enc = convconfig.enc2;
|
1831
|
+
}
|
1715
1832
|
}
|
1716
1833
|
ptr->enc = enc;
|
1717
1834
|
if (WRITABLE(self)) {
|
@@ -1731,24 +1848,16 @@ strio_set_encoding_by_bom(VALUE self)
|
|
1731
1848
|
}
|
1732
1849
|
|
1733
1850
|
/*
|
1734
|
-
*
|
1851
|
+
* \IO streams for strings, with access similar to
|
1852
|
+
* {IO}[https://docs.ruby-lang.org/en/master/IO.html];
|
1853
|
+
* see {IO}[https://docs.ruby-lang.org/en/master/IO.html].
|
1735
1854
|
*
|
1736
|
-
*
|
1855
|
+
* === About the Examples
|
1737
1856
|
*
|
1738
|
-
*
|
1857
|
+
* Examples on this page assume that \StringIO has been required:
|
1739
1858
|
*
|
1740
1859
|
* require 'stringio'
|
1741
1860
|
*
|
1742
|
-
* # Writing stream emulation
|
1743
|
-
* io = StringIO.new
|
1744
|
-
* io.puts "Hello World"
|
1745
|
-
* io.string #=> "Hello World\n"
|
1746
|
-
*
|
1747
|
-
* # Reading stream emulation
|
1748
|
-
* io = StringIO.new "first\nsecond\nlast\n"
|
1749
|
-
* io.getc #=> "f"
|
1750
|
-
* io.gets #=> "irst\n"
|
1751
|
-
* io.read #=> "second\nlast\n"
|
1752
1861
|
*/
|
1753
1862
|
void
|
1754
1863
|
Init_stringio(void)
|