summaryrefslogtreecommitdiffstats
path: root/gvim/vim-7.2/7.2.149
blob: 7b51a571e17335174bf2103f45d4df890c1c9efe (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
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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
To: vim-dev@vim.org
Subject: Patch 7.2.149
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.149
Problem:    Using return value of function that doesn't return a value results
	    in reading uninitialized memory.
Solution:   Set the default to return zero.  Make cursor() return -1 on
	    failure.  Let complete() return an empty string in case of an
	    error.  (partly by Dominique Pelle)
Files:	    runtime/doc/eval.txt, src/eval.c


*** ../vim-7.2.148/runtime/doc/eval.txt	Tue Dec  9 10:56:50 2008
--- runtime/doc/eval.txt	Sun Mar 22 14:28:49 2009
***************
*** 2414,2419 ****
--- 2419,2425 ----
  		When 'virtualedit' is used {off} specifies the offset in
  		screen columns from the start of the character.  E.g., a
  		position within a <Tab> or after the last character.
+ 		Returns 0 when the position could be set, -1 otherwise.
  
  
  deepcopy({expr}[, {noref}])				*deepcopy()* *E698*
***************
*** 4516,4521 ****
--- 4526,4532 ----
  		should also work to move files across file systems.  The
  		result is a Number, which is 0 if the file was renamed
  		successfully, and non-zero when the renaming failed.
+ 		NOTE: If {to} exists it is overwritten without warning.
  		This function is not available in the |sandbox|.
  
  repeat({expr}, {count})					*repeat()*
*** ../vim-7.2.148/src/eval.c	Wed Feb  4 16:25:53 2009
--- src/eval.c	Sun Mar 22 20:45:18 2009
***************
*** 1285,1291 ****
--- 1285,1293 ----
      typval_T	tv;
      char_u	*retval;
      garray_T	ga;
+ #ifdef FEAT_FLOAT
      char_u	numbuf[NUMBUFLEN];
+ #endif
  
      if (eval0(arg, &tv, nextcmd, TRUE) == FAIL)
  	retval = NULL;
***************
*** 8018,8024 ****
      /* execute the function if no errors detected and executing */
      if (evaluate && error == ERROR_NONE)
      {
! 	rettv->v_type = VAR_NUMBER;	/* default is number rettv */
  	error = ERROR_UNKNOWN;
  
  	if (!builtin_function(fname))
--- 8020,8027 ----
      /* execute the function if no errors detected and executing */
      if (evaluate && error == ERROR_NONE)
      {
! 	rettv->v_type = VAR_NUMBER;	/* default rettv is number zero */
! 	rettv->vval.v_number = 0;
  	error = ERROR_UNKNOWN;
  
  	if (!builtin_function(fname))
***************
*** 8268,8274 ****
  		return;
  	    li = l->lv_first;
  	}
- 	rettv->vval.v_number = 0;	/* Default: Success */
  	for (;;)
  	{
  	    if (l == NULL)
--- 8271,8276 ----
***************
*** 8728,8734 ****
      int		dummy;
      dict_T	*selfdict = NULL;
  
-     rettv->vval.v_number = 0;
      if (argvars[1].v_type != VAR_LIST)
      {
  	EMSG(_(e_listreq));
--- 8730,8735 ----
***************
*** 9036,9048 ****
      if (buttons == NULL || *buttons == NUL)
  	buttons = (char_u *)_("&Ok");
  
!     if (error)
! 	rettv->vval.v_number = 0;
!     else
  	rettv->vval.v_number = do_dialog(type, NULL, message, buttons,
  								   def, NULL);
- #else
-     rettv->vval.v_number = 0;
  #endif
  }
  
--- 9037,9045 ----
      if (buttons == NULL || *buttons == NUL)
  	buttons = (char_u *)_("&Ok");
  
!     if (!error)
  	rettv->vval.v_number = do_dialog(type, NULL, message, buttons,
  								   def, NULL);
  #endif
  }
  
***************
*** 9181,9195 ****
      }
  
      rettv->vval.v_number = cs_connection(num, dbpath, prepend);
- #else
-     rettv->vval.v_number = 0;
  #endif
  }
  
  /*
   * "cursor(lnum, col)" function
   *
!  * Moves the cursor to the specified line and column
   */
  /*ARGSUSED*/
      static void
--- 9178,9191 ----
      }
  
      rettv->vval.v_number = cs_connection(num, dbpath, prepend);
  #endif
  }
  
  /*
   * "cursor(lnum, col)" function
   *
!  * Moves the cursor to the specified line and column.
!  * Returns 0 when the position could be set, -1 otherwise.
   */
  /*ARGSUSED*/
      static void
***************
*** 9202,9207 ****
--- 9198,9204 ----
      long	coladd = 0;
  #endif
  
+     rettv->vval.v_number = -1;
      if (argvars[1].v_type == VAR_UNKNOWN)
      {
  	pos_T	    pos;
***************
*** 9246,9251 ****
--- 9243,9249 ----
  #endif
  
      curwin->w_set_curswant = TRUE;
+     rettv->vval.v_number = 0;
  }
  
  /*
***************
*** 9291,9298 ****
  {
  #ifdef FEAT_AUTOCMD
      rettv->vval.v_number = did_filetype;
- #else
-     rettv->vval.v_number = 0;
  #endif
  }
  
--- 9289,9294 ----
***************
*** 9605,9611 ****
      typval_T	*argvars;
      typval_T	*rettv;
  {
-     rettv->vval.v_number = 0;
      if (argvars[0].v_type == VAR_LIST && argvars[1].v_type == VAR_LIST)
      {
  	list_T		*l1, *l2;
--- 9601,9606 ----
***************
*** 9733,9739 ****
      if (check_secure())
  	return;
  
-     rettv->vval.v_number = 0;
      keys = get_tv_string(&argvars[0]);
      if (*keys != NUL)
      {
--- 9728,9733 ----
***************
*** 9901,9907 ****
      char_u	*ermsg = map ? (char_u *)"map()" : (char_u *)"filter()";
      int		save_did_emsg;
  
-     rettv->vval.v_number = 0;
      if (argvars[0].v_type == VAR_LIST)
      {
  	if ((l = argvars[0].vval.v_list) == NULL
--- 9895,9900 ----
***************
*** 10084,10091 ****
  	else
  	    rettv->vval.v_number = (varnumber_T)f;
      }
-     else
- 	rettv->vval.v_number = 0;
  }
  
  /*
--- 10077,10082 ----
***************
*** 10219,10227 ****
      lnum = get_tv_lnum(argvars);
      if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count)
  	rettv->vval.v_number = foldLevel(lnum);
-     else
  #endif
- 	rettv->vval.v_number = 0;
  }
  
  /*
--- 10210,10216 ----
***************
*** 10337,10343 ****
      typval_T	*argvars;
      typval_T	*rettv;
  {
-     rettv->vval.v_number = 0;
  #ifdef FEAT_GUI
      if (gui.in_use)
  	gui_mch_set_foreground();
--- 10326,10331 ----
***************
*** 10359,10365 ****
  {
      char_u	*s;
  
-     rettv->vval.v_number = 0;
      s = get_tv_string(&argvars[0]);
      if (s == NULL || *s == NUL || VIM_ISDIGIT(*s))
  	EMSG2(_(e_invarg2), s);
--- 10347,10352 ----
***************
*** 10429,10437 ****
  
      if (tv == NULL)
      {
! 	if (argvars[2].v_type == VAR_UNKNOWN)
! 	    rettv->vval.v_number = 0;
! 	else
  	    copy_tv(&argvars[2], rettv);
      }
      else
--- 10416,10422 ----
  
      if (tv == NULL)
      {
! 	if (argvars[2].v_type != VAR_UNKNOWN)
  	    copy_tv(&argvars[2], rettv);
      }
      else
***************
*** 10456,10468 ****
  {
      char_u	*p;
  
!     if (retlist)
!     {
! 	if (rettv_list_alloc(rettv) == FAIL)
! 	    return;
!     }
!     else
! 	rettv->vval.v_number = 0;
  
      if (buf == NULL || buf->b_ml.ml_mfp == NULL || start < 0)
  	return;
--- 10441,10448 ----
  {
      char_u	*p;
  
!     if (retlist && rettv_list_alloc(rettv) == FAIL)
! 	return;
  
      if (buf == NULL || buf->b_ml.ml_mfp == NULL || start < 0)
  	return;
***************
*** 11009,11016 ****
      dict_T	*dict;
      matchitem_T	*cur = curwin->w_match_head;
  
-     rettv->vval.v_number = 0;
- 
      if (rettv_list_alloc(rettv) == OK)
      {
  	while (cur != NULL)
--- 10989,10994 ----
***************
*** 11089,11095 ****
      win_T	*wp;
  #endif
  
-     rettv->vval.v_number = 0;
  #ifdef FEAT_QUICKFIX
      if (rettv_list_alloc(rettv) == OK)
      {
--- 11067,11072 ----
***************
*** 11935,11941 ****
      typval_T	*argvars;
      typval_T	*rettv;
  {
-     rettv->vval.v_number = 0;
      if (argvars[0].v_type != VAR_DICT)
      {
  	EMSG(_(e_dictreq));
--- 11912,11917 ----
***************
*** 12052,12059 ****
  	n = del_history_entry(get_histtype(str),
  				      get_tv_string_buf(&argvars[1], buf));
      rettv->vval.v_number = n;
- #else
-     rettv->vval.v_number = 0;
  #endif
  }
  
--- 12028,12033 ----
***************
*** 12415,12421 ****
      int		selected;
      int		mouse_used;
  
-     rettv->vval.v_number = 0;
  #ifdef NO_CONSOLE_INPUT
      /* While starting up, there is no place to enter text. */
      if (no_console_input())
--- 12389,12394 ----
***************
*** 12464,12470 ****
  	--ga_userinput.ga_len;
  	restore_typeahead((tasave_T *)(ga_userinput.ga_data)
  						       + ga_userinput.ga_len);
! 	rettv->vval.v_number = 0; /* OK */
      }
      else if (p_verbose > 1)
      {
--- 12437,12443 ----
  	--ga_userinput.ga_len;
  	restore_typeahead((tasave_T *)(ga_userinput.ga_data)
  						       + ga_userinput.ga_len);
! 	/* default return is zero == OK */
      }
      else if (p_verbose > 1)
      {
***************
*** 12488,12494 ****
  	save_typeahead((tasave_T *)(ga_userinput.ga_data)
  						       + ga_userinput.ga_len);
  	++ga_userinput.ga_len;
! 	rettv->vval.v_number = 0; /* OK */
      }
      else
  	rettv->vval.v_number = 1; /* Failed */
--- 12461,12467 ----
  	save_typeahead((tasave_T *)(ga_userinput.ga_data)
  						       + ga_userinput.ga_len);
  	++ga_userinput.ga_len;
! 	/* default return is zero == OK */
      }
      else
  	rettv->vval.v_number = 1; /* Failed */
***************
*** 12522,12528 ****
      list_T	*l;
      int		error = FALSE;
  
-     rettv->vval.v_number = 0;
      if (argvars[0].v_type != VAR_LIST)
  	EMSG2(_(e_listarg), "insert()");
      else if ((l = argvars[0].vval.v_list) != NULL
--- 12495,12500 ----
***************
*** 12641,12647 ****
      dict_T	*d;
      int		todo;
  
-     rettv->vval.v_number = 0;
      if (argvars[0].v_type != VAR_DICT)
      {
  	EMSG(_(e_dictreq));
--- 12613,12618 ----
***************
*** 12729,12735 ****
      garray_T	ga;
      char_u	*sep;
  
-     rettv->vval.v_number = 0;
      if (argvars[0].v_type != VAR_LIST)
      {
  	EMSG(_(e_listreq));
--- 12700,12705 ----
***************
*** 12827,12835 ****
  #endif
  
      rettv->v_type = type;
!     if (type == VAR_NUMBER)
! 	rettv->vval.v_number = 0;
!     else
  	rettv->vval.v_string = NULL;
  
      if (check_restricted() || check_secure())
--- 12797,12803 ----
  #endif
  
      rettv->v_type = type;
!     if (type != VAR_NUMBER)
  	rettv->vval.v_string = NULL;
  
      if (check_restricted() || check_secure())
***************
*** 13770,13776 ****
      typval_T	*argvars;
      typval_T	*rettv;
  {
-     rettv->vval.v_number = 0;
  #ifdef FEAT_INS_EXPAND
      if (pum_visible())
  	rettv->vval.v_number = 1;
--- 13738,13743 ----
***************
*** 13804,13810 ****
  	    stride = get_tv_number_chk(&argvars[2], &error);
      }
  
-     rettv->vval.v_number = 0;
      if (error)
  	return;		/* type error; errmsg already given */
      if (stride == 0)
--- 13771,13776 ----
***************
*** 14193,14199 ****
      typval_T	*argvars;
      typval_T	*rettv;
  {
-     rettv->vval.v_number = 0;
  #ifdef FEAT_CLIENTSERVER
  # ifdef WIN32
      /* On Win32 it's done in this application. */
--- 14159,14164 ----
***************
*** 14249,14255 ****
  	rettv->vval.v_number = (s != NULL);
      }
  # else
-     rettv->vval.v_number = 0;
      if (check_connection() == FAIL)
  	return;
  
--- 14214,14219 ----
***************
*** 14338,14344 ****
      dict_T	*d;
      dictitem_T	*di;
  
-     rettv->vval.v_number = 0;
      if (argvars[0].v_type == VAR_DICT)
      {
  	if (argvars[2].v_type != VAR_UNKNOWN)
--- 14302,14307 ----
***************
*** 14696,14702 ****
      list_T	*l;
      listitem_T	*li, *ni;
  
-     rettv->vval.v_number = 0;
      if (argvars[0].v_type != VAR_LIST)
  	EMSG2(_(e_listarg), "reverse()");
      else if ((l = argvars[0].vval.v_list) != NULL
--- 14659,14664 ----
***************
*** 15048,15055 ****
      int		lnum = 0;
      int		col = 0;
  
-     rettv->vval.v_number = 0;
- 
      if (rettv_list_alloc(rettv) == FAIL)
  	return;
  
--- 15010,15015 ----
***************
*** 15236,15243 ****
      int		n;
      int		flags = 0;
  
-     rettv->vval.v_number = 0;
- 
      if (rettv_list_alloc(rettv) == FAIL)
  	return;
  
--- 15196,15201 ----
***************
*** 15323,15330 ****
      typval_T	*varp;
      char_u	nbuf[NUMBUFLEN];
  
-     rettv->vval.v_number = 0;
- 
      if (check_restricted() || check_secure())
  	return;
      (void)get_tv_number(&argvars[0]);	    /* issue errmsg if type error */
--- 15281,15286 ----
***************
*** 15404,15410 ****
      else
  	line = get_tv_string_chk(&argvars[1]);
  
!     rettv->vval.v_number = 0;		/* OK */
      for (;;)
      {
  	if (l != NULL)
--- 15360,15366 ----
      else
  	line = get_tv_string_chk(&argvars[1]);
  
!     /* default result is zero == OK */
      for (;;)
      {
  	if (l != NULL)
***************
*** 15717,15722 ****
--- 15673,15679 ----
  /*
   * "setwinvar()" and "settabwinvar()" functions
   */
+ /*ARGSUSED*/
      static void
  setwinvar(argvars, rettv, off)
      typval_T	*argvars;
***************
*** 15733,15740 ****
      char_u	nbuf[NUMBUFLEN];
      tabpage_T	*tp;
  
-     rettv->vval.v_number = 0;
- 
      if (check_restricted() || check_secure())
  	return;
  
--- 15690,15695 ----
***************
*** 15947,15953 ****
      long	len;
      long	i;
  
-     rettv->vval.v_number = 0;
      if (argvars[0].v_type != VAR_LIST)
  	EMSG2(_(e_listarg), "sort()");
      else
--- 15902,15907 ----
***************
*** 16870,16878 ****
      typval_T	*argvars;
      typval_T	*rettv;
  {
! #ifndef FEAT_WINDOWS
!     rettv->vval.v_number = 0;
! #else
      tabpage_T	*tp;
      win_T	*wp = NULL;
  
--- 16824,16830 ----
      typval_T	*argvars;
      typval_T	*rettv;
  {
! #ifdef FEAT_WINDOWS
      tabpage_T	*tp;
      win_T	*wp = NULL;
  
***************
*** 16884,16902 ****
  	if (tp != NULL)
  	    wp = (tp == curtab) ? firstwin : tp->tp_firstwin;
      }
!     if (wp == NULL)
! 	rettv->vval.v_number = 0;
!     else
      {
! 	if (rettv_list_alloc(rettv) == FAIL)
! 	    rettv->vval.v_number = 0;
! 	else
! 	{
! 	    for (; wp != NULL; wp = wp->w_next)
! 		if (list_append_number(rettv->vval.v_list,
  						wp->w_buffer->b_fnum) == FAIL)
! 		    break;
! 	}
      }
  #endif
  }
--- 16836,16847 ----
  	if (tp != NULL)
  	    wp = (tp == curtab) ? firstwin : tp->tp_firstwin;
      }
!     if (wp != NULL && rettv_list_alloc(rettv) != FAIL)
      {
! 	for (; wp != NULL; wp = wp->w_next)
! 	    if (list_append_number(rettv->vval.v_list,
  						wp->w_buffer->b_fnum) == FAIL)
! 		break;
      }
  #endif
  }
***************
*** 17024,17033 ****
      int		first;
  
      if (rettv_list_alloc(rettv) == FAIL)
-     {
- 	rettv->vval.v_number = 0;
  	return;
-     }
  
      for (first = TRUE; ; first = FALSE)
  	if (get_tagfname(&tn, first, fname) == FAIL
--- 16969,16975 ----
***************
*** 17401,17408 ****
      /* A non-zero number or non-empty string argument: reset mode. */
      if (non_zero_arg(&argvars[0]))
  	curbuf->b_visual_mode_eval = NUL;
- #else
-     rettv->vval.v_number = 0; /* return anything, it won't work anyway */
  #endif
  }
  
--- 17343,17348 ----
*** ../vim-7.2.148/src/version.c	Wed Mar 18 19:07:09 2009
--- src/version.c	Wed Apr 22 12:44:05 2009
***************
*** 678,679 ****
--- 678,681 ----
  {   /* Add new patch number below this line */
+ /**/
+     149,
  /**/


-- 
WOMAN:   Well, 'ow did you become king then?
ARTHUR:  The Lady of the Lake, [angels sing] her arm clad in the purest
         shimmering samite, held aloft Excalibur from the bosom of the water
         signifying by Divine Providence that I, Arthur, was to carry
         Excalibur.  [singing stops] That is why I am your king!
                                  The Quest for the Holy Grail (Monty Python)

 /// 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    ///