home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.2 / 7.2.336 < prev    next >
Encoding:
Internet Message Format  |  2010-01-18  |  25.6 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 7.2.336
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.2.336
  11. Problem:    MzScheme interface can't evaluate an expression.
  12. Solution:   Add mzeval(). (Sergey Khorev)
  13. Files:        runtime/doc/eval.txt, runtime/doc/if_mzsch.txt,
  14.         runtime/doc/usr_41.txt, src/eval.c, src/if_mzsch.c,
  15.         src/proto/eval.pro, src/proto/if_mzsch.pro,
  16.         src/testdir/Make_dos.mak, src/testdir/Make_ming.mak,
  17.         src/testdir/Makefile, src/testdir/main.aap, src/testdir/test1.in,
  18.         src/testdir/test70.in, src/testdir/test70.ok
  19.  
  20.  
  21. *** ../vim-7.2.335/runtime/doc/eval.txt    2009-11-17 12:20:30.000000000 +0100
  22. --- runtime/doc/eval.txt    2010-01-19 15:30:50.000000000 +0100
  23. ***************
  24. *** 1815,1825 ****
  25.                   List    match and submatches of {pat} in {expr}
  26.   matchstr( {expr}, {pat}[, {start}[, {count}]])
  27.                   String    {count}'th match of {pat} in {expr}
  28. ! max({list})            Number    maximum value of items in {list}
  29. ! min({list})            Number    minimum value of items in {list}
  30. ! mkdir({name} [, {path} [, {prot}]])
  31.                   Number    create directory {name}
  32.   mode( [expr])            String    current editing mode
  33.   nextnonblank( {lnum})        Number    line nr of non-blank line >= {lnum}
  34.   nr2char( {expr})        String    single char with ASCII value {expr}
  35.   pathshorten( {expr})        String    shorten directory names in a path
  36. --- 1821,1832 ----
  37.                   List    match and submatches of {pat} in {expr}
  38.   matchstr( {expr}, {pat}[, {start}[, {count}]])
  39.                   String    {count}'th match of {pat} in {expr}
  40. ! max( {list})            Number    maximum value of items in {list}
  41. ! min( {list})            Number    minimum value of items in {list}
  42. ! mkdir( {name} [, {path} [, {prot}]])
  43.                   Number    create directory {name}
  44.   mode( [expr])            String    current editing mode
  45. + mzeval( {expr})            any    evaluate |MzScheme| expression
  46.   nextnonblank( {lnum})        Number    line nr of non-blank line >= {lnum}
  47.   nr2char( {expr})        String    single char with ASCII value {expr}
  48.   pathshorten( {expr})        String    shorten directory names in a path
  49. ***************
  50. *** 4090,4095 ****
  51. --- 4103,4125 ----
  52.           "c" or "n".
  53.           Also see |visualmode()|.
  54.   
  55. + mzeval({expr})                            *mzeval()*
  56. +         Evaluate MzScheme expression {expr} and return its result
  57. +         convert to Vim data structures.
  58. +         Numbers and strings are returned as they are.
  59. +         Pairs (including lists and improper lists) and vectors are
  60. +         returned as Vim |Lists|.
  61. +         Hash tables are represented as Vim |Dictionary| type with keys
  62. +         converted to strings.
  63. +         All other types are converted to string with display function.
  64. +         Examples: >
  65. +             :mz (define l (list 1 2 3))
  66. +             :mz (define h (make-hash)) (hash-set! h "list" l)
  67. +             :echo mzeval("l")
  68. +             :echo mzeval("h")
  69. + <
  70. +         {only available when compiled with the |+mzscheme| feature}
  71.   nextnonblank({lnum})                    *nextnonblank()*
  72.           Return the line number of the first line at or below {lnum}
  73.           that is not blank.  Example: >
  74. *** ../vim-7.2.335/runtime/doc/if_mzsch.txt    2009-06-24 17:51:01.000000000 +0200
  75. --- runtime/doc/if_mzsch.txt    2010-01-19 15:33:00.000000000 +0100
  76. ***************
  77. *** 1,4 ****
  78. ! *if_mzsch.txt*  For Vim version 7.2.  Last change: 2009 Jun 24
  79.   
  80.   
  81.             VIM REFERENCE MANUAL    by Sergey Khorev
  82. --- 1,4 ----
  83. ! *if_mzsch.txt*  For Vim version 7.2.  Last change: 2010 Jan 19
  84.   
  85.   
  86.             VIM REFERENCE MANUAL    by Sergey Khorev
  87. ***************
  88. *** 9,16 ****
  89.   1. Commands                |mzscheme-commands|
  90.   2. Examples                |mzscheme-examples|
  91.   3. Threads                |mzscheme-threads|
  92. ! 4. The Vim access procedures        |mzscheme-vim|
  93. ! 5. Dynamic loading            |mzscheme-dynamic|
  94.   
  95.   {Vi does not have any of these commands}
  96.   
  97. --- 9,17 ----
  98.   1. Commands                |mzscheme-commands|
  99.   2. Examples                |mzscheme-examples|
  100.   3. Threads                |mzscheme-threads|
  101. ! 4. Vim access from MzScheme        |mzscheme-vim|
  102. ! 5. mzeval() Vim function        |mzscheme-mzeval|
  103. ! 6. Dynamic loading            |mzscheme-dynamic|
  104.   
  105.   {Vi does not have any of these commands}
  106.   
  107. ***************
  108. *** 142,148 ****
  109.   GUI version.
  110.   
  111.   ==============================================================================
  112. ! 5. VIM Functions                    *mzscheme-vim*
  113.   
  114.                               *mzscheme-vimext*
  115.   The 'vimext' module provides access to procedures defined in the MzScheme
  116. --- 143,149 ----
  117.   GUI version.
  118.   
  119.   ==============================================================================
  120. ! 4. Vim access from MzScheme                *mzscheme-vim*
  121.   
  122.                               *mzscheme-vimext*
  123.   The 'vimext' module provides access to procedures defined in the MzScheme
  124. ***************
  125. *** 231,237 ****
  126.       (set-cursor (line . col) [window])  Set cursor position.
  127.   
  128.   ==============================================================================
  129. ! 5. Dynamic loading                    *mzscheme-dynamic* *E815*
  130.   
  131.   On MS-Windows the MzScheme libraries can be loaded dynamically. The |:version|
  132.   output then includes |+mzscheme/dyn|.
  133. --- 232,244 ----
  134.       (set-cursor (line . col) [window])  Set cursor position.
  135.   
  136.   ==============================================================================
  137. ! 5. mzeval() Vim function                    *mzscheme-mzeval*
  138. ! To facilitate bi-directional interface, you can use |mzeval| function to
  139. ! evaluate MzScheme expressions and pass their values to VimL.
  140. ! ==============================================================================
  141. ! 6. Dynamic loading                    *mzscheme-dynamic* *E815*
  142.   
  143.   On MS-Windows the MzScheme libraries can be loaded dynamically. The |:version|
  144.   output then includes |+mzscheme/dyn|.
  145. *** ../vim-7.2.335/runtime/doc/usr_41.txt    2008-08-09 19:36:54.000000000 +0200
  146. --- runtime/doc/usr_41.txt    2010-01-19 15:29:01.000000000 +0100
  147. ***************
  148. *** 868,873 ****
  149. --- 868,875 ----
  150.       taglist()        get list of matching tags
  151.       tagfiles()        get a list of tags files
  152.   
  153. +     mzeval()        evaluate |MzScheme| expression
  154.   ==============================================================================
  155.   *41.7*    Defining a function
  156.   
  157. *** ../vim-7.2.335/src/eval.c    2010-01-19 12:46:51.000000000 +0100
  158. --- src/eval.c    2010-01-19 15:48:12.000000000 +0100
  159. ***************
  160. *** 433,439 ****
  161.   static long list_find_nr __ARGS((list_T *l, long idx, int *errorp));
  162.   static long list_idx_of_item __ARGS((list_T *l, listitem_T *item));
  163.   static void list_append __ARGS((list_T *l, listitem_T *item));
  164. - static int list_append_tv __ARGS((list_T *l, typval_T *tv));
  165.   static int list_append_number __ARGS((list_T *l, varnumber_T n));
  166.   static int list_insert_tv __ARGS((list_T *l, typval_T *tv, listitem_T *item));
  167.   static int list_extend __ARGS((list_T    *l1, list_T *l2, listitem_T *bef));
  168. --- 433,438 ----
  169. ***************
  170. *** 448,459 ****
  171.   static void set_ref_in_item __ARGS((typval_T *tv, int copyID));
  172.   static void dict_unref __ARGS((dict_T *d));
  173.   static void dict_free __ARGS((dict_T *d, int recurse));
  174. - static dictitem_T *dictitem_alloc __ARGS((char_u *key));
  175.   static dictitem_T *dictitem_copy __ARGS((dictitem_T *org));
  176.   static void dictitem_remove __ARGS((dict_T *dict, dictitem_T *item));
  177. - static void dictitem_free __ARGS((dictitem_T *item));
  178.   static dict_T *dict_copy __ARGS((dict_T *orig, int deep, int copyID));
  179. - static int dict_add __ARGS((dict_T *d, dictitem_T *item));
  180.   static long dict_len __ARGS((dict_T *d));
  181.   static dictitem_T *dict_find __ARGS((dict_T *d, char_u *key, int len));
  182.   static char_u *dict2string __ARGS((typval_T *tv, int copyID));
  183. --- 447,455 ----
  184. ***************
  185. *** 628,633 ****
  186. --- 624,632 ----
  187.   static void f_mkdir __ARGS((typval_T *argvars, typval_T *rettv));
  188.   #endif
  189.   static void f_mode __ARGS((typval_T *argvars, typval_T *rettv));
  190. + #ifdef FEAT_MZSCHEME
  191. + static void f_mzeval __ARGS((typval_T *argvars, typval_T *rettv));
  192. + #endif
  193.   static void f_nextnonblank __ARGS((typval_T *argvars, typval_T *rettv));
  194.   static void f_nr2char __ARGS((typval_T *argvars, typval_T *rettv));
  195.   static void f_pathshorten __ARGS((typval_T *argvars, typval_T *rettv));
  196. ***************
  197. *** 764,770 ****
  198.   static int var_check_ro __ARGS((int flags, char_u *name));
  199.   static int var_check_fixed __ARGS((int flags, char_u *name));
  200.   static int tv_check_lock __ARGS((int lock, char_u *name));
  201. - static void copy_tv __ARGS((typval_T *from, typval_T *to));
  202.   static int item_copy __ARGS((typval_T *from, typval_T *to, int deep, int copyID));
  203.   static char_u *find_option_end __ARGS((char_u **arg, int *opt_flags));
  204.   static char_u *trans_function_name __ARGS((char_u **pp, int skip, int flags, funcdict_T *fd));
  205. --- 763,768 ----
  206. ***************
  207. *** 6155,6161 ****
  208.    * Append typval_T "tv" to the end of list "l".
  209.    * Return FAIL when out of memory.
  210.    */
  211. !     static int
  212.   list_append_tv(l, tv)
  213.       list_T    *l;
  214.       typval_T    *tv;
  215. --- 6153,6159 ----
  216.    * Append typval_T "tv" to the end of list "l".
  217.    * Return FAIL when out of memory.
  218.    */
  219. !     int
  220.   list_append_tv(l, tv)
  221.       list_T    *l;
  222.       typval_T    *tv;
  223. ***************
  224. *** 6812,6818 ****
  225.    * Note that the value of the item "di_tv" still needs to be initialized!
  226.    * Returns NULL when out of memory.
  227.    */
  228. !     static dictitem_T *
  229.   dictitem_alloc(key)
  230.       char_u    *key;
  231.   {
  232. --- 6810,6816 ----
  233.    * Note that the value of the item "di_tv" still needs to be initialized!
  234.    * Returns NULL when out of memory.
  235.    */
  236. !     dictitem_T *
  237.   dictitem_alloc(key)
  238.       char_u    *key;
  239.   {
  240. ***************
  241. *** 6868,6874 ****
  242.   /*
  243.    * Free a dict item.  Also clears the value.
  244.    */
  245. !     static void
  246.   dictitem_free(item)
  247.       dictitem_T *item;
  248.   {
  249. --- 6866,6872 ----
  250.   /*
  251.    * Free a dict item.  Also clears the value.
  252.    */
  253. !     void
  254.   dictitem_free(item)
  255.       dictitem_T *item;
  256.   {
  257. ***************
  258. *** 6948,6954 ****
  259.    * Add item "item" to Dictionary "d".
  260.    * Returns FAIL when out of memory and when key already existed.
  261.    */
  262. !     static int
  263.   dict_add(d, item)
  264.       dict_T    *d;
  265.       dictitem_T    *item;
  266. --- 6946,6952 ----
  267.    * Add item "item" to Dictionary "d".
  268.    * Returns FAIL when out of memory and when key already existed.
  269.    */
  270. !     int
  271.   dict_add(d, item)
  272.       dict_T    *d;
  273.       dictitem_T    *item;
  274. ***************
  275. *** 7699,7704 ****
  276. --- 7697,7705 ----
  277.       {"mkdir",        1, 3, f_mkdir},
  278.   #endif
  279.       {"mode",        0, 1, f_mode},
  280. + #ifdef FEAT_MZSCHEME
  281. +     {"mzeval",        1, 1, f_mzeval},
  282. + #endif
  283.       {"nextnonblank",    1, 1, f_nextnonblank},
  284.       {"nr2char",        1, 1, f_nr2char},
  285.       {"pathshorten",    1, 1, f_pathshorten},
  286. ***************
  287. *** 13591,13596 ****
  288. --- 13592,13614 ----
  289.       rettv->v_type = VAR_STRING;
  290.   }
  291.   
  292. + #ifdef FEAT_MZSCHEME
  293. + /*
  294. +  * "mzeval()" function
  295. +  */
  296. +     static void
  297. + f_mzeval(argvars, rettv)
  298. +     typval_T    *argvars;
  299. +     typval_T    *rettv;
  300. + {
  301. +     char_u    *str;
  302. +     char_u    buf[NUMBUFLEN];
  303. +     str = get_tv_string_buf(&argvars[0], buf);
  304. +     do_mzeval(str, rettv);
  305. + }
  306. + #endif
  307.   /*
  308.    * "nextnonblank()" function
  309.    */
  310. ***************
  311. *** 19274,19280 ****
  312.    * It is OK for "from" and "to" to point to the same item.  This is used to
  313.    * make a copy later.
  314.    */
  315. !     static void
  316.   copy_tv(from, to)
  317.       typval_T *from;
  318.       typval_T *to;
  319. --- 19292,19298 ----
  320.    * It is OK for "from" and "to" to point to the same item.  This is used to
  321.    * make a copy later.
  322.    */
  323. !     void
  324.   copy_tv(from, to)
  325.       typval_T *from;
  326.       typval_T *to;
  327. *** ../vim-7.2.335/src/if_mzsch.c    2009-12-16 19:02:05.000000000 +0100
  328. --- src/if_mzsch.c    2010-01-19 15:43:05.000000000 +0100
  329. ***************
  330. *** 170,175 ****
  331. --- 170,177 ----
  332.   #ifdef FEAT_EVAL
  333.   static Scheme_Object *vim_to_mzscheme(typval_T *vim_value, int depth,
  334.       Scheme_Hash_Table *visited);
  335. + static int mzscheme_to_vim(Scheme_Object *obj, typval_T *tv, int depth,
  336. +     Scheme_Hash_Table *visited);
  337.   #endif
  338.   
  339.   #ifdef MZ_PRECISE_GC
  340. ***************
  341. *** 2733,2738 ****
  342. --- 2735,2959 ----
  343.       MZ_GC_UNREG();
  344.       return result;
  345.   }
  346. +     static int
  347. + mzscheme_to_vim(Scheme_Object *obj, typval_T *tv, int depth,
  348. +     Scheme_Hash_Table *visited)
  349. + {
  350. +     int        status = OK;
  351. +     typval_T    *found;
  352. +     MZ_GC_CHECK();
  353. +     if (depth > 100) /* limit the deepest recursion level */
  354. +     {
  355. +     tv->v_type = VAR_NUMBER;
  356. +     tv->vval.v_number = 0;
  357. +     return FAIL;
  358. +     }
  359. +     found = (typval_T *)scheme_hash_get(visited, obj);
  360. +     if (found != NULL)
  361. +     copy_tv(found, tv);
  362. +     else if (SCHEME_VOIDP(obj))
  363. +     {
  364. +     tv->v_type = VAR_NUMBER;
  365. +     tv->vval.v_number = 0;
  366. +     }
  367. +     else if (SCHEME_INTP(obj))
  368. +     {
  369. +     tv->v_type = VAR_NUMBER;
  370. +     tv->vval.v_number = SCHEME_INT_VAL(obj);
  371. +     }
  372. +     else if (SCHEME_BOOLP(obj))
  373. +     {
  374. +     tv->v_type = VAR_NUMBER;
  375. +     tv->vval.v_number = SCHEME_TRUEP(obj);
  376. +     }
  377. + # ifdef FEAT_FLOAT
  378. +     else if (SCHEME_DBLP(obj))
  379. +     {
  380. +     tv->v_type = VAR_FLOAT;
  381. +     tv->vval.v_float = SCHEME_DBL_VAL(obj);
  382. +     }
  383. + # endif
  384. +     else if (SCHEME_STRINGP(obj))
  385. +     {
  386. +     tv->v_type = VAR_STRING;
  387. +     tv->vval.v_string = vim_strsave((char_u *)SCHEME_STR_VAL(obj));
  388. +     }
  389. +     else if (SCHEME_VECTORP(obj) || SCHEME_NULLP(obj)
  390. +         || SCHEME_PAIRP(obj) || SCHEME_MUTABLE_PAIRP(obj))
  391. +     {
  392. +     list_T  *list = list_alloc();
  393. +     if (list == NULL)
  394. +         status = FAIL;
  395. +     else
  396. +     {
  397. +         int            i;
  398. +         Scheme_Object   *curr = NULL;
  399. +         Scheme_Object   *cval = NULL;
  400. +         /* temporary var to hold current element of vectors and pairs */
  401. +         typval_T        *v;
  402. +         MZ_GC_DECL_REG(2);
  403. +         MZ_GC_VAR_IN_REG(0, curr);
  404. +         MZ_GC_VAR_IN_REG(1, cval);
  405. +         MZ_GC_REG();
  406. +         tv->v_type = VAR_LIST;
  407. +         tv->vval.v_list = list;
  408. +         ++list->lv_refcount;
  409. +         v = (typval_T *)alloc(sizeof(typval_T));
  410. +         if (v == NULL)
  411. +         status = FAIL;
  412. +         else
  413. +         {
  414. +         /* add the value in advance to allow handling of self-referencial
  415. +          * data structures */
  416. +         typval_T    *visited_tv = (typval_T *)alloc(sizeof(typval_T));
  417. +         copy_tv(tv, visited_tv);
  418. +         scheme_hash_set(visited, obj, (Scheme_Object *)visited_tv);
  419. +         if (SCHEME_VECTORP(obj))
  420. +         {
  421. +             for (i = 0; i < SCHEME_VEC_SIZE(obj); ++i)
  422. +             {
  423. +             cval = SCHEME_VEC_ELS(obj)[i];
  424. +             status = mzscheme_to_vim(cval, v, depth + 1, visited);
  425. +             if (status == FAIL)
  426. +                 break;
  427. +             status = list_append_tv(list, v);
  428. +             clear_tv(v);
  429. +             if (status == FAIL)
  430. +                 break;
  431. +             }
  432. +         }
  433. +         else if (SCHEME_PAIRP(obj) || SCHEME_MUTABLE_PAIRP(obj))
  434. +         {
  435. +             for (curr = obj;
  436. +                 SCHEME_PAIRP(curr) || SCHEME_MUTABLE_PAIRP(curr);
  437. +                 curr = SCHEME_CDR(curr))
  438. +             {
  439. +             cval = SCHEME_CAR(curr);
  440. +             status = mzscheme_to_vim(cval, v, depth + 1, visited);
  441. +             if (status == FAIL)
  442. +                 break;
  443. +             status = list_append_tv(list, v);
  444. +             clear_tv(v);
  445. +             if (status == FAIL)
  446. +                 break;
  447. +             }
  448. +             /* impoper list not terminated with null
  449. +              * need to handle the last element */
  450. +             if (status == OK && !SCHEME_NULLP(curr))
  451. +             {
  452. +             status = mzscheme_to_vim(cval, v, depth + 1, visited);
  453. +             if (status == OK)
  454. +             {
  455. +                 status = list_append_tv(list, v);
  456. +                 clear_tv(v);
  457. +             }
  458. +             }
  459. +         }
  460. +         /* nothing to do for scheme_null */
  461. +         vim_free(v);
  462. +         }
  463. +         MZ_GC_UNREG();
  464. +     }
  465. +     }
  466. +     else if (SCHEME_HASHTP(obj))
  467. +     {
  468. +     int        i;
  469. +     dict_T        *dict;
  470. +     Scheme_Object   *key = NULL;
  471. +     Scheme_Object   *val = NULL;
  472. +     MZ_GC_DECL_REG(2);
  473. +     MZ_GC_VAR_IN_REG(0, key);
  474. +     MZ_GC_VAR_IN_REG(1, val);
  475. +     MZ_GC_REG();
  476. +     dict = dict_alloc();
  477. +     if (dict == NULL)
  478. +         status = FAIL;
  479. +     else
  480. +     {
  481. +         typval_T    *visited_tv = (typval_T *)alloc(sizeof(typval_T));
  482. +         tv->v_type = VAR_DICT;
  483. +         tv->vval.v_dict = dict;
  484. +         ++dict->dv_refcount;
  485. +         copy_tv(tv, visited_tv);
  486. +         scheme_hash_set(visited, obj, (Scheme_Object *)visited_tv);
  487. +         for (i = 0; i < ((Scheme_Hash_Table *)obj)->size; ++i)
  488. +         {
  489. +         if (((Scheme_Hash_Table *) obj)->vals[i] != NULL)
  490. +         {
  491. +             /* generate item for `diplay'ed Scheme key */
  492. +             dictitem_T  *item = dictitem_alloc((char_u *)string_to_line(
  493. +                 ((Scheme_Hash_Table *) obj)->keys[i]));
  494. +             /* convert Scheme val to Vim and add it to the dict */
  495. +             if (mzscheme_to_vim(((Scheme_Hash_Table *) obj)->vals[i],
  496. +                     &item->di_tv, depth + 1, visited) == FAIL
  497. +                 || dict_add(dict, item) == FAIL)
  498. +             {
  499. +             dictitem_free(item);
  500. +             status = FAIL;
  501. +             break;
  502. +             }
  503. +         }
  504. +         }
  505. +     }
  506. +     MZ_GC_UNREG();
  507. +     }
  508. +     else
  509. +     {
  510. +     /* `display' any other value to string */
  511. +     tv->v_type = VAR_STRING;
  512. +     tv->vval.v_string = (char_u *)string_to_line(obj);
  513. +     }
  514. +     return status;
  515. + }
  516. +     void
  517. + do_mzeval(char_u *str, typval_T *rettv)
  518. + {
  519. +     int i;
  520. +     Scheme_Object    *ret = NULL;
  521. +     Scheme_Hash_Table    *visited = NULL;
  522. +     MZ_GC_DECL_REG(2);
  523. +     MZ_GC_VAR_IN_REG(0, ret);
  524. +     MZ_GC_VAR_IN_REG(0, visited);
  525. +     MZ_GC_REG();
  526. +     if (mzscheme_init())
  527. +     {
  528. +     MZ_GC_UNREG();
  529. +     return;
  530. +     }
  531. +     MZ_GC_CHECK();
  532. +     visited = scheme_make_hash_table(SCHEME_hash_ptr);
  533. +     MZ_GC_CHECK();
  534. +     if (eval_with_exn_handling(str, do_eval, &ret) == OK)
  535. +     mzscheme_to_vim(ret, rettv, 1, visited);
  536. +     for (i = 0; i < visited->size; ++i)
  537. +     {
  538. +     /* free up remembered objects */
  539. +     if (visited->vals[i] != NULL)
  540. +     {
  541. +         free_tv((typval_T *)visited->vals[i]);
  542. +     }
  543. +     }
  544. +     MZ_GC_UNREG();
  545. + }
  546.   #endif
  547.   
  548.   /*
  549. *** ../vim-7.2.335/src/proto/eval.pro    2009-09-30 15:15:33.000000000 +0200
  550. --- src/proto/eval.pro    2010-01-19 15:45:39.000000000 +0100
  551. ***************
  552. *** 47,56 ****
  553. --- 47,60 ----
  554.   void list_free __ARGS((list_T *l, int recurse));
  555.   dictitem_T *dict_lookup __ARGS((hashitem_T *hi));
  556.   char_u *list_find_str __ARGS((list_T *l, long idx));
  557. + int list_append_tv __ARGS((list_T *l, typval_T *tv));
  558.   int list_append_dict __ARGS((list_T *list, dict_T *dict));
  559.   int list_append_string __ARGS((list_T *l, char_u *str, int len));
  560.   int garbage_collect __ARGS((void));
  561.   dict_T *dict_alloc __ARGS((void));
  562. + dictitem_T *dictitem_alloc __ARGS((char_u *key));
  563. + void dictitem_free __ARGS((dictitem_T *item));
  564. + int dict_add __ARGS((dict_T *d, dictitem_T *item));
  565.   int dict_add_nr_str __ARGS((dict_T *d, char *key, long nr, char_u *str));
  566.   char_u *get_dict_string __ARGS((dict_T *d, char_u *key, int save));
  567.   long get_dict_number __ARGS((dict_T *d, char_u *key));
  568. ***************
  569. *** 77,82 ****
  570. --- 81,87 ----
  571.   void new_script_vars __ARGS((scid_T id));
  572.   void init_var_dict __ARGS((dict_T *dict, dictitem_T *dict_var));
  573.   void vars_clear __ARGS((hashtab_T *ht));
  574. + void copy_tv __ARGS((typval_T *from, typval_T *to));
  575.   void ex_echo __ARGS((exarg_T *eap));
  576.   void ex_echohl __ARGS((exarg_T *eap));
  577.   void ex_execute __ARGS((exarg_T *eap));
  578. *** ../vim-7.2.335/src/proto/if_mzsch.pro    2009-12-16 19:02:05.000000000 +0100
  579. --- src/proto/if_mzsch.pro    2010-01-19 15:29:01.000000000 +0100
  580. ***************
  581. *** 15,18 ****
  582. --- 15,19 ----
  583.   void *mzvim_eval_string __ARGS((char_u *str));
  584.   int mzthreads_allowed __ARGS((void));
  585.   void mzscheme_main __ARGS((void));
  586. + void do_mzeval __ARGS((char_u *str, typval_T *rettv));
  587.   /* vim: set ft=c : */
  588. *** ../vim-7.2.335/src/testdir/Make_dos.mak    2009-11-17 17:57:10.000000000 +0100
  589. --- src/testdir/Make_dos.mak    2010-01-19 15:43:48.000000000 +0100
  590. ***************
  591. *** 29,35 ****
  592.           test42.out test52.out test65.out test66.out test67.out \
  593.           test68.out test69.out
  594.   
  595. ! SCRIPTS32 =    test50.out
  596.   
  597.   SCRIPTS_GUI = test16.out
  598.   
  599. --- 29,35 ----
  600.           test42.out test52.out test65.out test66.out test67.out \
  601.           test68.out test69.out
  602.   
  603. ! SCRIPTS32 =    test50.out test70.out
  604.   
  605.   SCRIPTS_GUI = test16.out
  606.   
  607. *** ../vim-7.2.335/src/testdir/Make_ming.mak    2009-11-17 17:57:10.000000000 +0100
  608. --- src/testdir/Make_ming.mak    2010-01-19 15:29:01.000000000 +0100
  609. ***************
  610. *** 48,54 ****
  611.           test42.out test52.out test65.out test66.out test67.out \
  612.           test68.out test69.out
  613.   
  614. ! SCRIPTS32 =    test50.out
  615.   
  616.   SCRIPTS_GUI = test16.out
  617.   
  618. --- 48,54 ----
  619.           test42.out test52.out test65.out test66.out test67.out \
  620.           test68.out test69.out
  621.   
  622. ! SCRIPTS32 =    test50.out test70.out
  623.   
  624.   SCRIPTS_GUI = test16.out
  625.   
  626. ***************
  627. *** 78,83 ****
  628. --- 78,84 ----
  629.       -$(DEL) small.vim
  630.       -$(DEL) tiny.vim
  631.       -$(DEL) mbyte.vim
  632. +     -$(DEL) mzscheme.vim
  633.       -$(DEL) X*
  634.       -$(DEL) viminfo
  635.   
  636. *** ../vim-7.2.335/src/testdir/Makefile    2009-11-17 17:40:34.000000000 +0100
  637. --- src/testdir/Makefile    2010-01-19 15:29:01.000000000 +0100
  638. ***************
  639. *** 23,29 ****
  640.           test54.out test55.out test56.out test57.out test58.out \
  641.           test59.out test60.out test61.out test62.out test63.out \
  642.           test64.out test65.out test66.out test67.out test68.out \
  643. !         test69.out
  644.   
  645.   SCRIPTS_GUI = test16.out
  646.   
  647. --- 23,29 ----
  648.           test54.out test55.out test56.out test57.out test58.out \
  649.           test59.out test60.out test61.out test62.out test63.out \
  650.           test64.out test65.out test66.out test67.out test68.out \
  651. !         test69.out test70.out
  652.   
  653.   SCRIPTS_GUI = test16.out
  654.   
  655. ***************
  656. *** 44,53 ****
  657.   $(SCRIPTS) $(SCRIPTS_GUI): $(VIMPROG)
  658.   
  659.   clean:
  660. !     -rm -rf *.out *.failed *.rej *.orig test.log tiny.vim small.vim mbyte.vim test.ok X* valgrind.pid* viminfo
  661.   
  662.   test1.out: test1.in
  663. !     -rm -f $*.failed tiny.vim small.vim mbyte.vim test.ok X* viminfo
  664.       $(VALGRIND) $(VIMPROG) -u unix.vim -U NONE --noplugin -s dotest.in $*.in
  665.       @/bin/sh -c "if diff test.out $*.ok; \
  666.           then mv -f test.out $*.out; \
  667. --- 44,53 ----
  668.   $(SCRIPTS) $(SCRIPTS_GUI): $(VIMPROG)
  669.   
  670.   clean:
  671. !     -rm -rf *.out *.failed *.rej *.orig test.log tiny.vim small.vim mbyte.vim mzscheme.vim test.ok X* valgrind.pid* viminfo
  672.   
  673.   test1.out: test1.in
  674. !     -rm -f $*.failed tiny.vim small.vim mbyte.vim mzscheme.vim test.ok X* viminfo
  675.       $(VALGRIND) $(VIMPROG) -u unix.vim -U NONE --noplugin -s dotest.in $*.in
  676.       @/bin/sh -c "if diff test.out $*.ok; \
  677.           then mv -f test.out $*.out; \
  678. *** ../vim-7.2.335/src/testdir/main.aap    2004-06-13 21:05:31.000000000 +0200
  679. --- src/testdir/main.aap    2010-01-19 15:29:01.000000000 +0100
  680. ***************
  681. *** 32,42 ****
  682.   $Scripts $ScriptsGUI: $VimProg
  683.   
  684.   clean:
  685. !     :del {r}{force} *.out test.log tiny.vim small.vim mbyte.vim test.ok X*
  686.   
  687.   # test1 is special, it checks for features
  688.   test1.out: test1.in
  689. !     :del {force} test1.failed tiny.vim small.vim mbyte.vim
  690.       :sys {i} $VimProg -u unix.vim -U NONE --noplugin -s dotest.in test1.in
  691.       @if os.system("diff test.out test1.ok") != 0:
  692.           :error test1 FAILED - Something basic is wrong
  693. --- 32,42 ----
  694.   $Scripts $ScriptsGUI: $VimProg
  695.   
  696.   clean:
  697. !     :del {r}{force} *.out test.log tiny.vim small.vim mbyte.vim mzscheme.vim test.ok X*
  698.   
  699.   # test1 is special, it checks for features
  700.   test1.out: test1.in
  701. !     :del {force} test1.failed tiny.vim small.vim mbyte.vim mzscheme.vim
  702.       :sys {i} $VimProg -u unix.vim -U NONE --noplugin -s dotest.in test1.in
  703.       @if os.system("diff test.out test1.ok") != 0:
  704.           :error test1 FAILED - Something basic is wrong
  705. *** ../vim-7.2.335/src/testdir/test1.in    2004-06-13 20:19:23.000000000 +0200
  706. --- src/testdir/test1.in    2010-01-19 15:38:44.000000000 +0100
  707. ***************
  708. *** 13,18 ****
  709. --- 13,19 ----
  710.   
  711.   If Vim was not compiled with the +multi_byte feature, the mbyte.vim script will be set like small.vim above.  mbyte.vim is sourced by tests that require the
  712.   +multi_byte feature.
  713. + Similar logic is applied to the +mzscheme feature, using mzscheme.vim.
  714.   
  715.   STARTTEST
  716.   :" Write a single line to test.out to check if testing works at all.
  717. ***************
  718. *** 25,32 ****
  719. --- 26,36 ----
  720.   w! test.out
  721.   qa!
  722.   :w! mbyte.vim
  723. + :w! mzscheme.vim
  724.   :" If +multi_byte feature supported, make mbyte.vim empty.
  725.   :if has("multi_byte") | sp another | w! mbyte.vim | q | endif
  726. + :" If +mzscheme feature supported, make mzscheme.vim empty.
  727. + :if has("mzscheme") | sp another | w! mzscheme.vim | q | endif
  728.   :" If +eval feature supported quit here, leaving tiny.vim and small.vim empty.
  729.   :" Otherwise write small.vim to skip the test.
  730.   :if 1 | q! | endif
  731. *** ../vim-7.2.335/src/testdir/test70.in    2010-01-19 15:47:24.000000000 +0100
  732. --- src/testdir/test70.in    2010-01-19 15:29:01.000000000 +0100
  733. ***************
  734. *** 0 ****
  735. --- 1,53 ----
  736. + Smoke test for MzScheme interface and mzeval() function
  737. + STARTTEST
  738. + :so mzscheme.vim
  739. + :set nocompatible viminfo+=nviminfo
  740. + :function! MzRequire()
  741. + :redir => l:mzversion
  742. + :mz (version)
  743. + :redir END
  744. + :if strpart(l:mzversion, 1, 1) < "4"
  745. + :" MzScheme versions < 4.x:
  746. + :mz (require (prefix vim- vimext))
  747. + :else
  748. + :" newer versions:
  749. + :mz (require (prefix-in vim- 'vimext))
  750. + :mz (require r5rs)
  751. + :endif
  752. + :endfunction
  753. + :silent call MzRequire()
  754. + :mz (define l '("item0" "dictionary with list OK" "item2"))
  755. + :mz (define h (make-hash))
  756. + :mz (hash-set! h "list" l)
  757. + /^1
  758. + :" change buffer contents
  759. + :mz (vim-set-buff-line (vim-eval "line('.')") "1 changed line 1")
  760. + :" scalar test
  761. + :let tmp_string = mzeval('"string"')
  762. + :let tmp_1000 = mzeval('1000')
  763. + :if tmp_string . tmp_1000 == "string1000"
  764. + :let scalar_res = "OK"
  765. + :else
  766. + :let scalar_res = "FAILED"
  767. + :endif
  768. + :call append(search("^1"), "scalar test " . scalar_res)
  769. + :" dictionary containing a list
  770. + :let tmp = mzeval("h")["list"][1]
  771. + :/^2/put =tmp
  772. + :" circular list (at the same time test lists containing lists)
  773. + :mz (set-car! (cddr l) l)
  774. + :let l2 = mzeval("h")["list"]
  775. + :if l2[2] == l2
  776. + :let res = "OK"
  777. + :else
  778. + :let res = "FAILED"
  779. + :endif
  780. + :call setline(search("^3"), "circular test " . res)
  781. + :?^1?,$w! test.out
  782. + :qa!
  783. + ENDTEST
  784. + 1 line 1
  785. + 2 line 2
  786. + 3 line 3
  787. *** ../vim-7.2.335/src/testdir/test70.ok    2010-01-19 15:47:24.000000000 +0100
  788. --- src/testdir/test70.ok    2010-01-19 15:29:01.000000000 +0100
  789. ***************
  790. *** 0 ****
  791. --- 1,5 ----
  792. + 1 changed line 1
  793. + scalar test OK
  794. + 2 line 2
  795. + dictionary with list OK
  796. + circular test OK
  797. *** ../vim-7.2.335/src/version.c    2010-01-19 15:23:38.000000000 +0100
  798. --- src/version.c    2010-01-19 15:46:44.000000000 +0100
  799. ***************
  800. *** 683,684 ****
  801. --- 683,686 ----
  802.   {   /* Add new patch number below this line */
  803. + /**/
  804. +     336,
  805.   /**/
  806.  
  807. -- 
  808. "Computers in the future may weigh no more than 1.5 tons."
  809.                                    Popular Mechanics, 1949
  810.  
  811.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  812. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  813. \\\        download, build and distribute -- http://www.A-A-P.org        ///
  814.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  815.