Merge pull request #1622 from klusark/test29

default to 'nocompatible'
This commit is contained in:
Justin M. Keyes 2014-12-13 15:38:42 -05:00
commit 9af6485e8b
9 changed files with 31 additions and 101 deletions

View File

@ -1869,7 +1869,7 @@ int viminfo_readline(vir_T *virp)
* *
* Check for a long line as written by viminfo_writestring(). * Check for a long line as written by viminfo_writestring().
* *
* Return the string in allocated memory (or NULL to indicate failure). * Return the string in allocated memory.
*/ */
char_u * char_u *
viminfo_readstring ( viminfo_readstring (
@ -1877,6 +1877,7 @@ viminfo_readstring (
int off, /* offset for virp->vir_line */ int off, /* offset for virp->vir_line */
int convert /* convert the string */ int convert /* convert the string */
) )
FUNC_ATTR_NONNULL_RET
{ {
char_u *retval; char_u *retval;
char_u *s, *d; char_u *s, *d;

View File

@ -6961,15 +6961,6 @@ static void ex_mkrc(exarg_T *eap)
failed = TRUE; failed = TRUE;
} }
if (eap->cmdidx != CMD_mkview) {
/* Write setting 'compatible' first, because it has side effects.
* For that same reason only do it when needed. */
if (p_cp)
(void)put_line(fd, "if !&cp | set cp | endif");
else
(void)put_line(fd, "if &cp | set nocp | endif");
}
if (!view_session if (!view_session
|| (eap->cmdidx == CMD_mksession || (eap->cmdidx == CMD_mksession
&& (*flagp & SSOP_OPTIONS))) && (*flagp & SSOP_OPTIONS)))

View File

@ -1229,6 +1229,7 @@ EXTERN char_u e_invalpat[] INIT(= N_(
EXTERN char_u e_bufloaded[] INIT(= N_("E139: File is loaded in another buffer")); EXTERN char_u e_bufloaded[] INIT(= N_("E139: File is loaded in another buffer"));
EXTERN char_u e_notset[] INIT(= N_("E764: Option '%s' is not set")); EXTERN char_u e_notset[] INIT(= N_("E764: Option '%s' is not set"));
EXTERN char_u e_invalidreg[] INIT(= N_("E850: Invalid register name")); EXTERN char_u e_invalidreg[] INIT(= N_("E850: Invalid register name"));
EXTERN char_u e_unsupportedoption[] INIT(= N_("E519: Option not supported"));
EXTERN char top_bot_msg[] INIT(= N_("search hit TOP, continuing at BOTTOM")); EXTERN char top_bot_msg[] INIT(= N_("search hit TOP, continuing at BOTTOM"));

View File

@ -955,7 +955,6 @@ static void parse_command_name(mparm_T *parmp)
exmode_active = EXMODE_VIM; exmode_active = EXMODE_VIM;
else else
exmode_active = EXMODE_NORMAL; exmode_active = EXMODE_NORMAL;
change_compatible(TRUE); /* set 'compatible' */
} }
} }
@ -1090,10 +1089,6 @@ static void command_line_scan(mparm_T *parmp)
curbuf->b_p_bin = 1; /* binary file I/O */ curbuf->b_p_bin = 1; /* binary file I/O */
break; break;
case 'C': /* "-C" Compatible */
change_compatible(TRUE);
break;
case 'e': /* "-e" Ex mode */ case 'e': /* "-e" Ex mode */
exmode_active = EXMODE_NORMAL; exmode_active = EXMODE_NORMAL;
break; break;
@ -1142,7 +1137,7 @@ static void command_line_scan(mparm_T *parmp)
break; break;
case 'N': /* "-N" Nocompatible */ case 'N': /* "-N" Nocompatible */
change_compatible(FALSE); /* No-op */
break; break;
case 'n': /* "-n" no swap file */ case 'n': /* "-n" no swap file */
@ -2207,8 +2202,6 @@ static void usage(void)
main_msg(_("-M\t\t\tModifications in text not allowed")); main_msg(_("-M\t\t\tModifications in text not allowed"));
main_msg(_("-b\t\t\tBinary mode")); main_msg(_("-b\t\t\tBinary mode"));
main_msg(_("-l\t\t\tLisp mode")); main_msg(_("-l\t\t\tLisp mode"));
main_msg(_("-C\t\t\tCompatible with Vi: 'compatible'"));
main_msg(_("-N\t\t\tNot fully Vi compatible: 'nocompatible'"));
main_msg(_("-V[N][fname]\t\tBe verbose [level N] [log messages to fname]")); main_msg(_("-V[N][fname]\t\tBe verbose [level N] [log messages to fname]"));
main_msg(_("-D\t\t\tDebugging mode")); main_msg(_("-D\t\t\tDebugging mode"));
main_msg(_("-n\t\t\tNo swap file, use memory only")); main_msg(_("-n\t\t\tNo swap file, use memory only"));

View File

@ -839,7 +839,7 @@ void wait_return(int redraw)
* to avoid that typing one 'j' too many makes the messages * to avoid that typing one 'j' too many makes the messages
* disappear. * disappear.
*/ */
if (p_more && !p_cp) { if (p_more) {
if (c == 'b' || c == 'k' || c == 'u' || c == 'g' if (c == 'b' || c == 'k' || c == 'u' || c == 'g'
|| c == K_UP || c == K_PAGEUP) { || c == K_UP || c == K_PAGEUP) {
if (msg_scrolled > Rows) if (msg_scrolled > Rows)

View File

@ -4449,7 +4449,6 @@ int read_viminfo_register(vir_T *virp, int force)
int do_it = TRUE; int do_it = TRUE;
int size; int size;
int limit; int limit;
int i;
int set_prev = FALSE; int set_prev = FALSE;
char_u *str; char_u *str;
char_u **array = NULL; char_u **array = NULL;
@ -4483,9 +4482,13 @@ int read_viminfo_register(vir_T *virp, int force)
if (do_it) { if (do_it) {
if (set_prev) if (set_prev)
y_previous = y_current; y_previous = y_current;
for (int i = 0; i < y_current->y_size; i++) {
free(y_current->y_array[i]);
}
free(y_current->y_array); free(y_current->y_array);
array = y_current->y_array = array = xmalloc(limit * sizeof(char_u *));
(char_u **)xmalloc(limit * sizeof(char_u *));
str = skipwhite(skiptowhite(str)); str = skipwhite(skiptowhite(str));
if (STRNCMP(str, "CHAR", 4) == 0) if (STRNCMP(str, "CHAR", 4) == 0)
y_current->y_type = MCHAR; y_current->y_type = MCHAR;
@ -4502,30 +4505,21 @@ int read_viminfo_register(vir_T *virp, int force)
&& (virp->vir_line[0] == TAB || virp->vir_line[0] == '<')) { && (virp->vir_line[0] == TAB || virp->vir_line[0] == '<')) {
if (do_it) { if (do_it) {
if (size >= limit) { if (size >= limit) {
y_current->y_array = (char_u **)xmalloc(limit * 2 * sizeof(char_u *));
for (i = 0; i < limit; i++)
y_current->y_array[i] = array[i];
free(array);
limit *= 2; limit *= 2;
array = y_current->y_array; array = xrealloc(array, limit * sizeof(char_u *));
} }
str = viminfo_readstring(virp, 1, TRUE); array[size++] = viminfo_readstring(virp, 1, TRUE);
if (str != NULL)
array[size++] = str;
else
do_it = FALSE;
} }
} }
if (do_it) { if (do_it) {
if (size == 0) { if (size == 0) {
free(array); free(array);
y_current->y_array = NULL; y_current->y_array = NULL;
} else if (size < limit) { } else if (size < limit) {
y_current->y_array = y_current->y_array = xrealloc(array, size * sizeof(char_u *));
(char_u **)xmalloc(size * sizeof(char_u *)); } else {
for (i = 0; i < size; i++) y_current->y_array = array;
y_current->y_array[i] = array[i];
free(array);
} }
y_current->y_size = size; y_current->y_size = size;
} }

View File

@ -1851,8 +1851,8 @@ void set_init_1(void)
langmap_init(); langmap_init();
/* Be Vi compatible by default */ /* Be nocompatible */
p_cp = TRUE; p_cp = FALSE;
/* Use POSIX compatibility when $VIM_POSIX is set. */ /* Use POSIX compatibility when $VIM_POSIX is set. */
if (os_getenv("VIM_POSIX") != NULL) { if (os_getenv("VIM_POSIX") != NULL) {
@ -1995,6 +1995,9 @@ void set_init_1(void)
check_win_options(curwin); check_win_options(curwin);
check_options(); check_options();
/* Set all options to their Vim default */
set_options_default(OPT_FREE);
/* Must be before option_expand(), because that one needs vim_isIDc() */ /* Must be before option_expand(), because that one needs vim_isIDc() */
didset_options(); didset_options();
@ -2617,7 +2620,7 @@ do_set (
if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
&& (!(options[opt_idx].flags & P_BOOL) && (!(options[opt_idx].flags & P_BOOL)
|| nextchar == '?')) || nextchar == '?'))
errmsg = (char_u *)N_("E519: Option not supported"); errmsg = (char_u *)_(e_unsupportedoption);
goto skip; goto skip;
} }
@ -4922,13 +4925,10 @@ set_bool_option (
if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
*(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value; *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
/* if ((int *)varp == &p_cp && p_cp == TRUE) {
* Handle side effects of changing a bool option. /* Ensure that compatible can not be enabled */
*/ p_cp = FALSE;
return e_unsupportedoption;
/* 'compatible' */
if ((int *)varp == &p_cp) {
compatible_set();
} }
/* 'undofile' */ /* 'undofile' */
else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf) { else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf) {
@ -7748,18 +7748,9 @@ static void paste_option_changed(void)
*/ */
void vimrc_found(char_u *fname, char_u *envname) void vimrc_found(char_u *fname, char_u *envname)
{ {
int opt_idx;
int dofree = FALSE; int dofree = FALSE;
char_u *p; char_u *p;
if (!option_was_set((char_u *)"cp")) {
p_cp = FALSE;
for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
set_option_default(opt_idx, OPT_FREE, FALSE);
didset_options();
}
if (fname != NULL) { if (fname != NULL) {
p = vim_getenv(envname, &dofree); p = vim_getenv(envname, &dofree);
if (p == NULL) { if (p == NULL) {
@ -7774,22 +7765,6 @@ void vimrc_found(char_u *fname, char_u *envname)
} }
} }
/*
* Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
*/
void change_compatible(int on)
{
int opt_idx;
if (p_cp != on) {
p_cp = on;
compatible_set();
}
opt_idx = findoption((char_u *)"cp");
if (opt_idx >= 0)
options[opt_idx].flags |= P_WAS_SET;
}
/* /*
* Return TRUE when option "name" has been set. * Return TRUE when option "name" has been set.
* Only works correctly for global options. * Only works correctly for global options.
@ -7817,25 +7792,6 @@ void reset_option_was_set(char_u *name)
options[idx].flags &= ~P_WAS_SET; options[idx].flags &= ~P_WAS_SET;
} }
/*
* compatible_set() - Called when 'compatible' has been set or unset.
*
* When 'compatible' set: Set all relevant options (those that have the P_VIM)
* flag) to a Vi compatible value.
* When 'compatible' is unset: Set all options that have a different default
* for Vim (without the P_VI_DEF flag) to that default.
*/
static void compatible_set(void)
{
int opt_idx;
for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
if ( ((options[opt_idx].flags & P_VIM) && p_cp)
|| (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
set_option_default(opt_idx, OPT_FREE, p_cp);
didset_options();
}
/* /*
* fill_breakat_flags() -- called when 'breakat' changes value. * fill_breakat_flags() -- called when 'breakat' changes value.
*/ */

View File

@ -5,7 +5,7 @@ Test for joining lines and marks in them
STARTTEST STARTTEST
:so small.vim :so small.vim
:set nocompatible viminfo+=nviminfo :set viminfo+=nviminfo
:set nojoinspaces :set nojoinspaces
:set cpoptions-=j :set cpoptions-=j
/firstline/ /firstline/
@ -13,7 +13,7 @@ j"td/^STARTTEST/-1
PJjJjJjJjJjJjJjJjJjJjJjJjJjJj05lmx2j06lmy2k4Jy3l$p`xyl$p`yy2l$p:set cpoptions+=j PJjJjJjJjJjJjJjJjJjJjJjJjJjJj05lmx2j06lmy2k4Jy3l$p`xyl$p`yy2l$p:set cpoptions+=j
j05lmx2j06lmy2k4Jy3l$p`xyl$p`yy2l$p:set cpoptions-=j joinspaces j05lmx2j06lmy2k4Jy3l$p`xyl$p`yy2l$p:set cpoptions-=j joinspaces
j"tpJjJjJjJjJjJjJjJjJjJjJjJjJjJj05lmx2j06lmy2k4Jy3l$p`xyl$p`yy2l$p:set cpoptions+=j j"tpJjJjJjJjJjJjJjJjJjJjJjJjJjJj05lmx2j06lmy2k4Jy3l$p`xyl$p`yy2l$p:set cpoptions+=j
j05lmx2j06lmy2k4Jy3l$p`xyl$p`yy2l$p:set cpoptions-=j nojoinspaces compatible j05lmx2j06lmy2k4Jy3l$p`xyl$p`yy2l$p:set cpo+=qo
j"tpJjJjJjJjJjJjJjJjJjJjJjJjJjJj4Jy3l$pjd/STARTTEST/-2 j"tpJjJjJjJjJjJjJjJjJjJjJjJjJjJj4Jy3l$pjd/STARTTEST/-2
ENDTEST ENDTEST
@ -104,7 +104,7 @@ if (condition) // Remove the next comment leader!
STARTTEST STARTTEST
:" Test with backspace set to the non-compatible setting :" Test with backspace set to the non-compatible setting
/^\d\+ this /^\d\+ this
:set cp bs=2 :set bs=2
Avim1 Avim1
Avim2u Avim2u
:set cpo-=< :set cpo-=<
@ -118,7 +118,7 @@ A vim5A
A vim6Azweiu A vim6Azweiu
:inoremap <c-u> <left><c-u> :inoremap <c-u> <left><c-u>
A vim7 A vim7
:set cp :set noesckeys
ENDTEST ENDTEST
1 this shouldn't be deleted 1 this shouldn't be deleted
2 this shouldn't be deleted 2 this shouldn't be deleted

View File

@ -944,12 +944,6 @@ void intro_message(int colon)
if (((row >= 2) && (Columns >= 50)) || colon) { if (((row >= 2) && (Columns >= 50)) || colon) {
for (i = 0; i < (int)(sizeof(lines) / sizeof(char *)); ++i) { for (i = 0; i < (int)(sizeof(lines) / sizeof(char *)); ++i) {
p = lines[i]; p = lines[i];
if (p == NULL) {
if (!p_cp) {
break;
}
continue;
}
if (sponsor != 0) { if (sponsor != 0) {
if (strstr(p, "children") != NULL) { if (strstr(p, "children") != NULL) {