astepano / rpms / vim

Forked from rpms/vim 6 years ago
Clone
91ff595
To: vim_dev@googlegroups.com
91ff595
Subject: Patch 7.4.232
91ff595
Fcc: outbox
91ff595
From: Bram Moolenaar <Bram@moolenaar.net>
91ff595
Mime-Version: 1.0
91ff595
Content-Type: text/plain; charset=UTF-8
91ff595
Content-Transfer-Encoding: 8bit
91ff595
------------
91ff595
91ff595
Patch 7.4.232
91ff595
Problem:    ":%s/\n//" uses a lot of memory. (Aidan Marlin)
91ff595
Solution:   Turn this into a join command. (Christian Brabandt)
91ff595
Files:	    src/ex_cmds.c, src/ex_docmd.c, src/proto/ex_docmd.pro
91ff595
91ff595
91ff595
*** ../vim-7.4.231/src/ex_cmds.c	2014-03-23 15:12:29.919264336 +0100
91ff595
--- src/ex_cmds.c	2014-04-01 17:37:59.560901015 +0200
91ff595
***************
91ff595
*** 4420,4425 ****
91ff595
--- 4420,4450 ----
91ff595
  	endcolumn = (curwin->w_curswant == MAXCOL);
91ff595
      }
91ff595
  
91ff595
+     /* Recognize ":%s/\n//" and turn it into a join command, which is much
91ff595
+      * more efficient.
91ff595
+      * TODO: find a generic solution to make line-joining operations more
91ff595
+      * efficient, avoid allocating a string that grows in size.
91ff595
+      */
91ff595
+     if (STRCMP(pat, "\\n") == 0 && STRLEN(pat) == 2
91ff595
+ 	    && *sub == NUL
91ff595
+ 	    && (*cmd == NUL || (cmd[1] == NUL && (*cmd == 'g' || *cmd == 'l'
91ff595
+ 					     || *cmd == 'p' || *cmd == '#'))))
91ff595
+     {
91ff595
+ 	curwin->w_cursor.lnum = eap->line1;
91ff595
+ 	if (*cmd == 'l')
91ff595
+ 	    eap->flags = EXFLAG_LIST;
91ff595
+ 	else if (*cmd == '#')
91ff595
+ 	    eap->flags = EXFLAG_NR;
91ff595
+ 	else if (*cmd == 'p')
91ff595
+ 	    eap->flags = EXFLAG_PRINT;
91ff595
+ 
91ff595
+ 	(void)do_join(eap->line2 - eap->line1 + 1, FALSE, TRUE, FALSE);
91ff595
+ 	sub_nlines = sub_nsubs = eap->line2 - eap->line1 + 1;
91ff595
+ 	(void)do_sub_msg(FALSE);
91ff595
+ 	ex_may_print(eap);
91ff595
+ 	return;
91ff595
+     }
91ff595
+ 
91ff595
      /*
91ff595
       * Find trailing options.  When '&' is used, keep old options.
91ff595
       */
91ff595
*** ../vim-7.4.231/src/ex_docmd.c	2014-03-25 13:03:44.937793766 +0100
91ff595
--- src/ex_docmd.c	2014-04-01 17:31:59.708905965 +0200
91ff595
***************
91ff595
*** 316,322 ****
91ff595
  static void	ex_operators __ARGS((exarg_T *eap));
91ff595
  static void	ex_put __ARGS((exarg_T *eap));
91ff595
  static void	ex_copymove __ARGS((exarg_T *eap));
91ff595
- static void	ex_may_print __ARGS((exarg_T *eap));
91ff595
  static void	ex_submagic __ARGS((exarg_T *eap));
91ff595
  static void	ex_join __ARGS((exarg_T *eap));
91ff595
  static void	ex_at __ARGS((exarg_T *eap));
91ff595
--- 316,321 ----
91ff595
***************
91ff595
*** 8683,8689 ****
91ff595
  /*
91ff595
   * Print the current line if flags were given to the Ex command.
91ff595
   */
91ff595
!     static void
91ff595
  ex_may_print(eap)
91ff595
      exarg_T	*eap;
91ff595
  {
91ff595
--- 8682,8688 ----
91ff595
  /*
91ff595
   * Print the current line if flags were given to the Ex command.
91ff595
   */
91ff595
!     void
91ff595
  ex_may_print(eap)
91ff595
      exarg_T	*eap;
91ff595
  {
91ff595
*** ../vim-7.4.231/src/proto/ex_docmd.pro	2013-08-10 13:37:10.000000000 +0200
91ff595
--- src/proto/ex_docmd.pro	2014-04-01 17:31:59.708905965 +0200
91ff595
***************
91ff595
*** 54,57 ****
91ff595
--- 54,58 ----
91ff595
  int put_line __ARGS((FILE *fd, char *s));
91ff595
  void dialog_msg __ARGS((char_u *buff, char *format, char_u *fname));
91ff595
  char_u *get_behave_arg __ARGS((expand_T *xp, int idx));
91ff595
+ void ex_may_print __ARGS((exarg_T *eap));
91ff595
  /* vim: set ft=c : */
91ff595
*** ../vim-7.4.231/src/version.c	2014-04-01 14:08:14.689074130 +0200
91ff595
--- src/version.c	2014-04-01 17:33:03.920905082 +0200
91ff595
***************
91ff595
*** 736,737 ****
91ff595
--- 736,739 ----
91ff595
  {   /* Add new patch number below this line */
91ff595
+ /**/
91ff595
+     232,
91ff595
  /**/
91ff595
91ff595
-- 
91ff595
hundred-and-one symptoms of being an internet addict:
91ff595
16. You step out of your room and realize that your parents have moved and
91ff595
    you don't have a clue when it happened.
91ff595
91ff595
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
91ff595
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
91ff595
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
91ff595
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///