Karsten Hopp 4b8a0c
To: vim_dev@googlegroups.com
Karsten Hopp 4b8a0c
Subject: Patch 7.3.791
Karsten Hopp 4b8a0c
Fcc: outbox
Karsten Hopp 4b8a0c
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 4b8a0c
Mime-Version: 1.0
Karsten Hopp 4b8a0c
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 4b8a0c
Content-Transfer-Encoding: 8bit
Karsten Hopp 4b8a0c
------------
Karsten Hopp 4b8a0c
Karsten Hopp 4b8a0c
Patch 7.3.791
Karsten Hopp 4b8a0c
Problem:    MzScheme interface doesn't work propely.
Karsten Hopp 4b8a0c
Solution:   Make it work better. (Sergey Khorev)
Karsten Hopp 4b8a0c
Files:	    runtime/doc/if_mzsch.txt, src/configure.in, src/auto/configure,
Karsten Hopp 4b8a0c
	    src/eval.c, src/if_mzsch.c, src/if_mzsch.h, src/Make_ming.mak,
Karsten Hopp 4b8a0c
	    src/Make_mvc.mak, src/os_unix.c, src/proto/eval.pro,
Karsten Hopp 4b8a0c
	    src/testdir/test70.in, src/testdir/test70.ok
Karsten Hopp 4b8a0c
Karsten Hopp 4b8a0c
Karsten Hopp 4b8a0c
*** ../vim-7.3.790/runtime/doc/if_mzsch.txt	2010-08-15 21:57:14.000000000 +0200
Karsten Hopp 4b8a0c
--- runtime/doc/if_mzsch.txt	2013-01-30 14:26:44.000000000 +0100
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 11,17 ****
Karsten Hopp 4b8a0c
  3. Threads				|mzscheme-threads|
Karsten Hopp 4b8a0c
  4. Vim access from MzScheme		|mzscheme-vim|
Karsten Hopp 4b8a0c
  5. mzeval() Vim function		|mzscheme-mzeval|
Karsten Hopp 4b8a0c
! 6. Dynamic loading			|mzscheme-dynamic|
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  {Vi does not have any of these commands}
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
--- 11,18 ----
Karsten Hopp 4b8a0c
  3. Threads				|mzscheme-threads|
Karsten Hopp 4b8a0c
  4. Vim access from MzScheme		|mzscheme-vim|
Karsten Hopp 4b8a0c
  5. mzeval() Vim function		|mzscheme-mzeval|
Karsten Hopp 4b8a0c
! 6. Using Function references		|mzscheme-funcref|
Karsten Hopp 4b8a0c
! 7. Dynamic loading			|mzscheme-dynamic|
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  {Vi does not have any of these commands}
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 21,30 ****
Karsten Hopp 4b8a0c
  Based on the work of Brent Fulgham.
Karsten Hopp 4b8a0c
  Dynamic loading added by Sergey Khorev
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
! For downloading MzScheme and other info:
Karsten Hopp 4b8a0c
! 	http://www.plt-scheme.org/software/mzscheme/
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
! Note: On FreeBSD you should use the "drscheme" port.
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  ==============================================================================
Karsten Hopp 4b8a0c
  1. Commands						*mzscheme-commands*
Karsten Hopp 4b8a0c
--- 22,38 ----
Karsten Hopp 4b8a0c
  Based on the work of Brent Fulgham.
Karsten Hopp 4b8a0c
  Dynamic loading added by Sergey Khorev
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
! MzScheme and PLT Scheme names have been rebranded as Racket. For more
Karsten Hopp 4b8a0c
! information please check http://racket-lang.org
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
! Futures and places of Racket version 5.x up to and including 5.3.1 do not
Karsten Hopp 4b8a0c
! work correctly with processes created by Vim.
Karsten Hopp 4b8a0c
! The simplest solution is to build Racket on your own with these features
Karsten Hopp 4b8a0c
! disabled: >
Karsten Hopp 4b8a0c
!   ./configure --disable-futures --disable-places --prefix=your-install-prefix
Karsten Hopp 4b8a0c
! 
Karsten Hopp 4b8a0c
! To speed up the process, you might also want to use --disable-gracket and
Karsten Hopp 4b8a0c
! --disable-docs
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  ==============================================================================
Karsten Hopp 4b8a0c
  1. Commands						*mzscheme-commands*
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 155,162 ****
Karsten Hopp 4b8a0c
      (eval {expr-string})	    Evaluate the vim expression into
Karsten Hopp 4b8a0c
  				    respective MzScheme object: |Lists| are
Karsten Hopp 4b8a0c
  				    represented as Scheme lists,
Karsten Hopp 4b8a0c
! 				    |Dictionaries| as hash tables.
Karsten Hopp 4b8a0c
! 				    NOTE the name clashes with MzScheme eval
Karsten Hopp 4b8a0c
      (range-start)		    Start/End of the range passed with
Karsten Hopp 4b8a0c
      (range-end)			    the Scheme command.
Karsten Hopp 4b8a0c
      (beep)			    beep
Karsten Hopp 4b8a0c
--- 163,173 ----
Karsten Hopp 4b8a0c
      (eval {expr-string})	    Evaluate the vim expression into
Karsten Hopp 4b8a0c
  				    respective MzScheme object: |Lists| are
Karsten Hopp 4b8a0c
  				    represented as Scheme lists,
Karsten Hopp 4b8a0c
! 				    |Dictionaries| as hash tables,
Karsten Hopp 4b8a0c
! 				    |Funcref|s as functions (see also
Karsten Hopp 4b8a0c
! 				    |mzscheme-funcref|)
Karsten Hopp 4b8a0c
! 				    NOTE the name clashes with MzScheme eval,
Karsten Hopp 4b8a0c
! 				    use module qualifiers to overcome this.
Karsten Hopp 4b8a0c
      (range-start)		    Start/End of the range passed with
Karsten Hopp 4b8a0c
      (range-end)			    the Scheme command.
Karsten Hopp 4b8a0c
      (beep)			    beep
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 237,243 ****
Karsten Hopp 4b8a0c
  evaluate MzScheme expressions and pass their values to VimL.
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  ==============================================================================
Karsten Hopp 4b8a0c
! 6. Dynamic loading				    *mzscheme-dynamic* *E815*
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  On MS-Windows the MzScheme libraries can be loaded dynamically. The |:version|
Karsten Hopp 4b8a0c
  output then includes |+mzscheme/dyn|.
Karsten Hopp 4b8a0c
--- 248,270 ----
Karsten Hopp 4b8a0c
  evaluate MzScheme expressions and pass their values to VimL.
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  ==============================================================================
Karsten Hopp 4b8a0c
! 6. Using Function references				    *mzscheme-funcref*
Karsten Hopp 4b8a0c
! 
Karsten Hopp 4b8a0c
! MzScheme interface allows use of |Funcref|s so you can call Vim functions
Karsten Hopp 4b8a0c
! directly from Scheme. For instance: >
Karsten Hopp 4b8a0c
!     function! MyAdd2(arg)
Karsten Hopp 4b8a0c
! 	return a:arg + 2
Karsten Hopp 4b8a0c
!     endfunction
Karsten Hopp 4b8a0c
!     mz (define f2 (vim-eval "function(\"MyAdd2\")"))
Karsten Hopp 4b8a0c
!     mz (f2 7)
Karsten Hopp 4b8a0c
! < or : >
Karsten Hopp 4b8a0c
!     :mz (define indent (vim-eval "function('indent')"))
Karsten Hopp 4b8a0c
!     " return Vim indent for line 12
Karsten Hopp 4b8a0c
!     :mz (indent 12)
Karsten Hopp 4b8a0c
! <
Karsten Hopp 4b8a0c
! 
Karsten Hopp 4b8a0c
! ==============================================================================
Karsten Hopp 4b8a0c
! 7. Dynamic loading				    *mzscheme-dynamic* *E815*
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  On MS-Windows the MzScheme libraries can be loaded dynamically. The |:version|
Karsten Hopp 4b8a0c
  output then includes |+mzscheme/dyn|.
Karsten Hopp 4b8a0c
*** ../vim-7.3.790/src/configure.in	2012-12-12 14:25:01.000000000 +0100
Karsten Hopp 4b8a0c
--- src/configure.in	2013-01-30 14:26:44.000000000 +0100
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 617,623 ****
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
    if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Karsten Hopp 4b8a0c
      if test "x$MACOSX" = "xyes"; then
Karsten Hopp 4b8a0c
!       MZSCHEME_LIBS="-framework PLT_MzScheme"
Karsten Hopp 4b8a0c
      elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"; then
Karsten Hopp 4b8a0c
        MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"
Karsten Hopp 4b8a0c
        MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
Karsten Hopp 4b8a0c
--- 617,624 ----
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
    if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Karsten Hopp 4b8a0c
      if test "x$MACOSX" = "xyes"; then
Karsten Hopp 4b8a0c
!       MZSCHEME_LIBS="-framework Racket"
Karsten Hopp 4b8a0c
!       MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
Karsten Hopp 4b8a0c
      elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"; then
Karsten Hopp 4b8a0c
        MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"
Karsten Hopp 4b8a0c
        MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 660,665 ****
Karsten Hopp 4b8a0c
--- 661,670 ----
Karsten Hopp 4b8a0c
        else
Karsten Hopp 4b8a0c
  	if test -d $vi_cv_path_mzscheme_pfx/share/racket/collects; then
Karsten Hopp 4b8a0c
  	  SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
Karsten Hopp 4b8a0c
+ 	else
Karsten Hopp 4b8a0c
+ 	  if test -d $vi_cv_path_mzscheme_pfx/collects; then
Karsten Hopp 4b8a0c
+ 	    SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
Karsten Hopp 4b8a0c
+ 	  fi
Karsten Hopp 4b8a0c
  	fi
Karsten Hopp 4b8a0c
        fi
Karsten Hopp 4b8a0c
      fi
Karsten Hopp 4b8a0c
*** ../vim-7.3.790/src/auto/configure	2012-12-12 14:25:01.000000000 +0100
Karsten Hopp 4b8a0c
--- src/auto/configure	2013-01-30 14:27:31.000000000 +0100
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 4927,4933 ****
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
    if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Karsten Hopp 4b8a0c
      if test "x$MACOSX" = "xyes"; then
Karsten Hopp 4b8a0c
!       MZSCHEME_LIBS="-framework PLT_MzScheme"
Karsten Hopp 4b8a0c
      elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"; then
Karsten Hopp 4b8a0c
        MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"
Karsten Hopp 4b8a0c
        MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
Karsten Hopp 4b8a0c
--- 4927,4934 ----
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
    if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
Karsten Hopp 4b8a0c
      if test "x$MACOSX" = "xyes"; then
Karsten Hopp 4b8a0c
!       MZSCHEME_LIBS="-framework Racket"
Karsten Hopp 4b8a0c
!       MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
Karsten Hopp 4b8a0c
      elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"; then
Karsten Hopp 4b8a0c
        MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"
Karsten Hopp 4b8a0c
        MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 4968,4973 ****
Karsten Hopp 4b8a0c
--- 4969,4978 ----
Karsten Hopp 4b8a0c
        else
Karsten Hopp 4b8a0c
  	if test -d $vi_cv_path_mzscheme_pfx/share/racket/collects; then
Karsten Hopp 4b8a0c
  	  SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
Karsten Hopp 4b8a0c
+ 	else
Karsten Hopp 4b8a0c
+ 	  if test -d $vi_cv_path_mzscheme_pfx/collects; then
Karsten Hopp 4b8a0c
+ 	    SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
Karsten Hopp 4b8a0c
+ 	  fi
Karsten Hopp 4b8a0c
  	fi
Karsten Hopp 4b8a0c
        fi
Karsten Hopp 4b8a0c
      fi
Karsten Hopp 4b8a0c
*** ../vim-7.3.790/src/eval.c	2013-01-23 17:15:25.000000000 +0100
Karsten Hopp 4b8a0c
--- src/eval.c	2013-01-30 14:33:00.000000000 +0100
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 14333,14338 ****
Karsten Hopp 4b8a0c
--- 14333,14354 ----
Karsten Hopp 4b8a0c
      str = get_tv_string_buf(&argvars[0], buf);
Karsten Hopp 4b8a0c
      do_mzeval(str, rettv);
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
+ 
Karsten Hopp 4b8a0c
+     void
Karsten Hopp 4b8a0c
+ mzscheme_call_vim(name, args, rettv)
Karsten Hopp 4b8a0c
+     char_u	*name;
Karsten Hopp 4b8a0c
+     typval_T	*args;
Karsten Hopp 4b8a0c
+     typval_T	*rettv;
Karsten Hopp 4b8a0c
+ {
Karsten Hopp 4b8a0c
+     typval_T argvars[3];
Karsten Hopp 4b8a0c
+ 
Karsten Hopp 4b8a0c
+     argvars[0].v_type = VAR_STRING;
Karsten Hopp 4b8a0c
+     argvars[0].vval.v_string = name;
Karsten Hopp 4b8a0c
+     copy_tv(args, &argvars[1]);
Karsten Hopp 4b8a0c
+     argvars[2].v_type = VAR_UNKNOWN;
Karsten Hopp 4b8a0c
+     f_call(argvars, rettv);
Karsten Hopp 4b8a0c
+     clear_tv(&argvars[1]);
Karsten Hopp 4b8a0c
+ }
Karsten Hopp 4b8a0c
  #endif
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  /*
Karsten Hopp 4b8a0c
*** ../vim-7.3.790/src/if_mzsch.c	2012-11-28 15:37:46.000000000 +0100
Karsten Hopp 4b8a0c
--- src/if_mzsch.c	2013-01-30 14:34:37.000000000 +0100
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 1,11 ****
Karsten Hopp 4b8a0c
  /* vi:set ts=8 sts=4 sw=4:
Karsten Hopp 4b8a0c
   *
Karsten Hopp 4b8a0c
   * MzScheme interface by Sergey Khorev <sergey.khorev@gmail.com>
Karsten Hopp 4b8a0c
!  * Original work by Brent Fulgham <bfulgham@debian.org>
Karsten Hopp 4b8a0c
   * (Based on lots of help from Matthew Flatt)
Karsten Hopp 4b8a0c
   *
Karsten Hopp 4b8a0c
-  * TODO Convert byte-strings to char strings?
Karsten Hopp 4b8a0c
-  *
Karsten Hopp 4b8a0c
   * This consists of six parts:
Karsten Hopp 4b8a0c
   * 1. MzScheme interpreter main program
Karsten Hopp 4b8a0c
   * 2. Routines that handle the external interface between MzScheme and
Karsten Hopp 4b8a0c
--- 1,9 ----
Karsten Hopp 4b8a0c
  /* vi:set ts=8 sts=4 sw=4:
Karsten Hopp 4b8a0c
   *
Karsten Hopp 4b8a0c
   * MzScheme interface by Sergey Khorev <sergey.khorev@gmail.com>
Karsten Hopp 4b8a0c
!  * Based on work by Brent Fulgham <bfulgham@debian.org>
Karsten Hopp 4b8a0c
   * (Based on lots of help from Matthew Flatt)
Karsten Hopp 4b8a0c
   *
Karsten Hopp 4b8a0c
   * This consists of six parts:
Karsten Hopp 4b8a0c
   * 1. MzScheme interpreter main program
Karsten Hopp 4b8a0c
   * 2. Routines that handle the external interface between MzScheme and
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 142,148 ****
Karsten Hopp 4b8a0c
  static int do_mzscheme_command(exarg_T *, void *, Scheme_Closed_Prim *what);
Karsten Hopp 4b8a0c
  static void startup_mzscheme(void);
Karsten Hopp 4b8a0c
  static char *string_to_line(Scheme_Object *obj);
Karsten Hopp 4b8a0c
! static void do_output(char *mesg, intptr_t len);
Karsten Hopp 4b8a0c
  static void do_printf(char *format, ...);
Karsten Hopp 4b8a0c
  static void do_flush(void);
Karsten Hopp 4b8a0c
  static Scheme_Object *_apply_thunk_catch_exceptions(
Karsten Hopp 4b8a0c
--- 140,151 ----
Karsten Hopp 4b8a0c
  static int do_mzscheme_command(exarg_T *, void *, Scheme_Closed_Prim *what);
Karsten Hopp 4b8a0c
  static void startup_mzscheme(void);
Karsten Hopp 4b8a0c
  static char *string_to_line(Scheme_Object *obj);
Karsten Hopp 4b8a0c
! #if MZSCHEME_VERSION_MAJOR >= 500
Karsten Hopp 4b8a0c
! # define OUTPUT_LEN_TYPE intptr_t
Karsten Hopp 4b8a0c
! #else
Karsten Hopp 4b8a0c
! # define OUTPUT_LEN_TYPE long
Karsten Hopp 4b8a0c
! #endif
Karsten Hopp 4b8a0c
! static void do_output(char *mesg, OUTPUT_LEN_TYPE len);
Karsten Hopp 4b8a0c
  static void do_printf(char *format, ...);
Karsten Hopp 4b8a0c
  static void do_flush(void);
Karsten Hopp 4b8a0c
  static Scheme_Object *_apply_thunk_catch_exceptions(
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 166,175 ****
Karsten Hopp 4b8a0c
  static int mzscheme_env_main(Scheme_Env *env, int argc, char **argv);
Karsten Hopp 4b8a0c
  static int mzscheme_init(void);
Karsten Hopp 4b8a0c
  #ifdef FEAT_EVAL
Karsten Hopp 4b8a0c
! static Scheme_Object *vim_to_mzscheme(typval_T *vim_value, int depth,
Karsten Hopp 4b8a0c
  	Scheme_Hash_Table *visited);
Karsten Hopp 4b8a0c
! static int mzscheme_to_vim(Scheme_Object *obj, typval_T *tv, int depth,
Karsten Hopp 4b8a0c
  	Scheme_Hash_Table *visited);
Karsten Hopp 4b8a0c
  #endif
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  #ifdef MZ_PRECISE_GC
Karsten Hopp 4b8a0c
--- 169,181 ----
Karsten Hopp 4b8a0c
  static int mzscheme_env_main(Scheme_Env *env, int argc, char **argv);
Karsten Hopp 4b8a0c
  static int mzscheme_init(void);
Karsten Hopp 4b8a0c
  #ifdef FEAT_EVAL
Karsten Hopp 4b8a0c
! static Scheme_Object *vim_to_mzscheme(typval_T *vim_value);
Karsten Hopp 4b8a0c
! static Scheme_Object *vim_to_mzscheme_impl(typval_T *vim_value, int depth,
Karsten Hopp 4b8a0c
  	Scheme_Hash_Table *visited);
Karsten Hopp 4b8a0c
! static int mzscheme_to_vim(Scheme_Object *obj, typval_T *tv);
Karsten Hopp 4b8a0c
! static int mzscheme_to_vim_impl(Scheme_Object *obj, typval_T *tv, int depth,
Karsten Hopp 4b8a0c
  	Scheme_Hash_Table *visited);
Karsten Hopp 4b8a0c
+ static Scheme_Object *vim_funcref(void *data, int argc, Scheme_Object **argv);
Karsten Hopp 4b8a0c
  #endif
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  #ifdef MZ_PRECISE_GC
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 183,188 ****
Karsten Hopp 4b8a0c
--- 189,201 ----
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  static int buffer_fixup_proc(void *obj)
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
+     /* apparently not needed as the object will be uncollectable while
Karsten Hopp 4b8a0c
+      * the buffer is alive
Karsten Hopp 4b8a0c
+      */
Karsten Hopp 4b8a0c
+     /*
Karsten Hopp 4b8a0c
+     vim_mz_buffer* buf = (vim_mz_buffer*) obj;
Karsten Hopp 4b8a0c
+     buf->buf->b_mzscheme_ref = GC_fixup_self(obj);
Karsten Hopp 4b8a0c
+     */
Karsten Hopp 4b8a0c
      return buffer_size_proc(obj);
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  static int window_size_proc(void *obj UNUSED)
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 195,206 ****
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  static int window_fixup_proc(void *obj)
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
      return window_size_proc(obj);
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  #endif
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  #ifdef DYNAMIC_MZSCHEME
Karsten Hopp 4b8a0c
- 
Karsten Hopp 4b8a0c
  static Scheme_Object *dll_scheme_eof;
Karsten Hopp 4b8a0c
  static Scheme_Object *dll_scheme_false;
Karsten Hopp 4b8a0c
  static Scheme_Object *dll_scheme_void;
Karsten Hopp 4b8a0c
--- 208,233 ----
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  static int window_fixup_proc(void *obj)
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
+     /* apparently not needed as the object will be uncollectable while
Karsten Hopp 4b8a0c
+      * the window is alive
Karsten Hopp 4b8a0c
+      */
Karsten Hopp 4b8a0c
+     /*
Karsten Hopp 4b8a0c
+     vim_mz_window* win = (vim_mz_window*) obj;
Karsten Hopp 4b8a0c
+     win->win->w_mzscheme_ref = GC_fixup_self(obj);
Karsten Hopp 4b8a0c
+     */
Karsten Hopp 4b8a0c
      return window_size_proc(obj);
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
+ /* with precise GC, w_mzscheme_ref and b_mzscheme_ref are immobile boxes
Karsten Hopp 4b8a0c
+  * containing pointers to a window/buffer
Karsten Hopp 4b8a0c
+  * with conservative GC these are simply pointers*/
Karsten Hopp 4b8a0c
+ # define WINDOW_REF(win) *(vim_mz_window **)((win)->w_mzscheme_ref)
Karsten Hopp 4b8a0c
+ # define BUFFER_REF(buf) *(vim_mz_buffer **)((buf)->b_mzscheme_ref)
Karsten Hopp 4b8a0c
+ #else
Karsten Hopp 4b8a0c
+ # define WINDOW_REF(win) (vim_mz_window *)((win)->w_mzscheme_ref)
Karsten Hopp 4b8a0c
+ # define BUFFER_REF(buf) (vim_mz_buffer *)((buf)->b_mzscheme_ref)
Karsten Hopp 4b8a0c
  #endif
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  #ifdef DYNAMIC_MZSCHEME
Karsten Hopp 4b8a0c
  static Scheme_Object *dll_scheme_eof;
Karsten Hopp 4b8a0c
  static Scheme_Object *dll_scheme_false;
Karsten Hopp 4b8a0c
  static Scheme_Object *dll_scheme_void;
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 319,324 ****
Karsten Hopp 4b8a0c
--- 346,352 ----
Karsten Hopp 4b8a0c
      (Scheme_Object *s);
Karsten Hopp 4b8a0c
  static Scheme_Object *(*dll_scheme_char_string_to_path)
Karsten Hopp 4b8a0c
      (Scheme_Object *s);
Karsten Hopp 4b8a0c
+ static void *(*dll_scheme_set_collects_path)(Scheme_Object *p);
Karsten Hopp 4b8a0c
  # endif
Karsten Hopp 4b8a0c
  static Scheme_Hash_Table *(*dll_scheme_make_hash_table)(int type);
Karsten Hopp 4b8a0c
  static void (*dll_scheme_hash_set)(Scheme_Hash_Table *table,
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 378,388 ****
Karsten Hopp 4b8a0c
  # endif
Karsten Hopp 4b8a0c
  # define scheme_gc_ptr_ok dll_scheme_gc_ptr_ok
Karsten Hopp 4b8a0c
  # if MZSCHEME_VERSION_MAJOR < 299
Karsten Hopp 4b8a0c
! #  define scheme_get_sized_string_output dll_scheme_get_sized_string_output
Karsten Hopp 4b8a0c
  # else
Karsten Hopp 4b8a0c
  #  define scheme_get_sized_byte_string_output \
Karsten Hopp 4b8a0c
      dll_scheme_get_sized_byte_string_output
Karsten Hopp 4b8a0c
! # define scheme_get_param dll_scheme_get_param
Karsten Hopp 4b8a0c
  # endif
Karsten Hopp 4b8a0c
  # define scheme_intern_symbol dll_scheme_intern_symbol
Karsten Hopp 4b8a0c
  # define scheme_lookup_global dll_scheme_lookup_global
Karsten Hopp 4b8a0c
--- 406,416 ----
Karsten Hopp 4b8a0c
  # endif
Karsten Hopp 4b8a0c
  # define scheme_gc_ptr_ok dll_scheme_gc_ptr_ok
Karsten Hopp 4b8a0c
  # if MZSCHEME_VERSION_MAJOR < 299
Karsten Hopp 4b8a0c
! #  define scheme_get_sized_byte_string_output dll_scheme_get_sized_string_output
Karsten Hopp 4b8a0c
  # else
Karsten Hopp 4b8a0c
  #  define scheme_get_sized_byte_string_output \
Karsten Hopp 4b8a0c
      dll_scheme_get_sized_byte_string_output
Karsten Hopp 4b8a0c
! #  define scheme_get_param dll_scheme_get_param
Karsten Hopp 4b8a0c
  # endif
Karsten Hopp 4b8a0c
  # define scheme_intern_symbol dll_scheme_intern_symbol
Karsten Hopp 4b8a0c
  # define scheme_lookup_global dll_scheme_lookup_global
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 391,398 ****
Karsten Hopp 4b8a0c
  # define scheme_make_pair dll_scheme_make_pair
Karsten Hopp 4b8a0c
  # define scheme_make_prim_w_arity dll_scheme_make_prim_w_arity
Karsten Hopp 4b8a0c
  # if MZSCHEME_VERSION_MAJOR < 299
Karsten Hopp 4b8a0c
! #  define scheme_make_string dll_scheme_make_string
Karsten Hopp 4b8a0c
! #  define scheme_make_string_output_port dll_scheme_make_string_output_port
Karsten Hopp 4b8a0c
  # else
Karsten Hopp 4b8a0c
  #  define scheme_make_byte_string dll_scheme_make_byte_string
Karsten Hopp 4b8a0c
  #  define scheme_make_byte_string_output_port \
Karsten Hopp 4b8a0c
--- 419,426 ----
Karsten Hopp 4b8a0c
  # define scheme_make_pair dll_scheme_make_pair
Karsten Hopp 4b8a0c
  # define scheme_make_prim_w_arity dll_scheme_make_prim_w_arity
Karsten Hopp 4b8a0c
  # if MZSCHEME_VERSION_MAJOR < 299
Karsten Hopp 4b8a0c
! #  define scheme_make_byte_string dll_scheme_make_string
Karsten Hopp 4b8a0c
! #  define scheme_make_byte_string_output_port dll_scheme_make_string_output_port
Karsten Hopp 4b8a0c
  # else
Karsten Hopp 4b8a0c
  #  define scheme_make_byte_string dll_scheme_make_byte_string
Karsten Hopp 4b8a0c
  #  define scheme_make_byte_string_output_port \
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 421,426 ****
Karsten Hopp 4b8a0c
--- 449,455 ----
Karsten Hopp 4b8a0c
      dll_scheme_char_string_to_byte_string
Karsten Hopp 4b8a0c
  #  define scheme_char_string_to_path \
Karsten Hopp 4b8a0c
      dll_scheme_char_string_to_path
Karsten Hopp 4b8a0c
+ #  define scheme_set_collects_path dll_scheme_set_collects_path
Karsten Hopp 4b8a0c
  # endif
Karsten Hopp 4b8a0c
  # define scheme_make_hash_table dll_scheme_make_hash_table
Karsten Hopp 4b8a0c
  # define scheme_hash_set dll_scheme_hash_set
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 529,534 ****
Karsten Hopp 4b8a0c
--- 558,564 ----
Karsten Hopp 4b8a0c
      {"scheme_char_string_to_byte_string",
Karsten Hopp 4b8a0c
  	(void **)&dll_scheme_char_string_to_byte_string},
Karsten Hopp 4b8a0c
      {"scheme_char_string_to_path", (void **)&dll_scheme_char_string_to_path},
Karsten Hopp 4b8a0c
+     {"scheme_set_collects_path", (void **)&dll_scheme_set_collects_path},
Karsten Hopp 4b8a0c
  # endif
Karsten Hopp 4b8a0c
      {"scheme_make_hash_table", (void **)&dll_scheme_make_hash_table},
Karsten Hopp 4b8a0c
      {"scheme_hash_set", (void **)&dll_scheme_hash_set},
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 625,635 ****
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  #endif /* DYNAMIC_MZSCHEME */
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  /* need to put it here for dynamic stuff to work */
Karsten Hopp 4b8a0c
  #if defined(INCLUDE_MZSCHEME_BASE)
Karsten Hopp 4b8a0c
  # include "mzscheme_base.c"
Karsten Hopp 4b8a0c
  #elif MZSCHEME_VERSION_MAJOR >= 400
Karsten Hopp 4b8a0c
! # error MzScheme 4.x must include mzscheme_base.c, for MinGW32 you need to define MZSCHEME_GENERATE_BASE=yes
Karsten Hopp 4b8a0c
  #endif
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  /*
Karsten Hopp 4b8a0c
--- 655,694 ----
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  #endif /* DYNAMIC_MZSCHEME */
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
+ #if MZSCHEME_VERSION_MAJOR < 299
Karsten Hopp 4b8a0c
+ # define GUARANTEED_STRING_ARG(proc, num) GUARANTEE_STRING(proc, num)
Karsten Hopp 4b8a0c
+ #else
Karsten Hopp 4b8a0c
+     static Scheme_Object *
Karsten Hopp 4b8a0c
+ guaranteed_byte_string_arg(char *proc, int num, int argc, Scheme_Object **argv)
Karsten Hopp 4b8a0c
+ {
Karsten Hopp 4b8a0c
+     if (SCHEME_BYTE_STRINGP(argv[num]))
Karsten Hopp 4b8a0c
+     {
Karsten Hopp 4b8a0c
+ 	return argv[num];
Karsten Hopp 4b8a0c
+     }
Karsten Hopp 4b8a0c
+     else if (SCHEME_CHAR_STRINGP(argv[num]))
Karsten Hopp 4b8a0c
+     {
Karsten Hopp 4b8a0c
+ 	Scheme_Object *tmp = NULL;
Karsten Hopp 4b8a0c
+ 	MZ_GC_DECL_REG(2);
Karsten Hopp 4b8a0c
+ 	MZ_GC_VAR_IN_REG(0, argv[num]);
Karsten Hopp 4b8a0c
+ 	MZ_GC_VAR_IN_REG(1, tmp);
Karsten Hopp 4b8a0c
+ 	MZ_GC_REG();
Karsten Hopp 4b8a0c
+ 	tmp = scheme_char_string_to_byte_string(argv[num]);
Karsten Hopp 4b8a0c
+ 	MZ_GC_UNREG();
Karsten Hopp 4b8a0c
+ 	return tmp;
Karsten Hopp 4b8a0c
+     }
Karsten Hopp 4b8a0c
+     else
Karsten Hopp 4b8a0c
+ 	scheme_wrong_type(proc, "string", num, argc, argv);
Karsten Hopp 4b8a0c
+     /* unreachable */
Karsten Hopp 4b8a0c
+     return scheme_void;
Karsten Hopp 4b8a0c
+ }
Karsten Hopp 4b8a0c
+ # define GUARANTEED_STRING_ARG(proc, num) guaranteed_byte_string_arg(proc, num, argc, argv)
Karsten Hopp 4b8a0c
+ #endif
Karsten Hopp 4b8a0c
+ 
Karsten Hopp 4b8a0c
  /* need to put it here for dynamic stuff to work */
Karsten Hopp 4b8a0c
  #if defined(INCLUDE_MZSCHEME_BASE)
Karsten Hopp 4b8a0c
  # include "mzscheme_base.c"
Karsten Hopp 4b8a0c
  #elif MZSCHEME_VERSION_MAJOR >= 400
Karsten Hopp 4b8a0c
! # error MzScheme >=4 must include mzscheme_base.c, for MinGW32 you need to define MZSCHEME_GENERATE_BASE=yes
Karsten Hopp 4b8a0c
  #endif
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  /*
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 861,866 ****
Karsten Hopp 4b8a0c
--- 920,930 ----
Karsten Hopp 4b8a0c
      scheme_set_stack_base(stack_base, 1);
Karsten Hopp 4b8a0c
  #endif
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
+ #ifndef TRAMPOLINED_MZVIM_STARTUP
Karsten Hopp 4b8a0c
+     /* in newer versions of precise GC the initial env has been created */
Karsten Hopp 4b8a0c
+     environment = scheme_basic_env();
Karsten Hopp 4b8a0c
+ #endif
Karsten Hopp 4b8a0c
+ 
Karsten Hopp 4b8a0c
      MZ_REGISTER_STATIC(environment);
Karsten Hopp 4b8a0c
      MZ_REGISTER_STATIC(curout);
Karsten Hopp 4b8a0c
      MZ_REGISTER_STATIC(curerr);
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 869,878 ****
Karsten Hopp 4b8a0c
      MZ_REGISTER_STATIC(exn_message);
Karsten Hopp 4b8a0c
      MZ_REGISTER_STATIC(vim_exn);
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
- #ifndef TRAMPOLINED_MZVIM_STARTUP
Karsten Hopp 4b8a0c
-     /* in newer versions of precise GC the initial env has been created */
Karsten Hopp 4b8a0c
-     environment = scheme_basic_env();
Karsten Hopp 4b8a0c
- #endif
Karsten Hopp 4b8a0c
      MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  #ifdef INCLUDE_MZSCHEME_BASE
Karsten Hopp 4b8a0c
--- 933,938 ----
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 909,923 ****
Karsten Hopp 4b8a0c
  	Scheme_Object	*coll_byte_string = NULL;
Karsten Hopp 4b8a0c
  	Scheme_Object	*coll_char_string = NULL;
Karsten Hopp 4b8a0c
  	Scheme_Object	*coll_path = NULL;
Karsten Hopp 4b8a0c
- 	Scheme_Object	*coll_pair = NULL;
Karsten Hopp 4b8a0c
- 	Scheme_Config	*config = NULL;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
! 	MZ_GC_DECL_REG(5);
Karsten Hopp 4b8a0c
  	MZ_GC_VAR_IN_REG(0, coll_byte_string);
Karsten Hopp 4b8a0c
  	MZ_GC_VAR_IN_REG(1, coll_char_string);
Karsten Hopp 4b8a0c
  	MZ_GC_VAR_IN_REG(2, coll_path);
Karsten Hopp 4b8a0c
- 	MZ_GC_VAR_IN_REG(3, coll_pair);
Karsten Hopp 4b8a0c
- 	MZ_GC_VAR_IN_REG(4, config);
Karsten Hopp 4b8a0c
  	MZ_GC_REG();
Karsten Hopp 4b8a0c
  	coll_byte_string = scheme_make_byte_string(MZSCHEME_COLLECTS);
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
--- 969,979 ----
Karsten Hopp 4b8a0c
  	Scheme_Object	*coll_byte_string = NULL;
Karsten Hopp 4b8a0c
  	Scheme_Object	*coll_char_string = NULL;
Karsten Hopp 4b8a0c
  	Scheme_Object	*coll_path = NULL;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
! 	MZ_GC_DECL_REG(3);
Karsten Hopp 4b8a0c
  	MZ_GC_VAR_IN_REG(0, coll_byte_string);
Karsten Hopp 4b8a0c
  	MZ_GC_VAR_IN_REG(1, coll_char_string);
Karsten Hopp 4b8a0c
  	MZ_GC_VAR_IN_REG(2, coll_path);
Karsten Hopp 4b8a0c
  	MZ_GC_REG();
Karsten Hopp 4b8a0c
  	coll_byte_string = scheme_make_byte_string(MZSCHEME_COLLECTS);
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 925,935 ****
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  	coll_path = scheme_char_string_to_path(coll_char_string);
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
! 	coll_pair = scheme_make_pair(coll_path, scheme_null);
Karsten Hopp 4b8a0c
! 	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
! 	config = scheme_config;
Karsten Hopp 4b8a0c
! 	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
! 	scheme_set_param(config, MZCONFIG_COLLECTION_PATHS, coll_pair);
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  	MZ_GC_UNREG();
Karsten Hopp 4b8a0c
      }
Karsten Hopp 4b8a0c
--- 981,987 ----
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  	coll_path = scheme_char_string_to_path(coll_char_string);
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
! 	scheme_set_collects_path(coll_path);
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  	MZ_GC_UNREG();
Karsten Hopp 4b8a0c
      }
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 944,954 ****
Karsten Hopp 4b8a0c
  	MZ_GC_VAR_IN_REG(1, coll_pair);
Karsten Hopp 4b8a0c
  	MZ_GC_VAR_IN_REG(2, config);
Karsten Hopp 4b8a0c
  	MZ_GC_REG();
Karsten Hopp 4b8a0c
! 	coll_string = scheme_make_string(MZSCHEME_COLLECTS);
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  	coll_pair = scheme_make_pair(coll_string, scheme_null);
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
! 	config = scheme_config;
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  	scheme_set_param(config, MZCONFIG_COLLECTION_PATHS, coll_pair);
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
--- 996,1006 ----
Karsten Hopp 4b8a0c
  	MZ_GC_VAR_IN_REG(1, coll_pair);
Karsten Hopp 4b8a0c
  	MZ_GC_VAR_IN_REG(2, config);
Karsten Hopp 4b8a0c
  	MZ_GC_REG();
Karsten Hopp 4b8a0c
! 	coll_string = scheme_make_byte_string(MZSCHEME_COLLECTS);
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  	coll_pair = scheme_make_pair(coll_string, scheme_null);
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
! 	config = scheme_current_config();
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  	scheme_set_param(config, MZCONFIG_COLLECTION_PATHS, coll_pair);
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 991,997 ****
Karsten Hopp 4b8a0c
  	    MZ_GC_VAR_IN_REG(3, guard);
Karsten Hopp 4b8a0c
  	    MZ_GC_VAR_IN_REG(4, config);
Karsten Hopp 4b8a0c
  	    MZ_GC_REG();
Karsten Hopp 4b8a0c
! 	    config = scheme_config;
Karsten Hopp 4b8a0c
  	    MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  	    args[0] = scheme_get_param(config, MZCONFIG_SECURITY_GUARD);
Karsten Hopp 4b8a0c
  	    MZ_GC_CHECK();
Karsten Hopp 4b8a0c
--- 1043,1049 ----
Karsten Hopp 4b8a0c
  	    MZ_GC_VAR_IN_REG(3, guard);
Karsten Hopp 4b8a0c
  	    MZ_GC_VAR_IN_REG(4, config);
Karsten Hopp 4b8a0c
  	    MZ_GC_REG();
Karsten Hopp 4b8a0c
! 	    config = scheme_current_config();
Karsten Hopp 4b8a0c
  	    MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  	    args[0] = scheme_get_param(config, MZCONFIG_SECURITY_GUARD);
Karsten Hopp 4b8a0c
  	    MZ_GC_CHECK();
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 1055,1066 ****
Karsten Hopp 4b8a0c
  	MZ_GC_DECL_REG(1);
Karsten Hopp 4b8a0c
  	MZ_GC_VAR_IN_REG(0, config);
Karsten Hopp 4b8a0c
  	MZ_GC_REG();
Karsten Hopp 4b8a0c
! 	config = scheme_config;
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  	/* recreate ports each call effectively clearing these ones */
Karsten Hopp 4b8a0c
! 	curout = scheme_make_string_output_port();
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
! 	curerr = scheme_make_string_output_port();
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  	scheme_set_param(config, MZCONFIG_OUTPUT_PORT, curout);
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
--- 1107,1118 ----
Karsten Hopp 4b8a0c
  	MZ_GC_DECL_REG(1);
Karsten Hopp 4b8a0c
  	MZ_GC_VAR_IN_REG(0, config);
Karsten Hopp 4b8a0c
  	MZ_GC_REG();
Karsten Hopp 4b8a0c
! 	config = scheme_current_config();
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  	/* recreate ports each call effectively clearing these ones */
Karsten Hopp 4b8a0c
! 	curout = scheme_make_byte_string_output_port();
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
! 	curerr = scheme_make_byte_string_output_port();
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  	scheme_set_param(config, MZCONFIG_OUTPUT_PORT, curout);
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 1149,1161 ****
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
      if (buf->b_mzscheme_ref)
Karsten Hopp 4b8a0c
      {
Karsten Hopp 4b8a0c
! 	vim_mz_buffer *bp;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
! 	bp = buf->b_mzscheme_ref;
Karsten Hopp 4b8a0c
  	bp->buf = INVALID_BUFFER_VALUE;
Karsten Hopp 4b8a0c
! 	buf->b_mzscheme_ref = NULL;
Karsten Hopp 4b8a0c
  	scheme_gc_ptr_ok(bp);
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
      }
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
--- 1201,1221 ----
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
      if (buf->b_mzscheme_ref)
Karsten Hopp 4b8a0c
      {
Karsten Hopp 4b8a0c
! 	vim_mz_buffer *bp = NULL;
Karsten Hopp 4b8a0c
! 	MZ_GC_DECL_REG(1);
Karsten Hopp 4b8a0c
! 	MZ_GC_VAR_IN_REG(0, bp);
Karsten Hopp 4b8a0c
! 	MZ_GC_REG();
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
! 	bp = BUFFER_REF(buf);
Karsten Hopp 4b8a0c
  	bp->buf = INVALID_BUFFER_VALUE;
Karsten Hopp 4b8a0c
! #ifndef MZ_PRECISE_GC
Karsten Hopp 4b8a0c
  	scheme_gc_ptr_ok(bp);
Karsten Hopp 4b8a0c
+ #else
Karsten Hopp 4b8a0c
+ 	scheme_free_immobile_box(buf->b_mzscheme_ref);
Karsten Hopp 4b8a0c
+ #endif
Karsten Hopp 4b8a0c
+ 	buf->b_mzscheme_ref = NULL;
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
+ 	MZ_GC_UNREG();
Karsten Hopp 4b8a0c
      }
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 1167,1178 ****
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
      if (win->w_mzscheme_ref)
Karsten Hopp 4b8a0c
      {
Karsten Hopp 4b8a0c
! 	vim_mz_window *wp;
Karsten Hopp 4b8a0c
! 	wp = win->w_mzscheme_ref;
Karsten Hopp 4b8a0c
  	wp->win = INVALID_WINDOW_VALUE;
Karsten Hopp 4b8a0c
! 	win->w_mzscheme_ref = NULL;
Karsten Hopp 4b8a0c
  	scheme_gc_ptr_ok(wp);
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
      }
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
--- 1227,1246 ----
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
      if (win->w_mzscheme_ref)
Karsten Hopp 4b8a0c
      {
Karsten Hopp 4b8a0c
! 	vim_mz_window *wp = NULL;
Karsten Hopp 4b8a0c
! 	MZ_GC_DECL_REG(1);
Karsten Hopp 4b8a0c
! 	MZ_GC_VAR_IN_REG(0, wp);
Karsten Hopp 4b8a0c
! 	MZ_GC_REG();
Karsten Hopp 4b8a0c
! 	wp = WINDOW_REF(win);
Karsten Hopp 4b8a0c
  	wp->win = INVALID_WINDOW_VALUE;
Karsten Hopp 4b8a0c
! #ifndef MZ_PRECISE_GC
Karsten Hopp 4b8a0c
  	scheme_gc_ptr_ok(wp);
Karsten Hopp 4b8a0c
+ #else
Karsten Hopp 4b8a0c
+ 	scheme_free_immobile_box(win->w_mzscheme_ref);
Karsten Hopp 4b8a0c
+ #endif
Karsten Hopp 4b8a0c
+ 	win->w_mzscheme_ref = NULL;
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
+ 	MZ_GC_UNREG();
Karsten Hopp 4b8a0c
      }
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 1349,1355 ****
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      static void
Karsten Hopp 4b8a0c
! do_output(char *mesg, intptr_t len UNUSED)
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
      /* TODO: use len, the string may not be NUL terminated */
Karsten Hopp 4b8a0c
      do_intrnl_output(mesg, 0);
Karsten Hopp 4b8a0c
--- 1417,1423 ----
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      static void
Karsten Hopp 4b8a0c
! do_output(char *mesg, OUTPUT_LEN_TYPE len UNUSED)
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
      /* TODO: use len, the string may not be NUL terminated */
Karsten Hopp 4b8a0c
      do_intrnl_output(mesg, 0);
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 1371,1379 ****
Karsten Hopp 4b8a0c
  do_flush(void)
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
      char *buff;
Karsten Hopp 4b8a0c
!     intptr_t length;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     buff = scheme_get_sized_string_output(curerr, &length);
Karsten Hopp 4b8a0c
      MZ_GC_CHECK();
Karsten Hopp 4b8a0c
      if (length)
Karsten Hopp 4b8a0c
      {
Karsten Hopp 4b8a0c
--- 1439,1447 ----
Karsten Hopp 4b8a0c
  do_flush(void)
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
      char *buff;
Karsten Hopp 4b8a0c
!     OUTPUT_LEN_TYPE length;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     buff = scheme_get_sized_byte_string_output(curerr, &length);
Karsten Hopp 4b8a0c
      MZ_GC_CHECK();
Karsten Hopp 4b8a0c
      if (length)
Karsten Hopp 4b8a0c
      {
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 1381,1387 ****
Karsten Hopp 4b8a0c
  	return;
Karsten Hopp 4b8a0c
      }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     buff = scheme_get_sized_string_output(curout, &length);
Karsten Hopp 4b8a0c
      MZ_GC_CHECK();
Karsten Hopp 4b8a0c
      if (length)
Karsten Hopp 4b8a0c
  	do_output(buff, length);
Karsten Hopp 4b8a0c
--- 1449,1455 ----
Karsten Hopp 4b8a0c
  	return;
Karsten Hopp 4b8a0c
      }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     buff = scheme_get_sized_byte_string_output(curout, &length);
Karsten Hopp 4b8a0c
      MZ_GC_CHECK();
Karsten Hopp 4b8a0c
      if (length)
Karsten Hopp 4b8a0c
  	do_output(buff, length);
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 1398,1409 ****
Karsten Hopp 4b8a0c
  vim_command(void *data, int argc, Scheme_Object **argv)
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
      Vim_Prim	*prim = (Vim_Prim *)data;
Karsten Hopp 4b8a0c
!     char	*cmd = SCHEME_STR_VAL(GUARANTEE_STRING(prim->name, 0));
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      /* may be use do_cmdline_cmd? */
Karsten Hopp 4b8a0c
!     do_cmdline((char_u *)cmd, NULL, NULL, DOCMD_NOWAIT|DOCMD_VERBOSE);
Karsten Hopp 4b8a0c
      update_screen(VALID);
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      raise_if_error();
Karsten Hopp 4b8a0c
      return scheme_void;
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
--- 1466,1482 ----
Karsten Hopp 4b8a0c
  vim_command(void *data, int argc, Scheme_Object **argv)
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
      Vim_Prim	*prim = (Vim_Prim *)data;
Karsten Hopp 4b8a0c
!     Scheme_Object *cmd = NULL;
Karsten Hopp 4b8a0c
!     MZ_GC_DECL_REG(1);
Karsten Hopp 4b8a0c
!     MZ_GC_VAR_IN_REG(0, cmd);
Karsten Hopp 4b8a0c
!     MZ_GC_REG();
Karsten Hopp 4b8a0c
!     cmd = GUARANTEED_STRING_ARG(prim->name, 0);
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      /* may be use do_cmdline_cmd? */
Karsten Hopp 4b8a0c
!     do_cmdline(BYTE_STRING_VALUE(cmd), NULL, NULL, DOCMD_NOWAIT|DOCMD_VERBOSE);
Karsten Hopp 4b8a0c
      update_screen(VALID);
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
+     MZ_GC_UNREG();
Karsten Hopp 4b8a0c
      raise_if_error();
Karsten Hopp 4b8a0c
      return scheme_void;
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 1414,1439 ****
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
  #ifdef FEAT_EVAL
Karsten Hopp 4b8a0c
      Vim_Prim		*prim = (Vim_Prim *)data;
Karsten Hopp 4b8a0c
!     char		*expr;
Karsten Hopp 4b8a0c
!     Scheme_Object	*result;
Karsten Hopp 4b8a0c
!     /* hash table to store visited values to avoid infinite loops */
Karsten Hopp 4b8a0c
!     Scheme_Hash_Table	*visited = NULL;
Karsten Hopp 4b8a0c
      typval_T		*vim_result;
Karsten Hopp 4b8a0c
! 
Karsten Hopp 4b8a0c
!     MZ_GC_DECL_REG(1);
Karsten Hopp 4b8a0c
!     MZ_GC_VAR_IN_REG(0, visited);
Karsten Hopp 4b8a0c
      MZ_GC_REG();
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     visited = scheme_make_hash_table(SCHEME_hash_ptr);
Karsten Hopp 4b8a0c
!     MZ_GC_CHECK();
Karsten Hopp 4b8a0c
! 
Karsten Hopp 4b8a0c
!     expr = SCHEME_STR_VAL(GUARANTEE_STRING(prim->name, 0));
Karsten Hopp 4b8a0c
!     vim_result = eval_expr((char_u *)expr, NULL);
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      if (vim_result == NULL)
Karsten Hopp 4b8a0c
  	raise_vim_exn(_("invalid expression"));
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     result = vim_to_mzscheme(vim_result, 1, visited);
Karsten Hopp 4b8a0c
      free_tv(vim_result);
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      MZ_GC_UNREG();
Karsten Hopp 4b8a0c
--- 1487,1508 ----
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
  #ifdef FEAT_EVAL
Karsten Hopp 4b8a0c
      Vim_Prim		*prim = (Vim_Prim *)data;
Karsten Hopp 4b8a0c
!     Scheme_Object	*result = NULL;
Karsten Hopp 4b8a0c
      typval_T		*vim_result;
Karsten Hopp 4b8a0c
!     Scheme_Object *expr = NULL;
Karsten Hopp 4b8a0c
!     MZ_GC_DECL_REG(2);
Karsten Hopp 4b8a0c
!     MZ_GC_VAR_IN_REG(0, result);
Karsten Hopp 4b8a0c
!     MZ_GC_VAR_IN_REG(1, expr);
Karsten Hopp 4b8a0c
      MZ_GC_REG();
Karsten Hopp 4b8a0c
+     expr = GUARANTEED_STRING_ARG(prim->name, 0);
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     vim_result = eval_expr(BYTE_STRING_VALUE(expr), NULL);
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      if (vim_result == NULL)
Karsten Hopp 4b8a0c
  	raise_vim_exn(_("invalid expression"));
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     result = vim_to_mzscheme(vim_result);
Karsten Hopp 4b8a0c
!     MZ_GC_CHECK();
Karsten Hopp 4b8a0c
      free_tv(vim_result);
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      MZ_GC_UNREG();
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 1474,1489 ****
Karsten Hopp 4b8a0c
  get_option(void *data, int argc, Scheme_Object **argv)
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
      Vim_Prim	    *prim = (Vim_Prim *)data;
Karsten Hopp 4b8a0c
-     char_u	    *name;
Karsten Hopp 4b8a0c
      long	    value;
Karsten Hopp 4b8a0c
      char	    *strval;
Karsten Hopp 4b8a0c
      int		    rc;
Karsten Hopp 4b8a0c
!     Scheme_Object   *rval;
Karsten Hopp 4b8a0c
      int		    opt_flags = 0;
Karsten Hopp 4b8a0c
      buf_T	    *save_curb = curbuf;
Karsten Hopp 4b8a0c
      win_T	    *save_curw = curwin;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     name = (char_u *)SCHEME_STR_VAL(GUARANTEE_STRING(prim->name, 0));
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      if (argc > 1)
Karsten Hopp 4b8a0c
      {
Karsten Hopp 4b8a0c
--- 1543,1563 ----
Karsten Hopp 4b8a0c
  get_option(void *data, int argc, Scheme_Object **argv)
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
      Vim_Prim	    *prim = (Vim_Prim *)data;
Karsten Hopp 4b8a0c
      long	    value;
Karsten Hopp 4b8a0c
      char	    *strval;
Karsten Hopp 4b8a0c
      int		    rc;
Karsten Hopp 4b8a0c
!     Scheme_Object   *rval = NULL;
Karsten Hopp 4b8a0c
!     Scheme_Object   *name = NULL;
Karsten Hopp 4b8a0c
      int		    opt_flags = 0;
Karsten Hopp 4b8a0c
      buf_T	    *save_curb = curbuf;
Karsten Hopp 4b8a0c
      win_T	    *save_curw = curwin;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     MZ_GC_DECL_REG(2);
Karsten Hopp 4b8a0c
!     MZ_GC_VAR_IN_REG(0, rval);
Karsten Hopp 4b8a0c
!     MZ_GC_VAR_IN_REG(1, name);
Karsten Hopp 4b8a0c
!     MZ_GC_REG();
Karsten Hopp 4b8a0c
! 
Karsten Hopp 4b8a0c
!     name = GUARANTEED_STRING_ARG(prim->name, 0);
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      if (argc > 1)
Karsten Hopp 4b8a0c
      {
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 1513,1535 ****
Karsten Hopp 4b8a0c
  	    scheme_wrong_type(prim->name, "vim-buffer/window", 1, argc, argv);
Karsten Hopp 4b8a0c
      }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     rc = get_option_value(name, &value, (char_u **)&strval, opt_flags);
Karsten Hopp 4b8a0c
      curbuf = save_curb;
Karsten Hopp 4b8a0c
      curwin = save_curw;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      switch (rc)
Karsten Hopp 4b8a0c
      {
Karsten Hopp 4b8a0c
      case 1:
Karsten Hopp 4b8a0c
  	return scheme_make_integer_value(value);
Karsten Hopp 4b8a0c
      case 0:
Karsten Hopp 4b8a0c
! 	rval = scheme_make_string(strval);
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  	vim_free(strval);
Karsten Hopp 4b8a0c
  	return rval;
Karsten Hopp 4b8a0c
      case -1:
Karsten Hopp 4b8a0c
      case -2:
Karsten Hopp 4b8a0c
  	raise_vim_exn(_("hidden option"));
Karsten Hopp 4b8a0c
      case -3:
Karsten Hopp 4b8a0c
  	raise_vim_exn(_("unknown option"));
Karsten Hopp 4b8a0c
      }
Karsten Hopp 4b8a0c
      /* unreachable */
Karsten Hopp 4b8a0c
--- 1587,1613 ----
Karsten Hopp 4b8a0c
  	    scheme_wrong_type(prim->name, "vim-buffer/window", 1, argc, argv);
Karsten Hopp 4b8a0c
      }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     rc = get_option_value(BYTE_STRING_VALUE(name), &value, (char_u **)&strval, opt_flags);
Karsten Hopp 4b8a0c
      curbuf = save_curb;
Karsten Hopp 4b8a0c
      curwin = save_curw;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      switch (rc)
Karsten Hopp 4b8a0c
      {
Karsten Hopp 4b8a0c
      case 1:
Karsten Hopp 4b8a0c
+ 	MZ_GC_UNREG();
Karsten Hopp 4b8a0c
  	return scheme_make_integer_value(value);
Karsten Hopp 4b8a0c
      case 0:
Karsten Hopp 4b8a0c
! 	rval = scheme_make_byte_string(strval);
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  	vim_free(strval);
Karsten Hopp 4b8a0c
+ 	MZ_GC_UNREG();
Karsten Hopp 4b8a0c
  	return rval;
Karsten Hopp 4b8a0c
      case -1:
Karsten Hopp 4b8a0c
      case -2:
Karsten Hopp 4b8a0c
+ 	MZ_GC_UNREG();
Karsten Hopp 4b8a0c
  	raise_vim_exn(_("hidden option"));
Karsten Hopp 4b8a0c
      case -3:
Karsten Hopp 4b8a0c
+ 	MZ_GC_UNREG();
Karsten Hopp 4b8a0c
  	raise_vim_exn(_("unknown option"));
Karsten Hopp 4b8a0c
      }
Karsten Hopp 4b8a0c
      /* unreachable */
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 1540,1552 ****
Karsten Hopp 4b8a0c
      static Scheme_Object *
Karsten Hopp 4b8a0c
  set_option(void *data, int argc, Scheme_Object **argv)
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
!     char_u	*cmd;
Karsten Hopp 4b8a0c
      int		opt_flags = 0;
Karsten Hopp 4b8a0c
      buf_T	*save_curb = curbuf;
Karsten Hopp 4b8a0c
      win_T	*save_curw = curwin;
Karsten Hopp 4b8a0c
      Vim_Prim	*prim = (Vim_Prim *)data;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
-     GUARANTEE_STRING(prim->name, 0);
Karsten Hopp 4b8a0c
      if (argc > 1)
Karsten Hopp 4b8a0c
      {
Karsten Hopp 4b8a0c
  	if (M_global == NULL)
Karsten Hopp 4b8a0c
--- 1618,1635 ----
Karsten Hopp 4b8a0c
      static Scheme_Object *
Karsten Hopp 4b8a0c
  set_option(void *data, int argc, Scheme_Object **argv)
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
!     char_u	*command = NULL;
Karsten Hopp 4b8a0c
      int		opt_flags = 0;
Karsten Hopp 4b8a0c
      buf_T	*save_curb = curbuf;
Karsten Hopp 4b8a0c
      win_T	*save_curw = curwin;
Karsten Hopp 4b8a0c
      Vim_Prim	*prim = (Vim_Prim *)data;
Karsten Hopp 4b8a0c
+     Scheme_Object *cmd = NULL;
Karsten Hopp 4b8a0c
+ 
Karsten Hopp 4b8a0c
+     MZ_GC_DECL_REG(1);
Karsten Hopp 4b8a0c
+     MZ_GC_VAR_IN_REG(0, cmd);
Karsten Hopp 4b8a0c
+     MZ_GC_REG();
Karsten Hopp 4b8a0c
+     cmd = GUARANTEED_STRING_ARG(prim->name, 0);
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      if (argc > 1)
Karsten Hopp 4b8a0c
      {
Karsten Hopp 4b8a0c
  	if (M_global == NULL)
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 1575,1583 ****
Karsten Hopp 4b8a0c
      }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      /* do_set can modify cmd, make copy */
Karsten Hopp 4b8a0c
!     cmd = vim_strsave((char_u *)SCHEME_STR_VAL(argv[0]));
Karsten Hopp 4b8a0c
!     do_set(cmd, opt_flags);
Karsten Hopp 4b8a0c
!     vim_free(cmd);
Karsten Hopp 4b8a0c
      update_screen(NOT_VALID);
Karsten Hopp 4b8a0c
      curbuf = save_curb;
Karsten Hopp 4b8a0c
      curwin = save_curw;
Karsten Hopp 4b8a0c
--- 1658,1667 ----
Karsten Hopp 4b8a0c
      }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      /* do_set can modify cmd, make copy */
Karsten Hopp 4b8a0c
!     command = vim_strsave(BYTE_STRING_VALUE(cmd));
Karsten Hopp 4b8a0c
!     MZ_GC_UNREG();
Karsten Hopp 4b8a0c
!     do_set(command, opt_flags);
Karsten Hopp 4b8a0c
!     vim_free(command);
Karsten Hopp 4b8a0c
      update_screen(NOT_VALID);
Karsten Hopp 4b8a0c
      curbuf = save_curb;
Karsten Hopp 4b8a0c
      curwin = save_curw;
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 1639,1645 ****
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      MZ_GC_DECL_REG(1);
Karsten Hopp 4b8a0c
      MZ_GC_VAR_IN_REG(0, self);
Karsten Hopp 4b8a0c
-     MZ_GC_REG();
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      /* We need to handle deletion of windows underneath us.
Karsten Hopp 4b8a0c
       * If we add a "w_mzscheme_ref" field to the win_T structure,
Karsten Hopp 4b8a0c
--- 1723,1728 ----
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 1650,1667 ****
Karsten Hopp 4b8a0c
       * object, and reject them if the win_T *field is invalid.
Karsten Hopp 4b8a0c
       */
Karsten Hopp 4b8a0c
      if (win->w_mzscheme_ref != NULL)
Karsten Hopp 4b8a0c
! 	return win->w_mzscheme_ref;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     self = scheme_malloc_fail_ok(scheme_malloc, sizeof(vim_mz_window));
Karsten Hopp 4b8a0c
      vim_memset(self, 0, sizeof(vim_mz_window));
Karsten Hopp 4b8a0c
      scheme_dont_gc_ptr(self);	/* because win isn't visible to GC */
Karsten Hopp 4b8a0c
      MZ_GC_CHECK();
Karsten Hopp 4b8a0c
-     win->w_mzscheme_ref = self;
Karsten Hopp 4b8a0c
      self->win = win;
Karsten Hopp 4b8a0c
      self->so.type = mz_window_type;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      MZ_GC_UNREG();
Karsten Hopp 4b8a0c
!     return (Scheme_Object *)(self);
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  /* (get-win-num [window]) */
Karsten Hopp 4b8a0c
--- 1733,1756 ----
Karsten Hopp 4b8a0c
       * object, and reject them if the win_T *field is invalid.
Karsten Hopp 4b8a0c
       */
Karsten Hopp 4b8a0c
      if (win->w_mzscheme_ref != NULL)
Karsten Hopp 4b8a0c
! 	return (Scheme_Object *)WINDOW_REF(win);
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     MZ_GC_REG();
Karsten Hopp 4b8a0c
!     self = scheme_malloc_fail_ok(scheme_malloc_tagged, sizeof(vim_mz_window));
Karsten Hopp 4b8a0c
      vim_memset(self, 0, sizeof(vim_mz_window));
Karsten Hopp 4b8a0c
+ #ifndef MZ_PRECISE_GC
Karsten Hopp 4b8a0c
      scheme_dont_gc_ptr(self);	/* because win isn't visible to GC */
Karsten Hopp 4b8a0c
+ #else
Karsten Hopp 4b8a0c
+     win->w_mzscheme_ref = scheme_malloc_immobile_box(NULL);
Karsten Hopp 4b8a0c
+ #endif
Karsten Hopp 4b8a0c
+     MZ_GC_CHECK();
Karsten Hopp 4b8a0c
+     WINDOW_REF(win) = self;
Karsten Hopp 4b8a0c
      MZ_GC_CHECK();
Karsten Hopp 4b8a0c
      self->win = win;
Karsten Hopp 4b8a0c
      self->so.type = mz_window_type;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      MZ_GC_UNREG();
Karsten Hopp 4b8a0c
!     return (Scheme_Object *)self;
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  /* (get-win-num [window]) */
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 1837,1858 ****
Karsten Hopp 4b8a0c
  mzscheme_open_buffer(void *data, int argc, Scheme_Object **argv)
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
      Vim_Prim	    *prim = (Vim_Prim *)data;
Karsten Hopp 4b8a0c
-     char_u	    *fname;
Karsten Hopp 4b8a0c
      int		    num = 0;
Karsten Hopp 4b8a0c
!     Scheme_Object   *onum;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  #ifdef HAVE_SANDBOX
Karsten Hopp 4b8a0c
      sandbox_check();
Karsten Hopp 4b8a0c
  #endif
Karsten Hopp 4b8a0c
-     fname = (char_u *)SCHEME_STR_VAL(GUARANTEE_STRING(prim->name, 0));
Karsten Hopp 4b8a0c
      /* TODO make open existing file */
Karsten Hopp 4b8a0c
!     num = buflist_add(fname, BLN_LISTED | BLN_CURBUF);
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      if (num == 0)
Karsten Hopp 4b8a0c
  	raise_vim_exn(_("couldn't open buffer"));
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      onum = scheme_make_integer(num);
Karsten Hopp 4b8a0c
!     return get_buffer_by_num(data, 1, &onum);
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  /* (get-buff-by-num {buffernum}) */
Karsten Hopp 4b8a0c
--- 1926,1956 ----
Karsten Hopp 4b8a0c
  mzscheme_open_buffer(void *data, int argc, Scheme_Object **argv)
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
      Vim_Prim	    *prim = (Vim_Prim *)data;
Karsten Hopp 4b8a0c
      int		    num = 0;
Karsten Hopp 4b8a0c
!     Scheme_Object   *onum = NULL;
Karsten Hopp 4b8a0c
!     Scheme_Object   *buf = NULL;
Karsten Hopp 4b8a0c
!     Scheme_Object   *fname;
Karsten Hopp 4b8a0c
! 
Karsten Hopp 4b8a0c
!     MZ_GC_DECL_REG(3);
Karsten Hopp 4b8a0c
!     MZ_GC_VAR_IN_REG(0, onum);
Karsten Hopp 4b8a0c
!     MZ_GC_VAR_IN_REG(1, buf);
Karsten Hopp 4b8a0c
!     MZ_GC_VAR_IN_REG(2, fname);
Karsten Hopp 4b8a0c
!     MZ_GC_REG();
Karsten Hopp 4b8a0c
!     fname = GUARANTEED_STRING_ARG(prim->name, 0);
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  #ifdef HAVE_SANDBOX
Karsten Hopp 4b8a0c
      sandbox_check();
Karsten Hopp 4b8a0c
  #endif
Karsten Hopp 4b8a0c
      /* TODO make open existing file */
Karsten Hopp 4b8a0c
!     num = buflist_add(BYTE_STRING_VALUE(fname), BLN_LISTED | BLN_CURBUF);
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      if (num == 0)
Karsten Hopp 4b8a0c
  	raise_vim_exn(_("couldn't open buffer"));
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      onum = scheme_make_integer(num);
Karsten Hopp 4b8a0c
!     buf = get_buffer_by_num(data, 1, &onum);
Karsten Hopp 4b8a0c
!     MZ_GC_UNREG();
Karsten Hopp 4b8a0c
!     return buf;
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  /* (get-buff-by-num {buffernum}) */
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 1878,1900 ****
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
      Vim_Prim	*prim = (Vim_Prim *)data;
Karsten Hopp 4b8a0c
      buf_T	*buf;
Karsten Hopp 4b8a0c
!     char_u	*fname;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     fname = (char_u *)SCHEME_STR_VAL(GUARANTEE_STRING(prim->name, 0));
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      for (buf = firstbuf; buf; buf = buf->b_next)
Karsten Hopp 4b8a0c
  	if (buf->b_ffname == NULL || buf->b_sfname == NULL)
Karsten Hopp 4b8a0c
  	    /* empty string */
Karsten Hopp 4b8a0c
  	{
Karsten Hopp 4b8a0c
! 	    if (fname[0] == NUL)
Karsten Hopp 4b8a0c
! 		return buffer_new(buf);
Karsten Hopp 4b8a0c
  	}
Karsten Hopp 4b8a0c
! 	else if (!fnamecmp(buf->b_ffname, fname)
Karsten Hopp 4b8a0c
! 		|| !fnamecmp(buf->b_sfname, fname))
Karsten Hopp 4b8a0c
  	    /* either short or long filename matches */
Karsten Hopp 4b8a0c
! 	    return buffer_new(buf);
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     return scheme_false;
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  /* (get-next-buff [buffer]) */
Karsten Hopp 4b8a0c
--- 1976,2009 ----
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
      Vim_Prim	*prim = (Vim_Prim *)data;
Karsten Hopp 4b8a0c
      buf_T	*buf;
Karsten Hopp 4b8a0c
!     Scheme_Object *buffer = NULL;
Karsten Hopp 4b8a0c
!     Scheme_Object *fname = NULL;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     MZ_GC_DECL_REG(2);
Karsten Hopp 4b8a0c
!     MZ_GC_VAR_IN_REG(0, buffer);
Karsten Hopp 4b8a0c
!     MZ_GC_VAR_IN_REG(1, fname);
Karsten Hopp 4b8a0c
!     MZ_GC_REG();
Karsten Hopp 4b8a0c
!     fname = GUARANTEED_STRING_ARG(prim->name, 0);
Karsten Hopp 4b8a0c
!     buffer = scheme_false;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      for (buf = firstbuf; buf; buf = buf->b_next)
Karsten Hopp 4b8a0c
+     {
Karsten Hopp 4b8a0c
  	if (buf->b_ffname == NULL || buf->b_sfname == NULL)
Karsten Hopp 4b8a0c
  	    /* empty string */
Karsten Hopp 4b8a0c
  	{
Karsten Hopp 4b8a0c
! 	    if (BYTE_STRING_VALUE(fname)[0] == NUL)
Karsten Hopp 4b8a0c
! 		buffer = buffer_new(buf);
Karsten Hopp 4b8a0c
  	}
Karsten Hopp 4b8a0c
! 	else if (!fnamecmp(buf->b_ffname, BYTE_STRING_VALUE(fname))
Karsten Hopp 4b8a0c
! 		|| !fnamecmp(buf->b_sfname, BYTE_STRING_VALUE(fname)))
Karsten Hopp 4b8a0c
! 	{
Karsten Hopp 4b8a0c
  	    /* either short or long filename matches */
Karsten Hopp 4b8a0c
! 	    buffer = buffer_new(buf);
Karsten Hopp 4b8a0c
! 	}
Karsten Hopp 4b8a0c
!     }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     MZ_GC_UNREG();
Karsten Hopp 4b8a0c
!     return buffer;
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  /* (get-next-buff [buffer]) */
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 1951,1957 ****
Karsten Hopp 4b8a0c
      Vim_Prim	    *prim = (Vim_Prim *)data;
Karsten Hopp 4b8a0c
      vim_mz_buffer   *buf = get_buffer_arg(prim->name, 0, argc, argv);
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     return scheme_make_string((char *)buf->buf->b_ffname);
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  /* (curr-buff) */
Karsten Hopp 4b8a0c
--- 2060,2066 ----
Karsten Hopp 4b8a0c
      Vim_Prim	    *prim = (Vim_Prim *)data;
Karsten Hopp 4b8a0c
      vim_mz_buffer   *buf = get_buffer_arg(prim->name, 0, argc, argv);
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     return scheme_make_byte_string((char *)buf->buf->b_ffname);
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  /* (curr-buff) */
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 1968,1992 ****
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      MZ_GC_DECL_REG(1);
Karsten Hopp 4b8a0c
      MZ_GC_VAR_IN_REG(0, self);
Karsten Hopp 4b8a0c
-     MZ_GC_REG();
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      /* We need to handle deletion of buffers underneath us.
Karsten Hopp 4b8a0c
       * If we add a "b_mzscheme_ref" field to the buf_T structure,
Karsten Hopp 4b8a0c
       * then we can get at it in buf_freeall() in vim.
Karsten Hopp 4b8a0c
       */
Karsten Hopp 4b8a0c
      if (buf->b_mzscheme_ref)
Karsten Hopp 4b8a0c
! 	return buf->b_mzscheme_ref;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     self = scheme_malloc_fail_ok(scheme_malloc, sizeof(vim_mz_buffer));
Karsten Hopp 4b8a0c
      vim_memset(self, 0, sizeof(vim_mz_buffer));
Karsten Hopp 4b8a0c
!     scheme_dont_gc_ptr(self); /* because buf isn't visible to GC */
Karsten Hopp 4b8a0c
      MZ_GC_CHECK();
Karsten Hopp 4b8a0c
-     buf->b_mzscheme_ref = self;
Karsten Hopp 4b8a0c
      self->buf = buf;
Karsten Hopp 4b8a0c
      self->so.type = mz_buffer_type;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      MZ_GC_UNREG();
Karsten Hopp 4b8a0c
!     return (Scheme_Object *)(self);
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  /*
Karsten Hopp 4b8a0c
--- 2077,2106 ----
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      MZ_GC_DECL_REG(1);
Karsten Hopp 4b8a0c
      MZ_GC_VAR_IN_REG(0, self);
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      /* We need to handle deletion of buffers underneath us.
Karsten Hopp 4b8a0c
       * If we add a "b_mzscheme_ref" field to the buf_T structure,
Karsten Hopp 4b8a0c
       * then we can get at it in buf_freeall() in vim.
Karsten Hopp 4b8a0c
       */
Karsten Hopp 4b8a0c
      if (buf->b_mzscheme_ref)
Karsten Hopp 4b8a0c
! 	return (Scheme_Object *)BUFFER_REF(buf);
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     MZ_GC_REG();
Karsten Hopp 4b8a0c
!     self = scheme_malloc_fail_ok(scheme_malloc_tagged, sizeof(vim_mz_buffer));
Karsten Hopp 4b8a0c
      vim_memset(self, 0, sizeof(vim_mz_buffer));
Karsten Hopp 4b8a0c
! #ifndef MZ_PRECISE_GC
Karsten Hopp 4b8a0c
!     scheme_dont_gc_ptr(self);	/* because buf isn't visible to GC */
Karsten Hopp 4b8a0c
! #else
Karsten Hopp 4b8a0c
!     buf->b_mzscheme_ref = scheme_malloc_immobile_box(NULL);
Karsten Hopp 4b8a0c
! #endif
Karsten Hopp 4b8a0c
!     MZ_GC_CHECK();
Karsten Hopp 4b8a0c
!     BUFFER_REF(buf) = self;
Karsten Hopp 4b8a0c
      MZ_GC_CHECK();
Karsten Hopp 4b8a0c
      self->buf = buf;
Karsten Hopp 4b8a0c
      self->so.type = mz_buffer_type;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      MZ_GC_UNREG();
Karsten Hopp 4b8a0c
!     return (Scheme_Object *)self;
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  /*
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 2023,2029 ****
Karsten Hopp 4b8a0c
      line = ml_get_buf(buf->buf, (linenr_T)linenr, FALSE);
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      raise_if_error();
Karsten Hopp 4b8a0c
!     return scheme_make_string((char *)line);
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
--- 2137,2143 ----
Karsten Hopp 4b8a0c
      line = ml_get_buf(buf->buf, (linenr_T)linenr, FALSE);
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      raise_if_error();
Karsten Hopp 4b8a0c
!     return scheme_make_byte_string((char *)line);
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 2066,2072 ****
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      for (i = n; i >= 0; --i)
Karsten Hopp 4b8a0c
      {
Karsten Hopp 4b8a0c
! 	Scheme_Object *str = scheme_make_string(
Karsten Hopp 4b8a0c
  		       (char *)ml_get_buf(buf->buf, (linenr_T)(lo+i), FALSE));
Karsten Hopp 4b8a0c
  	raise_if_error();
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
--- 2180,2186 ----
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      for (i = n; i >= 0; --i)
Karsten Hopp 4b8a0c
      {
Karsten Hopp 4b8a0c
! 	Scheme_Object *str = scheme_make_byte_string(
Karsten Hopp 4b8a0c
  		       (char *)ml_get_buf(buf->buf, (linenr_T)(lo+i), FALSE));
Karsten Hopp 4b8a0c
  	raise_if_error();
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 2298,2305 ****
Karsten Hopp 4b8a0c
  	    MZ_GC_VAR_IN_REG(1, rest);
Karsten Hopp 4b8a0c
  	    MZ_GC_REG();
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
! 	    array = (char **)alloc(new_len * sizeof(char *));
Karsten Hopp 4b8a0c
! 	    vim_memset(array, 0, new_len * sizeof(char *));
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  	    rest = line_list;
Karsten Hopp 4b8a0c
  	    for (i = 0; i < new_len; ++i)
Karsten Hopp 4b8a0c
--- 2412,2419 ----
Karsten Hopp 4b8a0c
  	    MZ_GC_VAR_IN_REG(1, rest);
Karsten Hopp 4b8a0c
  	    MZ_GC_REG();
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
! 	    array = (char **)alloc((new_len+1)* sizeof(char *));
Karsten Hopp 4b8a0c
! 	    vim_memset(array, 0, (new_len+1) * sizeof(char *));
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  	    rest = line_list;
Karsten Hopp 4b8a0c
  	    for (i = 0; i < new_len; ++i)
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 2481,2488 ****
Karsten Hopp 4b8a0c
  	MZ_GC_VAR_IN_REG(1, rest);
Karsten Hopp 4b8a0c
  	MZ_GC_REG();
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
! 	array = (char **)alloc(size * sizeof(char *));
Karsten Hopp 4b8a0c
! 	vim_memset(array, 0, size * sizeof(char *));
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  	rest = list;
Karsten Hopp 4b8a0c
  	for (i = 0; i < size; ++i)
Karsten Hopp 4b8a0c
--- 2595,2602 ----
Karsten Hopp 4b8a0c
  	MZ_GC_VAR_IN_REG(1, rest);
Karsten Hopp 4b8a0c
  	MZ_GC_REG();
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
! 	array = (char **)alloc((size+1) * sizeof(char *));
Karsten Hopp 4b8a0c
! 	vim_memset(array, 0, (size+1) * sizeof(char *));
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  	rest = list;
Karsten Hopp 4b8a0c
  	for (i = 0; i < size; ++i)
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 2589,2595 ****
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
      char	*scheme_str = NULL;
Karsten Hopp 4b8a0c
      char	*vim_str = NULL;
Karsten Hopp 4b8a0c
!     intptr_t	len;
Karsten Hopp 4b8a0c
      int		i;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      scheme_str = scheme_display_to_string(obj, &len;;
Karsten Hopp 4b8a0c
--- 2703,2709 ----
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
      char	*scheme_str = NULL;
Karsten Hopp 4b8a0c
      char	*vim_str = NULL;
Karsten Hopp 4b8a0c
!     OUTPUT_LEN_TYPE	len;
Karsten Hopp 4b8a0c
      int		i;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      scheme_str = scheme_display_to_string(obj, &len;;
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 2598,2607 ****
Karsten Hopp 4b8a0c
       * are replacing a single line, and we must replace it with
Karsten Hopp 4b8a0c
       * a single line.
Karsten Hopp 4b8a0c
       */
Karsten Hopp 4b8a0c
!     if (memchr(scheme_str, '\n', (size_t)len))
Karsten Hopp 4b8a0c
  	scheme_signal_error(_("string cannot contain newlines"));
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     vim_str = (char *)alloc((int)(len + 1));
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      /* Create a copy of the string, with internal nulls replaced by
Karsten Hopp 4b8a0c
       * newline characters, as is the vim convention.
Karsten Hopp 4b8a0c
--- 2712,2721 ----
Karsten Hopp 4b8a0c
       * are replacing a single line, and we must replace it with
Karsten Hopp 4b8a0c
       * a single line.
Karsten Hopp 4b8a0c
       */
Karsten Hopp 4b8a0c
!     if (memchr(scheme_str, '\n', len))
Karsten Hopp 4b8a0c
  	scheme_signal_error(_("string cannot contain newlines"));
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     vim_str = (char *)alloc(len + 1);
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      /* Create a copy of the string, with internal nulls replaced by
Karsten Hopp 4b8a0c
       * newline characters, as is the vim convention.
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 2625,2637 ****
Karsten Hopp 4b8a0c
   * Convert Vim value into MzScheme, adopted from if_python.c
Karsten Hopp 4b8a0c
   */
Karsten Hopp 4b8a0c
      static Scheme_Object *
Karsten Hopp 4b8a0c
! vim_to_mzscheme(typval_T *vim_value, int depth, Scheme_Hash_Table *visited)
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
      Scheme_Object   *result = NULL;
Karsten Hopp 4b8a0c
      int		    new_value = TRUE;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     MZ_GC_DECL_REG(1);
Karsten Hopp 4b8a0c
      MZ_GC_VAR_IN_REG(0, result);
Karsten Hopp 4b8a0c
      MZ_GC_REG();
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      /* Avoid infinite recursion */
Karsten Hopp 4b8a0c
--- 2739,2773 ----
Karsten Hopp 4b8a0c
   * Convert Vim value into MzScheme, adopted from if_python.c
Karsten Hopp 4b8a0c
   */
Karsten Hopp 4b8a0c
      static Scheme_Object *
Karsten Hopp 4b8a0c
! vim_to_mzscheme(typval_T *vim_value)
Karsten Hopp 4b8a0c
! {
Karsten Hopp 4b8a0c
!     Scheme_Object	*result = NULL;
Karsten Hopp 4b8a0c
!     /* hash table to store visited values to avoid infinite loops */
Karsten Hopp 4b8a0c
!     Scheme_Hash_Table	*visited = NULL;
Karsten Hopp 4b8a0c
! 
Karsten Hopp 4b8a0c
!     MZ_GC_DECL_REG(2);
Karsten Hopp 4b8a0c
!     MZ_GC_VAR_IN_REG(0, result);
Karsten Hopp 4b8a0c
!     MZ_GC_VAR_IN_REG(1, visited);
Karsten Hopp 4b8a0c
!     MZ_GC_REG();
Karsten Hopp 4b8a0c
! 
Karsten Hopp 4b8a0c
!     visited = scheme_make_hash_table(SCHEME_hash_ptr);
Karsten Hopp 4b8a0c
!     MZ_GC_CHECK();
Karsten Hopp 4b8a0c
! 
Karsten Hopp 4b8a0c
!     result = vim_to_mzscheme_impl(vim_value, 1, visited);
Karsten Hopp 4b8a0c
! 
Karsten Hopp 4b8a0c
!     MZ_GC_UNREG();
Karsten Hopp 4b8a0c
!     return result;
Karsten Hopp 4b8a0c
! }
Karsten Hopp 4b8a0c
! 
Karsten Hopp 4b8a0c
!     static Scheme_Object *
Karsten Hopp 4b8a0c
! vim_to_mzscheme_impl(typval_T *vim_value, int depth, Scheme_Hash_Table *visited)
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
      Scheme_Object   *result = NULL;
Karsten Hopp 4b8a0c
      int		    new_value = TRUE;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     MZ_GC_DECL_REG(2);
Karsten Hopp 4b8a0c
      MZ_GC_VAR_IN_REG(0, result);
Karsten Hopp 4b8a0c
+     MZ_GC_VAR_IN_REG(1, visited);
Karsten Hopp 4b8a0c
      MZ_GC_REG();
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      /* Avoid infinite recursion */
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 2650,2657 ****
Karsten Hopp 4b8a0c
  	new_value = FALSE;
Karsten Hopp 4b8a0c
      else if (vim_value->v_type == VAR_STRING)
Karsten Hopp 4b8a0c
      {
Karsten Hopp 4b8a0c
! 	result = scheme_make_string(vim_value->vval.v_string == NULL
Karsten Hopp 4b8a0c
! 				    ? "" : (char *)vim_value->vval.v_string);
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
      }
Karsten Hopp 4b8a0c
      else if (vim_value->v_type == VAR_NUMBER)
Karsten Hopp 4b8a0c
--- 2786,2792 ----
Karsten Hopp 4b8a0c
  	new_value = FALSE;
Karsten Hopp 4b8a0c
      else if (vim_value->v_type == VAR_STRING)
Karsten Hopp 4b8a0c
      {
Karsten Hopp 4b8a0c
! 	result = scheme_make_byte_string((char *)vim_value->vval.v_string);
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
      }
Karsten Hopp 4b8a0c
      else if (vim_value->v_type == VAR_NUMBER)
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 2682,2695 ****
Karsten Hopp 4b8a0c
  	    MZ_GC_REG();
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  	    curr = list->lv_last;
Karsten Hopp 4b8a0c
! 	    obj = vim_to_mzscheme(&curr->li_tv, depth + 1, visited);
Karsten Hopp 4b8a0c
  	    result = scheme_make_pair(obj, scheme_null);
Karsten Hopp 4b8a0c
  	    MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  	    while (curr != list->lv_first)
Karsten Hopp 4b8a0c
  	    {
Karsten Hopp 4b8a0c
  		curr = curr->li_prev;
Karsten Hopp 4b8a0c
! 		obj = vim_to_mzscheme(&curr->li_tv, depth + 1, visited);
Karsten Hopp 4b8a0c
  		result = scheme_make_pair(obj, result);
Karsten Hopp 4b8a0c
  		MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  	    }
Karsten Hopp 4b8a0c
--- 2817,2830 ----
Karsten Hopp 4b8a0c
  	    MZ_GC_REG();
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  	    curr = list->lv_last;
Karsten Hopp 4b8a0c
! 	    obj = vim_to_mzscheme_impl(&curr->li_tv, depth + 1, visited);
Karsten Hopp 4b8a0c
  	    result = scheme_make_pair(obj, scheme_null);
Karsten Hopp 4b8a0c
  	    MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  	    while (curr != list->lv_first)
Karsten Hopp 4b8a0c
  	    {
Karsten Hopp 4b8a0c
  		curr = curr->li_prev;
Karsten Hopp 4b8a0c
! 		obj = vim_to_mzscheme_impl(&curr->li_tv, depth + 1, visited);
Karsten Hopp 4b8a0c
  		result = scheme_make_pair(obj, result);
Karsten Hopp 4b8a0c
  		MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  	    }
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 2722,2729 ****
Karsten Hopp 4b8a0c
  		    --todo;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  		    di = dict_lookup(hi);
Karsten Hopp 4b8a0c
! 		    obj = vim_to_mzscheme(&di->di_tv, depth + 1, visited);
Karsten Hopp 4b8a0c
! 		    key = scheme_make_string((char *)hi->hi_key);
Karsten Hopp 4b8a0c
  		    MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  		    scheme_hash_set((Scheme_Hash_Table *)result, key, obj);
Karsten Hopp 4b8a0c
  		    MZ_GC_CHECK();
Karsten Hopp 4b8a0c
--- 2857,2864 ----
Karsten Hopp 4b8a0c
  		    --todo;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  		    di = dict_lookup(hi);
Karsten Hopp 4b8a0c
! 		    obj = vim_to_mzscheme_impl(&di->di_tv, depth + 1, visited);
Karsten Hopp 4b8a0c
! 		    key = scheme_make_byte_string((char *)hi->hi_key);
Karsten Hopp 4b8a0c
  		    MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  		    scheme_hash_set((Scheme_Hash_Table *)result, key, obj);
Karsten Hopp 4b8a0c
  		    MZ_GC_CHECK();
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 2732,2737 ****
Karsten Hopp 4b8a0c
--- 2867,2888 ----
Karsten Hopp 4b8a0c
  	}
Karsten Hopp 4b8a0c
  	MZ_GC_UNREG();
Karsten Hopp 4b8a0c
      }
Karsten Hopp 4b8a0c
+     else if (vim_value->v_type == VAR_FUNC)
Karsten Hopp 4b8a0c
+     {
Karsten Hopp 4b8a0c
+ 	Scheme_Object *funcname = NULL;
Karsten Hopp 4b8a0c
+ 
Karsten Hopp 4b8a0c
+ 	MZ_GC_DECL_REG(1);
Karsten Hopp 4b8a0c
+ 	MZ_GC_VAR_IN_REG(0, funcname);
Karsten Hopp 4b8a0c
+ 	MZ_GC_REG();
Karsten Hopp 4b8a0c
+ 
Karsten Hopp 4b8a0c
+ 	funcname = scheme_make_byte_string((char *)vim_value->vval.v_string);
Karsten Hopp 4b8a0c
+ 	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
+ 	result = scheme_make_closed_prim_w_arity(vim_funcref, funcname,
Karsten Hopp 4b8a0c
+ 		(const char *)BYTE_STRING_VALUE(funcname), 0, -1);
Karsten Hopp 4b8a0c
+ 	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
+ 
Karsten Hopp 4b8a0c
+ 	MZ_GC_UNREG();
Karsten Hopp 4b8a0c
+     }
Karsten Hopp 4b8a0c
      else
Karsten Hopp 4b8a0c
      {
Karsten Hopp 4b8a0c
  	result = scheme_void;
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 2747,2757 ****
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      static int
Karsten Hopp 4b8a0c
! mzscheme_to_vim(Scheme_Object *obj, typval_T *tv, int depth,
Karsten Hopp 4b8a0c
  	Scheme_Hash_Table *visited)
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
      int		status = OK;
Karsten Hopp 4b8a0c
      typval_T	*found;
Karsten Hopp 4b8a0c
      MZ_GC_CHECK();
Karsten Hopp 4b8a0c
      if (depth > 100) /* limit the deepest recursion level */
Karsten Hopp 4b8a0c
      {
Karsten Hopp 4b8a0c
--- 2898,2939 ----
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      static int
Karsten Hopp 4b8a0c
! mzscheme_to_vim(Scheme_Object *obj, typval_T *tv)
Karsten Hopp 4b8a0c
! {
Karsten Hopp 4b8a0c
!     int i, status;
Karsten Hopp 4b8a0c
!     Scheme_Hash_Table	*visited = NULL;
Karsten Hopp 4b8a0c
! 
Karsten Hopp 4b8a0c
!     MZ_GC_DECL_REG(2);
Karsten Hopp 4b8a0c
!     MZ_GC_VAR_IN_REG(0, obj);
Karsten Hopp 4b8a0c
!     MZ_GC_VAR_IN_REG(1, visited);
Karsten Hopp 4b8a0c
!     MZ_GC_REG();
Karsten Hopp 4b8a0c
! 
Karsten Hopp 4b8a0c
!     visited = scheme_make_hash_table(SCHEME_hash_ptr);
Karsten Hopp 4b8a0c
!     MZ_GC_CHECK();
Karsten Hopp 4b8a0c
! 
Karsten Hopp 4b8a0c
!     status = mzscheme_to_vim_impl(obj, tv, 1, visited);
Karsten Hopp 4b8a0c
!     for (i = 0; i < visited->size; ++i)
Karsten Hopp 4b8a0c
!     {
Karsten Hopp 4b8a0c
! 	/* free up remembered objects */
Karsten Hopp 4b8a0c
! 	if (visited->vals[i] != NULL)
Karsten Hopp 4b8a0c
! 	    free_tv((typval_T *)visited->vals[i]);
Karsten Hopp 4b8a0c
!     }
Karsten Hopp 4b8a0c
! 
Karsten Hopp 4b8a0c
!     MZ_GC_UNREG();
Karsten Hopp 4b8a0c
!     return status;
Karsten Hopp 4b8a0c
! }
Karsten Hopp 4b8a0c
!     static int
Karsten Hopp 4b8a0c
! mzscheme_to_vim_impl(Scheme_Object *obj, typval_T *tv, int depth,
Karsten Hopp 4b8a0c
  	Scheme_Hash_Table *visited)
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
      int		status = OK;
Karsten Hopp 4b8a0c
      typval_T	*found;
Karsten Hopp 4b8a0c
+ 
Karsten Hopp 4b8a0c
+     MZ_GC_DECL_REG(2);
Karsten Hopp 4b8a0c
+     MZ_GC_VAR_IN_REG(0, obj);
Karsten Hopp 4b8a0c
+     MZ_GC_VAR_IN_REG(1, visited);
Karsten Hopp 4b8a0c
+     MZ_GC_REG();
Karsten Hopp 4b8a0c
+ 
Karsten Hopp 4b8a0c
      MZ_GC_CHECK();
Karsten Hopp 4b8a0c
      if (depth > 100) /* limit the deepest recursion level */
Karsten Hopp 4b8a0c
      {
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 2785,2795 ****
Karsten Hopp 4b8a0c
  	tv->vval.v_float = SCHEME_DBL_VAL(obj);
Karsten Hopp 4b8a0c
      }
Karsten Hopp 4b8a0c
  # endif
Karsten Hopp 4b8a0c
!     else if (SCHEME_STRINGP(obj))
Karsten Hopp 4b8a0c
      {
Karsten Hopp 4b8a0c
  	tv->v_type = VAR_STRING;
Karsten Hopp 4b8a0c
! 	tv->vval.v_string = vim_strsave((char_u *)SCHEME_STR_VAL(obj));
Karsten Hopp 4b8a0c
      }
Karsten Hopp 4b8a0c
      else if (SCHEME_VECTORP(obj) || SCHEME_NULLP(obj)
Karsten Hopp 4b8a0c
  	    || SCHEME_PAIRP(obj) || SCHEME_MUTABLE_PAIRP(obj))
Karsten Hopp 4b8a0c
      {
Karsten Hopp 4b8a0c
--- 2967,2991 ----
Karsten Hopp 4b8a0c
  	tv->vval.v_float = SCHEME_DBL_VAL(obj);
Karsten Hopp 4b8a0c
      }
Karsten Hopp 4b8a0c
  # endif
Karsten Hopp 4b8a0c
!     else if (SCHEME_BYTE_STRINGP(obj))
Karsten Hopp 4b8a0c
      {
Karsten Hopp 4b8a0c
  	tv->v_type = VAR_STRING;
Karsten Hopp 4b8a0c
! 	tv->vval.v_string = vim_strsave(BYTE_STRING_VALUE(obj));
Karsten Hopp 4b8a0c
      }
Karsten Hopp 4b8a0c
+ # if MZSCHEME_VERSION_MAJOR >= 299
Karsten Hopp 4b8a0c
+     else if (SCHEME_CHAR_STRINGP(obj))
Karsten Hopp 4b8a0c
+     {
Karsten Hopp 4b8a0c
+ 	Scheme_Object *tmp = NULL;
Karsten Hopp 4b8a0c
+ 	MZ_GC_DECL_REG(1);
Karsten Hopp 4b8a0c
+ 	MZ_GC_VAR_IN_REG(0, tmp);
Karsten Hopp 4b8a0c
+ 	MZ_GC_REG();
Karsten Hopp 4b8a0c
+ 
Karsten Hopp 4b8a0c
+ 	tmp = scheme_char_string_to_byte_string(obj);
Karsten Hopp 4b8a0c
+ 	tv->v_type = VAR_STRING;
Karsten Hopp 4b8a0c
+ 	tv->vval.v_string = vim_strsave(BYTE_STRING_VALUE(tmp));
Karsten Hopp 4b8a0c
+ 	MZ_GC_UNREG();
Karsten Hopp 4b8a0c
+     }
Karsten Hopp 4b8a0c
+ #endif
Karsten Hopp 4b8a0c
      else if (SCHEME_VECTORP(obj) || SCHEME_NULLP(obj)
Karsten Hopp 4b8a0c
  	    || SCHEME_PAIRP(obj) || SCHEME_MUTABLE_PAIRP(obj))
Karsten Hopp 4b8a0c
      {
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 2829,2835 ****
Karsten Hopp 4b8a0c
  		    for (i = 0; i < SCHEME_VEC_SIZE(obj); ++i)
Karsten Hopp 4b8a0c
  		    {
Karsten Hopp 4b8a0c
  			cval = SCHEME_VEC_ELS(obj)[i];
Karsten Hopp 4b8a0c
! 			status = mzscheme_to_vim(cval, v, depth + 1, visited);
Karsten Hopp 4b8a0c
  			if (status == FAIL)
Karsten Hopp 4b8a0c
  			    break;
Karsten Hopp 4b8a0c
  			status = list_append_tv(list, v);
Karsten Hopp 4b8a0c
--- 3025,3031 ----
Karsten Hopp 4b8a0c
  		    for (i = 0; i < SCHEME_VEC_SIZE(obj); ++i)
Karsten Hopp 4b8a0c
  		    {
Karsten Hopp 4b8a0c
  			cval = SCHEME_VEC_ELS(obj)[i];
Karsten Hopp 4b8a0c
! 			status = mzscheme_to_vim_impl(cval, v, depth + 1, visited);
Karsten Hopp 4b8a0c
  			if (status == FAIL)
Karsten Hopp 4b8a0c
  			    break;
Karsten Hopp 4b8a0c
  			status = list_append_tv(list, v);
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 2845,2851 ****
Karsten Hopp 4b8a0c
  			    curr = SCHEME_CDR(curr))
Karsten Hopp 4b8a0c
  		    {
Karsten Hopp 4b8a0c
  			cval = SCHEME_CAR(curr);
Karsten Hopp 4b8a0c
! 			status = mzscheme_to_vim(cval, v, depth + 1, visited);
Karsten Hopp 4b8a0c
  			if (status == FAIL)
Karsten Hopp 4b8a0c
  			    break;
Karsten Hopp 4b8a0c
  			status = list_append_tv(list, v);
Karsten Hopp 4b8a0c
--- 3041,3047 ----
Karsten Hopp 4b8a0c
  			    curr = SCHEME_CDR(curr))
Karsten Hopp 4b8a0c
  		    {
Karsten Hopp 4b8a0c
  			cval = SCHEME_CAR(curr);
Karsten Hopp 4b8a0c
! 			status = mzscheme_to_vim_impl(cval, v, depth + 1, visited);
Karsten Hopp 4b8a0c
  			if (status == FAIL)
Karsten Hopp 4b8a0c
  			    break;
Karsten Hopp 4b8a0c
  			status = list_append_tv(list, v);
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 2857,2863 ****
Karsten Hopp 4b8a0c
  		     * need to handle the last element */
Karsten Hopp 4b8a0c
  		    if (status == OK && !SCHEME_NULLP(curr))
Karsten Hopp 4b8a0c
  		    {
Karsten Hopp 4b8a0c
! 			status = mzscheme_to_vim(cval, v, depth + 1, visited);
Karsten Hopp 4b8a0c
  			if (status == OK)
Karsten Hopp 4b8a0c
  			{
Karsten Hopp 4b8a0c
  			    status = list_append_tv(list, v);
Karsten Hopp 4b8a0c
--- 3053,3059 ----
Karsten Hopp 4b8a0c
  		     * need to handle the last element */
Karsten Hopp 4b8a0c
  		    if (status == OK && !SCHEME_NULLP(curr))
Karsten Hopp 4b8a0c
  		    {
Karsten Hopp 4b8a0c
! 			status = mzscheme_to_vim_impl(cval, v, depth + 1, visited);
Karsten Hopp 4b8a0c
  			if (status == OK)
Karsten Hopp 4b8a0c
  			{
Karsten Hopp 4b8a0c
  			    status = list_append_tv(list, v);
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 2905,2911 ****
Karsten Hopp 4b8a0c
  		    dictitem_T  *item = dictitem_alloc((char_u *)string_to_line(
Karsten Hopp 4b8a0c
  				((Scheme_Hash_Table *) obj)->keys[i]));
Karsten Hopp 4b8a0c
  		    /* convert Scheme val to Vim and add it to the dict */
Karsten Hopp 4b8a0c
! 		    if (mzscheme_to_vim(((Scheme_Hash_Table *) obj)->vals[i],
Karsten Hopp 4b8a0c
  				    &item->di_tv, depth + 1, visited) == FAIL
Karsten Hopp 4b8a0c
  			    || dict_add(dict, item) == FAIL)
Karsten Hopp 4b8a0c
  		    {
Karsten Hopp 4b8a0c
--- 3101,3107 ----
Karsten Hopp 4b8a0c
  		    dictitem_T  *item = dictitem_alloc((char_u *)string_to_line(
Karsten Hopp 4b8a0c
  				((Scheme_Hash_Table *) obj)->keys[i]));
Karsten Hopp 4b8a0c
  		    /* convert Scheme val to Vim and add it to the dict */
Karsten Hopp 4b8a0c
! 		    if (mzscheme_to_vim_impl(((Scheme_Hash_Table *) obj)->vals[i],
Karsten Hopp 4b8a0c
  				    &item->di_tv, depth + 1, visited) == FAIL
Karsten Hopp 4b8a0c
  			    || dict_add(dict, item) == FAIL)
Karsten Hopp 4b8a0c
  		    {
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 2925,2943 ****
Karsten Hopp 4b8a0c
  	tv->v_type = VAR_STRING;
Karsten Hopp 4b8a0c
  	tv->vval.v_string = (char_u *)string_to_line(obj);
Karsten Hopp 4b8a0c
      }
Karsten Hopp 4b8a0c
      return status;
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      void
Karsten Hopp 4b8a0c
  do_mzeval(char_u *str, typval_T *rettv)
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
-     int i;
Karsten Hopp 4b8a0c
      Scheme_Object	*ret = NULL;
Karsten Hopp 4b8a0c
-     Scheme_Hash_Table	*visited = NULL;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     MZ_GC_DECL_REG(2);
Karsten Hopp 4b8a0c
      MZ_GC_VAR_IN_REG(0, ret);
Karsten Hopp 4b8a0c
-     MZ_GC_VAR_IN_REG(0, visited);
Karsten Hopp 4b8a0c
      MZ_GC_REG();
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      if (mzscheme_init())
Karsten Hopp 4b8a0c
--- 3121,3196 ----
Karsten Hopp 4b8a0c
  	tv->v_type = VAR_STRING;
Karsten Hopp 4b8a0c
  	tv->vval.v_string = (char_u *)string_to_line(obj);
Karsten Hopp 4b8a0c
      }
Karsten Hopp 4b8a0c
+     MZ_GC_UNREG();
Karsten Hopp 4b8a0c
      return status;
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
+ /* Scheme prim procedure wrapping Vim funcref */
Karsten Hopp 4b8a0c
+     static Scheme_Object *
Karsten Hopp 4b8a0c
+ vim_funcref(void *name, int argc, Scheme_Object **argv)
Karsten Hopp 4b8a0c
+ {
Karsten Hopp 4b8a0c
+     int i;
Karsten Hopp 4b8a0c
+     typval_T args;
Karsten Hopp 4b8a0c
+     int status = OK;
Karsten Hopp 4b8a0c
+     Scheme_Object *result = NULL;
Karsten Hopp 4b8a0c
+     list_T *list = list_alloc();
Karsten Hopp 4b8a0c
+ 
Karsten Hopp 4b8a0c
+     MZ_GC_DECL_REG(1);
Karsten Hopp 4b8a0c
+     MZ_GC_VAR_IN_REG(0, result);
Karsten Hopp 4b8a0c
+     MZ_GC_REG();
Karsten Hopp 4b8a0c
+ 
Karsten Hopp 4b8a0c
+     result = scheme_void;
Karsten Hopp 4b8a0c
+     if (list == NULL)
Karsten Hopp 4b8a0c
+ 	status = FAIL;
Karsten Hopp 4b8a0c
+     else
Karsten Hopp 4b8a0c
+     {
Karsten Hopp 4b8a0c
+ 	args.v_type = VAR_LIST;
Karsten Hopp 4b8a0c
+ 	args.vval.v_list = list;
Karsten Hopp 4b8a0c
+ 	++list->lv_refcount;
Karsten Hopp 4b8a0c
+ 	for (i = 0; status == OK && i < argc; ++i)
Karsten Hopp 4b8a0c
+ 	{
Karsten Hopp 4b8a0c
+ 	    typval_T *v = (typval_T *)alloc(sizeof(typval_T));
Karsten Hopp 4b8a0c
+ 	    if (v == NULL)
Karsten Hopp 4b8a0c
+ 		status = FAIL;
Karsten Hopp 4b8a0c
+ 	    else
Karsten Hopp 4b8a0c
+ 	    {
Karsten Hopp 4b8a0c
+ 		status = mzscheme_to_vim(argv[i], v);
Karsten Hopp 4b8a0c
+ 		if (status == OK)
Karsten Hopp 4b8a0c
+ 		{
Karsten Hopp 4b8a0c
+ 		    status = list_append_tv(list, v);
Karsten Hopp 4b8a0c
+ 		    clear_tv(v);
Karsten Hopp 4b8a0c
+ 		}
Karsten Hopp 4b8a0c
+ 		vim_free(v);
Karsten Hopp 4b8a0c
+ 	    }
Karsten Hopp 4b8a0c
+ 	}
Karsten Hopp 4b8a0c
+ 	if (status == OK)
Karsten Hopp 4b8a0c
+ 	{
Karsten Hopp 4b8a0c
+ 	    typval_T ret;
Karsten Hopp 4b8a0c
+ 	    ret.v_type = VAR_UNKNOWN;
Karsten Hopp 4b8a0c
+ 
Karsten Hopp 4b8a0c
+ 	    mzscheme_call_vim(BYTE_STRING_VALUE((Scheme_Object *)name), &args, &ret;;
Karsten Hopp 4b8a0c
+ 	    MZ_GC_CHECK();
Karsten Hopp 4b8a0c
+ 	    result = vim_to_mzscheme(&ret;;
Karsten Hopp 4b8a0c
+ 	    clear_tv(&ret;;
Karsten Hopp 4b8a0c
+ 	    MZ_GC_CHECK();
Karsten Hopp 4b8a0c
+ 	}
Karsten Hopp 4b8a0c
+     }
Karsten Hopp 4b8a0c
+     clear_tv(&args);
Karsten Hopp 4b8a0c
+     MZ_GC_UNREG();
Karsten Hopp 4b8a0c
+     if (status != OK)
Karsten Hopp 4b8a0c
+ 	raise_vim_exn(_("error converting Scheme values to Vim"));
Karsten Hopp 4b8a0c
+     else
Karsten Hopp 4b8a0c
+ 	raise_if_error();
Karsten Hopp 4b8a0c
+     return result;
Karsten Hopp 4b8a0c
+ }
Karsten Hopp 4b8a0c
+ 
Karsten Hopp 4b8a0c
      void
Karsten Hopp 4b8a0c
  do_mzeval(char_u *str, typval_T *rettv)
Karsten Hopp 4b8a0c
  {
Karsten Hopp 4b8a0c
      Scheme_Object	*ret = NULL;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     MZ_GC_DECL_REG(1);
Karsten Hopp 4b8a0c
      MZ_GC_VAR_IN_REG(0, ret);
Karsten Hopp 4b8a0c
      MZ_GC_REG();
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      if (mzscheme_init())
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 2947,2966 ****
Karsten Hopp 4b8a0c
      }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      MZ_GC_CHECK();
Karsten Hopp 4b8a0c
-     visited = scheme_make_hash_table(SCHEME_hash_ptr);
Karsten Hopp 4b8a0c
-     MZ_GC_CHECK();
Karsten Hopp 4b8a0c
- 
Karsten Hopp 4b8a0c
      if (eval_with_exn_handling(str, do_eval, &ret) == OK)
Karsten Hopp 4b8a0c
! 	mzscheme_to_vim(ret, rettv, 1, visited);
Karsten Hopp 4b8a0c
! 
Karsten Hopp 4b8a0c
!     for (i = 0; i < visited->size; ++i)
Karsten Hopp 4b8a0c
!     {
Karsten Hopp 4b8a0c
! 	/* free up remembered objects */
Karsten Hopp 4b8a0c
! 	if (visited->vals[i] != NULL)
Karsten Hopp 4b8a0c
! 	{
Karsten Hopp 4b8a0c
! 	    free_tv((typval_T *)visited->vals[i]);
Karsten Hopp 4b8a0c
! 	}
Karsten Hopp 4b8a0c
!     }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      MZ_GC_UNREG();
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
--- 3200,3207 ----
Karsten Hopp 4b8a0c
      }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      MZ_GC_CHECK();
Karsten Hopp 4b8a0c
      if (eval_with_exn_handling(str, do_eval, &ret) == OK)
Karsten Hopp 4b8a0c
! 	mzscheme_to_vim(ret, rettv);
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      MZ_GC_UNREG();
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 3043,3079 ****
Karsten Hopp 4b8a0c
      char	    *fmt = _("Vim error: ~a");
Karsten Hopp 4b8a0c
      Scheme_Object   *argv[2] = {NULL, NULL};
Karsten Hopp 4b8a0c
      Scheme_Object   *exn = NULL;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     MZ_GC_DECL_REG(4);
Karsten Hopp 4b8a0c
      MZ_GC_ARRAY_VAR_IN_REG(0, argv, 2);
Karsten Hopp 4b8a0c
      MZ_GC_VAR_IN_REG(3, exn);
Karsten Hopp 4b8a0c
      MZ_GC_REG();
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      if (add_info != NULL)
Karsten Hopp 4b8a0c
      {
Karsten Hopp 4b8a0c
  	char		*c_string = NULL;
Karsten Hopp 4b8a0c
- 	Scheme_Object	*byte_string = NULL;
Karsten Hopp 4b8a0c
  	Scheme_Object   *info = NULL;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  	MZ_GC_DECL_REG(3);
Karsten Hopp 4b8a0c
  	MZ_GC_VAR_IN_REG(0, c_string);
Karsten Hopp 4b8a0c
- 	MZ_GC_VAR_IN_REG(1, byte_string);
Karsten Hopp 4b8a0c
  	MZ_GC_VAR_IN_REG(2, info);
Karsten Hopp 4b8a0c
  	MZ_GC_REG();
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
! 	info = scheme_make_string(add_info);
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
! 	c_string = scheme_format(fmt, STRLEN(fmt), 1, &info, NULL);
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
! 	byte_string = scheme_make_string(c_string);
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  	argv[0] = scheme_byte_string_to_char_string(byte_string);
Karsten Hopp 4b8a0c
- 	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  	SCHEME_SET_IMMUTABLE(argv[0]);
Karsten Hopp 4b8a0c
  	MZ_GC_UNREG();
Karsten Hopp 4b8a0c
      }
Karsten Hopp 4b8a0c
      else
Karsten Hopp 4b8a0c
! 	argv[0] = scheme_make_string(_("Vim error"));
Karsten Hopp 4b8a0c
      MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  #if MZSCHEME_VERSION_MAJOR < 360
Karsten Hopp 4b8a0c
--- 3284,3324 ----
Karsten Hopp 4b8a0c
      char	    *fmt = _("Vim error: ~a");
Karsten Hopp 4b8a0c
      Scheme_Object   *argv[2] = {NULL, NULL};
Karsten Hopp 4b8a0c
      Scheme_Object   *exn = NULL;
Karsten Hopp 4b8a0c
+     Scheme_Object   *byte_string = NULL;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
!     MZ_GC_DECL_REG(5);
Karsten Hopp 4b8a0c
      MZ_GC_ARRAY_VAR_IN_REG(0, argv, 2);
Karsten Hopp 4b8a0c
      MZ_GC_VAR_IN_REG(3, exn);
Karsten Hopp 4b8a0c
+     MZ_GC_VAR_IN_REG(4, byte_string);
Karsten Hopp 4b8a0c
      MZ_GC_REG();
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      if (add_info != NULL)
Karsten Hopp 4b8a0c
      {
Karsten Hopp 4b8a0c
  	char		*c_string = NULL;
Karsten Hopp 4b8a0c
  	Scheme_Object   *info = NULL;
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  	MZ_GC_DECL_REG(3);
Karsten Hopp 4b8a0c
  	MZ_GC_VAR_IN_REG(0, c_string);
Karsten Hopp 4b8a0c
  	MZ_GC_VAR_IN_REG(2, info);
Karsten Hopp 4b8a0c
  	MZ_GC_REG();
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
! 	info = scheme_make_byte_string(add_info);
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
! 	c_string = scheme_format_utf8(fmt, STRLEN(fmt), 1, &info, NULL);
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
! 	byte_string = scheme_make_byte_string(c_string);
Karsten Hopp 4b8a0c
  	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  	argv[0] = scheme_byte_string_to_char_string(byte_string);
Karsten Hopp 4b8a0c
  	SCHEME_SET_IMMUTABLE(argv[0]);
Karsten Hopp 4b8a0c
  	MZ_GC_UNREG();
Karsten Hopp 4b8a0c
      }
Karsten Hopp 4b8a0c
      else
Karsten Hopp 4b8a0c
!     {
Karsten Hopp 4b8a0c
! 	byte_string = scheme_make_byte_string(_("Vim error"));
Karsten Hopp 4b8a0c
! 	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
! 	argv[0] = scheme_byte_string_to_char_string(byte_string);
Karsten Hopp 4b8a0c
! 	MZ_GC_CHECK();
Karsten Hopp 4b8a0c
!     }
Karsten Hopp 4b8a0c
      MZ_GC_CHECK();
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  #if MZSCHEME_VERSION_MAJOR < 360
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 3264,3270 ****
Karsten Hopp 4b8a0c
      if (curbuf->b_mzscheme_ref == NULL)
Karsten Hopp 4b8a0c
  	return (vim_mz_buffer *)buffer_new(curbuf);
Karsten Hopp 4b8a0c
      else
Karsten Hopp 4b8a0c
! 	return (vim_mz_buffer *)curbuf->b_mzscheme_ref;
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  /* return MzScheme wrapper for curwin */
Karsten Hopp 4b8a0c
--- 3509,3515 ----
Karsten Hopp 4b8a0c
      if (curbuf->b_mzscheme_ref == NULL)
Karsten Hopp 4b8a0c
  	return (vim_mz_buffer *)buffer_new(curbuf);
Karsten Hopp 4b8a0c
      else
Karsten Hopp 4b8a0c
! 	return BUFFER_REF(curbuf);
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  /* return MzScheme wrapper for curwin */
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 3274,3280 ****
Karsten Hopp 4b8a0c
      if (curwin->w_mzscheme_ref == NULL)
Karsten Hopp 4b8a0c
  	return (vim_mz_window *)window_new(curwin);
Karsten Hopp 4b8a0c
      else
Karsten Hopp 4b8a0c
! 	return (vim_mz_window *)curwin->w_mzscheme_ref;
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      static void
Karsten Hopp 4b8a0c
--- 3519,3525 ----
Karsten Hopp 4b8a0c
      if (curwin->w_mzscheme_ref == NULL)
Karsten Hopp 4b8a0c
  	return (vim_mz_window *)window_new(curwin);
Karsten Hopp 4b8a0c
      else
Karsten Hopp 4b8a0c
! 	return WINDOW_REF(curwin);
Karsten Hopp 4b8a0c
  }
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
      static void
Karsten Hopp 4b8a0c
*** ../vim-7.3.790/src/if_mzsch.h	2010-08-15 21:57:29.000000000 +0200
Karsten Hopp 4b8a0c
--- src/if_mzsch.h	2013-01-30 14:26:44.000000000 +0100
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 7,12 ****
Karsten Hopp 4b8a0c
--- 7,13 ----
Karsten Hopp 4b8a0c
  #ifdef __MINGW32__
Karsten Hopp 4b8a0c
  /* Hack to engage Cygwin-specific settings */
Karsten Hopp 4b8a0c
  # define __CYGWIN32__
Karsten Hopp 4b8a0c
+ # include <stdint.h>
Karsten Hopp 4b8a0c
  #endif
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  /* #ifdef needed for "make depend" */
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 20,50 ****
Karsten Hopp 4b8a0c
  #endif
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  #if MZSCHEME_VERSION_MAJOR >= 299
Karsten Hopp 4b8a0c
- /* macros to be compatible with 20x versions */
Karsten Hopp 4b8a0c
- # define scheme_config scheme_current_config()
Karsten Hopp 4b8a0c
- # define scheme_make_string scheme_make_byte_string
Karsten Hopp 4b8a0c
- # define scheme_make_string_output_port scheme_make_byte_string_output_port
Karsten Hopp 4b8a0c
- # define scheme_get_sized_string_output scheme_get_sized_byte_string_output
Karsten Hopp 4b8a0c
- # define scheme_write_string scheme_write_byte_string
Karsten Hopp 4b8a0c
- # define scheme_make_sized_string scheme_make_sized_byte_string
Karsten Hopp 4b8a0c
- 
Karsten Hopp 4b8a0c
  # define SCHEME_STRINGP(obj) (SCHEME_BYTE_STRINGP(obj) || SCHEME_CHAR_STRINGP(obj))
Karsten Hopp 4b8a0c
! # define SCHEME_STR_VAL(obj) SCHEME_BYTE_STR_VAL(   \
Karsten Hopp 4b8a0c
! 		(SCHEME_BYTE_STRINGP(obj) ? obj : scheme_char_string_to_byte_string(obj)))
Karsten Hopp 4b8a0c
! # define GUARANTEE_STRING(fname, argnum) GUARANTEE_TYPE(fname, argnum, SCHEME_STRINGP, "string")
Karsten Hopp 4b8a0c
! 
Karsten Hopp 4b8a0c
! # ifdef scheme_format
Karsten Hopp 4b8a0c
! #  undef scheme_format
Karsten Hopp 4b8a0c
  # endif
Karsten Hopp 4b8a0c
- # define scheme_format scheme_format_utf8
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
- # define SCHEME_GET_BYTE_STRING(obj) (SCHEME_BYTE_STRINGP(obj) ? obj :   \
Karsten Hopp 4b8a0c
- 	scheme_char_string_to_byte_string(obj))
Karsten Hopp 4b8a0c
- #else
Karsten Hopp 4b8a0c
- # define SCHEME_GET_BYTE_STRING(obj) (obj)
Karsten Hopp 4b8a0c
  # define SCHEME_BYTE_STRLEN_VAL SCHEME_STRLEN_VAL
Karsten Hopp 4b8a0c
! # define SCHEME_BYTE_STR_VAL SCHEME_STR_VAL
Karsten Hopp 4b8a0c
  # define scheme_byte_string_to_char_string(obj) (obj)
Karsten Hopp 4b8a0c
  #endif
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  /* Precise GC macros */
Karsten Hopp 4b8a0c
--- 21,44 ----
Karsten Hopp 4b8a0c
  #endif
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  #if MZSCHEME_VERSION_MAJOR >= 299
Karsten Hopp 4b8a0c
  # define SCHEME_STRINGP(obj) (SCHEME_BYTE_STRINGP(obj) || SCHEME_CHAR_STRINGP(obj))
Karsten Hopp 4b8a0c
! # define BYTE_STRING_VALUE(obj) ((char_u *)SCHEME_BYTE_STR_VAL(obj))
Karsten Hopp 4b8a0c
! #else
Karsten Hopp 4b8a0c
! /* macros for compatibility with older versions */
Karsten Hopp 4b8a0c
! # define scheme_current_config() scheme_config
Karsten Hopp 4b8a0c
! # define scheme_make_sized_byte_string scheme_make_sized_string
Karsten Hopp 4b8a0c
! # define scheme_format_utf8 scheme_format
Karsten Hopp 4b8a0c
! # ifndef DYNAMIC_MZSCHEME
Karsten Hopp 4b8a0c
! /* for dynamic MzScheme there will be separate definitions in if_mzsch.c */
Karsten Hopp 4b8a0c
! #  define scheme_get_sized_byte_string_output scheme_get_sized_string_output
Karsten Hopp 4b8a0c
! #  define scheme_make_byte_string scheme_make_string
Karsten Hopp 4b8a0c
! #  define scheme_make_byte_string_output_port scheme_make_string_output_port
Karsten Hopp 4b8a0c
  # endif
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  # define SCHEME_BYTE_STRLEN_VAL SCHEME_STRLEN_VAL
Karsten Hopp 4b8a0c
! # define BYTE_STRING_VALUE(obj) ((char_u *)SCHEME_STR_VAL(obj))
Karsten Hopp 4b8a0c
  # define scheme_byte_string_to_char_string(obj) (obj)
Karsten Hopp 4b8a0c
+ # define SCHEME_BYTE_STRINGP SCHEME_STRINGP
Karsten Hopp 4b8a0c
  #endif
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  /* Precise GC macros */
Karsten Hopp 4b8a0c
*** ../vim-7.3.790/src/Make_ming.mak	2013-01-23 13:55:16.000000000 +0100
Karsten Hopp 4b8a0c
--- src/Make_ming.mak	2013-01-30 14:26:44.000000000 +0100
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 384,389 ****
Karsten Hopp 4b8a0c
--- 384,392 ----
Karsten Hopp 4b8a0c
  ifeq (yes, $(DYNAMIC_MZSCHEME))
Karsten Hopp 4b8a0c
  CFLAGS += -DDYNAMIC_MZSCHEME -DDYNAMIC_MZSCH_DLL=\"lib$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER).dll\" -DDYNAMIC_MZGC_DLL=\"libmzgc$(MZSCHEME_VER).dll\"
Karsten Hopp 4b8a0c
  endif
Karsten Hopp 4b8a0c
+ ifeq (yes, "$(MZSCHEME_DEBUG)")
Karsten Hopp 4b8a0c
+ CFLAGS += -DMZSCHEME_FORCE_GC
Karsten Hopp 4b8a0c
+ endif
Karsten Hopp 4b8a0c
  endif
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
  ifdef RUBY
Karsten Hopp 4b8a0c
*** ../vim-7.3.790/src/Make_mvc.mak	2012-12-06 21:30:24.000000000 +0100
Karsten Hopp 4b8a0c
--- src/Make_mvc.mak	2013-01-30 14:26:44.000000000 +0100
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 1096,1102 ****
Karsten Hopp 4b8a0c
  $(OUTDIR)/if_perlsfio.obj: $(OUTDIR) if_perlsfio.c  $(INCL)
Karsten Hopp 4b8a0c
  	$(CC) $(CFLAGS) $(PERL_INC) if_perlsfio.c
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
! $(OUTDIR)/if_mzsch.obj: $(OUTDIR) if_mzsch.c  $(INCL) $(MZSCHEME_EXTRA_DEP)
Karsten Hopp 4b8a0c
  	$(CC) $(CFLAGS) if_mzsch.c \
Karsten Hopp 4b8a0c
  		-DMZSCHEME_COLLECTS=\"$(MZSCHEME:\=\\)\\collects\"
Karsten Hopp 4b8a0c
  mzscheme_base.c:
Karsten Hopp 4b8a0c
--- 1096,1102 ----
Karsten Hopp 4b8a0c
  $(OUTDIR)/if_perlsfio.obj: $(OUTDIR) if_perlsfio.c  $(INCL)
Karsten Hopp 4b8a0c
  	$(CC) $(CFLAGS) $(PERL_INC) if_perlsfio.c
Karsten Hopp 4b8a0c
  
Karsten Hopp 4b8a0c
! $(OUTDIR)/if_mzsch.obj: $(OUTDIR) if_mzsch.c if_mzsch.h $(INCL) $(MZSCHEME_EXTRA_DEP)
Karsten Hopp 4b8a0c
  	$(CC) $(CFLAGS) if_mzsch.c \
Karsten Hopp 4b8a0c
  		-DMZSCHEME_COLLECTS=\"$(MZSCHEME:\=\\)\\collects\"
Karsten Hopp 4b8a0c
  mzscheme_base.c:
Karsten Hopp 4b8a0c
*** ../vim-7.3.790/src/os_unix.c	2012-10-14 04:35:16.000000000 +0200
Karsten Hopp 4b8a0c
--- src/os_unix.c	2013-01-30 14:26:44.000000000 +0100
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 278,284 ****
Karsten Hopp 4b8a0c
  #ifdef SIGBUS
Karsten Hopp 4b8a0c
      {SIGBUS,	    "BUS",	TRUE},
Karsten Hopp 4b8a0c
  #endif
Karsten Hopp 4b8a0c
! #ifdef SIGSEGV
Karsten Hopp 4b8a0c
      {SIGSEGV,	    "SEGV",	TRUE},
Karsten Hopp 4b8a0c
  #endif
Karsten Hopp 4b8a0c
  #ifdef SIGSYS
Karsten Hopp 4b8a0c
--- 278,285 ----
Karsten Hopp 4b8a0c
  #ifdef SIGBUS
Karsten Hopp 4b8a0c
      {SIGBUS,	    "BUS",	TRUE},
Karsten Hopp 4b8a0c
  #endif
Karsten Hopp 4b8a0c
! #if defined(SIGSEGV) && !defined(FEAT_MZSCHEME)
Karsten Hopp 4b8a0c
!     /* MzScheme uses SEGV in its garbage collector */
Karsten Hopp 4b8a0c
      {SIGSEGV,	    "SEGV",	TRUE},
Karsten Hopp 4b8a0c
  #endif
Karsten Hopp 4b8a0c
  #ifdef SIGSYS
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 3778,3784 ****
Karsten Hopp 4b8a0c
  # endif
Karsten Hopp 4b8a0c
  	if (wait_pid == 0)
Karsten Hopp 4b8a0c
  	{
Karsten Hopp 4b8a0c
! 	    /* Wait for 1/100 sec before trying again. */
Karsten Hopp 4b8a0c
  	    mch_delay(10L, TRUE);
Karsten Hopp 4b8a0c
  	    continue;
Karsten Hopp 4b8a0c
  	}
Karsten Hopp 4b8a0c
--- 3779,3785 ----
Karsten Hopp 4b8a0c
  # endif
Karsten Hopp 4b8a0c
  	if (wait_pid == 0)
Karsten Hopp 4b8a0c
  	{
Karsten Hopp 4b8a0c
! 	    /* Wait for 10 msec before trying again. */
Karsten Hopp 4b8a0c
  	    mch_delay(10L, TRUE);
Karsten Hopp 4b8a0c
  	    continue;
Karsten Hopp 4b8a0c
  	}
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 4797,4803 ****
Karsten Hopp 4b8a0c
  	    {
Karsten Hopp 4b8a0c
  		/* LINTED avoid "bitwise operation on signed value" */
Karsten Hopp 4b8a0c
  		retval = WEXITSTATUS(status);
Karsten Hopp 4b8a0c
! 		if (retval && !emsg_silent)
Karsten Hopp 4b8a0c
  		{
Karsten Hopp 4b8a0c
  		    if (retval == EXEC_FAILED)
Karsten Hopp 4b8a0c
  		    {
Karsten Hopp 4b8a0c
--- 4798,4804 ----
Karsten Hopp 4b8a0c
  	    {
Karsten Hopp 4b8a0c
  		/* LINTED avoid "bitwise operation on signed value" */
Karsten Hopp 4b8a0c
  		retval = WEXITSTATUS(status);
Karsten Hopp 4b8a0c
! 		if (retval != 0 && !emsg_silent)
Karsten Hopp 4b8a0c
  		{
Karsten Hopp 4b8a0c
  		    if (retval == EXEC_FAILED)
Karsten Hopp 4b8a0c
  		    {
Karsten Hopp 4b8a0c
*** ../vim-7.3.790/src/proto/eval.pro	2012-07-25 16:46:59.000000000 +0200
Karsten Hopp 4b8a0c
--- src/proto/eval.pro	2013-01-30 14:32:04.000000000 +0100
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 74,79 ****
Karsten Hopp 4b8a0c
--- 74,80 ----
Karsten Hopp 4b8a0c
  char_u *get_function_name __ARGS((expand_T *xp, int idx));
Karsten Hopp 4b8a0c
  char_u *get_expr_name __ARGS((expand_T *xp, int idx));
Karsten Hopp 4b8a0c
  int func_call __ARGS((char_u *name, typval_T *args, dict_T *selfdict, typval_T *rettv));
Karsten Hopp 4b8a0c
+ void mzscheme_call_vim __ARGS((char_u *name, typval_T *args, typval_T *rettv));
Karsten Hopp 4b8a0c
  long do_searchpair __ARGS((char_u *spat, char_u *mpat, char_u *epat, int dir, char_u *skip, int flags, pos_T *match_pos, linenr_T lnum_stop, long time_limit));
Karsten Hopp 4b8a0c
  void set_vim_var_nr __ARGS((int idx, long val));
Karsten Hopp 4b8a0c
  long get_vim_var_nr __ARGS((int idx));
Karsten Hopp 4b8a0c
*** ../vim-7.3.790/src/testdir/test70.in	2010-08-15 21:57:29.000000000 +0200
Karsten Hopp 4b8a0c
--- src/testdir/test70.in	2013-01-30 14:50:02.000000000 +0100
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 38,49 ****
Karsten Hopp 4b8a0c
  :" circular list (at the same time test lists containing lists)
Karsten Hopp 4b8a0c
  :mz (set-car! (cddr l) l)
Karsten Hopp 4b8a0c
  :let l2 = mzeval("h")["list"]
Karsten Hopp 4b8a0c
! :if l2[2] == l2
Karsten Hopp 4b8a0c
  :let res = "OK"
Karsten Hopp 4b8a0c
  :else
Karsten Hopp 4b8a0c
! :let res = "FAILED"
Karsten Hopp 4b8a0c
  :endif
Karsten Hopp 4b8a0c
  :call setline(search("^3"), "circular test " . res)
Karsten Hopp 4b8a0c
  :?^1?,$w! test.out
Karsten Hopp 4b8a0c
  :qa!
Karsten Hopp 4b8a0c
  ENDTEST
Karsten Hopp 4b8a0c
--- 38,60 ----
Karsten Hopp 4b8a0c
  :" circular list (at the same time test lists containing lists)
Karsten Hopp 4b8a0c
  :mz (set-car! (cddr l) l)
Karsten Hopp 4b8a0c
  :let l2 = mzeval("h")["list"]
Karsten Hopp 4b8a0c
! :" bug: this returns item2, but it should be l2
Karsten Hopp 4b8a0c
! :if l2[2] == "item2"
Karsten Hopp 4b8a0c
  :let res = "OK"
Karsten Hopp 4b8a0c
  :else
Karsten Hopp 4b8a0c
! :let res = "FAILED: " . l2[2]
Karsten Hopp 4b8a0c
  :endif
Karsten Hopp 4b8a0c
  :call setline(search("^3"), "circular test " . res)
Karsten Hopp 4b8a0c
+ :" funcrefs
Karsten Hopp 4b8a0c
+ :mz (define vim:max (vim-eval "function('max')"))
Karsten Hopp 4b8a0c
+ :mz (define m (vim:max '(1 100 8)))
Karsten Hopp 4b8a0c
+ :let m = mzeval('m')
Karsten Hopp 4b8a0c
+ :if m == 100
Karsten Hopp 4b8a0c
+ :let fref_res = "OK"
Karsten Hopp 4b8a0c
+ :else
Karsten Hopp 4b8a0c
+ :let fref_res = "FAILED: " . m
Karsten Hopp 4b8a0c
+ :end
Karsten Hopp 4b8a0c
+ :call append(line('$'), 'funcrefs '. fref_res)
Karsten Hopp 4b8a0c
  :?^1?,$w! test.out
Karsten Hopp 4b8a0c
  :qa!
Karsten Hopp 4b8a0c
  ENDTEST
Karsten Hopp 4b8a0c
*** ../vim-7.3.790/src/testdir/test70.ok	2010-08-15 21:57:29.000000000 +0200
Karsten Hopp 4b8a0c
--- src/testdir/test70.ok	2013-01-30 14:26:44.000000000 +0100
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 3,5 ****
Karsten Hopp 4b8a0c
--- 3,6 ----
Karsten Hopp 4b8a0c
  2 line 2
Karsten Hopp 4b8a0c
  dictionary with list OK
Karsten Hopp 4b8a0c
  circular test OK
Karsten Hopp 4b8a0c
+ funcrefs OK
Karsten Hopp 4b8a0c
*** ../vim-7.3.790/src/version.c	2013-01-30 14:13:52.000000000 +0100
Karsten Hopp 4b8a0c
--- src/version.c	2013-01-30 14:52:31.000000000 +0100
Karsten Hopp 4b8a0c
***************
Karsten Hopp 4b8a0c
*** 727,728 ****
Karsten Hopp 4b8a0c
--- 727,730 ----
Karsten Hopp 4b8a0c
  {   /* Add new patch number below this line */
Karsten Hopp 4b8a0c
+ /**/
Karsten Hopp 4b8a0c
+     791,
Karsten Hopp 4b8a0c
  /**/
Karsten Hopp 4b8a0c
Karsten Hopp 4b8a0c
Karsten Hopp 4b8a0c
-- 
Karsten Hopp 4b8a0c
5 out of 4 people have trouble with fractions.
Karsten Hopp 4b8a0c
Karsten Hopp 4b8a0c
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 4b8a0c
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 4b8a0c
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 4b8a0c
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///