From 349ce4e580ca2b5a4d6fbd58a49cf84c6a302559 Mon Sep 17 00:00:00 2001 From: edyfox Date: Thu, 18 Feb 2010 06:01:34 +0000 Subject: [PATCH] Merged from the latest developing branch. git-svn-id: https://vim.svn.sourceforge.net/svnroot/vim/trunk@1766 2a77ed30-b011-0410-a7ad-c7884a0aa172 --- src/GvimExt/gvimext.h | 8 +-- src/Makefile | 4 +- src/auto/configure | 30 ++++++-- src/configure.in | 16 ++++- src/gui_gtk_x11.c | 2 +- src/gui_w32.c | 23 ++++++ src/gui_w48.c | 11 +-- src/if_perl.xs | 9 +++ src/if_ruby.c | 191 ++++++++++++++++++++++++++++++++++++++++++++------ src/memline.c | 9 +++ src/move.c | 21 ++++-- src/option.c | 4 ++ src/os_unix.c | 6 ++ src/version.c | 22 ++++++ src/xxd/xxd.c | 10 +-- 15 files changed, 309 insertions(+), 57 deletions(-) diff --git a/src/GvimExt/gvimext.h b/src/GvimExt/gvimext.h index 506ab8fc..3b6b40b1 100644 --- a/src/GvimExt/gvimext.h +++ b/src/GvimExt/gvimext.h @@ -14,9 +14,9 @@ #if !defined(AFX_STDAFX_H__3389658B_AD83_11D3_9C1E_0090278BBD99__INCLUDED_) #define AFX_STDAFX_H__3389658B_AD83_11D3_9C1E_0090278BBD99__INCLUDED_ -#if _MSC_VER > 1000 +#if defined(_MSC_VER) && _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 +#endif // Insert your headers here // #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers @@ -34,7 +34,7 @@ #define INC_OLE2 // WIN32, get ole2 from windows.h /* Visual Studio 2005 has 'deprecated' many of the standard CRT functions */ -#if _MSC_VER >= 1400 +#if defined(_MSC_VER) && _MSC_VER >= 1400 # define _CRT_SECURE_NO_DEPRECATE # define _CRT_NONSTDC_NO_DEPRECATE #endif @@ -44,7 +44,7 @@ #include /* Accommodate old versions of VC that don't have a modern Platform SDK */ -#if _MSC_VER < 1300 +#if defined(_MSC_VER) && _MSC_VER < 1300 # undef UINT_PTR # define UINT_PTR UINT #endif diff --git a/src/Makefile b/src/Makefile index 02b8d6cb..7bc2820d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -395,7 +395,9 @@ CClink = $(CC) # RUBY # Uncomment this when you want to include the Ruby interface. -#CONF_OPT_RUBY = --enable-rubyinterp +# Note: you need the development package (e.g., ruby1.9.1-dev on Ubuntu). +# CONF_OPT_RUBY = --enable-rubyinterp +# CONF_OPT_RUBY = --enable-rubyinterp --with-ruby-command=ruby1.9.1 # MZSCHEME # Uncomment this when you want to include the MzScheme interface. diff --git a/src/auto/configure b/src/auto/configure index f586b8f6..c2f1d027 100755 --- a/src/auto/configure +++ b/src/auto/configure @@ -793,6 +793,7 @@ with_python_config_dir enable_tclinterp with_tclsh enable_rubyinterp +with_ruby_command enable_cscope enable_workshop enable_netbeans @@ -1503,6 +1504,7 @@ Optional Packages: --with-plthome=PLTHOME Use PLTHOME. --with-python-config-dir=PATH Python's config directory --with-tclsh=PATH which tclsh to use (default: tclsh8.0) + --with-ruby-command=RUBY name of the Ruby command (default: ruby) --with-x use the X Window System --with-gtk-prefix=PFX Prefix where GTK is installed (optional) --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional) @@ -5703,9 +5705,21 @@ fi { $as_echo "$as_me:$LINENO: result: $enable_rubyinterp" >&5 $as_echo "$enable_rubyinterp" >&6; } if test "$enable_rubyinterp" = "yes"; then + { $as_echo "$as_me:$LINENO: checking --with-ruby-command argument" >&5 +$as_echo_n "checking --with-ruby-command argument... " >&6; } - # Extract the first word of "ruby", so it can be a program name with args. -set dummy ruby; ac_word=$2 +# Check whether --with-ruby-command was given. +if test "${with_ruby_command+set}" = set; then + withval=$with_ruby_command; RUBY_CMD="$withval"; { $as_echo "$as_me:$LINENO: result: $RUBY_CMD" >&5 +$as_echo "$RUBY_CMD" >&6; } +else + RUBY_CMD="ruby"; { $as_echo "$as_me:$LINENO: result: defaulting to $RUBY_CMD" >&5 +$as_echo "defaulting to $RUBY_CMD" >&6; } +fi + + + # Extract the first word of "$RUBY_CMD", so it can be a program name with args. +set dummy $RUBY_CMD; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_path_vi_cv_path_ruby+set}" = set; then @@ -5752,11 +5766,17 @@ $as_echo_n "checking Ruby version... " >&6; } $as_echo "OK" >&6; } { $as_echo "$as_me:$LINENO: checking Ruby header files" >&5 $as_echo_n "checking Ruby header files... " >&6; } - rubyhdrdir=`$vi_cv_path_ruby -r mkmf -e 'print Config::CONFIG["archdir"] || $hdrdir' 2>/dev/null` + rubyhdrdir=`$vi_cv_path_ruby -r mkmf -e 'print Config::CONFIG["rubyhdrdir"] || Config::CONFIG["archdir"] || $hdrdir' 2>/dev/null` if test "X$rubyhdrdir" != "X"; then { $as_echo "$as_me:$LINENO: result: $rubyhdrdir" >&5 $as_echo "$rubyhdrdir" >&6; } RUBY_CFLAGS="-I$rubyhdrdir" + rubyarch=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG["arch"]'` + if test -d "$rubyhdrdir/$rubyarch"; then + RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyhdrdir/$rubyarch" + fi + rubyversion=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG["ruby_version"].gsub(/\./, "")[0,2]'` + RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion" rubylibs=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG["LIBS"]'` if test "X$rubylibs" != "X"; then RUBY_LIBS="$rubylibs" @@ -5793,8 +5813,8 @@ $as_echo "$rubyhdrdir" >&6; } _ACEOF else - { $as_echo "$as_me:$LINENO: result: not found" >&5 -$as_echo "not found" >&6; } + { $as_echo "$as_me:$LINENO: result: not found; disabling Ruby" >&5 +$as_echo "not found; disabling Ruby" >&6; } fi else { $as_echo "$as_me:$LINENO: result: too old; need Ruby version 1.6.0 or later" >&5 diff --git a/src/configure.in b/src/configure.in index 6bc8fd75..b7187996 100644 --- a/src/configure.in +++ b/src/configure.in @@ -949,17 +949,27 @@ AC_ARG_ENABLE(rubyinterp, [enable_rubyinterp="no"]) AC_MSG_RESULT($enable_rubyinterp) if test "$enable_rubyinterp" = "yes"; then + AC_MSG_CHECKING(--with-ruby-command argument) + AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)], + RUBY_CMD="$withval"; AC_MSG_RESULT($RUBY_CMD), + RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD)) AC_SUBST(vi_cv_path_ruby) - AC_PATH_PROG(vi_cv_path_ruby, ruby) + AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD) if test "X$vi_cv_path_ruby" != "X"; then AC_MSG_CHECKING(Ruby version) if $vi_cv_path_ruby -e '(VERSION rescue RUBY_VERSION) >= "1.6.0" or exit 1' >/dev/null 2>/dev/null; then AC_MSG_RESULT(OK) AC_MSG_CHECKING(Ruby header files) - rubyhdrdir=`$vi_cv_path_ruby -r mkmf -e 'print Config::CONFIG[["archdir"]] || $hdrdir' 2>/dev/null` + rubyhdrdir=`$vi_cv_path_ruby -r mkmf -e 'print Config::CONFIG[["rubyhdrdir"]] || Config::CONFIG[["archdir"]] || $hdrdir' 2>/dev/null` if test "X$rubyhdrdir" != "X"; then AC_MSG_RESULT($rubyhdrdir) RUBY_CFLAGS="-I$rubyhdrdir" + rubyarch=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG[["arch"]]'` + if test -d "$rubyhdrdir/$rubyarch"; then + RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyhdrdir/$rubyarch" + fi + rubyversion=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG[["ruby_version"]].gsub(/\./, "")[[0,2]]'` + RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion" rubylibs=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG[["LIBS"]]'` if test "X$rubylibs" != "X"; then RUBY_LIBS="$rubylibs" @@ -997,7 +1007,7 @@ if test "$enable_rubyinterp" = "yes"; then RUBY_PRO="if_ruby.pro" AC_DEFINE(FEAT_RUBY) else - AC_MSG_RESULT(not found, disabling Ruby) + AC_MSG_RESULT(not found; disabling Ruby) fi else AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later) diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c index de8f265e..f905eaf6 100644 --- a/src/gui_gtk_x11.c +++ b/src/gui_gtk_x11.c @@ -6190,7 +6190,7 @@ gui_mch_draw_string(int row, int col, char_u *s, int len, int flags) int pcc[MAX_MCO]; /* TODO: use the composing characters */ - c = utfc_ptr2char_len(p, &pcc, len - (p - s)); + c = utfc_ptr2char_len(p, pcc, len - (p - s)); if (c >= 0x10000) /* show chars > 0xffff as ? */ c = 0xbf; buf[textlen].byte1 = c >> 8; diff --git a/src/gui_w32.c b/src/gui_w32.c index 5a43d826..3331d54d 100644 --- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -1329,6 +1329,7 @@ gui_mch_init(void) WNDCLASS wndclass; #ifdef FEAT_MBYTE const WCHAR szVimWndClassW[] = VIM_CLASSW; + const WCHAR szTextAreaClassW[] = L"VimTextArea"; WNDCLASSW wndclassw; #endif #ifdef GLOBAL_IME @@ -1479,6 +1480,28 @@ gui_mch_init(void) #endif /* Create the text area window */ +#ifdef FEAT_MBYTE + if (wide_WindowProc) + { + if (GetClassInfoW(s_hinst, szTextAreaClassW, &wndclassw) == 0) + { + wndclassw.style = CS_OWNDC; + wndclassw.lpfnWndProc = _TextAreaWndProc; + wndclassw.cbClsExtra = 0; + wndclassw.cbWndExtra = 0; + wndclassw.hInstance = s_hinst; + wndclassw.hIcon = NULL; + wndclassw.hCursor = LoadCursor(NULL, IDC_ARROW); + wndclassw.hbrBackground = NULL; + wndclassw.lpszMenuName = NULL; + wndclassw.lpszClassName = szTextAreaClassW; + + if (RegisterClassW(&wndclassw) == 0) + return FAIL; + } + } + else +#endif if (GetClassInfo(s_hinst, szTextAreaClass, &wndclass) == 0) { wndclass.style = CS_OWNDC; diff --git a/src/gui_w48.c b/src/gui_w48.c index 40af60fa..477acfa9 100644 --- a/src/gui_w48.c +++ b/src/gui_w48.c @@ -1084,13 +1084,6 @@ _TextAreaWndProc( case WM_NOTIFY: Handle_WM_Notify(hwnd, (LPNMHDR)lParam); return TRUE; #endif - /* Workaround for the problem that MyWindowProc() returns FALSE on 64 - * bit windows when cross-compiled using Mingw libraries. (Andy - * Kittner) */ - case WM_NCCREATE: - MyWindowProc(hwnd, uMsg, wParam, lParam); - return TRUE; - default: return MyWindowProc(hwnd, uMsg, wParam, lParam); } @@ -3352,7 +3345,7 @@ gui_mch_browseW( #ifdef OPENFILENAME_SIZE_VERSION_400 /* be compatible with Windows NT 4.0 */ /* TODO: what to use for OPENFILENAMEW??? */ - fileStruct.lStructSize = sizeof(OPENFILENAME_SIZE_VERSION_400); + fileStruct.lStructSize = OPENFILENAME_SIZE_VERSION_400; #else fileStruct.lStructSize = sizeof(fileStruct); #endif @@ -3513,7 +3506,7 @@ gui_mch_browse( memset(&fileStruct, 0, sizeof(OPENFILENAME)); #ifdef OPENFILENAME_SIZE_VERSION_400 /* be compatible with Windows NT 4.0 */ - fileStruct.lStructSize = sizeof(OPENFILENAME_SIZE_VERSION_400); + fileStruct.lStructSize = OPENFILENAME_SIZE_VERSION_400; #else fileStruct.lStructSize = sizeof(fileStruct); #endif diff --git a/src/if_perl.xs b/src/if_perl.xs index 1ef0eb4a..97847079 100644 --- a/src/if_perl.xs +++ b/src/if_perl.xs @@ -93,6 +93,9 @@ EXTERN_C void boot_DynaLoader __ARGS((pTHX_ CV*)); # define perl_free dll_perl_free # define Perl_get_context dll_Perl_get_context # define Perl_croak dll_Perl_croak +# if (PERL_REVISION == 5) && (PERL_VERSION >= 10) +# define Perl_croak_xs_usage dll_Perl_croak_xs_usage +# endif # ifndef PROTO # define Perl_croak_nocontext dll_Perl_croak_nocontext # define Perl_call_argv dll_Perl_call_argv @@ -202,6 +205,9 @@ static int (*perl_run)(PerlInterpreter*); static int (*perl_parse)(PerlInterpreter*, XSINIT_t, int, char**, char**); static void* (*Perl_get_context)(void); static void (*Perl_croak)(pTHX_ const char*, ...); +#if (PERL_REVISION == 5) && (PERL_VERSION >= 10) +static void (*Perl_croak_xs_usage)(pTHX_ const CV *const, const char *const params); +#endif static void (*Perl_croak_nocontext)(const char*, ...); static I32 (*Perl_dowantarray)(pTHX); static void (*Perl_free_tmps)(pTHX); @@ -306,6 +312,9 @@ static struct { {"perl_parse", (PERL_PROC*)&perl_parse}, {"Perl_get_context", (PERL_PROC*)&Perl_get_context}, {"Perl_croak", (PERL_PROC*)&Perl_croak}, +#if (PERL_REVISION == 5) && (PERL_VERSION >= 10) + {"Perl_croak_xs_usage", (PERL_PROC*)&Perl_croak_xs_usage}, +#endif {"Perl_croak_nocontext", (PERL_PROC*)&Perl_croak_nocontext}, {"Perl_dowantarray", (PERL_PROC*)&Perl_dowantarray}, {"Perl_free_tmps", (PERL_PROC*)&Perl_free_tmps}, diff --git a/src/if_ruby.c b/src/if_ruby.c index 0fed2c01..2295fa5b 100644 --- a/src/if_ruby.c +++ b/src/if_ruby.c @@ -48,7 +48,15 @@ # endif #endif +/* suggested by Ariya Mizutani */ +#if (_MSC_VER == 1200) +# undef _WIN32_WINNT +#endif + #include +#if defined(RUBY_VERSION) && RUBY_VERSION >= 19 +# include +#endif #undef EXTERN #undef _ @@ -60,6 +68,28 @@ # define __OPENTRANSPORTPROVIDERS__ #endif +/* + * Backward compatiblity for Ruby 1.8 and earlier. + * Ruby 1.9 does not provide STR2CSTR, instead StringValuePtr is provided. + * Ruby 1.9 does not provide RXXX(s)->len and RXXX(s)->ptr, instead + * RXXX_LEN(s) and RXXX_PTR(s) are provided. + */ +#ifndef StringValuePtr +# define StringValuePtr(s) STR2CSTR(s) +#endif +#ifndef RARRAY_LEN +# define RARRAY_LEN(s) RARRAY(s)->len +#endif +#ifndef RARRAY_PTR +# define RARRAY_PTR(s) RARRAY(s)->ptr +#endif +#ifndef RSTRING_LEN +# define RSTRING_LEN(s) RSTRING(s)->len +#endif +#ifndef RSTRING_PTR +# define RSTRING_PTR(s) RSTRING(s)->ptr +#endif + #include "vim.h" #include "version.h" @@ -129,13 +159,26 @@ static void ruby_vim_init(void); #define rb_str_concat dll_rb_str_concat #define rb_str_new dll_rb_str_new #define rb_str_new2 dll_rb_str_new2 -#define ruby_errinfo (*dll_ruby_errinfo) +#if defined(RUBY_VERSION) && RUBY_VERSION >= 19 +# define rb_errinfo dll_rb_errinfo +#else +# define ruby_errinfo (*dll_ruby_errinfo) +#endif #define ruby_init dll_ruby_init #define ruby_init_loadpath dll_ruby_init_loadpath +#define NtInitialize dll_NtInitialize #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 # define rb_w32_snprintf dll_rb_w32_snprintf #endif +#if defined(RUBY_VERSION) && RUBY_VERSION >= 19 +# define ruby_script dll_ruby_script +# define rb_enc_find_index dll_rb_enc_find_index +# define rb_enc_find dll_rb_enc_find +# define rb_enc_str_new dll_rb_enc_str_new +# define rb_sprintf dll_rb_sprintf +#endif + /* * Pointers for dynamic link */ @@ -183,13 +226,26 @@ static VALUE (*dll_rb_str_cat) (VALUE, const char*, long); static VALUE (*dll_rb_str_concat) (VALUE, VALUE); static VALUE (*dll_rb_str_new) (const char*, long); static VALUE (*dll_rb_str_new2) (const char*); +#if defined(RUBY_VERSION) && RUBY_VERSION >= 19 +static VALUE (*dll_rb_errinfo) (void); +#else static VALUE *dll_ruby_errinfo; +#endif static void (*dll_ruby_init) (void); static void (*dll_ruby_init_loadpath) (void); +static void (*dll_NtInitialize) (int*, char***); #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 static int (*dll_rb_w32_snprintf)(char*, size_t, const char*, ...); #endif +#if defined(RUBY_VERSION) && RUBY_VERSION >= 19 +static void (*dll_ruby_script) (const char*); +static int (*dll_rb_enc_find_index) (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_sprintf) (const char*, ...); +#endif + static HINSTANCE hinstRuby = 0; /* Instance of ruby.dll */ /* @@ -245,12 +301,24 @@ static struct {"rb_str_concat", (RUBY_PROC*)&dll_rb_str_concat}, {"rb_str_new", (RUBY_PROC*)&dll_rb_str_new}, {"rb_str_new2", (RUBY_PROC*)&dll_rb_str_new2}, +#if defined(RUBY_VERSION) && RUBY_VERSION >= 19 + {"rb_errinfo", (RUBY_PROC*)&dll_rb_errinfo}, +#else {"ruby_errinfo", (RUBY_PROC*)&dll_ruby_errinfo}, +#endif {"ruby_init", (RUBY_PROC*)&dll_ruby_init}, {"ruby_init_loadpath", (RUBY_PROC*)&dll_ruby_init_loadpath}, + {"NtInitialize", (RUBY_PROC*)&dll_NtInitialize}, #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 {"rb_w32_snprintf", (RUBY_PROC*)&dll_rb_w32_snprintf}, #endif +#if defined(RUBY_VERSION) && RUBY_VERSION >= 19 + {"ruby_script", (RUBY_PROC*)&dll_ruby_script}, + {"rb_enc_find_index", (RUBY_PROC*)&dll_rb_enc_find_index}, + {"rb_enc_find", (RUBY_PROC*)&dll_rb_enc_find}, + {"rb_enc_str_new", (RUBY_PROC*)&dll_rb_enc_str_new}, + {"rb_sprintf", (RUBY_PROC*)&dll_rb_sprintf}, +#endif {"", NULL}, }; @@ -340,6 +408,58 @@ void ex_ruby(exarg_T *eap) vim_free(script); } +/* + * In Ruby 1.9 or later, ruby String object has encoding. + * conversion buffer string of vim to ruby String object using + * VIM encoding option. + */ + static VALUE +vim_str2rb_enc_str(const char *s) +{ +#if defined(RUBY_VERSION) && RUBY_VERSION >= 19 + int isnum; + long lval; + char_u *sval; + rb_encoding *enc; + + isnum = get_option_value((char_u *)"enc", &lval, &sval, 0); + if (isnum == 0) + { + enc = rb_enc_find((char *)sval); + vim_free(sval); + if (enc) { + return rb_enc_str_new(s, strlen(s), enc); + } + } +#endif + return rb_str_new2(s); +} + + static VALUE +eval_enc_string_protect(const char *str, int *state) +{ +#if defined(RUBY_VERSION) && RUBY_VERSION >= 19 + int isnum; + long lval; + char_u *sval; + rb_encoding *enc; + VALUE v; + + isnum = get_option_value((char_u *)"enc", &lval, &sval, 0); + if (isnum == 0) + { + enc = rb_enc_find((char *)sval); + vim_free(sval); + if (enc) + { + v = rb_sprintf("#-*- coding:%s -*-\n%s", rb_enc_name(enc), str); + return rb_eval_string_protect(StringValuePtr(v), state); + } + } +#endif + return rb_eval_string_protect(str, state); +} + void ex_rubydo(exarg_T *eap) { int state; @@ -352,9 +472,9 @@ void ex_rubydo(exarg_T *eap) for (i = eap->line1; i <= eap->line2; i++) { VALUE line, oldline; - line = oldline = rb_str_new2((char *)ml_get(i)); + line = oldline = vim_str2rb_enc_str((char *)ml_get(i)); rb_lastline_set(line); - rb_eval_string_protect((char *) eap->arg, &state); + eval_enc_string_protect((char *) eap->arg, &state); if (state) { error_print(state); break; @@ -365,7 +485,7 @@ void ex_rubydo(exarg_T *eap) EMSG(_("E265: $_ must be an instance of String")); return; } - ml_replace(i, (char_u *) STR2CSTR(line), 1); + ml_replace(i, (char_u *) StringValuePtr(line), 1); changed(); #ifdef SYNTAX_HL syn_changed(i); /* recompute syntax hl. for this line */ @@ -414,9 +534,24 @@ static int ensure_ruby_initialized(void) if (ruby_enabled(TRUE)) { #endif +#ifdef _WIN32 + /* suggested by Ariya Mizutani */ + int argc = 1; + char *argv[] = {"gvim.exe"}; + NtInitialize(&argc, &argv); +#endif +#if defined(RUBY_VERSION) && RUBY_VERSION >= 19 + RUBY_INIT_STACK; +#endif ruby_init(); +#if defined(RUBY_VERSION) && RUBY_VERSION >= 19 + ruby_script("vim-ruby"); +#endif ruby_init_loadpath(); ruby_io_init(); +#if defined(RUBY_VERSION) && RUBY_VERSION >= 19 + rb_enc_find_index("encdb"); +#endif ruby_vim_init(); ruby_initialized = 1; #ifdef DYNAMIC_RUBY @@ -434,8 +569,10 @@ static int ensure_ruby_initialized(void) static void error_print(int state) { #ifndef DYNAMIC_RUBY +#if !(defined(RUBY_VERSION) && RUBY_VERSION >= 19) RUBYEXTERN VALUE ruby_errinfo; #endif +#endif VALUE eclass; VALUE einfo; char buff[BUFSIZ]; @@ -468,9 +605,14 @@ static void error_print(int state) break; case TAG_RAISE: case TAG_FATAL: +#if defined(RUBY_VERSION) && RUBY_VERSION >= 19 + eclass = CLASS_OF(rb_errinfo()); + einfo = rb_obj_as_string(rb_errinfo()); +#else eclass = CLASS_OF(ruby_errinfo); einfo = rb_obj_as_string(ruby_errinfo); - if (eclass == rb_eRuntimeError && RSTRING(einfo)->len == 0) { +#endif + if (eclass == rb_eRuntimeError && RSTRING_LEN(einfo) == 0) { EMSG(_("E272: unhandled exception")); } else { @@ -479,7 +621,7 @@ static void error_print(int state) epath = rb_class_path(eclass); vim_snprintf(buff, BUFSIZ, "%s: %s", - RSTRING(epath)->ptr, RSTRING(einfo)->ptr); + RSTRING_PTR(epath), RSTRING_PTR(einfo)); p = strchr(buff, '\n'); if (p) *p = '\0'; EMSG(buff); @@ -497,8 +639,8 @@ static VALUE vim_message(VALUE self UNUSED, VALUE str) char *buff, *p; str = rb_obj_as_string(str); - buff = ALLOCA_N(char, RSTRING(str)->len); - strcpy(buff, RSTRING(str)->ptr); + buff = ALLOCA_N(char, RSTRING_LEN(str)); + strcpy(buff, RSTRING_PTR(str)); p = strchr(buff, '\n'); if (p) *p = '\0'; MSG(buff); @@ -507,21 +649,21 @@ static VALUE vim_message(VALUE self UNUSED, VALUE str) static VALUE vim_set_option(VALUE self UNUSED, VALUE str) { - do_set((char_u *)STR2CSTR(str), 0); + do_set((char_u *)StringValuePtr(str), 0); update_screen(NOT_VALID); return Qnil; } static VALUE vim_command(VALUE self UNUSED, VALUE str) { - do_cmdline_cmd((char_u *)STR2CSTR(str)); + do_cmdline_cmd((char_u *)StringValuePtr(str)); return Qnil; } static VALUE vim_evaluate(VALUE self UNUSED, VALUE str) { #ifdef FEAT_EVAL - char_u *value = eval_to_string((char_u *)STR2CSTR(str), NULL, TRUE); + char_u *value = eval_to_string((char_u *)StringValuePtr(str), NULL, TRUE); if (value != NULL) { @@ -626,9 +768,9 @@ static VALUE get_buffer_line(buf_T *buf, linenr_T n) if (n > 0 && n <= buf->b_ml.ml_line_count) { char *line = (char *)ml_get_buf(buf, n, FALSE); - return line ? rb_str_new2(line) : Qnil; + return line ? vim_str2rb_enc_str(line) : Qnil; } - rb_raise(rb_eIndexError, "index %d out of buffer", n); + rb_raise(rb_eIndexError, "line number %ld out of range", (long)n); #ifndef __GNUC__ return Qnil; /* For stop warning */ #endif @@ -645,7 +787,7 @@ static VALUE buffer_aref(VALUE self, VALUE num) static VALUE set_buffer_line(buf_T *buf, linenr_T n, VALUE str) { - char *line = STR2CSTR(str); + char *line = StringValuePtr(str); aco_save_T aco; if (n > 0 && n <= buf->b_ml.ml_line_count && line != NULL) @@ -669,7 +811,7 @@ static VALUE set_buffer_line(buf_T *buf, linenr_T n, VALUE str) } else { - rb_raise(rb_eIndexError, "index %d out of buffer", n); + rb_raise(rb_eIndexError, "line number %ld out of range", (long)n); #ifndef __GNUC__ return Qnil; /* For stop warning */ #endif @@ -715,7 +857,7 @@ static VALUE buffer_delete(VALUE self, VALUE num) } else { - rb_raise(rb_eIndexError, "index %d out of buffer", n); + rb_raise(rb_eIndexError, "line number %ld out of range", n); } return Qnil; } @@ -723,11 +865,14 @@ static VALUE buffer_delete(VALUE self, VALUE num) static VALUE buffer_append(VALUE self, VALUE num, VALUE str) { buf_T *buf = get_buf(self); - char *line = STR2CSTR(str); + char *line = StringValuePtr(str); long n = NUM2LONG(num); aco_save_T aco; - if (n >= 0 && n <= buf->b_ml.ml_line_count && line != NULL) + if (line != NULL) { + rb_raise(rb_eIndexError, "NULL line"); + } + else if (n >= 0 && n <= buf->b_ml.ml_line_count) { /* set curwin/curbuf for "buf" and save some things */ aucmd_prepbuf(&aco, buf); @@ -749,7 +894,7 @@ static VALUE buffer_append(VALUE self, VALUE num, VALUE str) update_curbuf(NOT_VALID); } else { - rb_raise(rb_eIndexError, "index %d out of buffer", n); + rb_raise(rb_eIndexError, "line number %ld out of range", n); } return str; } @@ -890,10 +1035,10 @@ static VALUE window_set_cursor(VALUE self, VALUE pos) win_T *win = get_win(self); Check_Type(pos, T_ARRAY); - if (RARRAY(pos)->len != 2) + if (RARRAY_LEN(pos) != 2) rb_raise(rb_eArgError, "array length must be 2"); - lnum = RARRAY(pos)->ptr[0]; - col = RARRAY(pos)->ptr[1]; + lnum = RARRAY_PTR(pos)[0]; + col = RARRAY_PTR(pos)[1]; win->w_cursor.lnum = NUM2LONG(lnum); win->w_cursor.col = NUM2UINT(col); check_cursor(); /* put cursor on an existing line */ @@ -910,7 +1055,7 @@ static VALUE f_p(int argc, VALUE *argv, VALUE self UNUSED) if (i > 0) rb_str_cat(str, ", ", 2); rb_str_concat(str, rb_inspect(argv[i])); } - MSG(RSTRING(str)->ptr); + MSG(RSTRING_PTR(str)); return Qnil; } diff --git a/src/memline.c b/src/memline.c index 480e93cf..29a6e5cc 100644 --- a/src/memline.c +++ b/src/memline.c @@ -3087,12 +3087,19 @@ ml_flush_line(buf) int start; int count; int i; + static int entered = FALSE; if (buf->b_ml.ml_line_lnum == 0 || buf->b_ml.ml_mfp == NULL) return; /* nothing to do */ if (buf->b_ml.ml_flags & ML_LINE_DIRTY) { + /* This code doesn't work recursively, but Netbeans may call back here + * when obtaining the cursor position. */ + if (entered) + return; + entered = TRUE; + lnum = buf->b_ml.ml_line_lnum; new_line = buf->b_ml.ml_line_ptr; @@ -3160,6 +3167,8 @@ ml_flush_line(buf) } } vim_free(new_line); + + entered = FALSE; } buf->b_ml.ml_line_lnum = 0; diff --git a/src/move.c b/src/move.c index ad1f4d61..b4818ff1 100644 --- a/src/move.c +++ b/src/move.c @@ -1610,7 +1610,7 @@ scrollup_clamp() * Add one line above "lp->lnum". This can be a filler line, a closed fold or * a (wrapped) text line. Uses and sets "lp->fill". * Returns the height of the added line in "lp->height". - * Lines above the first one are incredibly high. + * Lines above the first one are incredibly high: MAXCOL. */ static void topline_back(lp) @@ -1942,7 +1942,7 @@ scroll_cursor_bot(min_scroll, set_topbot) { loff.lnum = curwin->w_topline; topline_back(&loff); - if (used + loff.height > curwin->w_height) + if (loff.height == MAXCOL || used + loff.height > curwin->w_height) break; used += loff.height; #ifdef FEAT_DIFF @@ -2021,7 +2021,10 @@ scroll_cursor_bot(min_scroll, set_topbot) /* Add one line above */ topline_back(&loff); - used += loff.height; + if (loff.height == MAXCOL) + used = MAXCOL; + else + used += loff.height; if (used > curwin->w_height) break; if (loff.lnum >= curwin->w_botline @@ -2175,7 +2178,10 @@ scroll_cursor_halfway(atend) if (below > above) /* add a line above the cursor */ { topline_back(&loff); - used += loff.height; + if (loff.height == MAXCOL) + used = MAXCOL; + else + used += loff.height; if (used > curwin->w_height) break; above += loff.height; @@ -2472,9 +2478,12 @@ onepage(dir, count) while (n <= curwin->w_height && loff.lnum >= 1) { topline_back(&loff); - n += loff.height; + if (loff.height == MAXCOL) + n = MAXCOL; + else + n += loff.height; } - if (n <= curwin->w_height) /* at begin of file */ + if (loff.lnum < 1) /* at begin of file */ { curwin->w_topline = 1; #ifdef FEAT_DIFF diff --git a/src/option.c b/src/option.c index 491a8d8e..99e94d5e 100644 --- a/src/option.c +++ b/src/option.c @@ -5867,6 +5867,10 @@ did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf, #endif /* update flag in swap file */ ml_setflags(curbuf); + /* Redraw needed when switching to/from "mac": a CR in the text + * will be displayed differently. */ + if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm') + redraw_curbuf_later(NOT_VALID); } } diff --git a/src/os_unix.c b/src/os_unix.c index a5f033db..5e11eea3 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -1471,6 +1471,9 @@ x_IOerror_check(dpy) { /* This function should not return, it causes exit(). Longjump instead. */ LONGJMP(lc_jump_env, 1); +# ifdef VMS + return 0; /* avoid the compiler complains about missing return value */ +# endif } # endif @@ -1490,6 +1493,9 @@ x_IOerror_handler(dpy) /* This function should not return, it causes exit(). Longjump instead. */ LONGJMP(x_jump_env, 1); +# ifdef VMS + return 0; /* avoid the compiler complains about missing return value */ +# endif } #endif diff --git a/src/version.c b/src/version.c index b7aacc13..3d1455f1 100644 --- a/src/version.c +++ b/src/version.c @@ -682,6 +682,28 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 367, +/**/ + 366, +/**/ + 365, +/**/ + 364, +/**/ + 363, +/**/ + 362, +/**/ + 361, +/**/ + 360, +/**/ + 359, +/**/ + 358, +/**/ + 357, +/**/ 356, /**/ 355, diff --git a/src/xxd/xxd.c b/src/xxd/xxd.c index c558426a..41f8a246 100644 --- a/src/xxd/xxd.c +++ b/src/xxd/xxd.c @@ -231,7 +231,7 @@ char *pname; fprintf(stderr, " or\n %s -r [-s [-]offset] [-c cols] [-ps] [infile [outfile]]\n", pname); fprintf(stderr, "Options:\n"); fprintf(stderr, " -a toggle autoskip: A single '*' replaces nul-lines. Default off.\n"); - fprintf(stderr, " -b binary digit dump (incompatible with -p,-i,-r). Default hex.\n"); + fprintf(stderr, " -b binary digit dump (incompatible with -ps,-i,-r). Default hex.\n"); fprintf(stderr, " -c cols format octets per line. Default 16 (-i: 12, -ps: 30).\n"); fprintf(stderr, " -E show characters in EBCDIC. Default ASCII.\n"); fprintf(stderr, " -g number of octets per group in normal output. Default 2.\n"); @@ -276,11 +276,11 @@ long base_off; if (c == '\r') /* Doze style input file? */ continue; -#if 0 /* this doesn't work when there is normal text after the hex codes in - the last line that looks like hex */ - if (c == ' ' || c == '\n' || c == '\t') /* allow multiple spaces */ + /* Allow multiple spaces. This doesn't work when there is normal text + * after the hex codes in the last line that looks like hex, thus only + * use it for PostScript format. */ + if (hextype == HEX_POSTSCRIPT && (c == ' ' || c == '\n' || c == '\t')) continue; -#endif n3 = n2; n2 = n1; -- 2.11.4.GIT