To: vim-dev@vim.org Subject: Patch 5.5.013 Fcc: outbox From: Bram Moolenaar ------------ Patch 5.5.013 Problem: The ":append" and ":insert" commands allow using a leading backslash in a line. The ":source" command concatenates those lines. (Heinlein) Solution: Add the 'C' flag in 'cpoptions' to switch off concatenation. Files: src/ex_docmd.c, src/option.h, runtime/doc/options.txt, runtime/filetype.vim, runtime/scripts.vim *** ../vim-5.5.12/src/ex_docmd.c Sat Sep 25 20:56:51 1999 --- src/ex_docmd.c Sat Oct 2 15:34:10 1999 *************** *** 4375,4381 **** if (is_vimrc) vimrc_found(); - #ifdef USE_CRNL /* If no automatic file format: Set default to CR-NL. */ if (*p_ffs == NUL) --- 4375,4380 ---- *************** *** 4486,4504 **** * one now. */ if (sp->nextline == NULL) - { line = get_one_sourceline(sp); - --sourcing_lnum; - } else { line = sp->nextline; sp->nextline = NULL; } ! /* concatenate lines that start with a backslash */ ! if (line != NULL) { for (;;) { sp->nextline = get_one_sourceline(sp); --- 4485,4504 ---- * one now. */ if (sp->nextline == NULL) line = get_one_sourceline(sp); else { line = sp->nextline; sp->nextline = NULL; + ++sourcing_lnum; } ! /* Only concatenate lines starting with a \ when 'cpoptions' doesn't ! * contain the 'C' flag. */ ! if (line != NULL && (vim_strchr(p_cpo, CPO_CONCAT) == NULL)) { + /* compensate for the one line read-ahead */ + --sourcing_lnum; for (;;) { sp->nextline = get_one_sourceline(sp); *** ../vim-5.5.12/src/option.h Wed Sep 22 10:06:20 1999 --- src/option.h Sat Oct 2 14:27:41 1999 *************** *** 105,110 **** --- 105,111 ---- #define CPO_BAR 'b' /* "\|" ends a mapping */ #define CPO_BSLASH 'B' /* backslash in mapping is not special */ #define CPO_SEARCH 'c' + #define CPO_CONCAT 'C' /* Don't concatenate sourced lines */ #define CPO_DOTTAG 'd' /* "./tags" in 'tags' is in current dir */ #define CPO_EXECBUF 'e' #define CPO_EMPTYREGION 'E' /* operating on empty region is an error */ *************** *** 135,141 **** #define CPO_STAR '*' /* ":*" means ":@" */ #define CPO_SPECI '<' /* don't recognize <> in mappings */ #define CPO_DEFAULT "aABceFs" ! #define CPO_ALL "aAbBcdeEfFjJkKlLmoOprsStuwWxy$!%*<" /* characters for p_ww option: */ #define WW_ALL "bshl<>[],~" --- 136,142 ---- #define CPO_STAR '*' /* ":*" means ":@" */ #define CPO_SPECI '<' /* don't recognize <> in mappings */ #define CPO_DEFAULT "aABceFs" ! #define CPO_ALL "aAbBcCdeEfFjJkKlLmoOprsStuwWxy$!%*<" /* characters for p_ww option: */ #define WW_ALL "bshl<>[],~" *** ../vim-5.5.12/runtime/doc/options.txt Wed Sep 22 10:06:41 1999 --- runtime/doc/options.txt Sat Oct 2 14:39:29 1999 *************** *** 1,4 **** ! *options.txt* For Vim version 5.5. Last change: 1999 Sep 18 VIM REFERENCE MANUAL by Bram Moolenaar --- 1,4 ---- ! *options.txt* For Vim version 5.5. Last change: 1999 Oct 02 VIM REFERENCE MANUAL by Bram Moolenaar *************** *** 974,979 **** --- 974,981 ---- 'B' included: "\^[" (^[ is a real ) 'B' excluded: "" (5 characters) ('<' excluded in both cases) + C Do not concatenate sourced lines that start with a + backslash. See |line-continuation|. < Disable the recognition of special key codes in |<>| form in mappings, abbreviations, and the "to" part of menu commands. For example, the command *** ../vim-5.5.12/runtime/filetype.vim Wed Sep 22 10:06:46 1999 --- runtime/filetype.vim Sat Oct 2 15:35:48 1999 *************** *** 1,11 **** " Vim support file to detect file types " " Maintainer: Bram Moolenaar ! " Last change: 1999 Sep 12 if !exists("did_load_filetypes") let did_load_filetypes = 1 augroup filetype " Ignored extensions --- 1,15 ---- " Vim support file to detect file types " " Maintainer: Bram Moolenaar ! " Last change: 1999 Oct 02 if !exists("did_load_filetypes") let did_load_filetypes = 1 + " Line continuation is used here, remove 'C' from 'cpoptions' + let ft_cpo_save = &cpo + set cpo-=C + augroup filetype " Ignored extensions *************** *** 550,555 **** --- 562,571 ---- if has("gui_running") && !exists("did_install_syntax_menu") && &guioptions !~# "M" source :p:h/menu.vim endif + + " Restore 'cpoptions' + let &cpo = ft_cpo_save + unlet ft_cpo_save endif " !exists("did_load_filetypes") *** ../vim-5.5.12/runtime/scripts.vim Wed Sep 22 10:06:46 1999 --- runtime/scripts.vim Sat Oct 2 15:38:42 1999 *************** *** 1,7 **** " Vim support file to detect file types in scripts " " Maintainer: Bram Moolenaar ! " Last change: 1999 Jul 09 " This file is called by an autocommand for every file that has just been " loaded into a buffer. It checks if the type of file can be recognized by --- 1,7 ---- " Vim support file to detect file types in scripts " " Maintainer: Bram Moolenaar ! " Last change: 1999 Oct 02 " This file is called by an autocommand for every file that has just been " loaded into a buffer. It checks if the type of file can be recognized by *************** *** 17,22 **** --- 17,26 ---- " Only do this when the FileType autocommand has not been triggered yet if !did_filetype() + " Line continuation is used here, remove 'C' from 'cpoptions' + let scr_cpo_save = &cpo + set cpo-=C + " Bourne-like shell scripts: sh ksh bash if getline(1) =~ '^#!.*[/\\][bk]\=a\=sh\>' if exists("is_bash") *************** *** 125,135 **** --- 129,147 ---- elseif getline(1) =~ '^\*\*\*\* Purify' set ft=purifylog + " XML + elseif getline(1) =~ '' + set ft=xml + " XXD output elseif getline(1) =~ '^\x\{7}: \x\{4} \x\{4} ' set ft=xxd endif + + " Restore 'cpoptions' + let &cpo = scr_cpo_save + unlet scr_cpo_save endif " !did_filetype() *** ../vim-5.5.12/src/version.c Sat Oct 2 16:00:01 1999 --- src/version.c Sat Oct 2 15:59:39 1999 *************** *** 420,420 **** --- 420,421 ---- { /* Add new patch number below this line */ + 13, -- ARTHUR: This new learning amazes me, Sir Bedevere. Explain again how sheep's bladders may be employed to prevent earthquakes. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD --/-/---- Bram Moolenaar ---- Bram@moolenaar.net ---- Bram@vim.org ---\-\-- \ \ www.vim.org/iccf www.moolenaar.net www.vim.org / /