Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 268608 | Differences between
and this patch

Collapse All | Expand All

(-)vim7/src/auto/configure (-1 / +7 lines)
Lines 5754-5756 Link Here
5754
$as_echo_n "checking Ruby header files... " >&6; }
5754
$as_echo_n "checking Ruby header files... " >&6; }
5755
      rubyhdrdir=`$vi_cv_path_ruby -r mkmf -e 'print Config::CONFIG["archdir"] || $hdrdir' 2>/dev/null`
5755
      rubyhdrdir=`$vi_cv_path_ruby -r mkmf -e 'print Config::CONFIG["rubyhdrdir"] || Config::CONFIG["archdir"] || $hdrdir' 2>/dev/null`
5756
      if test "X$rubyhdrdir" != "X"; then
5756
      if test "X$rubyhdrdir" != "X"; then
Lines 5759-5760 Link Here
5759
	RUBY_CFLAGS="-I$rubyhdrdir"
5759
	RUBY_CFLAGS="-I$rubyhdrdir"
5760
        rubyarch=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG["arch"]'`
5761
        if test -d "$rubyhdrdir/$rubyarch"; then
5762
          RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyhdrdir/$rubyarch"
5763
        fi
5764
        rubyversion=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG["ruby_version"].gsub(/\./, "")[0,2]'`
5765
        RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
5760
	rubylibs=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG["LIBS"]'`
5766
	rubylibs=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG["LIBS"]'`
(-)vim7/src/configure.in (-1 / +7 lines)
Lines 958-960 Link Here
958
      AC_MSG_CHECKING(Ruby header files)
958
      AC_MSG_CHECKING(Ruby header files)
959
      rubyhdrdir=`$vi_cv_path_ruby -r mkmf -e 'print Config::CONFIG[["archdir"]] || $hdrdir' 2>/dev/null`
959
      rubyhdrdir=`$vi_cv_path_ruby -r mkmf -e 'print Config::CONFIG[["rubyhdrdir"]] || Config::CONFIG[["archdir"]] || $hdrdir' 2>/dev/null`
960
      if test "X$rubyhdrdir" != "X"; then
960
      if test "X$rubyhdrdir" != "X"; then
Lines 962-963 Link Here
962
	RUBY_CFLAGS="-I$rubyhdrdir"
962
	RUBY_CFLAGS="-I$rubyhdrdir"
963
        rubyarch=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG[["arch"]]'`
964
        if test -d "$rubyhdrdir/$rubyarch"; then
965
          RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyhdrdir/$rubyarch"
966
        fi
967
        rubyversion=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG[["ruby_version"]].gsub(/\./, "")[[0,2]]'`
968
        RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
963
	rubylibs=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG[["LIBS"]]'`
969
	rubylibs=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG[["LIBS"]]'`
(-)vim7/src/if_ruby.c (-17 / +140 lines)
Lines 51-52 Link Here
51
#include <ruby.h>
51
#include <ruby.h>
52
#if defined(RUBY_VERSION) && RUBY_VERSION >=19
53
#include <ruby/encoding.h>
54
#endif
52
55
Lines 62-63 Link Here
62
65
66
/*
67
 * backward compatiblity for Ruby 1.8(or before).
68
 * Ruby 1.9 does not provide STR2CSTR, instead StringValuePtr is provided.
69
 * Ruby 1.9 does not provide RXXX(s)->len, RXXX(s)->ptr, instead
70
 * RXXX_LEN(s), RXXX_PTR(s) is provided.
71
 */
72
#ifndef StringValuePtr
73
#define StringValuePtr(s) STR2CSTR(s)
74
#endif
75
#ifndef RARRAY_LEN
76
#define RARRAY_LEN(s) RARRAY(s)->len
77
#endif 
78
#ifndef RARRAY_PTR
79
#define RARRAY_PTR(s) RARRAY(s)->ptr
80
#endif
81
#ifndef RSTRING_LEN
82
#define RSTRING_LEN(s) RSTRING(s)->len
83
#endif
84
#ifndef RSTRING_PTR
85
#define RSTRING_PTR(s) RSTRING(s)->ptr
86
#endif
87
63
#include "vim.h"
88
#include "vim.h"
Lines 131-133 Link Here
131
#define rb_str_new2			dll_rb_str_new2
156
#define rb_str_new2			dll_rb_str_new2
157
#if defined(RUBY_VERSION) && RUBY_VERSION >= 19
158
#define rb_errinfo                      dll_rb_errinfo
159
#else
132
#define ruby_errinfo			(*dll_ruby_errinfo)
160
#define ruby_errinfo			(*dll_ruby_errinfo)
161
#endif
133
#define ruby_init			dll_ruby_init
162
#define ruby_init			dll_ruby_init
Lines 138-139 Link Here
138
167
168
#if defined(RUBY_VERSION) && RUBY_VERSION >= 19
169
#define ruby_script                     dll_ruby_script
170
#define rb_enc_find_index               dll_rb_enc_find_index
171
#define rb_enc_find                     dll_rb_enc_find
172
#define rb_enc_str_new                  dll_rb_enc_str_new
173
#define rb_sprintf                      dll_rb_sprintf
174
#endif
175
139
/*
176
/*
Lines 185-187 Link Here
185
static VALUE (*dll_rb_str_new2) (const char*);
222
static VALUE (*dll_rb_str_new2) (const char*);
223
#if defined(RUBY_VERSION) && RUBY_VERSION >= 19
224
static VALUE (*dll_rb_errinfo) (void);
225
#else
186
static VALUE *dll_ruby_errinfo;
226
static VALUE *dll_ruby_errinfo;
227
#endif
187
static void (*dll_ruby_init) (void);
228
static void (*dll_ruby_init) (void);
Lines 192-193 Link Here
192
233
234
#if defined(RUBY_VERSION) && RUBY_VERSION >= 19
235
static void (*dll_ruby_script) (const char*);
236
static int (*dll_rb_enc_find_index) (const char*);
237
static rb_encoding* (*dll_rb_enc_find) (const char*); 
238
static VALUE (*dll_rb_enc_str_new) (const char*, long, rb_encoding*);
239
static VALUE (*dll_rb_sprintf) (const char*, ...);
240
#endif
241
193
static HINSTANCE hinstRuby = 0; /* Instance of ruby.dll */
242
static HINSTANCE hinstRuby = 0; /* Instance of ruby.dll */
Lines 247-249 Link Here
247
    {"rb_str_new2", (RUBY_PROC*)&dll_rb_str_new2},
296
    {"rb_str_new2", (RUBY_PROC*)&dll_rb_str_new2},
297
#if defined(RUBY_VERSION) && RUBY_VERSION >= 19
298
    {"rb_errinfo", (RUBY_PROC*)&dll_rb_errinfo},
299
#else
248
    {"ruby_errinfo", (RUBY_PROC*)&dll_ruby_errinfo},
300
    {"ruby_errinfo", (RUBY_PROC*)&dll_ruby_errinfo},
301
#endif
249
    {"ruby_init", (RUBY_PROC*)&dll_ruby_init},
302
    {"ruby_init", (RUBY_PROC*)&dll_ruby_init},
Lines 253-254 Link Here
253
#endif
306
#endif
307
#if defined(RUBY_VERSION) && RUBY_VERSION >= 19
308
    {"ruby_script", (RUBY_PROC*)&dll_ruby_script},
309
    {"rb_enc_find_index", (RUBY_PROC*)&dll_rb_enc_find_index},
310
    {"rb_enc_find", (RUBY_PROC*)&dll_rb_enc_find},
311
    {"rb_enc_str_new", (RUBY_PROC*)&dll_rb_enc_str_new},
312
    {"rb_sprintf", (RUBY_PROC*)&dll_rb_sprintf},
313
#endif
254
    {"", NULL},
314
    {"", NULL},
Lines 342-343 Link Here
342
402
403
/*
404
 *  In Ruby 1.9 or later, ruby String object has encoding.
405
 *  conversion buffer string of vim to ruby String object using
406
 *  VIM encoding option.
407
 */
408
    static VALUE 
409
vim_str2rb_enc_str(const char *s)
410
{
411
#if defined(RUBY_VERSION) && RUBY_VERSION >= 19
412
    int isnum;
413
    long lval;
414
    char_u *sval;
415
    rb_encoding *enc;
416
    isnum = get_option_value((char_u *)"enc", &lval, &sval, 0);
417
    if (isnum == 0) {
418
        enc = rb_enc_find((char*)sval);
419
        vim_free(sval);
420
        if (enc) {
421
            return rb_enc_str_new(s, strlen(s), enc);
422
        }
423
    }
424
#endif
425
    return rb_str_new2(s);
426
}
427
428
static VALUE
429
eval_enc_string_protect(const char *str, int *state)
430
{
431
#if defined(RUBY_VERSION) && RUBY_VERSION >= 19
432
    int isnum;
433
    long lval;
434
    char_u *sval;
435
    rb_encoding *enc;
436
    VALUE v;
437
    isnum = get_option_value((char_u *)"enc", &lval, &sval, 0);
438
    if (isnum == 0) {
439
        enc = rb_enc_find((char*)sval);
440
        vim_free(sval);
441
        if(enc) {
442
            v = rb_sprintf("#-*- coding:%s -*-\n%s", rb_enc_name(enc), str);
443
            return rb_eval_string_protect(StringValuePtr(v), state);
444
        }
445
    }
446
#endif
447
    return rb_eval_string_protect(str, state);
448
}
449
343
void ex_rubydo(exarg_T *eap)
450
void ex_rubydo(exarg_T *eap)
Lines 354-358 Link Here
354
461
355
	    line = oldline = rb_str_new2((char *)ml_get(i));
462
	    line = oldline = vim_str2rb_enc_str((char *)ml_get(i));
356
	    rb_lastline_set(line);
463
	    rb_lastline_set(line);
357
	    rb_eval_string_protect((char *) eap->arg, &state);
464
	    eval_enc_string_protect((char *) eap->arg, &state);
358
	    if (state) {
465
	    if (state) {
Lines 367-369 Link Here
367
		}
474
		}
368
		ml_replace(i, (char_u *) STR2CSTR(line), 1);
475
		ml_replace(i, (char_u *) StringValuePtr(line), 1);
369
		changed();
476
		changed();
Lines 416-420 Link Here
416
#endif
523
#endif
524
#if defined(RUBY_VERSION) && RUBY_VERSION >= 19
525
            RUBY_INIT_STACK;
526
#endif
417
	    ruby_init();
527
	    ruby_init();
528
#if defined(RUBY_VERSION) && RUBY_VERSION >= 19
529
            ruby_script("vim-ruby");
530
#endif
418
	    ruby_init_loadpath();
531
	    ruby_init_loadpath();
419
	    ruby_io_init();
532
	    ruby_io_init();
533
#if defined(RUBY_VERSION) && RUBY_VERSION >= 19
534
            rb_enc_find_index("encdb");
535
#endif
420
	    ruby_vim_init();
536
	    ruby_vim_init();
Lines 436-439 Link Here
436
#ifndef DYNAMIC_RUBY
552
#ifndef DYNAMIC_RUBY
553
#if !(defined(RUBY_VERSION) &&  RUBY_VERSION >= 19)
437
    RUBYEXTERN VALUE ruby_errinfo;
554
    RUBYEXTERN VALUE ruby_errinfo;
438
#endif
555
#endif
556
#endif
439
    VALUE eclass;
557
    VALUE eclass;
Lines 470-474 Link Here
470
    case TAG_FATAL:
588
    case TAG_FATAL:
589
# if defined(RUBY_VERSION) && RUBY_VERSION >= 19
590
	eclass = CLASS_OF(rb_errinfo());
591
	einfo = rb_obj_as_string(rb_errinfo());
592
#else
471
	eclass = CLASS_OF(ruby_errinfo);
593
	eclass = CLASS_OF(ruby_errinfo);
472
	einfo = rb_obj_as_string(ruby_errinfo);
594
	einfo = rb_obj_as_string(ruby_errinfo);
473
	if (eclass == rb_eRuntimeError && RSTRING(einfo)->len == 0) {
595
#endif
596
	if (eclass == rb_eRuntimeError && RSTRING_LEN(einfo) == 0) {
474
	    EMSG(_("E272: unhandled exception"));
597
	    EMSG(_("E272: unhandled exception"));
Lines 481-483 Link Here
481
	    vim_snprintf(buff, BUFSIZ, "%s: %s",
604
	    vim_snprintf(buff, BUFSIZ, "%s: %s",
482
		     RSTRING(epath)->ptr, RSTRING(einfo)->ptr);
605
		     RSTRING_PTR(epath), RSTRING_PTR(einfo));
483
	    p = strchr(buff, '\n');
606
	    p = strchr(buff, '\n');
Lines 499-502 Link Here
499
    str = rb_obj_as_string(str);
622
    str = rb_obj_as_string(str);
500
    buff = ALLOCA_N(char, RSTRING(str)->len);
623
    buff = ALLOCA_N(char, RSTRING_LEN(str));
501
    strcpy(buff, RSTRING(str)->ptr);
624
    strcpy(buff, RSTRING_PTR(str));
502
    p = strchr(buff, '\n');
625
    p = strchr(buff, '\n');
Lines 509-511 Link Here
509
{
632
{
510
    do_set((char_u *)STR2CSTR(str), 0);
633
    do_set((char_u *)StringValuePtr(str), 0);
511
    update_screen(NOT_VALID);
634
    update_screen(NOT_VALID);
Lines 516-518 Link Here
516
{
639
{
517
    do_cmdline_cmd((char_u *)STR2CSTR(str));
640
    do_cmdline_cmd((char_u *)StringValuePtr(str));
518
    return Qnil;
641
    return Qnil;
Lines 523-525 Link Here
523
#ifdef FEAT_EVAL
646
#ifdef FEAT_EVAL
524
    char_u *value = eval_to_string((char_u *)STR2CSTR(str), NULL, TRUE);
647
    char_u *value = eval_to_string((char_u *)StringValuePtr(str), NULL, TRUE);
525
648
Lines 628-630 Link Here
628
	char *line = (char *)ml_get_buf(buf, n, FALSE);
751
	char *line = (char *)ml_get_buf(buf, n, FALSE);
629
	return line ? rb_str_new2(line) : Qnil;
752
	return line ? vim_str2rb_enc_str(line) : Qnil;
630
    }
753
    }
Lines 647-649 Link Here
647
{
770
{
648
    char	*line = STR2CSTR(str);
771
    char	*line = StringValuePtr(str);
649
    aco_save_T	aco;
772
    aco_save_T	aco;
Lines 725-727 Link Here
725
    buf_T	*buf = get_buf(self);
848
    buf_T	*buf = get_buf(self);
726
    char	*line = STR2CSTR(str);
849
    char	*line = StringValuePtr(str);
727
    long	n = NUM2LONG(num);
850
    long	n = NUM2LONG(num);
Lines 892-897 Link Here
892
    Check_Type(pos, T_ARRAY);
1015
    Check_Type(pos, T_ARRAY);
893
    if (RARRAY(pos)->len != 2)
1016
    if (RARRAY_LEN(pos) != 2)
894
	rb_raise(rb_eArgError, "array length must be 2");
1017
	rb_raise(rb_eArgError, "array length must be 2");
895
    lnum = RARRAY(pos)->ptr[0];
1018
    lnum = RARRAY_PTR(pos)[0];
896
    col = RARRAY(pos)->ptr[1];
1019
    col = RARRAY_PTR(pos)[1];
897
    win->w_cursor.lnum = NUM2LONG(lnum);
1020
    win->w_cursor.lnum = NUM2LONG(lnum);
Lines 912-914 Link Here
912
    }
1035
    }
913
    MSG(RSTRING(str)->ptr);
1036
    MSG(RSTRING_PTR(str));
914
    return Qnil;
1037
    return Qnil;

Return to bug 268608