]> git.pld-linux.org Git - packages/vim.git/blob - 7.2.084
- new
[packages/vim.git] / 7.2.084
1 To: vim-dev@vim.org
2 Subject: Patch 7.2.084
3 Fcc: outbox
4 From: Bram Moolenaar <Bram@moolenaar.net>
5 Mime-Version: 1.0
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
8 ------------
9
10 Patch 7.2.084
11 Problem:    Recursive structures are not handled properly in Python
12             vim.eval().
13 Solution:   Keep track of references in a better way. (Yukihiro Nakadaira)
14 Files:      src/if_python.c
15
16
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
19 ***************
20 *** 1151,1164 ****
21   
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);
26 !     if (result != NULL)
27 !       Py_INCREF(result);
28 !     else if (our_tv->v_type == VAR_STRING)
29       {
30         result = Py_BuildValue("s", our_tv->vval.v_string);
31 -       PyDict_SetItemString(lookupDict, ptrBuf, result);
32       }
33       else if (our_tv->v_type == VAR_NUMBER)
34       {
35 --- 1151,1173 ----
36   
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))
41 !     {
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);
46 !       if (result != NULL)
47 !       {
48 !           Py_INCREF(result);
49 !           return result;
50 !       }
51 !     }
52
53 !     if (our_tv->v_type == VAR_STRING)
54       {
55         result = Py_BuildValue("s", our_tv->vval.v_string);
56       }
57       else if (our_tv->v_type == VAR_NUMBER)
58       {
59 ***************
60 *** 1167,1173 ****
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);
65       }
66   # ifdef FEAT_FLOAT
67       else if (our_tv->v_type == VAR_FLOAT)
68 --- 1176,1181 ----
69 ***************
70 *** 1176,1182 ****
71   
72         sprintf(buf, "%f", our_tv->vval.v_float);
73         result = Py_BuildValue("s", buf);
74 -       PyDict_SetItemString(lookupDict, ptrBuf, result);
75       }
76   # endif
77       else if (our_tv->v_type == VAR_LIST)
78 --- 1184,1189 ----
79 ***************
80 *** 1185,1194 ****
81         listitem_T      *curr;
82   
83         result = PyList_New(0);
84 -       PyDict_SetItemString(lookupDict, ptrBuf, result);
85   
86         if (list != NULL)
87         {
88             for (curr = list->lv_first; curr != NULL; curr = curr->li_next)
89             {
90                 newObj = VimToPython(&curr->li_tv, depth + 1, lookupDict);
91 --- 1192,1202 ----
92         listitem_T      *curr;
93   
94         result = PyList_New(0);
95   
96         if (list != NULL)
97         {
98 +           PyDict_SetItemString(lookupDict, ptrBuf, result);
99
100             for (curr = list->lv_first; curr != NULL; curr = curr->li_next)
101             {
102                 newObj = VimToPython(&curr->li_tv, depth + 1, lookupDict);
103 ***************
104 *** 1200,1206 ****
105       else if (our_tv->v_type == VAR_DICT)
106       {
107         result = PyDict_New();
108 -       PyDict_SetItemString(lookupDict, ptrBuf, result);
109   
110         if (our_tv->vval.v_dict != NULL)
111         {
112 --- 1208,1213 ----
113 ***************
114 *** 1209,1214 ****
115 --- 1216,1223 ----
116             hashitem_T  *hi;
117             dictitem_T  *di;
118   
119 +           PyDict_SetItemString(lookupDict, ptrBuf, result);
120
121             for (hi = ht->ht_array; todo > 0; ++hi)
122             {
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
126 ***************
127 *** 678,679 ****
128 --- 678,681 ----
129   {   /* Add new patch number below this line */
130 + /**/
131 +     84,
132   /**/
133
134 -- 
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
139 ceremony?
140
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    ///
This page took 0.070111 seconds and 3 git commands to generate.