diff --git a/ext/psych/psych.h b/ext/psych/psych.h index 0e146588..3548ece3 100644 --- a/ext/psych/psych.h +++ b/ext/psych/psych.h @@ -4,6 +4,10 @@ #include #include +#ifndef HAVE_RB_LEN_T +typedef long rb_len_t; +#endif + #ifdef PSYCH_USE_LIBFYAML #include #else diff --git a/ext/psych/psych_emitter.c b/ext/psych/psych_emitter.c index 187aebc3..afe273d6 100644 --- a/ext/psych/psych_emitter.c +++ b/ext/psych/psych_emitter.c @@ -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); } @@ -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); diff --git a/ext/psych/psych_emitter_fy.c b/ext/psych/psych_emitter_fy.c index 22bf23e5..4834d9f7 100644 --- a/ext/psych/psych_emitter_fy.c +++ b/ext/psych/psych_emitter_fy.c @@ -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; } @@ -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) { diff --git a/ext/psych/psych_parser.c b/ext/psych/psych_parser.c index 2b50fcae..bb37623f 100644 --- a/ext/psych/psych_parser.c +++ b/ext/psych/psych_parser.c @@ -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); diff --git a/ext/psych/psych_parser_fy.c b/ext/psych/psych_parser_fy.c index ccb05776..e79ec360 100644 --- a/ext/psych/psych_parser_fy.c +++ b/ext/psych/psych_parser_fy.c @@ -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; }