Merge pull request #2943 from Pyrohh/rm-posix

[RDY] Remove POSIX 'cpoptions'

Reviewed-by: Felipe Morales <hel.sheep@gmail.com>
Reviewed-by: Marco Hinz <mh.codebro@gmail.com>
This commit is contained in:
Michael Reed 2015-07-19 15:39:03 -04:00
commit 259db27aef
21 changed files with 15 additions and 258 deletions

View File

@ -714,9 +714,6 @@ When the {string} starts with "\=" it is evaluated as an expression, see
characters.
Otherwise these characters in {string} have a special meaning:
*:s%*
When {string} is equal to "%" and '/' is included with the 'cpoptions' option,
then the {string} of the previous substitute command is used, see |cpo-/|
magic nomagic action ~
& \& replaced with the whole matched pattern *s/\&*

View File

@ -269,11 +269,6 @@ Vi "the original". Without further remarks this is the version
to. Only runs under Unix. Source code only available with a
license. More information on Vi can be found through:
http://vi-editor.org [doesn't currently work...]
*Posix*
Posix From the IEEE standard 1003.2, Part 2: Shell and utilities.
Generally known as "Posix". This is a textual description of
how Vi is supposed to work.
See |posix-compliance|.
*Nvi*
Nvi The "New" Vi. The version of Vi that comes with BSD 4.4 and FreeBSD.
Very good compatibility with the original Vi, with a few extensions.

View File

@ -469,9 +469,7 @@ the macros ".IP", ".LP", etc. (These are nroff macros, so the dot must be in
the first column). A section boundary is also a paragraph boundary.
Note that a blank line (only containing white space) is NOT a paragraph
boundary.
Also note that this does not include a '{' or '}' in the first column. When
the '{' flag is in 'cpoptions' then '{' in the first column is used as a
paragraph boundary |posix|.
Note: this does not include a '{' or '}' in the first column.
*section*
A section begins after a form-feed (<C-L>) in the first column and at each of

View File

@ -1493,8 +1493,7 @@ A jump table for the options with a short description can be found at |Q_op|.
'columns' 'co' number (default 80 or terminal width)
global
Number of columns of the screen. Normally this is set by the terminal
initialization and does not have to be set by hand. Also see
|posix-screen-size|.
initialization and does not have to be set by hand.
When Vim is running in the GUI or in a resizable window, setting this
option will cause the window size to be changed. When you only want
to use the size for the GUI, put the command in your |gvimrc| file.
@ -1701,10 +1700,6 @@ A jump table for the options with a short description can be found at |Q_op|.
Commas can be added for readability.
To avoid problems with flags that are added in the future, use the
"+=" and "-=" feature of ":set" |add-option-flags|.
NOTE: This option is set to the POSIX default value at startup when
the Vi default value would be used and the $VIM_POSIX environment
variable exists |posix|. This means Vim tries to behave like the
POSIX specification.
contains behavior ~
*cpo-a*
@ -1802,7 +1797,6 @@ A jump table for the options with a short description can be found at |Q_op|.
See |/[]|
'l' included: "/[ \t]" finds <Space>, '\' and 't'
'l' excluded: "/[ \t]" finds <Space> and <Tab>
Also see |cpo-\|.
*cpo-L*
L When the 'list' option is set, 'wrapmargin',
'textwidth', 'softtabstop' and Virtual Replace mode
@ -1942,38 +1936,6 @@ A jump table for the options with a short description can be found at |Q_op|.
the cursor would skip over it and jump to the
following occurrence.
POSIX flags. These are not included in the Vi default value, except
when $VIM_POSIX was set on startup. |posix|
contains behavior ~
*cpo-#*
# A count before "D", "o" and "O" has no effect.
*cpo-&*
& When ":preserve" was used keep the swap file when
exiting normally while this buffer is still loaded.
This flag is tested when exiting.
*cpo-\*
\ Backslash in a [] range in a search pattern is taken
literally, only "\]" is special See |/[]|
'\' included: "/[ \-]" finds <Space>, '\' and '-'
'\' excluded: "/[ \-]" finds <Space> and '-'
Also see |cpo-l|.
*cpo-/*
/ When "%" is used as the replacement string in a |:s|
command, use the previous replacement string. |:s%|
*cpo-{*
{ The |{| and |}| commands also stop at a "{" character
at the start of a line.
*cpo-.*
. The ":chdir" and ":cd" commands fail if the current
buffer is modified, unless ! is used. Vim doesn't
need this, since it remembers the full path of an
opened file.
*cpo-bar*
| The value of the $LINES and $COLUMNS environment
variables overrule the terminal size values obtained
with system specific functions.
*'cryptmethod'* *'cm'*
'cryptmethod' Removed. |vim-differences| {Nvim}
@ -4157,7 +4119,7 @@ A jump table for the options with a short description can be found at |Q_op|.
global
Number of lines of the Vim window.
Normally you don't need to set this. It is done automatically by the
terminal initialization code. Also see |posix-screen-size|.
terminal initialization code.
When Vim is running in the GUI or in a resizable window, setting this
option will cause the window size to be changed. When you only want
to use the size for the GUI, put the command in your |gvimrc| file.
@ -5630,8 +5592,7 @@ A jump table for the options with a short description can be found at |Q_op|.
function to get the effective shiftwidth value.
*'shortmess'* *'shm'*
'shortmess' 'shm' string (Vim default "filnxtToO", Vi default: "",
POSIX default: "A")
'shortmess' 'shm' string (Vim default "filnxtToO", Vi default: "")
global
This option helps to avoid all the |hit-enter| prompts caused by file
messages, for example with CTRL-G, and to avoid some other messages.

View File

@ -111,10 +111,6 @@ command:
*:pre* *:preserve* *E313* *E314*
:pre[serve] Write all text for all buffers into swap file. The
original file is no longer needed for recovery.
This sets a flag in the current buffer. When the '&'
flag is present in 'cpoptions' the swap file will not
be deleted for this buffer when Vim exits and the
buffer is still loaded |cpo-&|.
A Vim swap file can be recognized by the first six characters: "b0VIM ".
After that comes the version number, e.g., "3.0".

View File

@ -1994,71 +1994,6 @@ Awaiting updated patches:
- Patch for "paranoid mode" by Kevin Collins, March 7. Needs much more work.
Vi incompatibility:
- Try new POSIX tests, made after my comments. (Geoff Clare, 2005 April 7)
Version 1.5 is in ~/src/posix/1.5. (Lynne Canal)
8 With undo/redo only marks in the changed lines should be changed. Other
marks should be kept. Vi keeps each mark at the same text, even when it
is deleted or restored. (Webb)
Also: A mark is lost after: make change, undo, redo and undo.
Example: "{d''" then "u" then "d''": deletes an extra line, because the ''
position is one line down. (Veselinovic)
8 When stdin is not a tty, and Vim reads commands from it, an error should
make Vim exit.
7 Unix Vim (not gvim): Typing CTRL-C in Ex mode should finish the line
(currently you can continue typing, but it's truncated later anyway).
Requires a way to make CTRL-C interrupt select() when in cooked input.
8 When loading a file in the .exrc, Vi loads the argument anyway. Vim skips
loading the argument if there is a file already. When no file argument
given, Vi starts with an empty buffer, Vim keeps the loaded file. (Bearded)
6 In Insert mode, when using <BS> or <Del>, don't wipe out the text, but
only move back the cursor. Behaves like '$' in 'cpoptions'. Use a flag
in 'cpoptions' to switch this on/off.
8 When editing a file which is a symbolic link, and then opening another
symbolic link on the same file, Vim uses the name of the first one.
Adjust the file name in the buffer to the last one used? Use several file
names in one buffer???
Also: When first editing file "test", which is symlink to "test2", and
then editing "test2", you end up editing buffer "test" again. It's not
logical that the name that was first used sticks with the buffer.
7 The ":undo" command works differently in Ex mode. Edit a file, make some
changes, "Q", "undo" and _all_ changes are undone, like the ":visual"
command was one command.
On the other hand, an ":undo" command in an Ex script only undoes the last
change (e.g., use two :append commands, then :undo).
7 The ":map" command output overwrites the command. Perhaps it should keep
the ":map" when it's used without arguments?
7 CTRL-L is not the end of a section? It is for Posix! Make it an option.
7 Implement 'prompt' option. Init to off when stdin is not a tty.
7 CTRL-T in Insert mode inserts 'shiftwidth' of spaces at the cursor. Add a
flag in 'cpoptions' for this.
7 Add a way to send an email for a crashed edit session. Create a file when
making changes (containing name of the swap file), delete it when writing
the file. Supply a program that can check for crashed sessions (either
all, for a system startup, or for one user, for in a .login file).
7 Vi doesn't do autoindenting when input is not from a tty (in Ex mode).
7 "z3<CR>" should still use the whole window, but only redisplay 3 lines.
7 ":tag xx" should move the cursor to the first non-blank. Or should it go
to the match with the tag? Option?
7 Implement 'autoprint'/'ap' option.
7 Add flag in 'cpoptions' that makes <BS> after a count work like <Del>
(Sayre).
7 Add flag in 'cpoptions' that makes operator (yank, filter) not move the
cursor, at least when cancelled. (default Vi compatible).
7 This Vi-trick doesn't work: "Q" to go to Ex mode, then "g/pattern/visual".
In Vi you can edit in visual mode, and when doing "Q" you jump to the next
match. Nvi can do it too.
7 Support '\' for line continuation in Ex mode for these commands: (Luebking)
g/./a\ g/pattern1/ s/pattern2/rep1\\
line 1\ line 2\\
line 2\ line 3\\
. line4/
6 ":e /tmp/$tty" doesn't work. ":e $uid" does. Is $tty not set because of
the way the shell is started?
6 Vi compatibility (optional): make "ia<CR><ESC>10." do the same strange
thing. (only repeat insert for the first line).
MSDOS and Win32:
8 Should $USERPROFILE be preferred above $HOMEDRIVE/$HOMEPATH? No, but it's
a good fallback, thus use:

View File

@ -10,17 +10,12 @@ Throughout the help files differences between Vim and Vi/Ex are given in
curly braces, like "{not in Vi}". This file only lists what has not been
mentioned in other files and gives an overview.
Vim is mostly POSIX 1003.2-1 compliant. The only command known to be missing
is ":open". There are probably a lot of small differences (either because Vim
is missing something or because Posix is beside the mark).
1. Simulated command |simulated-command|
2. Missing options |missing-options|
3. Limits |limits|
4. The most interesting additions |vim-additions|
5. Other vim features |other-features|
6. Command-line arguments |cmdline-arguments|
7. POSIX compliance |posix-compliance|
==============================================================================
1. Simulated command *simulated-command*
@ -919,59 +914,5 @@ Only Vim is able to accept options in between and after the file names.
@{cmdfile} Vile: use {cmdfile} as startup file.
==============================================================================
7. POSIX compliance *posix* *posix-compliance*
In 2005 the POSIX test suite was run to check the compatibility of Vim. Most
of the test was executed properly. There are the few things where Vim
is not POSIX compliant, even when run in Vi compatibility mode.
Set the $VIM_POSIX environment variable to have 'cpoptions' include the POSIX
flags when Vim starts up. This makes Vim run as POSIX as it can. That's
a bit different from being Vi compatible.
This is where Vim does not behave as POSIX specifies and why:
*posix-screen-size*
The $COLUMNS and $LINES environment variables are ignored by Vim if
the size can be obtained from the terminal in a more reliable way.
Add the '|' flag to 'cpoptions' to have $COLUMNS and $LINES overrule
sizes obtained in another way.
The "{" and "}" commands don't stop at a "{" in the original Vi, but
POSIX specifies it does. Add the '{' flag to 'cpoptions' if you want
it the POSIX way.
The "D", "o" and "O" commands accept a count. Also when repeated.
Add the '#' flag to 'cpoptions' if you want to ignore the count.
The ":cd" command fails if the current buffer is modified when the '.'
flag is present in 'cpoptions'.
There is no ATTENTION message, the "A" flag is added to 'shortmess'.
These are remarks about running the POSIX test suite:
- vi test 33 sometimes fails for unknown reasons
- vi test 250 fails; behavior will be changed in a new revision
http://www.opengroup.org/austin/mailarchives/ag-review/msg01710.html
(link no longer works, perhaps it's now:
https://www.opengroup.org/sophocles/show_mail.tpl?CALLER=show_archive.tpl&source=L&listname=austin-review-l&id=1711)
- vi test 310 fails; exit code non-zero when any error occurred?
- ex test 24 fails because test is wrong. Changed between SUSv2 and SUSv3.
- ex tests 47, 48, 49, 72, 73 fail because .exrc file isn't read in silent
mode and $EXINIT isn't used.
- ex tests 76, 78 fail because echo is used instead of printf. (fixed)
Also: problem with \s not changed to space.
- ex test 355 fails because 'window' isn't used for "30z".
- ex test 368 fails because shell command isn't echoed in silent mode.
- ex test 394 fails because "=" command output isn't visible in silent mode.
- ex test 411 fails because test file is wrong, contains stray ':'.
- ex test 475 and 476 fail because reprint output isn't visible in silent mode.
- ex test 480 and 481 fail because the tags file has spaces instead of a tab.
- ex test 502 fails because .exrc isn't read in silent mode.
- ex test 509 fails because .exrc isn't read in silent mode. and exit code is
1 instead of 2.
- ex test 534 fails because .exrc isn't read in silent mode.
vim:tw=78:ts=8:ft=help:norl:

View File

@ -135,6 +135,7 @@ Highlight groups:
|hl-VisualNOS|
Other options:
'cpoptions' ('g', 'w', 'H', '*', '-', 'j', and all POSIX flags were removed)
'guioptions' (only the 't' flag was removed)
'guipty'
'macatsui'

View File

@ -3472,18 +3472,8 @@ void do_sub(exarg_T *eap)
}
if (!eap->skip) {
/* In POSIX vi ":s/pat/%/" uses the previous subst. string. */
if (STRCMP(sub, "%") == 0
&& vim_strchr(p_cpo, CPO_SUBPERCENT) != NULL) {
if (old_sub == NULL) { /* there is no previous command */
EMSG(_(e_nopresub));
return;
}
sub = old_sub;
} else {
xfree(old_sub);
old_sub = vim_strsave(sub);
}
xfree(old_sub);
old_sub = vim_strsave(sub);
}
} else if (!eap->skip) { /* use previous pattern and substitution */
if (old_sub == NULL) { /* there is no previous command */

View File

@ -6834,12 +6834,6 @@ void ex_cd(exarg_T *eap)
{
if (allbuf_locked())
return;
if (vim_strchr(p_cpo, CPO_CHDIR) != NULL && curbufIsChanged()
&& !eap->forceit) {
EMSG(_(
"E747: Cannot change directory, buffer is modified (add ! to override)"));
return;
}
/* ":cd -": Change to previous directory */
if (STRCMP(new_dir, "-") == 0) {

View File

@ -587,8 +587,7 @@ void ml_close(buf_T *buf, int del_file)
void ml_close_all(int del_file)
{
FOR_ALL_BUFFERS(buf) {
ml_close(buf, del_file && ((buf->b_flags & BF_PRESERVED) == 0
|| vim_strchr(p_cpo, CPO_PRESERVE) == NULL));
ml_close(buf, del_file && ((buf->b_flags & BF_PRESERVED) == 0));
}
spell_delete_wordlist(); /* delete the internal wordlist */
vim_deltempdir(); /* delete created temp directory */

View File

@ -5735,22 +5735,10 @@ static void nv_optrans(cmdarg_T *cap)
static char_u *str = (char_u *)"xXDCsSY&";
if (!checkclearopq(cap->oap)) {
/* In Vi "2D" doesn't delete the next line. Can't translate it
* either, because "2." should also not use the count. */
if (cap->cmdchar == 'D' && vim_strchr(p_cpo, CPO_HASH) != NULL) {
cap->oap->start = curwin->w_cursor;
cap->oap->op_type = OP_DELETE;
set_op_var(OP_DELETE);
cap->count1 = 1;
nv_dollar(cap);
finish_op = true;
ResetRedobuff();
AppendCharToRedobuff('D');
} else {
if (cap->count0)
stuffnumReadbuff(cap->count0);
stuffReadbuff(ar[(int)(vim_strchr(str, cap->cmdchar) - str)]);
if (cap->count0) {
stuffnumReadbuff(cap->count0);
}
stuffReadbuff(ar[(int)(vim_strchr(str, cap->cmdchar) - str)]);
}
cap->opcount = 0;
}
@ -6548,9 +6536,6 @@ static void n_opencmd(cmdarg_T *cap)
0, 0)) {
if (curwin->w_p_cole > 0 && oldline != curwin->w_cursor.lnum)
update_single_line(curwin, oldline);
/* When '#' is in 'cpoptions' ignore the count. */
if (vim_strchr(p_cpo, CPO_HASH) != NULL)
cap->count1 = 1;
invoke_edit(cap, false, cap->cmdchar, true);
}
}

View File

@ -1724,12 +1724,6 @@ void set_init_1(void)
/* Be nocompatible */
p_cp = FALSE;
/* Use POSIX compatibility when $VIM_POSIX is set. */
if (os_env_exists("VIM_POSIX")) {
set_string_default("cpo", (char_u *)CPO_ALL);
set_string_default("shm", (char_u *)"A");
}
/*
* Find default value for 'shell' option.
* Don't use it if it is empty.
@ -4226,7 +4220,7 @@ did_set_string_option (
if (varp == &p_shm)
p = (char_u *)SHM_ALL;
else if (varp == &(p_cpo))
p = (char_u *)CPO_ALL;
p = (char_u *)CPO_VI;
else if (varp == &(curbuf->b_p_fo))
p = (char_u *)FO_ALL;
else if (varp == &curwin->w_p_cocu)

View File

@ -128,21 +128,11 @@
#define CPO_PLUS '+' /* ":write file" resets 'modified' */
#define CPO_SPECI '<' /* don't recognize <> in mappings */
#define CPO_REGAPPEND '>' /* insert NL when appending to a register */
/* POSIX flags */
#define CPO_HASH '#' /* "D", "o" and "O" do not use a count */
#define CPO_PARA '{' /* "{" is also a paragraph boundary */
#define CPO_TSIZE '|' /* $LINES and $COLUMNS overrule term size */
#define CPO_PRESERVE '&' /* keep swap file after :preserve */
#define CPO_SUBPERCENT '/' /* % in :s string uses previous one */
#define CPO_BACKSL '\\' /* \ is not special in [] */
#define CPO_CHDIR '.' /* don't chdir if buffer is modified */
#define CPO_SCOLON ';' /* using "," and ";" will skip over char if
* cursor would not move */
/* default values for Vim, Vi and POSIX */
/* default values for Vim and Vi */
#define CPO_VIM "aABceFs"
#define CPO_VI "aAbBcCdDeEfFiIJkKlLmMnoOpPqrRsStuvWxXyZ$!%+<>;"
#define CPO_ALL \
"aAbBcCdDeEfFiIJkKlLmMnoOpPqrRsStuvWxXyZ$!%+<>#{|&/\\.;"
/* characters for p_ww option: */
#define WW_ALL "bshl<>[],~"

View File

@ -1120,12 +1120,10 @@ static int get_coll_element(char_u **pp)
}
static int reg_cpo_lit; /* 'cpoptions' contains 'l' flag */
static int reg_cpo_bsl; /* 'cpoptions' contains '\' flag */
static void get_cpo_flags(void)
{
reg_cpo_lit = vim_strchr(p_cpo, CPO_LITERAL) != NULL;
reg_cpo_bsl = vim_strchr(p_cpo, CPO_BACKSL) != NULL;
}
/*
@ -1149,7 +1147,6 @@ static char_u *skip_anyof(char_u *p)
if (*p != ']' && *p != NUL)
mb_ptr_adv(p);
} else if (*p == '\\'
&& !reg_cpo_bsl
&& (vim_strchr(REGEXP_INRANGE, p[1]) != NULL
|| (!reg_cpo_lit && vim_strchr(REGEXP_ABBR, p[1]) != NULL)))
p += 2;
@ -2222,7 +2219,7 @@ collection:
}
/* Handle \o40, \x20 and \u20AC style sequences */
if (endc == '\\' && !reg_cpo_lit && !reg_cpo_bsl)
if (endc == '\\' && !reg_cpo_lit)
endc = coll_get_char();
if (startc > endc)
@ -2245,10 +2242,8 @@ collection:
* Only "\]", "\^", "\]" and "\\" are special in Vi. Vim
* accepts "\t", "\e", etc., but only when the 'l' flag in
* 'cpoptions' is not included.
* Posix doesn't recognize backslash at all.
*/
else if (*regparse == '\\'
&& !reg_cpo_bsl
&& (vim_strchr(REGEXP_INRANGE, regparse[1]) != NULL
|| (!reg_cpo_lit
&& vim_strchr(REGEXP_ABBR,

View File

@ -1584,10 +1584,8 @@ collection:
* Only "\]", "\^", "\]" and "\\" are special in Vi. Vim
* accepts "\t", "\e", etc., but only when the 'l' flag in
* 'cpoptions' is not included.
* Posix doesn't recognize backslash at all.
*/
if (*regparse == '\\'
&& !reg_cpo_bsl
&& regparse + 1 <= endp
&& (vim_strchr(REGEXP_INRANGE, regparse[1]) != NULL
|| (!reg_cpo_lit

View File

@ -2199,7 +2199,6 @@ findpar (
linenr_T curr;
bool did_skip; /* true after separating lines have been skipped */
bool first; /* true on first line */
int posix = (vim_strchr(p_cpo, CPO_PARA) != NULL);
linenr_T fold_first; /* first line of a closed fold */
linenr_T fold_last; /* last line of a closed fold */
bool fold_skipped; /* true if a closed fold was skipped this
@ -2220,12 +2219,7 @@ findpar (
fold_skipped = true;
}
/* POSIX has it's own ideas of what a paragraph boundary is and it
* doesn't match historical Vi: It also stops at a "{" in the
* first column and at an empty line. */
if (!first && did_skip && (startPS(curr, what, both)
|| (posix && what == NUL && *ml_get(curr) ==
'{')))
if (!first && did_skip && startPS(curr, what, both))
break;
if (fold_skipped)

Binary file not shown.

Binary file not shown.

View File

@ -126,10 +126,6 @@ TEST_6:
STARTTEST
:set magic&
:$put =\"\n\nTEST_6:\"
:set cpo+=/
:$put =substitute('A', 'A', 'a', '')
:$put =substitute('B', 'B', '%', '')
:set cpo-=/
:$put =substitute('C', 'C', 'c', '')
:$put =substitute('D', 'D', '%', '')
/^TEST_7

View File

@ -94,8 +94,6 @@ A123456789987654321
TEST_6:
a
%
c
%