home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 6.0.030 < prev    next >
Encoding:
Internet Message Format  |  2001-10-27  |  9.6 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.0.030
  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 6.0.030
  11. Problem:    Using ":source! file" doesn't work inside a loop or after
  12.         ":argdo". (Pavol Juhas)
  13. Solution:   Execute the commands in the file right away, do not let the main
  14.         loop do it.
  15. Files:        src/ex_cmds2.c, src/ex_docmd.c, src/getchar.c, src/globals.h,
  16.         src/proto/ex_docmd.pro, src/proto/getchar.pro
  17.  
  18.  
  19. *** ../vim60.29/src/ex_cmds2.c    Tue Sep 25 14:18:04 2001
  20. --- src/ex_cmds2.c    Thu Oct 25 10:08:24 2001
  21. ***************
  22. *** 14,20 ****
  23.   #include "vim.h"
  24.   #include "version.h"
  25.   
  26. ! static void    cmd_source __ARGS((char_u *fname, int forceit));
  27.   
  28.   #if defined(FEAT_EVAL) || defined(PROTO)
  29.   
  30. --- 14,20 ----
  31.   #include "vim.h"
  32.   #include "version.h"
  33.   
  34. ! static void    cmd_source __ARGS((char_u *fname, exarg_T *eap));
  35.   
  36.   #if defined(FEAT_EVAL) || defined(PROTO)
  37.   
  38. ***************
  39. *** 1454,1461 ****
  40. --- 1454,1463 ----
  41.   #endif
  42.   
  43.           /* execute the command */
  44. +         listcmd_busy = TRUE;
  45.           do_cmdline(eap->arg, eap->getline, eap->cookie,
  46.                           DOCMD_VERBOSE + DOCMD_NOWAIT);
  47. +         listcmd_busy = FALSE;
  48.   
  49.           if (eap->cmdidx == CMD_bufdo)
  50.           {
  51. ***************
  52. *** 1693,1699 ****
  53.   ex_options(eap)
  54.       exarg_T    *eap;
  55.   {
  56. !     cmd_source((char_u *)SYS_OPTWIN_FILE, FALSE);
  57.   }
  58.   #endif
  59.   
  60. --- 1695,1701 ----
  61.   ex_options(eap)
  62.       exarg_T    *eap;
  63.   {
  64. !     cmd_source((char_u *)SYS_OPTWIN_FILE, NULL);
  65.   }
  66.   #endif
  67.   
  68. ***************
  69. *** 1713,1737 ****
  70.           NULL, NULL, eap->arg, BROWSE_FILTER_MACROS, curbuf);
  71.       if (fname != NULL)
  72.       {
  73. !         cmd_source(fname, eap->forceit);
  74.           vim_free(fname);
  75.       }
  76.       }
  77.       else
  78.   #endif
  79. !     cmd_source(eap->arg, eap->forceit);
  80.   }
  81.   
  82.       static void
  83. ! cmd_source(fname, forceit)
  84.       char_u    *fname;
  85. !     int        forceit;
  86.   {
  87.       if (*fname == NUL)
  88.       EMSG(_(e_argreq));
  89. !     else if (forceit)        /* :so! read vi commands */
  90. !     (void)openscript(fname);
  91. !                 /* :so read ex commands */
  92.       else if (do_source(fname, FALSE, FALSE) == FAIL)
  93.       EMSG2(_(e_notopen), fname);
  94.   }
  95. --- 1715,1752 ----
  96.           NULL, NULL, eap->arg, BROWSE_FILTER_MACROS, curbuf);
  97.       if (fname != NULL)
  98.       {
  99. !         cmd_source(fname, eap);
  100.           vim_free(fname);
  101.       }
  102.       }
  103.       else
  104.   #endif
  105. !     cmd_source(eap->arg, eap);
  106.   }
  107.   
  108.       static void
  109. ! cmd_source(fname, eap)
  110.       char_u    *fname;
  111. !     exarg_T    *eap;
  112.   {
  113.       if (*fname == NUL)
  114.       EMSG(_(e_argreq));
  115. !     /* ":source!" read vi commands */
  116. !     else if (eap != NULL && eap->forceit)
  117. !     /* Need to execute the commands directly when:
  118. !      * - ":g" command busy
  119. !      * - after ":argdo", ":windo" or ":bufdo"
  120. !      * - another command follows
  121. !      * - inside a loop
  122. !      */
  123. !     openscript(fname, global_busy || listcmd_busy || eap->nextcmd != NULL
  124. ! #ifdef FEAT_EVAL
  125. !                          || eap->cstack->cs_idx >= 0
  126. ! #endif
  127. !                          );
  128. !     /* ":source" read ex commands */
  129.       else if (do_source(fname, FALSE, FALSE) == FAIL)
  130.       EMSG2(_(e_notopen), fname);
  131.   }
  132. *** ../vim60.29/src/ex_docmd.c    Fri Oct 19 11:18:45 2001
  133. --- src/ex_docmd.c    Sat Oct 20 16:53:27 2001
  134. ***************
  135. *** 276,282 ****
  136.   #endif
  137.   #ifdef FEAT_EX_EXTRA
  138.   static void    ex_normal __ARGS((exarg_T *eap));
  139. - static void    update_topline_cursor __ARGS((void));
  140.   static void    ex_startinsert __ARGS((exarg_T *eap));
  141.   #else
  142.   # define ex_normal        ex_ni
  143. --- 276,281 ----
  144. ***************
  145. *** 6777,6782 ****
  146. --- 6776,6794 ----
  147.       }
  148.   }
  149.   
  150. + /*
  151. +  * Update w_topline, w_leftcol and the cursor position.
  152. +  */
  153. +     void
  154. + update_topline_cursor()
  155. + {
  156. +     check_cursor();        /* put cursor on valid line */
  157. +     update_topline();
  158. +     if (!curwin->w_p_wrap)
  159. +     validate_cursor();
  160. +     update_curswant();
  161. + }
  162.   #ifdef FEAT_EX_EXTRA
  163.   /*
  164.    * ":normal[!] {commands}": Execute normal mode commands.
  165. ***************
  166. *** 6937,6955 ****
  167.   #ifdef FEAT_MBYTE
  168.       vim_free(arg);
  169.   #endif
  170. - }
  171. - /*
  172. -  * Update w_topline, w_leftcol and the cursor position.
  173. -  */
  174. -     static void
  175. - update_topline_cursor()
  176. - {
  177. -     check_cursor();        /* put cursor on valid line */
  178. -     update_topline();
  179. -     if (!curwin->w_p_wrap)
  180. -     validate_cursor();
  181. -     update_curswant();
  182.   }
  183.   
  184.   /*
  185. --- 6949,6954 ----
  186. *** ../vim60.29/src/getchar.c    Sun Sep 16 14:38:55 2001
  187. --- src/getchar.c    Sat Oct 20 18:07:04 2001
  188. ***************
  189. *** 1224,1244 ****
  190.   }
  191.   
  192.   /*
  193. !  * open new script file for ":so!" command
  194. !  * return OK on success, FAIL on error
  195.    */
  196. !     int
  197. ! openscript(name)
  198. !     char_u *name;
  199.   {
  200. -     int        oldcurscript;
  201. -     oparg_T    oa;
  202. -     int        save_State;
  203.       if (curscript + 1 == NSCRIPT)
  204.       {
  205.       EMSG(_(e_nesting));
  206. !     return FAIL;
  207.       }
  208.   
  209.       if (scriptin[curscript] != NULL)    /* already reading script */
  210. --- 1224,1240 ----
  211.   }
  212.   
  213.   /*
  214. !  * Open a new script file for the ":source!" command.
  215.    */
  216. !     void
  217. ! openscript(name, directly)
  218. !     char_u    *name;
  219. !     int        directly;    /* when TRUE execute directly */
  220.   {
  221.       if (curscript + 1 == NSCRIPT)
  222.       {
  223.       EMSG(_(e_nesting));
  224. !     return;
  225.       }
  226.   
  227.       if (scriptin[curscript] != NULL)    /* already reading script */
  228. ***************
  229. *** 1250,1281 ****
  230.       EMSG2(_(e_notopen), name);
  231.       if (curscript)
  232.           --curscript;
  233. !     return FAIL;
  234.       }
  235.       if (save_typebuf() == FAIL)
  236. !     return FAIL;
  237.   
  238.       /*
  239. !      * With command ":g/pat/so! file" we have to execute the
  240. !      * commands from the file now.
  241.        */
  242. !     if (global_busy)
  243.       {
  244. !     clear_oparg(&oa);
  245. !     save_State = State;
  246.       State = NORMAL;
  247.       oldcurscript = curscript;
  248.       do
  249.       {
  250. !         check_cursor();    /* put cursor on an existing line */
  251. !         normal_cmd(&oa, FALSE);
  252. !         vpeekc();        /* check for end of file */
  253.       }
  254.       while (scriptin[oldcurscript] != NULL);
  255.       State = save_State;
  256.       }
  257. -     return OK;
  258.   }
  259.   
  260.   /*
  261. --- 1246,1294 ----
  262.       EMSG2(_(e_notopen), name);
  263.       if (curscript)
  264.           --curscript;
  265. !     return;
  266.       }
  267.       if (save_typebuf() == FAIL)
  268. !     return;
  269.   
  270.       /*
  271. !      * Execute the commands from the file right now when using ":source!"
  272. !      * after ":global" or ":argdo" or in a loop.  Also when another command
  273. !      * follows.  This means the display won't be updated.  Don't do this
  274. !      * always, "make test" would fail.
  275.        */
  276. !     if (directly)
  277.       {
  278. !     oparg_T    oa;
  279. !     int    oldcurscript;
  280. !     int    save_State = State;
  281. !     int    save_restart_edit = restart_edit;
  282. !     int    save_insertmode = p_im;
  283. !     int    save_finish_op = finish_op;
  284. !     int    save_msg_scroll = msg_scroll;
  285.       State = NORMAL;
  286. +     msg_scroll = FALSE;    /* no msg scrolling in Normal mode */
  287. +     restart_edit = 0;    /* don't go to Insert mode */
  288. +     p_im = FALSE;        /* don't use 'insertmode' */
  289. +     clear_oparg(&oa);
  290. +     finish_op = FALSE;
  291.       oldcurscript = curscript;
  292.       do
  293.       {
  294. !         update_topline_cursor();    /* update cursor position and topline */
  295. !         normal_cmd(&oa, FALSE);    /* execute one command */
  296. !         vpeekc();            /* check for end of file */
  297.       }
  298.       while (scriptin[oldcurscript] != NULL);
  299.       State = save_State;
  300. +     msg_scroll = save_msg_scroll;
  301. +     restart_edit = save_restart_edit;
  302. +     p_im = save_insertmode;
  303. +     finish_op = save_finish_op;
  304.       }
  305.   }
  306.   
  307.   /*
  308. *** ../vim60.29/src/globals.h    Fri Sep 28 22:19:57 2001
  309. --- src/globals.h    Sat Oct 20 17:49:38 2001
  310. ***************
  311. *** 752,757 ****
  312. --- 752,759 ----
  313.                           /* set after swap write error msg */
  314.   EXTERN int    undo_off INIT(= FALSE);        /* undo switched off for now */
  315.   EXTERN int    global_busy INIT(= 0);        /* set when :global is executing */
  316. + EXTERN int    listcmd_busy INIT(= FALSE); /* set when :argdo, :windo or
  317. +                            :bufdo is executing */
  318.   EXTERN int    need_start_insertmode INIT(= FALSE);
  319.                           /* start insert mode soon */
  320.   EXTERN char_u    *last_cmdline INIT(= NULL); /* last command line (for ":) */
  321. *** ../vim60.29/src/proto/ex_docmd.pro    Tue Sep 25 21:49:13 2001
  322. --- src/proto/ex_docmd.pro    Sat Oct 20 16:55:04 2001
  323. ***************
  324. *** 29,34 ****
  325. --- 29,35 ----
  326.   void do_exedit __ARGS((exarg_T *eap, win_T *old_curwin));
  327.   void do_sleep __ARGS((long msec));
  328.   FILE *open_exfile __ARGS((char_u *fname, int forceit, char *mode));
  329. + void update_topline_cursor __ARGS((void));
  330.   char_u *eval_vars __ARGS((char_u *src, int *usedlen, linenr_T *lnump, char_u **errormsg, char_u *srcstart));
  331.   char_u *expand_sfile __ARGS((char_u *arg));
  332.   int put_eol __ARGS((FILE *fd));
  333. *** ../vim60.29/src/proto/getchar.pro    Tue Sep 25 21:49:15 2001
  334. --- src/proto/getchar.pro    Sat Oct 20 17:23:58 2001
  335. ***************
  336. *** 26,32 ****
  337.   int alloc_typebuf __ARGS((void));
  338.   void free_typebuf __ARGS((void));
  339.   int save_typebuf __ARGS((void));
  340. ! int openscript __ARGS((char_u *name));
  341.   int using_script __ARGS((void));
  342.   void updatescript __ARGS((int c));
  343.   int vgetc __ARGS((void));
  344. --- 26,32 ----
  345.   int alloc_typebuf __ARGS((void));
  346.   void free_typebuf __ARGS((void));
  347.   int save_typebuf __ARGS((void));
  348. ! void openscript __ARGS((char_u *name, int directly));
  349.   int using_script __ARGS((void));
  350.   void updatescript __ARGS((int c));
  351.   int vgetc __ARGS((void));
  352. *** ../vim60.29/src/version.c    Sun Oct 28 21:15:32 2001
  353. --- src/version.c    Sun Oct 28 21:17:56 2001
  354. ***************
  355. *** 608,609 ****
  356. --- 608,611 ----
  357.   {   /* Add new patch number below this line */
  358. + /**/
  359. +     30,
  360.   /**/
  361.  
  362. -- 
  363. BLACK KNIGHT:  I move for no man.
  364. ARTHUR:        So be it!
  365.     [hah] [parry thrust]
  366.     [ARTHUR chops the BLACK KNIGHT's left arm off]
  367. ARTHUR:        Now stand aside, worthy adversary.
  368. BLACK KNIGHT:  'Tis but a scratch.
  369.                                   The Quest for the Holy Grail (Monty Python)
  370.  
  371.  ///  Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net  \\\
  372. (((   Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim   )))
  373.  \\\  Help me helping AIDS orphans in Uganda - http://iccf-holland.org  ///
  374.