summaryrefslogtreecommitdiffstats
path: root/vi/vim-7.2/7.2.084
blob: 4c912ca7a597b39672e23a490a5585ff1342ec7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
To: vim-dev@vim.org
Subject: Patch 7.2.084
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------

Patch 7.2.084
Problem:    Recursive structures are not handled properly in Python
	    vim.eval().
Solution:   Keep track of references in a better way. (Yukihiro Nakadaira)
Files:	    src/if_python.c


*** ../vim-7.2.083/src/if_python.c	Thu Nov 20 11:04:01 2008
--- src/if_python.c	Tue Jan 13 18:08:06 2009
***************
*** 1151,1164 ****
  
      /* Check if we run into a recursive loop.  The item must be in lookupDict
       * then and we can use it again. */
!     sprintf(ptrBuf, PRINTF_DECIMAL_LONG_U, (long_u)our_tv);
!     result = PyDict_GetItemString(lookupDict, ptrBuf);
!     if (result != NULL)
! 	Py_INCREF(result);
!     else if (our_tv->v_type == VAR_STRING)
      {
  	result = Py_BuildValue("s", our_tv->vval.v_string);
- 	PyDict_SetItemString(lookupDict, ptrBuf, result);
      }
      else if (our_tv->v_type == VAR_NUMBER)
      {
--- 1151,1173 ----
  
      /* Check if we run into a recursive loop.  The item must be in lookupDict
       * then and we can use it again. */
!     if ((our_tv->v_type == VAR_LIST && our_tv->vval.v_list != NULL)
! 	    || (our_tv->v_type == VAR_DICT && our_tv->vval.v_dict != NULL))
!     {
! 	sprintf(ptrBuf, PRINTF_DECIMAL_LONG_U,
! 	        our_tv->v_type == VAR_LIST ? (long_u)our_tv->vval.v_list
! 		                           : (long_u)our_tv->vval.v_dict);
! 	result = PyDict_GetItemString(lookupDict, ptrBuf);
! 	if (result != NULL)
! 	{
! 	    Py_INCREF(result);
! 	    return result;
! 	}
!     }
! 
!     if (our_tv->v_type == VAR_STRING)
      {
  	result = Py_BuildValue("s", our_tv->vval.v_string);
      }
      else if (our_tv->v_type == VAR_NUMBER)
      {
***************
*** 1167,1173 ****
  	/* For backwards compatibility numbers are stored as strings. */
  	sprintf(buf, "%ld", (long)our_tv->vval.v_number);
  	result = Py_BuildValue("s", buf);
- 	PyDict_SetItemString(lookupDict, ptrBuf, result);
      }
  # ifdef FEAT_FLOAT
      else if (our_tv->v_type == VAR_FLOAT)
--- 1176,1181 ----
***************
*** 1176,1182 ****
  
  	sprintf(buf, "%f", our_tv->vval.v_float);
  	result = Py_BuildValue("s", buf);
- 	PyDict_SetItemString(lookupDict, ptrBuf, result);
      }
  # endif
      else if (our_tv->v_type == VAR_LIST)
--- 1184,1189 ----
***************
*** 1185,1194 ****
  	listitem_T	*curr;
  
  	result = PyList_New(0);
- 	PyDict_SetItemString(lookupDict, ptrBuf, result);
  
  	if (list != NULL)
  	{
  	    for (curr = list->lv_first; curr != NULL; curr = curr->li_next)
  	    {
  		newObj = VimToPython(&curr->li_tv, depth + 1, lookupDict);
--- 1192,1202 ----
  	listitem_T	*curr;
  
  	result = PyList_New(0);
  
  	if (list != NULL)
  	{
+ 	    PyDict_SetItemString(lookupDict, ptrBuf, result);
+ 
  	    for (curr = list->lv_first; curr != NULL; curr = curr->li_next)
  	    {
  		newObj = VimToPython(&curr->li_tv, depth + 1, lookupDict);
***************
*** 1200,1206 ****
      else if (our_tv->v_type == VAR_DICT)
      {
  	result = PyDict_New();
- 	PyDict_SetItemString(lookupDict, ptrBuf, result);
  
  	if (our_tv->vval.v_dict != NULL)
  	{
--- 1208,1213 ----
***************
*** 1209,1214 ****
--- 1216,1223 ----
  	    hashitem_T	*hi;
  	    dictitem_T	*di;
  
+ 	    PyDict_SetItemString(lookupDict, ptrBuf, result);
+ 
  	    for (hi = ht->ht_array; todo > 0; ++hi)
  	    {
  		if (!HASHITEM_EMPTY(hi))
*** ../vim-7.2.083/src/version.c	Tue Jan 13 17:27:18 2009
--- src/version.c	Tue Jan 13 17:54:14 2009
***************
*** 678,679 ****
--- 678,681 ----
  {   /* Add new patch number below this line */
+ /**/
+     84,
  /**/

-- 
Article in the first Free Software Magazine: "Bram Moolenaar studied electrical
engineering at the Technical University of Delft and graduated in 1985 on a
multi-processor Unix architecture."
Response by "dimator": Could the school not afford a proper stage for the
ceremony?

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///