stringio 0.1.0 → 0.1.3
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.
- checksums.yaml +4 -4
- data/ext/stringio/stringio.c +16 -8
- 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: 864faa7f9cd87b42a0aa0c6fde4baf5770280a51f269466c8e05f08a65a465e2
|
4
|
+
data.tar.gz: 388ee6afc1e098f6588d49e10cfc6c29d0299c6bd50932f667e1b15f666862b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6bb2fa90aa17aa3e3fe3c5ddde9e6117cfe100232b1805470e10d444aa57edccd9d08f08cde813004ef8afe6ecc6d095e17e691483d74fcadfdb09c911e09ce
|
7
|
+
data.tar.gz: 130f35508424d508a8362b2689a698877f8e999b8c777bb16626dc496665bd3b5aa191e2dc011245ec428c08aefbdde017f520447375843cc12a77a0dcd893c4
|
data/ext/stringio/stringio.c
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
|
12
12
|
**********************************************************************/
|
13
13
|
|
14
|
-
#define STRINGIO_VERSION "0.1.
|
14
|
+
#define STRINGIO_VERSION "0.1.3"
|
15
15
|
|
16
16
|
#include "ruby.h"
|
17
17
|
#include "ruby/io.h"
|
@@ -363,7 +363,12 @@ strio_init(int argc, VALUE *argv, struct StringIO *ptr, VALUE self)
|
|
363
363
|
rb_str_resize(string, 0);
|
364
364
|
}
|
365
365
|
ptr->string = string;
|
366
|
-
|
366
|
+
if (argc == 1) {
|
367
|
+
ptr->enc = rb_enc_get(string);
|
368
|
+
}
|
369
|
+
else {
|
370
|
+
ptr->enc = convconfig.enc;
|
371
|
+
}
|
367
372
|
ptr->pos = 0;
|
368
373
|
ptr->lineno = 0;
|
369
374
|
if (ptr->flags & FMODE_SETENC_BY_BOM) set_encoding_by_bom(ptr);
|
@@ -1424,13 +1429,18 @@ strio_write(VALUE self, VALUE str)
|
|
1424
1429
|
long len, olen;
|
1425
1430
|
rb_encoding *enc, *enc2;
|
1426
1431
|
rb_encoding *const ascii8bit = rb_ascii8bit_encoding();
|
1432
|
+
rb_encoding *usascii = 0;
|
1427
1433
|
|
1428
1434
|
if (!RB_TYPE_P(str, T_STRING))
|
1429
1435
|
str = rb_obj_as_string(str);
|
1430
1436
|
enc = get_enc(ptr);
|
1431
1437
|
enc2 = rb_enc_get(str);
|
1432
|
-
if (enc != enc2 && enc != ascii8bit) {
|
1433
|
-
|
1438
|
+
if (enc != enc2 && enc != ascii8bit && enc != (usascii = rb_usascii_encoding())) {
|
1439
|
+
VALUE converted = rb_str_conv_enc(str, enc2, enc);
|
1440
|
+
if (converted == str && enc2 != ascii8bit && enc2 != usascii) { /* conversion failed */
|
1441
|
+
rb_enc_check(rb_enc_from_encoding(enc), str);
|
1442
|
+
}
|
1443
|
+
str = converted;
|
1434
1444
|
}
|
1435
1445
|
len = RSTRING_LEN(str);
|
1436
1446
|
if (len == 0) return 0;
|
@@ -1527,7 +1537,6 @@ strio_read(int argc, VALUE *argv, VALUE self)
|
|
1527
1537
|
long len;
|
1528
1538
|
int binary = 0;
|
1529
1539
|
|
1530
|
-
rb_check_arity(argc, 0, 2);
|
1531
1540
|
switch (argc) {
|
1532
1541
|
case 2:
|
1533
1542
|
str = argv[1];
|
@@ -1567,6 +1576,8 @@ strio_read(int argc, VALUE *argv, VALUE self)
|
|
1567
1576
|
len -= ptr->pos;
|
1568
1577
|
}
|
1569
1578
|
break;
|
1579
|
+
default:
|
1580
|
+
rb_error_arity(argc, 0, 2);
|
1570
1581
|
}
|
1571
1582
|
if (NIL_P(str)) {
|
1572
1583
|
rb_encoding *enc = binary ? rb_ascii8bit_encoding() : get_enc(ptr);
|
@@ -1759,9 +1770,6 @@ strio_set_encoding_by_bom(VALUE self)
|
|
1759
1770
|
{
|
1760
1771
|
struct StringIO *ptr = StringIO(self);
|
1761
1772
|
|
1762
|
-
if (ptr->enc) {
|
1763
|
-
rb_raise(rb_eArgError, "encoding conversion is set");
|
1764
|
-
}
|
1765
1773
|
if (!set_encoding_by_bom(ptr)) return Qnil;
|
1766
1774
|
return rb_enc_from_encoding(ptr->enc);
|
1767
1775
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stringio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
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:
|
11
|
+
date: 2020-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -38,7 +38,7 @@ homepage: https://github.com/ruby/stringio
|
|
38
38
|
licenses:
|
39
39
|
- BSD-2-Clause
|
40
40
|
metadata: {}
|
41
|
-
post_install_message:
|
41
|
+
post_install_message:
|
42
42
|
rdoc_options: []
|
43
43
|
require_paths:
|
44
44
|
- lib
|
@@ -53,8 +53,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2.6'
|
55
55
|
requirements: []
|
56
|
-
rubygems_version: 3.0.
|
57
|
-
signing_key:
|
56
|
+
rubygems_version: 3.2.0.pre1
|
57
|
+
signing_key:
|
58
58
|
specification_version: 4
|
59
59
|
summary: Pseudo IO on String
|
60
60
|
test_files: []
|