Skip to content

Instantly share code, notes, and snippets.

@koron
Created January 12, 2012 03:31
Show Gist options
  • Save koron/1598475 to your computer and use it in GitHub Desktop.
Save koron/1598475 to your computer and use it in GitHub Desktop.
Rev.2
diff -r 0dabc2ce136c src/ex_cmds2.c
--- a/src/ex_cmds2.c Tue Jan 10 22:31:32 2012 +0100
+++ b/src/ex_cmds2.c Thu Jan 12 12:43:33 2012 +0900
@@ -3437,6 +3437,9 @@
* contain the 'C' flag. */
if (line != NULL && (vim_strchr(p_cpo, CPO_CONCAT) == NULL))
{
+ garray_T ga;
+ ga_init2(&ga, (int)sizeof(char_u *), 200);
+
/* compensate for the one line read-ahead */
--sourcing_lnum;
for (;;)
@@ -3447,15 +3450,17 @@
p = skipwhite(sp->nextline);
if (*p != '\\')
break;
- s = alloc((unsigned)(STRLEN(line) + STRLEN(p)));
- if (s == NULL) /* out of memory */
- break;
- STRCPY(s, line);
- STRCAT(s, p + 1);
+ if (ga.ga_data == NULL)
+ ga_concat(&ga, line);
+ ga_concat(&ga, p + 1);
+ }
+
+ if (ga.ga_data != NULL)
+ {
+ ga_append(&ga, NUL);
vim_free(line);
- line = s;
- vim_free(sp->nextline);
- }
+ line = ga.ga_data;
+ }
}
#ifdef FEAT_MBYTE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment