ext/rugged/rugged_signature.c in rugged-0.18.0.gh.de28323 vs ext/rugged/rugged_signature.c in rugged-0.19.0
- old
+ new
@@ -25,33 +25,29 @@
#include "rugged.h"
VALUE rugged_signature_new(const git_signature *sig, const char *encoding_name)
{
VALUE rb_sig, rb_time;
+ rb_encoding *encoding = rb_utf8_encoding();
-#ifdef HAVE_RUBY_ENCODING_H
- rb_encoding *encoding = NULL;
-
if (encoding_name != NULL)
encoding = rb_enc_find(encoding_name);
-#endif
rb_sig = rb_hash_new();
-#if RUBY_API_VERSION_MINOR >= 9
/* Allocate the time with a the given timezone */
rb_time = rb_funcall(
rb_time_new(sig->when.time, 0),
rb_intern("getlocal"), 1,
INT2FIX(sig->when.offset * 60)
);
-#else
- rb_time = rb_time_new(sig->when.time, 0);
- rb_hash_aset(rb_sig, CSTR2SYM("time_offset"), INT2FIX(sig->when.offset * 60));
-#endif
- rb_hash_aset(rb_sig, CSTR2SYM("name"), rugged_str_new2(sig->name, encoding));
- rb_hash_aset(rb_sig, CSTR2SYM("email"), rugged_str_new2(sig->email, encoding));
+ rb_hash_aset(rb_sig, CSTR2SYM("name"),
+ rb_enc_str_new(sig->name, strlen(sig->name), encoding));
+
+ rb_hash_aset(rb_sig, CSTR2SYM("email"),
+ rb_enc_str_new(sig->email, strlen(sig->email), encoding));
+
rb_hash_aset(rb_sig, CSTR2SYM("time"), rb_time);
return rb_sig;
}