summaryrefslogtreecommitdiffstats
path: root/source/ap/vim/patches/7.3.451
blob: 25d1b04677ee153437924e0b0daedafd7ae5fa86 (plain) (blame)
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
To: vim_dev@googlegroups.com
Subject: Patch 7.3.451
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.3.451
Problem:    Tcl doesn't work on 64 bit MS-Windows.
Solution:   Make it work. (Dave Bodenstab)
Files:	    src/Make_mvc.mak, src/if_tcl.c


*** ../vim-7.3.450/src/Make_mvc.mak	2012-02-12 01:55:50.000000000 +0100
--- src/Make_mvc.mak	2012-02-22 15:43:01.000000000 +0100
***************
*** 616,622 ****
  		-DDYNAMIC_TCL_VER=\"$(TCL_VER_LONG)\"
  TCL_OBJ	= $(OUTDIR)\if_tcl.obj
  TCL_INC	= /I "$(TCL)\Include" /I "$(TCL)"
! TCL_LIB = $(TCL)\lib\tclstub$(TCL_VER).lib
  !else
  CFLAGS  = $(CFLAGS) -DFEAT_TCL
  TCL_OBJ	= $(OUTDIR)\if_tcl.obj
--- 616,622 ----
  		-DDYNAMIC_TCL_VER=\"$(TCL_VER_LONG)\"
  TCL_OBJ	= $(OUTDIR)\if_tcl.obj
  TCL_INC	= /I "$(TCL)\Include" /I "$(TCL)"
! TCL_LIB = "$(TCL)\lib\tclstub$(TCL_VER).lib"
  !else
  CFLAGS  = $(CFLAGS) -DFEAT_TCL
  TCL_OBJ	= $(OUTDIR)\if_tcl.obj
*** ../vim-7.3.450/src/if_tcl.c	2011-07-27 14:15:41.000000000 +0200
--- src/if_tcl.c	2012-02-22 15:47:00.000000000 +0100
***************
*** 79,90 ****
  typedef struct
  {
      Tcl_Interp *interp;
      int range_start, range_end;
      int lbase;
      char *curbuf, *curwin;
  } tcl_info;
  
! static tcl_info tclinfo = { NULL, 0, 0, 0, NULL, NULL };
  
  #define VAR_RANGE1	"::vim::range(start)"
  #define VAR_RANGE2	"::vim::range(begin)"
--- 79,91 ----
  typedef struct
  {
      Tcl_Interp *interp;
+     int exitvalue;
      int range_start, range_end;
      int lbase;
      char *curbuf, *curwin;
  } tcl_info;
  
! static tcl_info tclinfo = { NULL, 0, 0, 0, 0, NULL, NULL };
  
  #define VAR_RANGE1	"::vim::range(start)"
  #define VAR_RANGE2	"::vim::range(begin)"
***************
*** 279,294 ****
   ****************************************************************************/
  
  /*
!  * Replace standard "exit" and "catch" commands.
   *
!  * This is a design flaw in Tcl -  the standard "exit" command just calls
!  * exit() and kills the application.  It should return TCL_EXIT to the
!  * app, which then decides if it wants to terminate or not.  In our case,
!  * we just delete the Tcl interpreter (and create a new one with the next
!  * :tcl command).
   */
- #define TCL_EXIT	5
- 
      static int
  exitcmd(dummy, interp, objc, objv)
      ClientData dummy UNUSED;
--- 280,298 ----
   ****************************************************************************/
  
  /*
!  * Replace standard "exit" command.
   *
!  * Delete the Tcl interpreter; a new one will be created with the next
!  * :tcl command). The exit code is saved (and retrieved in tclexit()).
!  * Since Tcl's exit is never expected to return and this replacement
!  * does, then (except for a trivial case) additional Tcl commands will
!  * be run. Since the interpreter is now marked as deleted, an error
!  * will be returned -- typically "attempt to call eval in deleted
!  * interpreter". Hopefully, at this point, checks for TCL_ERROR take
!  * place and control percolates back up to Vim -- but with this new error
!  * string in the interpreter's result value. Therefore it would be
!  * useless for this routine to return the exit code via Tcl_SetResult().
   */
      static int
  exitcmd(dummy, interp, objc, objv)
      ClientData dummy UNUSED;
***************
*** 305,351 ****
  		break;
  	    /* FALLTHROUGH */
  	case 1:
! 	    Tcl_SetObjResult(interp, Tcl_NewIntObj(value));
! 	    return TCL_EXIT;
! 	default:
! 	    Tcl_WrongNumArgs(interp, 1, objv, "?returnCode?");
!     }
!     return TCL_ERROR;
! }
  
!     static int
! catchcmd(dummy, interp, objc, objv)
!     ClientData	dummy UNUSED;
!     Tcl_Interp	*interp;
!     int		objc;
!     Tcl_Obj	*CONST objv[];
! {
!     char    *varname = NULL;
!     int	    result;
! 
!     switch (objc)
!     {
! 	case 3:
! 	    varname = Tcl_GetStringFromObj(objv[2], NULL);
! 	    /* fallthrough */
! 	case 2:
! 	    Tcl_ResetResult(interp);
! 	    Tcl_AllowExceptions(interp);
! 	    result = Tcl_EvalObj(interp, objv[1]);
! 	    if (result == TCL_EXIT)
! 		return result;
! 	    if (varname)
! 	    {
! 		if (Tcl_SetVar(interp, varname, Tcl_GetStringResult(interp), 0) == NULL)
! 		{
! 		    Tcl_SetResult(interp, "couldn't save command result in variable", TCL_STATIC);
! 		    return TCL_ERROR;
! 		}
! 	    }
! 	    Tcl_SetObjResult(interp, Tcl_NewIntObj(result));
! 	    return TCL_OK;
  	default:
! 	    Tcl_WrongNumArgs(interp, 1, objv, "command ?varName?");
      }
      return TCL_ERROR;
  }
--- 309,320 ----
  		break;
  	    /* FALLTHROUGH */
  	case 1:
! 	    tclinfo.exitvalue = value;
  
! 	    Tcl_DeleteInterp(interp);
! 	    break;
  	default:
! 	    Tcl_WrongNumArgs(interp, 1, objv, "?returnCode?");
      }
      return TCL_ERROR;
  }
***************
*** 372,377 ****
--- 341,347 ----
  /*
   *  "::vim::buffer list" - create a list of buffer commands.
   *  "::vim::buffer {N}" - create buffer command for buffer N.
+  *  "::vim::buffer exists {N}" - test if buffer N exists.
   *  "::vim::buffer new" - create a new buffer (not implemented)
   */
      static int
***************
*** 1663,1669 ****
  static Tcl_ChannelType channel_type =
  {
      "vimmessage",	/* typeName */
!     NULL,		/* version */
      channel_close,	/* closeProc */
      channel_input,	/* inputProc */
      channel_output,	/* outputProc */
--- 1633,1639 ----
  static Tcl_ChannelType channel_type =
  {
      "vimmessage",	/* typeName */
!     TCL_CHANNEL_VERSION_2, /* version */
      channel_close,	/* closeProc */
      channel_input,	/* inputProc */
      channel_output,	/* outputProc */
***************
*** 1678,1683 ****
--- 1648,1655 ----
      NULL,		/* flushProc */
      NULL,		/* handlerProc */
  #endif
+ /* The following should not be necessary since TCL_CHANNEL_VERSION_2 was
+  * set above */
  #ifdef TCL_CHANNEL_VERSION_3
      NULL,		/* wideSeekProc */
  #endif
***************
*** 1741,1747 ****
  	Tcl_Interp *interp;
  	static Tcl_Channel ch1, ch2;
  
! 	/* replace stdout and stderr */
  	ch1 = Tcl_CreateChannel(&channel_type, "vimout", VIMOUT, TCL_WRITABLE);
  	ch2 = Tcl_CreateChannel(&channel_type, "vimerr", VIMERR, TCL_WRITABLE);
  	Tcl_SetStdChannel(ch1, TCL_STDOUT);
--- 1713,1721 ----
  	Tcl_Interp *interp;
  	static Tcl_Channel ch1, ch2;
  
! 	/* Create replacement channels for stdout and stderr; this has to be
! 	 * done each time an interpreter is created since the channels are closed
! 	 * when the interpreter is deleted */
  	ch1 = Tcl_CreateChannel(&channel_type, "vimout", VIMOUT, TCL_WRITABLE);
  	ch2 = Tcl_CreateChannel(&channel_type, "vimerr", VIMERR, TCL_WRITABLE);
  	Tcl_SetStdChannel(ch1, TCL_STDOUT);
***************
*** 1761,1775 ****
  #endif
  
  	Tcl_SetChannelOption(interp, ch1, "-buffering", "line");
  	Tcl_SetChannelOption(interp, ch2, "-buffering", "line");
  
! 	/* replace some standard Tcl commands */
  	Tcl_DeleteCommand(interp, "exit");
  	Tcl_CreateObjCommand(interp, "exit", exitcmd,
  	    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
- 	Tcl_DeleteCommand(interp, "catch");
- 	Tcl_CreateObjCommand(interp, "catch", catchcmd,
- 	    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
  
  	/* new commands, in ::vim namespace */
  	Tcl_CreateObjCommand(interp, "::vim::buffer", buffercmd,
--- 1735,1752 ----
  #endif
  
  	Tcl_SetChannelOption(interp, ch1, "-buffering", "line");
+ #ifdef WIN3264
+ 	Tcl_SetChannelOption(interp, ch1, "-translation", "lf");
+ #endif
  	Tcl_SetChannelOption(interp, ch2, "-buffering", "line");
+ #ifdef WIN3264
+ 	Tcl_SetChannelOption(interp, ch2, "-translation", "lf");
+ #endif
  
! 	/* replace standard Tcl exit command */
  	Tcl_DeleteCommand(interp, "exit");
  	Tcl_CreateObjCommand(interp, "exit", exitcmd,
  	    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
  
  	/* new commands, in ::vim namespace */
  	Tcl_CreateObjCommand(interp, "::vim::buffer", buffercmd,
***************
*** 1821,1826 ****
--- 1798,1805 ----
  	tclinfo.range_end = row2tcl(eap->line2);
  	tclupdatevars();
      }
+ 
+     tclinfo.exitvalue = 0;
      return OK;
  }
  
***************
*** 1884,1913 ****
  {
      int newerr = OK;
  
!     if (error == TCL_EXIT)
      {
- 	int retval;
  	char buf[50];
- 	Tcl_Obj *robj;
  
! 	robj = Tcl_GetObjResult(tclinfo.interp);
! 	if (Tcl_GetIntFromObj(tclinfo.interp, robj, &retval) != TCL_OK)
  	{
! 	    EMSG(_("E281: TCL ERROR: exit code is not int!? Please report this to vim-dev@vim.org"));
! 	    newerr = FAIL;
  	}
  	else
! 	{
! 	    sprintf(buf, _("E572: exit code %d"), retval);
! 	    tclerrmsg(buf);
! 	    if (retval == 0)
! 	    {
! 		did_emsg = 0;
! 		newerr = OK;
! 	    }
! 	    else
! 		newerr = FAIL;
! 	}
  
  	tcldelthisinterp();
      }
--- 1863,1885 ----
  {
      int newerr = OK;
  
!     if (Tcl_InterpDeleted(tclinfo.interp)     /* True if we intercepted Tcl's exit command */
! #if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 5) || TCL_MAJOR_VERSION > 8
! 	|| Tcl_LimitExceeded(tclinfo.interp)  /* True if the interpreter cannot continue */
! #endif
! 	)
      {
  	char buf[50];
  
! 	sprintf(buf, _("E572: exit code %d"), tclinfo.exitvalue);
! 	tclerrmsg(buf);
! 	if (tclinfo.exitvalue == 0)
  	{
! 	    did_emsg = 0;
! 	    newerr = OK;
  	}
  	else
! 	    newerr = FAIL;
  
  	tcldelthisinterp();
      }
***************
*** 2021,2027 ****
  	Tcl_SetVar(tclinfo.interp, var_line, line, 0);
  	Tcl_AllowExceptions(tclinfo.interp);
  	err = Tcl_Eval(tclinfo.interp, script);
! 	if (err != TCL_OK)
  	    break;
  	line = (char *)Tcl_GetVar(tclinfo.interp, var_line, 0);
  	if (line)
--- 1993,2004 ----
  	Tcl_SetVar(tclinfo.interp, var_line, line, 0);
  	Tcl_AllowExceptions(tclinfo.interp);
  	err = Tcl_Eval(tclinfo.interp, script);
! 	if (err != TCL_OK
! 	    || Tcl_InterpDeleted(tclinfo.interp)
! #if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 5) || TCL_MAJOR_VERSION > 8
! 	    || Tcl_LimitExceeded(tclinfo.interp)
! #endif
! 	   )
  	    break;
  	line = (char *)Tcl_GetVar(tclinfo.interp, var_line, 0);
  	if (line)
*** ../vim-7.3.450/src/version.c	2012-02-22 15:34:05.000000000 +0100
--- src/version.c	2012-02-22 16:00:49.000000000 +0100
***************
*** 716,717 ****
--- 716,719 ----
  {   /* Add new patch number below this line */
+ /**/
+     451,
  /**/

-- 
Where do you want to crash today?

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///