0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

updated for version 7.3.058

Problem:    Error "code converter not found" when loading Ruby script.
Solution:   Load Gem module. (Yasuhiro Matsumoto)
This commit is contained in:
Bram Moolenaar
2010-11-16 14:46:19 +01:00
parent 66b4bf8980
commit 3c53160348
2 changed files with 24 additions and 12 deletions

View File

@@ -229,6 +229,9 @@ static void ruby_vim_init(void);
# define rb_enc_find_index dll_rb_enc_find_index # define rb_enc_find_index dll_rb_enc_find_index
# define rb_enc_find dll_rb_enc_find # define rb_enc_find dll_rb_enc_find
# define rb_enc_str_new dll_rb_enc_str_new # define rb_enc_str_new dll_rb_enc_str_new
# define rb_intern2 dll_rb_intern2
# define rb_const_remove dll_rb_const_remove
# define Init_prelude dll_Init_prelude
# define rb_sprintf dll_rb_sprintf # define rb_sprintf dll_rb_sprintf
# define ruby_init_stack dll_ruby_init_stack # define ruby_init_stack dll_ruby_init_stack
#endif #endif
@@ -317,6 +320,9 @@ static void (*dll_ruby_script) (const char*);
static int (*dll_rb_enc_find_index) (const char*); static int (*dll_rb_enc_find_index) (const char*);
static rb_encoding* (*dll_rb_enc_find) (const char*); static rb_encoding* (*dll_rb_enc_find) (const char*);
static VALUE (*dll_rb_enc_str_new) (const char*, long, rb_encoding*); static VALUE (*dll_rb_enc_str_new) (const char*, long, rb_encoding*);
static ID (*dll_rb_intern2) (const char*, long);
static void (*dll_Init_prelude) (void);
static VALUE (*dll_rb_const_remove) (VALUE, ID);
static VALUE (*dll_rb_sprintf) (const char*, ...); static VALUE (*dll_rb_sprintf) (const char*, ...);
static void (*ruby_init_stack)(VALUE*); static void (*ruby_init_stack)(VALUE*);
#endif #endif
@@ -425,6 +431,9 @@ static struct
{"rb_enc_find_index", (RUBY_PROC*)&dll_rb_enc_find_index}, {"rb_enc_find_index", (RUBY_PROC*)&dll_rb_enc_find_index},
{"rb_enc_find", (RUBY_PROC*)&dll_rb_enc_find}, {"rb_enc_find", (RUBY_PROC*)&dll_rb_enc_find},
{"rb_enc_str_new", (RUBY_PROC*)&dll_rb_enc_str_new}, {"rb_enc_str_new", (RUBY_PROC*)&dll_rb_enc_str_new},
{"rb_intern2", (RUBY_PROC*)&dll_rb_intern2},
{"rb_const_remove", (RUBY_PROC*)&dll_rb_const_remove},
{"Init_prelude", (RUBY_PROC*)&dll_Init_prelude},
{"rb_sprintf", (RUBY_PROC*)&dll_rb_sprintf}, {"rb_sprintf", (RUBY_PROC*)&dll_rb_sprintf},
{"ruby_init_stack", (RUBY_PROC*)&dll_ruby_init_stack}, {"ruby_init_stack", (RUBY_PROC*)&dll_ruby_init_stack},
#endif #endif
@@ -662,6 +671,12 @@ static int ensure_ruby_initialized(void)
ruby_io_init(); ruby_io_init();
#ifdef RUBY19_OR_LATER #ifdef RUBY19_OR_LATER
rb_enc_find_index("encdb"); rb_enc_find_index("encdb");
/* This avoids the error "Encoding::ConverterNotFoundError: code
* converter not found (UTF-16LE to ASCII-8BIT)". */
rb_define_module("Gem");
Init_prelude();
rb_const_remove(rb_cObject, rb_intern2("TMP_RUBY_PREFIX", 15));
#endif #endif
ruby_vim_init(); ruby_vim_init();
ruby_initialized = 1; ruby_initialized = 1;
@@ -946,13 +961,9 @@ static VALUE buffer_count(VALUE self)
static VALUE get_buffer_line(buf_T *buf, linenr_T n) static VALUE get_buffer_line(buf_T *buf, linenr_T n)
{ {
if (n > 0 && n <= buf->b_ml.ml_line_count) if (n <= 0 || n > buf->b_ml.ml_line_count)
{ rb_raise(rb_eIndexError, "line number %ld out of range", (long)n);
char *line = (char *)ml_get_buf(buf, n, FALSE); return vim_str2rb_enc_str((char *)ml_get_buf(buf, n, FALSE));
return line ? vim_str2rb_enc_str(line) : Qnil;
}
rb_raise(rb_eIndexError, "line number %ld out of range", (long)n);
return Qnil; /* For stop warning */
} }
static VALUE buffer_aref(VALUE self, VALUE num) static VALUE buffer_aref(VALUE self, VALUE num)
@@ -991,9 +1002,6 @@ static VALUE set_buffer_line(buf_T *buf, linenr_T n, VALUE str)
else else
{ {
rb_raise(rb_eIndexError, "line number %ld out of range", (long)n); rb_raise(rb_eIndexError, "line number %ld out of range", (long)n);
#ifndef __GNUC__
return Qnil; /* For stop warning */
#endif
} }
return str; return str;
} }
@@ -1048,7 +1056,8 @@ static VALUE buffer_append(VALUE self, VALUE num, VALUE str)
long n = NUM2LONG(num); long n = NUM2LONG(num);
aco_save_T aco; aco_save_T aco;
if (line == NULL) { if (line == NULL)
{
rb_raise(rb_eIndexError, "NULL line"); rb_raise(rb_eIndexError, "NULL line");
} }
else if (n >= 0 && n <= buf->b_ml.ml_line_count) else if (n >= 0 && n <= buf->b_ml.ml_line_count)
@@ -1072,7 +1081,8 @@ static VALUE buffer_append(VALUE self, VALUE num, VALUE str)
update_curbuf(NOT_VALID); update_curbuf(NOT_VALID);
} }
else { else
{
rb_raise(rb_eIndexError, "line number %ld out of range", n); rb_raise(rb_eIndexError, "line number %ld out of range", n);
} }
return str; return str;

View File

@@ -714,6 +714,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
58,
/**/ /**/
57, 57,
/**/ /**/