X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=ext%2Fcomments.c;h=6e6efd58460b787f541c82a1cbda9ccda9b5a7b9;hb=HEAD;hp=03a237b104f87d0fbfd77f78e165dae2a828fb34;hpb=c623a45b47d3061c47eac5abd4867913c9230b36;p=ruby-vorbistagger.git diff --git a/ext/comments.c b/ext/comments.c index 03a237b..6e6efd5 100644 --- a/ext/comments.c +++ b/ext/comments.c @@ -41,14 +41,17 @@ comments_init (VALUE self, vcedit_state *state) for (i = 0; i < vc->comments; i++) { VALUE k, v, pair; char *ptr, *content = vc->user_comments[i]; + int k_len, v_len; ptr = strchr (content, '='); assert (ptr); - k = rb_str_new (content, ptr - content); + k_len = ptr - content; + k = rb_str_new (content, k_len); OBJ_FREEZE (k); - v = rb_str_new2 (ptr + 1); + v_len = vc->comment_lengths[i] - k_len - 1; + v = rb_str_new (ptr + 1, v_len); pair = rb_ary_new3 (2, k, v); OBJ_FREEZE (pair); @@ -161,7 +164,7 @@ c_delete (VALUE self, VALUE key) struct RArray *pair = RARRAY (items->ptr[i]); VALUE tmp; - tmp = rb_funcall (pair->ptr[0], id_casecmp, 1, key); + tmp = rb_funcall2 (pair->ptr[0], id_casecmp, 1, &key); if (tmp == INT2FIX (0)) { ret = pair->ptr[1]; pos = i; @@ -276,7 +279,7 @@ c_aref (VALUE self, VALUE key) struct RArray *pair = RARRAY (items->ptr[i]); VALUE tmp; - tmp = rb_funcall (pair->ptr[0], id_casecmp, 1, key); + tmp = rb_funcall2 (pair->ptr[0], id_casecmp, 1, &key); if (tmp == INT2FIX (0)) return pair->ptr[1]; } @@ -303,9 +306,9 @@ c_aset (VALUE self, VALUE key, VALUE value) struct RArray *pair = RARRAY (items->ptr[i]); VALUE tmp; - tmp = rb_funcall (pair->ptr[0], id_casecmp, 1, key); + tmp = rb_funcall2 (pair->ptr[0], id_casecmp, 1, &key); if (tmp == INT2FIX (0)) { - rb_funcall (pair->ptr[1], id_replace, 1, value); + rb_funcall2 (pair->ptr[1], id_replace, 1, &value); return pair->ptr[1]; } } @@ -337,7 +340,7 @@ c_has_key (VALUE self, VALUE key) struct RArray *pair = RARRAY (items->ptr[i]); VALUE tmp; - tmp = rb_funcall (pair->ptr[0], id_casecmp, 1, key); + tmp = rb_funcall2 (pair->ptr[0], id_casecmp, 1, &key); if (tmp == INT2FIX (0)) return Qtrue; } @@ -423,7 +426,7 @@ c_compare (VALUE self, VALUE other) for (j = 0; j < 2; j++) { VALUE tmp; - tmp = rb_funcall (aa->ptr[j], id_compare, 1, bb->ptr[j]); + tmp = rb_funcall2 (aa->ptr[j], id_compare, 1, &bb->ptr[j]); if (FIX2INT (tmp) != 0) return tmp; }