Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ext/psych/psych.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#include <ruby.h>
#include <ruby/encoding.h>

#ifndef HAVE_RB_LEN_T
typedef long rb_len_t;
#endif

#ifdef PSYCH_USE_LIBFYAML
#include <libfyaml.h>
#else
Expand Down
6 changes: 3 additions & 3 deletions ext/psych/psych_emitter.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static void emit(yaml_emitter_t * emitter, yaml_event_t * event)
static int writer(void *ctx, unsigned char *buffer, size_t size)
{
VALUE self = (VALUE)ctx, io = rb_attr_get(self, id_io);
VALUE str = rb_enc_str_new((const char *)buffer, (long)size, rb_utf8_encoding());
VALUE str = rb_enc_str_new((const char *)buffer, (rb_len_t)size, rb_utf8_encoding());
VALUE wrote = rb_funcall(io, id_write, 1, str);
return (int)NUM2INT(wrote);
}
Expand Down Expand Up @@ -172,8 +172,8 @@ static VALUE start_document_try(VALUE d)
}

if(RTEST(tags)) {
long i = 0;
long len;
rb_len_t i = 0;
rb_len_t len;
rb_encoding * encoding = rb_utf8_encoding();

Check_Type(tags, T_ARRAY);
Expand Down
4 changes: 2 additions & 2 deletions ext/psych/psych_emitter_fy.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static int emitter_output(struct fy_emitter *emit, enum fy_emitter_write_type ty
{
VALUE self = (VALUE)userdata;
VALUE io = rb_attr_get(self, id_io);
VALUE s = rb_enc_str_new(str, (long)len, rb_utf8_encoding());
VALUE s = rb_enc_str_new(str, (rb_len_t)len, rb_utf8_encoding());
rb_funcall(io, id_write, 1, s);
return len;
}
Expand Down Expand Up @@ -186,7 +186,7 @@ static VALUE start_document_try(VALUE d)

if (RTEST(tags)) {
rb_encoding *encoding = rb_utf8_encoding();
long i, len;
rb_len_t i, len;
Check_Type(tags, T_ARRAY);
len = RARRAY_LEN(tags);
if (len > 0) {
Expand Down
2 changes: 1 addition & 1 deletion ext/psych/psych_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ static VALUE parse_body(VALUE ptr)
VALUE plain_implicit, quoted_implicit, style;
VALUE val = rb_str_new(
(const char *)event.data.scalar.value,
(long)event.data.scalar.length
(rb_len_t)event.data.scalar.length
);

PSYCH_TRANSCODE(val, encoding, internal_enc);
Expand Down
2 changes: 1 addition & 1 deletion ext/psych/psych_parser_fy.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ static VALUE token_to_str(struct fy_token *tok, int encoding, rb_encoding *inter
if (!text) {
return Qnil;
}
VALUE str = rb_str_new(text, (long)len);
VALUE str = rb_str_new(text, (rb_len_t)len);
PSYCH_TRANSCODE(str, encoding, internal_enc);
return str;
}
Expand Down
Loading