4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: Recursive structures are not handled properly in Python
13 Solution: Keep track of references in a better way. (Yukihiro Nakadaira)
14 Files: src/if_python.c
17 *** ../vim-7.2.083/src/if_python.c Thu Nov 20 11:04:01 2008
18 --- src/if_python.c Tue Jan 13 18:08:06 2009
22 /* Check if we run into a recursive loop. The item must be in lookupDict
23 * then and we can use it again. */
24 ! sprintf(ptrBuf, PRINTF_DECIMAL_LONG_U, (long_u)our_tv);
25 ! result = PyDict_GetItemString(lookupDict, ptrBuf);
28 ! else if (our_tv->v_type == VAR_STRING)
30 result = Py_BuildValue("s", our_tv->vval.v_string);
31 - PyDict_SetItemString(lookupDict, ptrBuf, result);
33 else if (our_tv->v_type == VAR_NUMBER)
37 /* Check if we run into a recursive loop. The item must be in lookupDict
38 * then and we can use it again. */
39 ! if ((our_tv->v_type == VAR_LIST && our_tv->vval.v_list != NULL)
40 ! || (our_tv->v_type == VAR_DICT && our_tv->vval.v_dict != NULL))
42 ! sprintf(ptrBuf, PRINTF_DECIMAL_LONG_U,
43 ! our_tv->v_type == VAR_LIST ? (long_u)our_tv->vval.v_list
44 ! : (long_u)our_tv->vval.v_dict);
45 ! result = PyDict_GetItemString(lookupDict, ptrBuf);
53 ! if (our_tv->v_type == VAR_STRING)
55 result = Py_BuildValue("s", our_tv->vval.v_string);
57 else if (our_tv->v_type == VAR_NUMBER)
61 /* For backwards compatibility numbers are stored as strings. */
62 sprintf(buf, "%ld", (long)our_tv->vval.v_number);
63 result = Py_BuildValue("s", buf);
64 - PyDict_SetItemString(lookupDict, ptrBuf, result);
67 else if (our_tv->v_type == VAR_FLOAT)
72 sprintf(buf, "%f", our_tv->vval.v_float);
73 result = Py_BuildValue("s", buf);
74 - PyDict_SetItemString(lookupDict, ptrBuf, result);
77 else if (our_tv->v_type == VAR_LIST)
83 result = PyList_New(0);
84 - PyDict_SetItemString(lookupDict, ptrBuf, result);
88 for (curr = list->lv_first; curr != NULL; curr = curr->li_next)
90 newObj = VimToPython(&curr->li_tv, depth + 1, lookupDict);
94 result = PyList_New(0);
98 + PyDict_SetItemString(lookupDict, ptrBuf, result);
100 for (curr = list->lv_first; curr != NULL; curr = curr->li_next)
102 newObj = VimToPython(&curr->li_tv, depth + 1, lookupDict);
105 else if (our_tv->v_type == VAR_DICT)
107 result = PyDict_New();
108 - PyDict_SetItemString(lookupDict, ptrBuf, result);
110 if (our_tv->vval.v_dict != NULL)
119 + PyDict_SetItemString(lookupDict, ptrBuf, result);
121 for (hi = ht->ht_array; todo > 0; ++hi)
123 if (!HASHITEM_EMPTY(hi))
124 *** ../vim-7.2.083/src/version.c Tue Jan 13 17:27:18 2009
125 --- src/version.c Tue Jan 13 17:54:14 2009
129 { /* Add new patch number below this line */
135 Article in the first Free Software Magazine: "Bram Moolenaar studied electrical
136 engineering at the Technical University of Delft and graduated in 1985 on a
137 multi-processor Unix architecture."
138 Response by "dimator": Could the school not afford a proper stage for the
141 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
142 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
143 \\\ download, build and distribute -- http://www.A-A-P.org ///
144 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///