1 To: vim_dev@googlegroups.com
4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: Error "code converter not found" when loading Ruby script.
12 Solution: Load Gem module. (Yasuhiro Matsumoto)
16 *** ../vim-7.3.057/src/if_ruby.c 2010-10-27 17:40:53.000000000 +0200
17 --- src/if_ruby.c 2010-11-16 14:37:48.000000000 +0100
21 # define rb_enc_find_index dll_rb_enc_find_index
22 # define rb_enc_find dll_rb_enc_find
23 # define rb_enc_str_new dll_rb_enc_str_new
24 + # define rb_intern2 dll_rb_intern2
25 + # define rb_const_remove dll_rb_const_remove
26 + # define Init_prelude dll_Init_prelude
27 # define rb_sprintf dll_rb_sprintf
28 # define ruby_init_stack dll_ruby_init_stack
33 static int (*dll_rb_enc_find_index) (const char*);
34 static rb_encoding* (*dll_rb_enc_find) (const char*);
35 static VALUE (*dll_rb_enc_str_new) (const char*, long, rb_encoding*);
36 + static ID (*dll_rb_intern2) (const char*, long);
37 + static void (*dll_Init_prelude) (void);
38 + static VALUE (*dll_rb_const_remove) (VALUE, ID);
39 static VALUE (*dll_rb_sprintf) (const char*, ...);
40 static void (*ruby_init_stack)(VALUE*);
45 {"rb_enc_find_index", (RUBY_PROC*)&dll_rb_enc_find_index},
46 {"rb_enc_find", (RUBY_PROC*)&dll_rb_enc_find},
47 {"rb_enc_str_new", (RUBY_PROC*)&dll_rb_enc_str_new},
48 + {"rb_intern2", (RUBY_PROC*)&dll_rb_intern2},
49 + {"rb_const_remove", (RUBY_PROC*)&dll_rb_const_remove},
50 + {"Init_prelude", (RUBY_PROC*)&dll_Init_prelude},
51 {"rb_sprintf", (RUBY_PROC*)&dll_rb_sprintf},
52 {"ruby_init_stack", (RUBY_PROC*)&dll_ruby_init_stack},
58 #ifdef RUBY19_OR_LATER
59 rb_enc_find_index("encdb");
61 + /* This avoids the error "Encoding::ConverterNotFoundError: code
62 + * converter not found (UTF-16LE to ASCII-8BIT)". */
63 + rb_define_module("Gem");
65 + rb_const_remove(rb_cObject, rb_intern2("TMP_RUBY_PREFIX", 15));
72 static VALUE get_buffer_line(buf_T *buf, linenr_T n)
74 ! if (n > 0 && n <= buf->b_ml.ml_line_count)
76 ! char *line = (char *)ml_get_buf(buf, n, FALSE);
77 ! return line ? vim_str2rb_enc_str(line) : Qnil;
79 ! rb_raise(rb_eIndexError, "line number %ld out of range", (long)n);
80 ! return Qnil; /* For stop warning */
83 static VALUE buffer_aref(VALUE self, VALUE num)
86 static VALUE get_buffer_line(buf_T *buf, linenr_T n)
88 ! if (n <= 0 || n > buf->b_ml.ml_line_count)
89 ! rb_raise(rb_eIndexError, "line number %ld out of range", (long)n);
90 ! return vim_str2rb_enc_str((char *)ml_get_buf(buf, n, FALSE));
93 static VALUE buffer_aref(VALUE self, VALUE num)
98 rb_raise(rb_eIndexError, "line number %ld out of range", (long)n);
100 - return Qnil; /* For stop warning */
108 long n = NUM2LONG(num);
111 ! if (line == NULL) {
112 rb_raise(rb_eIndexError, "NULL line");
114 else if (n >= 0 && n <= buf->b_ml.ml_line_count)
116 long n = NUM2LONG(num);
121 rb_raise(rb_eIndexError, "NULL line");
123 else if (n >= 0 && n <= buf->b_ml.ml_line_count)
127 update_curbuf(NOT_VALID);
130 rb_raise(rb_eIndexError, "line number %ld out of range", n);
135 update_curbuf(NOT_VALID);
139 rb_raise(rb_eIndexError, "line number %ld out of range", n);
142 *** ../vim-7.3.057/src/version.c 2010-11-16 14:05:48.000000000 +0100
143 --- src/version.c 2010-11-16 14:44:42.000000000 +0100
147 { /* Add new patch number below this line */
153 SIGIRO -- irony detected (iron core dumped)
155 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
156 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
157 \\\ an exciting new programming language -- http://www.Zimbu.org ///
158 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///