On Mi, 15 Jan 2014, Aidan Marlin wrote:
> Vim devs,
>
> I have discovered a bug which affects at least 7.4.135 and (likely) 7.3.547.
> Example file is available at
> https://mega.co.nz/#!ndVjXZTY!aMX_9ll-0ce861tQwNZBaFveb_kONCJxvAT2GZOvzlc
> (1.2MB in size) which will crash vim when attempting the following regex:
>
> :%s/\n//g
>
> The file contains 20 000 lines, each line containing 60 characters.
>
> Join (:%j) works fine and fast in these versions of vim, while the above
> regex seems to consume excessive amounts of memory, and results in vim crash.
How about to alias :s/\n// to the join function (see attached patch).
Best,
Christian
--
Heftigen Ehrgeiz und Mißtrauen habe ich noch allemal beisammen
gesehen.
-- Georg Christoph Lichtenberg
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -4411,6 +4411,26 @@
endcolumn = (curwin->w_curswant == MAXCOL);
}
+ if (STRCMP(pat, "\\n") == 0 && STRLEN(pat) == 2
+ && *sub == NUL && (*cmd == 'g' || *cmd == 'l' ||
+ *cmd == 'p' || *cmd == '#' || *cmd == NUL)
+ && STRLEN(cmd) <= 1)
+ {
+ curwin->w_cursor.lnum = eap->line1;
+ if (*cmd == 'l')
+ eap->flags = EXFLAG_LIST;
+ else if (*cmd == '#')
+ eap->flags = EXFLAG_NR;
+ else if (*cmd == 'p')
+ eap->flags = EXFLAG_PRINT;
+
+ (void)do_join(eap->line2 - eap->line1 +1, FALSE, TRUE, FALSE);
+ sub_nlines = sub_nsubs = eap->line2 - eap->line1 + 1;
+ (void)do_sub_msg(FALSE);
+ ex_may_print(eap);
+ return;
+ }
+
/*
* Find trailing options. When '&' is used, keep old options.
*/
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -316,7 +316,6 @@
static void ex_operators __ARGS((exarg_T *eap));
static void ex_put __ARGS((exarg_T *eap));
static void ex_copymove __ARGS((exarg_T *eap));
-static void ex_may_print __ARGS((exarg_T *eap));
static void ex_submagic __ARGS((exarg_T *eap));
static void ex_join __ARGS((exarg_T *eap));
static void ex_at __ARGS((exarg_T *eap));
@@ -8673,7 +8672,7 @@
/*
* Print the current line if flags were given to the Ex command.
*/
- static void
+ void
ex_may_print(eap)
exarg_T *eap;
{
diff --git a/src/proto/ex_docmd.pro b/src/proto/ex_docmd.pro
--- a/src/proto/ex_docmd.pro
+++ b/src/proto/ex_docmd.pro
@@ -54,4 +54,5 @@
int put_line __ARGS((FILE *fd, char *s));
void dialog_msg __ARGS((char_u *buff, char *format, char_u *fname));
char_u *get_behave_arg __ARGS((expand_T *xp, int idx));
+void ex_may_print __ARGS((exarg_T *eap));
/* vim: set ft=c : */