Patch 7.2.374

31 views
Skip to first unread message

Bram Moolenaar

unread,
Feb 24, 2010, 9:48:22 AM2/24/10
to vim...@vim.org

Patch 7.2.374
Problem: Ruby eval() doesn't understand Vim types.
Solution: Add the vim_to_ruby() function. (George Gensure)
Files: src/eval.c, src/if_ruby.c


*** ../vim-7.2.373/src/eval.c 2010-01-19 15:51:29.000000000 +0100
--- src/eval.c 2010-02-24 15:36:40.000000000 +0100
***************
*** 5872,5878 ****
return item1 == NULL && item2 == NULL;
}

! #if defined(FEAT_PYTHON) || defined(FEAT_MZSCHEME) || defined(PROTO)
/*
* Return the dictitem that an entry in a hashtable points to.
*/
--- 5872,5879 ----
return item1 == NULL && item2 == NULL;
}

! #if defined(FEAT_RUBY) || defined(FEAT_PYTHON) || defined(FEAT_MZSCHEME) \
! || defined(PROTO)
/*
* Return the dictitem that an entry in a hashtable points to.
*/
*** ../vim-7.2.373/src/if_ruby.c 2010-02-18 15:51:25.000000000 +0100
--- src/if_ruby.c 2010-02-24 15:45:15.000000000 +0100
***************
*** 660,679 ****
return Qnil;
}

static VALUE vim_evaluate(VALUE self UNUSED, VALUE str)
{
#ifdef FEAT_EVAL
! char_u *value = eval_to_string((char_u *)StringValuePtr(str), NULL, TRUE);

! if (value != NULL)
{
! VALUE val = rb_str_new2((char *)value);
! vim_free(value);
! return val;
}
! else
#endif
- return Qnil;
}

static VALUE buffer_new(buf_T *buf)
--- 660,747 ----
return Qnil;
}

+ #ifdef FEAT_EVAL
+ static VALUE vim_to_ruby(typval_T *tv)
+ {
+ VALUE result = Qnil;
+
+ if (tv->v_type == VAR_STRING)
+ {
+ result = rb_str_new2((char *)tv->vval.v_string);
+ }
+ else if (tv->v_type == VAR_NUMBER)
+ {
+ result = INT2NUM(tv->vval.v_number);
+ }
+ # ifdef FEAT_FLOAT
+ else if (tv->v_type == VAR_FLOAT)
+ {
+ result = rb_float_new(tv->vval.v_float);
+ }
+ # endif
+ else if (tv->v_type == VAR_LIST)
+ {
+ list_T *list = tv->vval.v_list;
+ listitem_T *curr;
+
+ result = rb_ary_new();
+
+ if (list != NULL)
+ {
+ for (curr = list->lv_first; curr != NULL; curr = curr->li_next)
+ {
+ rb_ary_push(result, vim_to_ruby(&curr->li_tv));
+ }
+ }
+ }
+ else if (tv->v_type == VAR_DICT)
+ {
+ result = rb_hash_new();
+
+ if (tv->vval.v_dict != NULL)
+ {
+ hashtab_T *ht = &tv->vval.v_dict->dv_hashtab;
+ long_u todo = ht->ht_used;
+ hashitem_T *hi;
+ dictitem_T *di;
+
+ for (hi = ht->ht_array; todo > 0; ++hi)
+ {
+ if (!HASHITEM_EMPTY(hi))
+ {
+ --todo;
+
+ di = dict_lookup(hi);
+ rb_hash_aset(result, rb_str_new2((char *)hi->hi_key),
+ vim_to_ruby(&di->di_tv));
+ }
+ }
+ }
+ } /* else return Qnil; */
+
+ return result;
+ }
+ #endif
+
static VALUE vim_evaluate(VALUE self UNUSED, VALUE str)
{
#ifdef FEAT_EVAL
! typval_T *tv;
! VALUE result;

! tv = eval_expr((char_u *)StringValuePtr(str), NULL);
! if (tv == NULL)
{
! return Qnil;
}
! result = vim_to_ruby(tv);
!
! free_tv(tv);
!
! return result;
! #else
! return Qnil;
#endif
}

static VALUE buffer_new(buf_T *buf)
*** ../vim-7.2.373/src/version.c 2010-02-24 15:25:13.000000000 +0100
--- src/version.c 2010-02-24 15:46:57.000000000 +0100
***************
*** 683,684 ****
--- 683,686 ----
{ /* Add new patch number below this line */
+ /**/
+ 374,
/**/

--
ARTHUR: (as the MAN next to him is squashed by a sheep) Knights! Run away!
Midst echoing shouts of "run away" the KNIGHTS retreat to cover with the odd
cow or goose hitting them still. The KNIGHTS crouch down under cover.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Steve Hall

unread,
Feb 24, 2010, 3:57:36 PM2/24/10
to vim...@googlegroups.com, vim...@vim.org
From: Bram Moolenaar, Wed, February 24, 2010 9:48 am

>
> Patch 7.2.374
> Problem: Ruby eval() doesn't understand Vim types.
> Solution: Add the vim_to_ruby() function. (George Gensure)
> Files: src/eval.c, src/if_ruby.c

I'm still seeing build errors with Windows/Cygwin related to Ruby,
hope this helps:

gobj/if_ruby.o:if_ruby.c:(.text+0x9b5): undefined reference to
`_rb_string_value_ptr'
gobj/if_ruby.o:if_ruby.c:(.text+0xae3): undefined reference to
`_rb_string_value_ptr'
gobj/if_ruby.o:if_ruby.c:(.text+0xb0d): undefined reference to
`_rb_string_value_ptr'
gobj/if_ruby.o:if_ruby.c:(.text+0xbee): undefined reference to
`_rb_float_new'
gobj/if_ruby.o:if_ruby.c:(.text+0xbfd): undefined reference to
`_rb_ary_new'
gobj/if_ruby.o:if_ruby.c:(.text+0xc1c): undefined reference to
`_rb_ary_push'
gobj/if_ruby.o:if_ruby.c:(.text+0xc3d): undefined reference to
`_rb_string_value_ptr'
gobj/if_ruby.o:if_ruby.c:(.text+0xf38): undefined reference to
`_rb_string_value_ptr'
gobj/if_ruby.o:if_ruby.c:(.text+0x1157): undefined reference to
`_rb_string_value_ptr'
collect2: ld returned 1 exit status
make: *** [gvim.exe] Error 1


--
Steve Hall [ digitect dancingpaper com ]


Bram Moolenaar

unread,
Feb 24, 2010, 5:27:48 PM2/24/10
to Steve Hall, vim...@vim.org

Steve Hall wrote:

Sorry, I still have no clue how to fix this without reverting that whole
patch. It builds fine on Linux, must be something MS-Windows or Cygwin
related. Did you try a MingW build?

--
The software said it requires Windows 95 or better, so I installed Linux.

Steve Hall

unread,
Feb 24, 2010, 5:52:01 PM2/24/10
to vim...@googlegroups.com
From: Bram Moolenaar, Wed, February 24, 2010 5:27 pm

> Steve Hall wrote:
> > From: Bram Moolenaar, Wed, February 24, 2010 9:48 am
> > >
> > > Patch 7.2.374
> >
> > I'm still seeing build errors with Windows/Cygwin related to Ruby,
>
[...]

>
> Sorry, I still have no clue how to fix this without reverting that
> whole patch. It builds fine on Linux, must be something MS-Windows
> or Cygwin related. Did you try a MingW build?

No, just Cygwin, but Cesar reported the same error with MinGW. He
reports success changing to DYNAMIC_RUBY=no, but that fails for me the
same as DYNAMIC_RUBY=yes.

SungHyun Nam

unread,
Feb 24, 2010, 7:51:34 PM2/24/10
to vim...@googlegroups.com, Steve Hall, vim...@vim.org, Bram Moolenaar

I have no build problem with up-to-dated cygwin/ruby.

You might want to report more information such as configure
option, cygwin/windows version, ruby version, gcc command line,
etc.

Regards,
namsh

$ uname -a
CYGWIN_NT-5.1 namsh 1.7.1(0.218/5/3) 2009-12-07 11:48 i686 Cygwin

$ ruby --version
ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin]

$ LANG= gvim
:ver
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Feb 25 2010 09:39:01)
Included patches: 1-376
Compiled by namsh@namsh
Normal version with GTK2 GUI. Features included (+) or not (-):
-arabic +autocmd +balloon_eval +browse +builtin_terms +byte_offset +cindent
+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info
+comments
+cryptv -cscope +cursorshape +dialog_con_gui +diff +digraphs +dnd -ebcdic
-emacs_tags +eval +ex_extra +extra_search -farsi +file_in_path +find_in_path
+float +folding -footer +fork() +gettext -hangul_input +iconv +insert_expand
+jumplist -keymap -langmap +libcall +linebreak +lispindent +listcmds
+localmap
+menu +mksession +modify_fname +mouse +mouseshape -mouse_dec -mouse_gpm
-mouse_jsbterm -mouse_netterm -mouse_sysmouse +mouse_xterm +multi_byte
+multi_lang -mzscheme +netbeans_intg -osfiletype +path_extra -perl
+postscript
+printer -profile +python +quickfix +reltime -rightleft +ruby +scrollbind
+signs +smartindent -sniff +startuptime +statusline -sun_workshop +syntax
+tag_binary +tag_old_static -tag_any_white -tcl +terminfo +termresponse
+textobjects +title +toolbar +user_commands +vertsplit +virtualedit +visual
+visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup
+X11 -xfontset +xim +xsmp_interact +xterm_clipboard -xterm_save
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
user exrc file: "$HOME/.exrc"
system gvimrc file: "$VIM/gvimrc"
user gvimrc file: "$HOME/.gvimrc"
system menu file: "$VIMRUNTIME/menu.vim"
fall-back for $VIM: "/opt/share/vim"
Compilation: gcc-4 -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK
-I/usr/include
/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0
-I/usr/include/cairo
-I/usr/include/pango-1.0 -I/usr/include/glib-2.0
-I/usr/lib/glib-2.0/include -I/
usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12
-O2 -m
arch=i686 -fno-strict-aliasing -pipe -D_FORTIFY_SOURCE=1
-I/usr/include/pyth
on2.5 -I/usr/lib/ruby/1.8/i386-cygwin -DRUBY_VERSION=18
Linking: gcc-4 -L. -L/usr/local/lib -o vim.exe -lgtk-x11-2.0
-lgdk-x11-2.0
-latk-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lgio-2.0 -lXinerama -lXi
-lXrandr -
lXcursor -lXcomposite -lXdamage -lpangoft2-1.0 -lXext -lXfixes -lcairo
-lpixman-
1 -lglitz -lpng12 -lxcb-render-util -lXrender -lxcb-render -lxcb -lXau
-lpango-1
.0 -lfontconfig -lexpat -lfreetype -lz -lgobject-2.0 -lgmodule-2.0
-lglib-2.0 -l
intl -lXt -lX11 -lSM -lICE -lncurses -liconv -lintl
-L/usr/lib/python2.5/conf
ig -lpython2.5 -lm -lruby -ldl -lcrypt

Cesar Romani

unread,
Feb 25, 2010, 9:05:00 AM2/25/10
to vim...@vim.org

You've compiled vim for Cygwin not for Windows

Best regards

--
Cesar

Cesar Romani

unread,
Feb 25, 2010, 9:51:36 AM2/25/10
to vim...@vim.org

In that case it can be reverted for Windows.
vim with ruby support v1.8.6, built fine until v7.2.360 on Windows.
MOreover vim doesn't build yet with ruby support v1.9.1 either with
DYNAMIC_RUBY=yes or no, on Windows.

Regards,

--
Cesar

Reply all
Reply to author
Forward
0 new messages