]> git.pld-linux.org Git - packages/vim.git/blob - 7.2.149
- new
[packages/vim.git] / 7.2.149
1 To: vim-dev@vim.org
2 Subject: Patch 7.2.149
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.149
11 Problem:    Using return value of function that doesn't return a value results
12             in reading uninitialized memory.
13 Solution:   Set the default to return zero.  Make cursor() return -1 on
14             failure.  Let complete() return an empty string in case of an
15             error.  (partly by Dominique Pelle)
16 Files:      runtime/doc/eval.txt, src/eval.c
17
18
19 *** ../vim-7.2.148/runtime/doc/eval.txt Tue Dec  9 10:56:50 2008
20 --- runtime/doc/eval.txt        Sun Mar 22 14:28:49 2009
21 ***************
22 *** 2414,2419 ****
23 --- 2419,2425 ----
24                 When 'virtualedit' is used {off} specifies the offset in
25                 screen columns from the start of the character.  E.g., a
26                 position within a <Tab> or after the last character.
27 +               Returns 0 when the position could be set, -1 otherwise.
28   
29   
30   deepcopy({expr}[, {noref}])                           *deepcopy()* *E698*
31 ***************
32 *** 4516,4521 ****
33 --- 4526,4532 ----
34                 should also work to move files across file systems.  The
35                 result is a Number, which is 0 if the file was renamed
36                 successfully, and non-zero when the renaming failed.
37 +               NOTE: If {to} exists it is overwritten without warning.
38                 This function is not available in the |sandbox|.
39   
40   repeat({expr}, {count})                                       *repeat()*
41 *** ../vim-7.2.148/src/eval.c   Wed Feb  4 16:25:53 2009
42 --- src/eval.c  Sun Mar 22 20:45:18 2009
43 ***************
44 *** 1285,1291 ****
45 --- 1285,1293 ----
46       typval_T  tv;
47       char_u    *retval;
48       garray_T  ga;
49 + #ifdef FEAT_FLOAT
50       char_u    numbuf[NUMBUFLEN];
51 + #endif
52   
53       if (eval0(arg, &tv, nextcmd, TRUE) == FAIL)
54         retval = NULL;
55 ***************
56 *** 8018,8024 ****
57       /* execute the function if no errors detected and executing */
58       if (evaluate && error == ERROR_NONE)
59       {
60 !       rettv->v_type = VAR_NUMBER;     /* default is number rettv */
61         error = ERROR_UNKNOWN;
62   
63         if (!builtin_function(fname))
64 --- 8020,8027 ----
65       /* execute the function if no errors detected and executing */
66       if (evaluate && error == ERROR_NONE)
67       {
68 !       rettv->v_type = VAR_NUMBER;     /* default rettv is number zero */
69 !       rettv->vval.v_number = 0;
70         error = ERROR_UNKNOWN;
71   
72         if (!builtin_function(fname))
73 ***************
74 *** 8268,8274 ****
75                 return;
76             li = l->lv_first;
77         }
78 -       rettv->vval.v_number = 0;       /* Default: Success */
79         for (;;)
80         {
81             if (l == NULL)
82 --- 8271,8276 ----
83 ***************
84 *** 8728,8734 ****
85       int               dummy;
86       dict_T    *selfdict = NULL;
87   
88 -     rettv->vval.v_number = 0;
89       if (argvars[1].v_type != VAR_LIST)
90       {
91         EMSG(_(e_listreq));
92 --- 8730,8735 ----
93 ***************
94 *** 9036,9048 ****
95       if (buttons == NULL || *buttons == NUL)
96         buttons = (char_u *)_("&Ok");
97   
98 !     if (error)
99 !       rettv->vval.v_number = 0;
100 !     else
101         rettv->vval.v_number = do_dialog(type, NULL, message, buttons,
102                                                                    def, NULL);
103 - #else
104 -     rettv->vval.v_number = 0;
105   #endif
106   }
107   
108 --- 9037,9045 ----
109       if (buttons == NULL || *buttons == NUL)
110         buttons = (char_u *)_("&Ok");
111   
112 !     if (!error)
113         rettv->vval.v_number = do_dialog(type, NULL, message, buttons,
114                                                                    def, NULL);
115   #endif
116   }
117   
118 ***************
119 *** 9181,9195 ****
120       }
121   
122       rettv->vval.v_number = cs_connection(num, dbpath, prepend);
123 - #else
124 -     rettv->vval.v_number = 0;
125   #endif
126   }
127   
128   /*
129    * "cursor(lnum, col)" function
130    *
131 !  * Moves the cursor to the specified line and column
132    */
133   /*ARGSUSED*/
134       static void
135 --- 9178,9191 ----
136       }
137   
138       rettv->vval.v_number = cs_connection(num, dbpath, prepend);
139   #endif
140   }
141   
142   /*
143    * "cursor(lnum, col)" function
144    *
145 !  * Moves the cursor to the specified line and column.
146 !  * Returns 0 when the position could be set, -1 otherwise.
147    */
148   /*ARGSUSED*/
149       static void
150 ***************
151 *** 9202,9207 ****
152 --- 9198,9204 ----
153       long      coladd = 0;
154   #endif
155   
156 +     rettv->vval.v_number = -1;
157       if (argvars[1].v_type == VAR_UNKNOWN)
158       {
159         pos_T       pos;
160 ***************
161 *** 9246,9251 ****
162 --- 9243,9249 ----
163   #endif
164   
165       curwin->w_set_curswant = TRUE;
166 +     rettv->vval.v_number = 0;
167   }
168   
169   /*
170 ***************
171 *** 9291,9298 ****
172   {
173   #ifdef FEAT_AUTOCMD
174       rettv->vval.v_number = did_filetype;
175 - #else
176 -     rettv->vval.v_number = 0;
177   #endif
178   }
179   
180 --- 9289,9294 ----
181 ***************
182 *** 9605,9611 ****
183       typval_T  *argvars;
184       typval_T  *rettv;
185   {
186 -     rettv->vval.v_number = 0;
187       if (argvars[0].v_type == VAR_LIST && argvars[1].v_type == VAR_LIST)
188       {
189         list_T          *l1, *l2;
190 --- 9601,9606 ----
191 ***************
192 *** 9733,9739 ****
193       if (check_secure())
194         return;
195   
196 -     rettv->vval.v_number = 0;
197       keys = get_tv_string(&argvars[0]);
198       if (*keys != NUL)
199       {
200 --- 9728,9733 ----
201 ***************
202 *** 9901,9907 ****
203       char_u    *ermsg = map ? (char_u *)"map()" : (char_u *)"filter()";
204       int               save_did_emsg;
205   
206 -     rettv->vval.v_number = 0;
207       if (argvars[0].v_type == VAR_LIST)
208       {
209         if ((l = argvars[0].vval.v_list) == NULL
210 --- 9895,9900 ----
211 ***************
212 *** 10084,10091 ****
213         else
214             rettv->vval.v_number = (varnumber_T)f;
215       }
216 -     else
217 -       rettv->vval.v_number = 0;
218   }
219   
220   /*
221 --- 10077,10082 ----
222 ***************
223 *** 10219,10227 ****
224       lnum = get_tv_lnum(argvars);
225       if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count)
226         rettv->vval.v_number = foldLevel(lnum);
227 -     else
228   #endif
229 -       rettv->vval.v_number = 0;
230   }
231   
232   /*
233 --- 10210,10216 ----
234 ***************
235 *** 10337,10343 ****
236       typval_T  *argvars;
237       typval_T  *rettv;
238   {
239 -     rettv->vval.v_number = 0;
240   #ifdef FEAT_GUI
241       if (gui.in_use)
242         gui_mch_set_foreground();
243 --- 10326,10331 ----
244 ***************
245 *** 10359,10365 ****
246   {
247       char_u    *s;
248   
249 -     rettv->vval.v_number = 0;
250       s = get_tv_string(&argvars[0]);
251       if (s == NULL || *s == NUL || VIM_ISDIGIT(*s))
252         EMSG2(_(e_invarg2), s);
253 --- 10347,10352 ----
254 ***************
255 *** 10429,10437 ****
256   
257       if (tv == NULL)
258       {
259 !       if (argvars[2].v_type == VAR_UNKNOWN)
260 !           rettv->vval.v_number = 0;
261 !       else
262             copy_tv(&argvars[2], rettv);
263       }
264       else
265 --- 10416,10422 ----
266   
267       if (tv == NULL)
268       {
269 !       if (argvars[2].v_type != VAR_UNKNOWN)
270             copy_tv(&argvars[2], rettv);
271       }
272       else
273 ***************
274 *** 10456,10468 ****
275   {
276       char_u    *p;
277   
278 !     if (retlist)
279 !     {
280 !       if (rettv_list_alloc(rettv) == FAIL)
281 !           return;
282 !     }
283 !     else
284 !       rettv->vval.v_number = 0;
285   
286       if (buf == NULL || buf->b_ml.ml_mfp == NULL || start < 0)
287         return;
288 --- 10441,10448 ----
289   {
290       char_u    *p;
291   
292 !     if (retlist && rettv_list_alloc(rettv) == FAIL)
293 !       return;
294   
295       if (buf == NULL || buf->b_ml.ml_mfp == NULL || start < 0)
296         return;
297 ***************
298 *** 11009,11016 ****
299       dict_T    *dict;
300       matchitem_T       *cur = curwin->w_match_head;
301   
302 -     rettv->vval.v_number = 0;
303
304       if (rettv_list_alloc(rettv) == OK)
305       {
306         while (cur != NULL)
307 --- 10989,10994 ----
308 ***************
309 *** 11089,11095 ****
310       win_T     *wp;
311   #endif
312   
313 -     rettv->vval.v_number = 0;
314   #ifdef FEAT_QUICKFIX
315       if (rettv_list_alloc(rettv) == OK)
316       {
317 --- 11067,11072 ----
318 ***************
319 *** 11935,11941 ****
320       typval_T  *argvars;
321       typval_T  *rettv;
322   {
323 -     rettv->vval.v_number = 0;
324       if (argvars[0].v_type != VAR_DICT)
325       {
326         EMSG(_(e_dictreq));
327 --- 11912,11917 ----
328 ***************
329 *** 12052,12059 ****
330         n = del_history_entry(get_histtype(str),
331                                       get_tv_string_buf(&argvars[1], buf));
332       rettv->vval.v_number = n;
333 - #else
334 -     rettv->vval.v_number = 0;
335   #endif
336   }
337   
338 --- 12028,12033 ----
339 ***************
340 *** 12415,12421 ****
341       int               selected;
342       int               mouse_used;
343   
344 -     rettv->vval.v_number = 0;
345   #ifdef NO_CONSOLE_INPUT
346       /* While starting up, there is no place to enter text. */
347       if (no_console_input())
348 --- 12389,12394 ----
349 ***************
350 *** 12464,12470 ****
351         --ga_userinput.ga_len;
352         restore_typeahead((tasave_T *)(ga_userinput.ga_data)
353                                                        + ga_userinput.ga_len);
354 !       rettv->vval.v_number = 0; /* OK */
355       }
356       else if (p_verbose > 1)
357       {
358 --- 12437,12443 ----
359         --ga_userinput.ga_len;
360         restore_typeahead((tasave_T *)(ga_userinput.ga_data)
361                                                        + ga_userinput.ga_len);
362 !       /* default return is zero == OK */
363       }
364       else if (p_verbose > 1)
365       {
366 ***************
367 *** 12488,12494 ****
368         save_typeahead((tasave_T *)(ga_userinput.ga_data)
369                                                        + ga_userinput.ga_len);
370         ++ga_userinput.ga_len;
371 !       rettv->vval.v_number = 0; /* OK */
372       }
373       else
374         rettv->vval.v_number = 1; /* Failed */
375 --- 12461,12467 ----
376         save_typeahead((tasave_T *)(ga_userinput.ga_data)
377                                                        + ga_userinput.ga_len);
378         ++ga_userinput.ga_len;
379 !       /* default return is zero == OK */
380       }
381       else
382         rettv->vval.v_number = 1; /* Failed */
383 ***************
384 *** 12522,12528 ****
385       list_T    *l;
386       int               error = FALSE;
387   
388 -     rettv->vval.v_number = 0;
389       if (argvars[0].v_type != VAR_LIST)
390         EMSG2(_(e_listarg), "insert()");
391       else if ((l = argvars[0].vval.v_list) != NULL
392 --- 12495,12500 ----
393 ***************
394 *** 12641,12647 ****
395       dict_T    *d;
396       int               todo;
397   
398 -     rettv->vval.v_number = 0;
399       if (argvars[0].v_type != VAR_DICT)
400       {
401         EMSG(_(e_dictreq));
402 --- 12613,12618 ----
403 ***************
404 *** 12729,12735 ****
405       garray_T  ga;
406       char_u    *sep;
407   
408 -     rettv->vval.v_number = 0;
409       if (argvars[0].v_type != VAR_LIST)
410       {
411         EMSG(_(e_listreq));
412 --- 12700,12705 ----
413 ***************
414 *** 12827,12835 ****
415   #endif
416   
417       rettv->v_type = type;
418 !     if (type == VAR_NUMBER)
419 !       rettv->vval.v_number = 0;
420 !     else
421         rettv->vval.v_string = NULL;
422   
423       if (check_restricted() || check_secure())
424 --- 12797,12803 ----
425   #endif
426   
427       rettv->v_type = type;
428 !     if (type != VAR_NUMBER)
429         rettv->vval.v_string = NULL;
430   
431       if (check_restricted() || check_secure())
432 ***************
433 *** 13770,13776 ****
434       typval_T  *argvars;
435       typval_T  *rettv;
436   {
437 -     rettv->vval.v_number = 0;
438   #ifdef FEAT_INS_EXPAND
439       if (pum_visible())
440         rettv->vval.v_number = 1;
441 --- 13738,13743 ----
442 ***************
443 *** 13804,13810 ****
444             stride = get_tv_number_chk(&argvars[2], &error);
445       }
446   
447 -     rettv->vval.v_number = 0;
448       if (error)
449         return;         /* type error; errmsg already given */
450       if (stride == 0)
451 --- 13771,13776 ----
452 ***************
453 *** 14193,14199 ****
454       typval_T  *argvars;
455       typval_T  *rettv;
456   {
457 -     rettv->vval.v_number = 0;
458   #ifdef FEAT_CLIENTSERVER
459   # ifdef WIN32
460       /* On Win32 it's done in this application. */
461 --- 14159,14164 ----
462 ***************
463 *** 14249,14255 ****
464         rettv->vval.v_number = (s != NULL);
465       }
466   # else
467 -     rettv->vval.v_number = 0;
468       if (check_connection() == FAIL)
469         return;
470   
471 --- 14214,14219 ----
472 ***************
473 *** 14338,14344 ****
474       dict_T    *d;
475       dictitem_T        *di;
476   
477 -     rettv->vval.v_number = 0;
478       if (argvars[0].v_type == VAR_DICT)
479       {
480         if (argvars[2].v_type != VAR_UNKNOWN)
481 --- 14302,14307 ----
482 ***************
483 *** 14696,14702 ****
484       list_T    *l;
485       listitem_T        *li, *ni;
486   
487 -     rettv->vval.v_number = 0;
488       if (argvars[0].v_type != VAR_LIST)
489         EMSG2(_(e_listarg), "reverse()");
490       else if ((l = argvars[0].vval.v_list) != NULL
491 --- 14659,14664 ----
492 ***************
493 *** 15048,15055 ****
494       int               lnum = 0;
495       int               col = 0;
496   
497 -     rettv->vval.v_number = 0;
498
499       if (rettv_list_alloc(rettv) == FAIL)
500         return;
501   
502 --- 15010,15015 ----
503 ***************
504 *** 15236,15243 ****
505       int               n;
506       int               flags = 0;
507   
508 -     rettv->vval.v_number = 0;
509
510       if (rettv_list_alloc(rettv) == FAIL)
511         return;
512   
513 --- 15196,15201 ----
514 ***************
515 *** 15323,15330 ****
516       typval_T  *varp;
517       char_u    nbuf[NUMBUFLEN];
518   
519 -     rettv->vval.v_number = 0;
520
521       if (check_restricted() || check_secure())
522         return;
523       (void)get_tv_number(&argvars[0]);     /* issue errmsg if type error */
524 --- 15281,15286 ----
525 ***************
526 *** 15404,15410 ****
527       else
528         line = get_tv_string_chk(&argvars[1]);
529   
530 !     rettv->vval.v_number = 0;         /* OK */
531       for (;;)
532       {
533         if (l != NULL)
534 --- 15360,15366 ----
535       else
536         line = get_tv_string_chk(&argvars[1]);
537   
538 !     /* default result is zero == OK */
539       for (;;)
540       {
541         if (l != NULL)
542 ***************
543 *** 15717,15722 ****
544 --- 15673,15679 ----
545   /*
546    * "setwinvar()" and "settabwinvar()" functions
547    */
548 + /*ARGSUSED*/
549       static void
550   setwinvar(argvars, rettv, off)
551       typval_T  *argvars;
552 ***************
553 *** 15733,15740 ****
554       char_u    nbuf[NUMBUFLEN];
555       tabpage_T *tp;
556   
557 -     rettv->vval.v_number = 0;
558
559       if (check_restricted() || check_secure())
560         return;
561   
562 --- 15690,15695 ----
563 ***************
564 *** 15947,15953 ****
565       long      len;
566       long      i;
567   
568 -     rettv->vval.v_number = 0;
569       if (argvars[0].v_type != VAR_LIST)
570         EMSG2(_(e_listarg), "sort()");
571       else
572 --- 15902,15907 ----
573 ***************
574 *** 16870,16878 ****
575       typval_T  *argvars;
576       typval_T  *rettv;
577   {
578 ! #ifndef FEAT_WINDOWS
579 !     rettv->vval.v_number = 0;
580 ! #else
581       tabpage_T *tp;
582       win_T     *wp = NULL;
583   
584 --- 16824,16830 ----
585       typval_T  *argvars;
586       typval_T  *rettv;
587   {
588 ! #ifdef FEAT_WINDOWS
589       tabpage_T *tp;
590       win_T     *wp = NULL;
591   
592 ***************
593 *** 16884,16902 ****
594         if (tp != NULL)
595             wp = (tp == curtab) ? firstwin : tp->tp_firstwin;
596       }
597 !     if (wp == NULL)
598 !       rettv->vval.v_number = 0;
599 !     else
600       {
601 !       if (rettv_list_alloc(rettv) == FAIL)
602 !           rettv->vval.v_number = 0;
603 !       else
604 !       {
605 !           for (; wp != NULL; wp = wp->w_next)
606 !               if (list_append_number(rettv->vval.v_list,
607                                                 wp->w_buffer->b_fnum) == FAIL)
608 !                   break;
609 !       }
610       }
611   #endif
612   }
613 --- 16836,16847 ----
614         if (tp != NULL)
615             wp = (tp == curtab) ? firstwin : tp->tp_firstwin;
616       }
617 !     if (wp != NULL && rettv_list_alloc(rettv) != FAIL)
618       {
619 !       for (; wp != NULL; wp = wp->w_next)
620 !           if (list_append_number(rettv->vval.v_list,
621                                                 wp->w_buffer->b_fnum) == FAIL)
622 !               break;
623       }
624   #endif
625   }
626 ***************
627 *** 17024,17033 ****
628       int               first;
629   
630       if (rettv_list_alloc(rettv) == FAIL)
631 -     {
632 -       rettv->vval.v_number = 0;
633         return;
634 -     }
635   
636       for (first = TRUE; ; first = FALSE)
637         if (get_tagfname(&tn, first, fname) == FAIL
638 --- 16969,16975 ----
639 ***************
640 *** 17401,17408 ****
641       /* A non-zero number or non-empty string argument: reset mode. */
642       if (non_zero_arg(&argvars[0]))
643         curbuf->b_visual_mode_eval = NUL;
644 - #else
645 -     rettv->vval.v_number = 0; /* return anything, it won't work anyway */
646   #endif
647   }
648   
649 --- 17343,17348 ----
650 *** ../vim-7.2.148/src/version.c        Wed Mar 18 19:07:09 2009
651 --- src/version.c       Wed Apr 22 12:44:05 2009
652 ***************
653 *** 678,679 ****
654 --- 678,681 ----
655   {   /* Add new patch number below this line */
656 + /**/
657 +     149,
658   /**/
659
660
661 -- 
662 WOMAN:   Well, 'ow did you become king then?
663 ARTHUR:  The Lady of the Lake, [angels sing] her arm clad in the purest
664          shimmering samite, held aloft Excalibur from the bosom of the water
665          signifying by Divine Providence that I, Arthur, was to carry
666          Excalibur.  [singing stops] That is why I am your king!
667                                   The Quest for the Holy Grail (Monty Python)
668
669  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
670 ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
671 \\\        download, build and distribute -- http://www.A-A-P.org        ///
672  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
This page took 0.093441 seconds and 3 git commands to generate.