comparison src/ex_cmds2.c @ 14714:bdbb049c2aa8 v8.1.0369

patch 8.1.0369: continuation lines cannot contain comments commit https://github.com/vim/vim/commit/67f8ab829911c7901c534ef2bf19cc34b622936f Author: Bram Moolenaar <Bram@vim.org> Date: Tue Sep 11 22:37:29 2018 +0200 patch 8.1.0369: continuation lines cannot contain comments Problem: Continuation lines cannot contain comments. Solution: Support using "\ .
author Christian Brabandt <cb@256bit.org>
date Tue, 11 Sep 2018 22:45:07 +0200
parents 0a3b9ecf7cb8
children 27b9a84395b5
comparison
equal deleted inserted replaced
14713:5c65d57ca84c 14714:bdbb049c2aa8
4862 if (line != NULL && (vim_strchr(p_cpo, CPO_CONCAT) == NULL)) 4862 if (line != NULL && (vim_strchr(p_cpo, CPO_CONCAT) == NULL))
4863 { 4863 {
4864 /* compensate for the one line read-ahead */ 4864 /* compensate for the one line read-ahead */
4865 --sourcing_lnum; 4865 --sourcing_lnum;
4866 4866
4867 /* Get the next line and concatenate it when it starts with a 4867 // Get the next line and concatenate it when it starts with a
4868 * backslash. We always need to read the next line, keep it in 4868 // backslash. We always need to read the next line, keep it in
4869 * sp->nextline. */ 4869 // sp->nextline.
4870 /* Also check for a comment in between continuation lines: "\ */
4870 sp->nextline = get_one_sourceline(sp); 4871 sp->nextline = get_one_sourceline(sp);
4871 if (sp->nextline != NULL && *(p = skipwhite(sp->nextline)) == '\\') 4872 if (sp->nextline != NULL
4873 && (*(p = skipwhite(sp->nextline)) == '\\'
4874 || (p[0] == '"' && p[1] == '\\' && p[2] == ' ')))
4872 { 4875 {
4873 garray_T ga; 4876 garray_T ga;
4874 4877
4875 ga_init2(&ga, (int)sizeof(char_u), 400); 4878 ga_init2(&ga, (int)sizeof(char_u), 400);
4876 ga_concat(&ga, line); 4879 ga_concat(&ga, line);
4877 ga_concat(&ga, p + 1); 4880 if (*p == '\\')
4881 ga_concat(&ga, p + 1);
4878 for (;;) 4882 for (;;)
4879 { 4883 {
4880 vim_free(sp->nextline); 4884 vim_free(sp->nextline);
4881 sp->nextline = get_one_sourceline(sp); 4885 sp->nextline = get_one_sourceline(sp);
4882 if (sp->nextline == NULL) 4886 if (sp->nextline == NULL)
4883 break; 4887 break;
4884 p = skipwhite(sp->nextline); 4888 p = skipwhite(sp->nextline);
4885 if (*p != '\\') 4889 if (*p == '\\')
4890 {
4891 // Adjust the growsize to the current length to speed up
4892 // concatenating many lines.
4893 if (ga.ga_len > 400)
4894 {
4895 if (ga.ga_len > 8000)
4896 ga.ga_growsize = 8000;
4897 else
4898 ga.ga_growsize = ga.ga_len;
4899 }
4900 ga_concat(&ga, p + 1);
4901 }
4902 else if (p[0] != '"' || p[1] != '\\' || p[2] != ' ')
4886 break; 4903 break;
4887 /* Adjust the growsize to the current length to speed up
4888 * concatenating many lines. */
4889 if (ga.ga_len > 400)
4890 {
4891 if (ga.ga_len > 8000)
4892 ga.ga_growsize = 8000;
4893 else
4894 ga.ga_growsize = ga.ga_len;
4895 }
4896 ga_concat(&ga, p + 1);
4897 } 4904 }
4898 ga_append(&ga, NUL); 4905 ga_append(&ga, NUL);
4899 vim_free(line); 4906 vim_free(line);
4900 line = ga.ga_data; 4907 line = ga.ga_data;
4901 } 4908 }