summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2021-11-11 17:31:58 +0900
committernagachika <nagachika@ruby-lang.org>2021-11-22 10:51:35 +0900
commite6fced73e55dda487f026c929d97542cf1832252 (patch)
tree65456d13bb4616404d36eca4948cd323a93fbbb7 /ext
parente735773fd4a0f9cbab82134e22d989bf540b744e (diff)
Bump stringio version to 3.0.1
Diffstat (limited to 'ext')
-rw-r--r--ext/stringio/stringio.c26
-rw-r--r--ext/stringio/stringio.gemspec3
2 files changed, 15 insertions, 14 deletions
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index 6c86e8964d..8df07e80f6 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; indent-tabs-mode: t -*- */
/**********************************************************************
stringio.c -
@@ -11,7 +12,7 @@
**********************************************************************/
-#define STRINGIO_VERSION "3.0.0"
+#define STRINGIO_VERSION "3.0.1"
#include "ruby.h"
#include "ruby/io.h"
@@ -64,7 +65,7 @@ strio_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash,
n = strchr(n, '|');
}
e = strchr(++n, ':');
- len = e ? e - n : strlen(n);
+ len = e ? e - n : (long)strlen(n);
if (len > 0 && len <= ENCODING_MAXNAMELEN) {
if (e) {
memcpy(encname, n, len);
@@ -599,6 +600,14 @@ strio_closed_write(VALUE self)
return Qtrue;
}
+static struct StringIO *
+strio_to_read(VALUE self)
+{
+ struct StringIO *ptr = readable(self);
+ if (ptr->pos < RSTRING_LEN(ptr->string)) return ptr;
+ return NULL;
+}
+
/*
* call-seq:
* strio.eof -> true or false
@@ -610,8 +619,7 @@ strio_closed_write(VALUE self)
static VALUE
strio_eof(VALUE self)
{
- struct StringIO *ptr = readable(self);
- if (ptr->pos < RSTRING_LEN(ptr->string)) return Qfalse;
+ if (strio_to_read(self)) return Qfalse;
return Qtrue;
}
@@ -821,11 +829,11 @@ strio_get_sync(VALUE self)
static VALUE
strio_each_byte(VALUE self)
{
- struct StringIO *ptr = readable(self);
+ struct StringIO *ptr;
RETURN_ENUMERATOR(self, 0, 0);
- while (ptr->pos < RSTRING_LEN(ptr->string)) {
+ while ((ptr = strio_to_read(self)) != NULL) {
char c = RSTRING_PTR(ptr->string)[ptr->pos++];
rb_yield(CHR2FIX(c));
}
@@ -1064,11 +1072,7 @@ strio_each_codepoint(VALUE self)
ptr = readable(self);
enc = get_enc(ptr);
- for (;;) {
- if (ptr->pos >= RSTRING_LEN(ptr->string)) {
- return self;
- }
-
+ while ((ptr = strio_to_read(self)) != NULL) {
c = rb_enc_codepoint_len(RSTRING_PTR(ptr->string)+ptr->pos,
RSTRING_END(ptr->string), &n, enc);
ptr->pos += n;
diff --git a/ext/stringio/stringio.gemspec b/ext/stringio/stringio.gemspec
index d12c648a7d..524d976cfb 100644
--- a/ext/stringio/stringio.gemspec
+++ b/ext/stringio/stringio.gemspec
@@ -28,7 +28,4 @@ Gem::Specification.new do |s|
# s.cert_chain = %w[certs/nobu.pem]
# s.signing_key = File.expand_path("~/.ssh/gem-private_key.pem") if $0 =~ /gem\z/
-
- s.add_development_dependency 'rake-compiler'
- s.add_development_dependency 'test-unit'
end