diff options
author | Bram Moolenaar <Bram@vim.org> | 2006-01-19 22:16:24 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2006-01-19 22:16:24 +0000 |
commit | 8ada17c4d9d783b370d081c2a947ea1350cc8338 (patch) | |
tree | 47f3570cfefb2433a4dda01a32fb11316cf9f5bc /src | |
parent | 05a7bb363b6ae132b7f2550be1a588e481a5dfa3 (diff) | |
download | vim-git-8ada17c4d9d783b370d081c2a947ea1350cc8338.tar.gz |
updated for version 7.0182v7.0182
Diffstat (limited to 'src')
-rw-r--r-- | src/edit.c | 7 | ||||
-rw-r--r-- | src/ex_cmds.c | 12 | ||||
-rw-r--r-- | src/ex_getln.c | 71 | ||||
-rw-r--r-- | src/globals.h | 2 | ||||
-rw-r--r-- | src/gui_gtk_x11.c | 1 | ||||
-rw-r--r-- | src/structs.h | 4 | ||||
-rw-r--r-- | src/undo.c | 72 | ||||
-rw-r--r-- | src/version.h | 4 |
8 files changed, 110 insertions, 63 deletions
diff --git a/src/edit.c b/src/edit.c index 298ebc3c8..ab3558a9f 100644 --- a/src/edit.c +++ b/src/edit.c @@ -289,6 +289,13 @@ edit(cmdchar, startln, count) return FALSE; } #endif + /* Don't allow changes in the buffer while editing the cmdline. The + * caller of getcmdline() may get confused. */ + if (cmdline_busy) + { + EMSG(_(e_secure)); + return FALSE; + } #ifdef FEAT_INS_EXPAND ins_compl_clear(); /* clear stuff for CTRL-X mode */ diff --git a/src/ex_cmds.c b/src/ex_cmds.c index c4fd0c4bd..e192d100c 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -2841,11 +2841,11 @@ check_readonly(forceit, buf) } /* - * try to abandon current file and edit a new or existing file - * 'fnum' is the number of the file, if zero use ffname/sfname + * Try to abandon current file and edit a new or existing file. + * 'fnum' is the number of the file, if zero use ffname/sfname. * - * return 1 for "normal" error, 2 for "not written" error, 0 for success - * -1 for succesfully opening another file + * Return 1 for "normal" error, 2 for "not written" error, 0 for success + * -1 for succesfully opening another file. * 'lnum' is the line number for the cursor in the new file (if non-zero). */ int @@ -2861,10 +2861,8 @@ getfile(fnum, ffname, sfname, setpm, lnum, forceit) int retval; char_u *free_me = NULL; -#ifdef FEAT_CMDWIN - if (cmdwin_type != 0) + if (editing_cmdline()) return 1; -#endif if (fnum == 0) { diff --git a/src/ex_getln.c b/src/ex_getln.c index 95109534a..b1142c472 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -258,6 +258,9 @@ getcmdline(firstc, count, indent) } xpc.xp_context = EXPAND_NOTHING; xpc.xp_backslash = XP_BS_NONE; +#ifndef BACKSLASH_IN_FILENAME + xpc.xp_shell = FALSE; +#endif #if defined(FEAT_EVAL) if (ccline.input_fn) @@ -658,17 +661,13 @@ getcmdline(firstc, count, indent) restore_cmdline(&save_ccline); if (c == '=') { - /* Need to save and restore ccline. And go into the - * sandbox to avoid nasty things like going to another - * buffer when evaluating an expression. */ + /* Need to save and restore ccline. And set cmdline_busy + * to avoid nasty things like going to another buffer when + * evaluating an expression. */ save_cmdline(&save_ccline); -#ifdef HAVE_SANDBOX - ++sandbox; -#endif + ++cmdline_busy; p = get_expr_line(); -#ifdef HAVE_SANDBOX - --sandbox; -#endif + --cmdline_busy; restore_cmdline(&save_ccline); if (p != NULL && realloc_cmdbuff((int)STRLEN(p) + 1) == OK) @@ -1875,6 +1874,35 @@ getcmdline_prompt(firstc, prompt, attr, xp_context, xp_arg) } #endif +/* + * Return TRUE when the command line is being edited. That means the current + * buffer and window can't be changed. + */ + int +editing_cmdline() +{ +#ifdef FEAT_CMDWIN + if (cmdwin_type != 0) + return TRUE; +#endif + return cmdline_busy; +} + +/* + * Give an error message for a command that isn't allowed while the cmdline + * window is open or editing the cmdline in another way. + */ + void +editing_cmdline_msg() +{ +#ifdef FEAT_CMDWIN + if (cmdwin_type != 0) + EMSG(_(e_cmdwin)); + else +#endif + EMSG(_(e_secure)); +} + static int cmdline_charsize(idx) int idx; @@ -2786,17 +2814,12 @@ cmdline_paste(regname, literally) regname = may_get_selection(regname); #endif - /* Need to save and restore ccline. And go into the sandbox to avoid - * nasty things like going to another buffer when evaluating an - * expression. */ + /* Need to save and restore ccline. And set cmdline_busy to avoid nasty + * things like going to another buffer when evaluating an expression. */ save_cmdline(&save_ccline); -#ifdef HAVE_SANDBOX - ++sandbox; -#endif + ++cmdline_busy; i = get_spec_reg(regname, &arg, &allocated, TRUE); -#ifdef HAVE_SANDBOX - --sandbox; -#endif + --cmdline_busy; restore_cmdline(&save_ccline); if (i) @@ -3368,8 +3391,14 @@ ExpandInit(xp) expand_T *xp; { xp->xp_backslash = XP_BS_NONE; +#ifndef BACKSLASH_IN_FILENAME + xp->xp_shell = FALSE; +#endif xp->xp_numfiles = -1; xp->xp_files = NULL; +#if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL) && defined(FEAT_CMDL_COMPL) + xp->xp_arg = NULL; +#endif } /* @@ -3446,7 +3475,8 @@ ExpandEscape(xp, str, numfiles, files, options) p = vim_strsave_escaped(files[i], buf); } #else - p = vim_strsave_escaped(files[i], PATH_ESC_CHARS); + p = vim_strsave_escaped(files[i], + xp->xp_shell ? SHELL_ESC_CHARS : PATH_ESC_CHARS); #endif if (p != NULL) { @@ -4527,8 +4557,9 @@ globpath(path, file) if (buf == NULL) return NULL; + ExpandInit(&xpc); xpc.xp_context = EXPAND_FILES; - xpc.xp_backslash = XP_BS_NONE; + ga_init2(&ga, 1, 100); /* Loop over all entries in {path}. */ diff --git a/src/globals.h b/src/globals.h index c22466c06..9c81e4efb 100644 --- a/src/globals.h +++ b/src/globals.h @@ -86,6 +86,8 @@ EXTERN int clear_cmdline INIT(= FALSE); /* cmdline must be cleared */ #if defined(FEAT_CRYPT) || defined(FEAT_EVAL) EXTERN int cmdline_star INIT(= FALSE); /* cmdline is crypted */ #endif +EXTERN int cmdline_busy INIT(= FALSE); /* editing the cmdline */ + EXTERN int exec_from_reg INIT(= FALSE); /* executing register */ EXTERN int screen_cleared INIT(= FALSE); /* screen has been cleared */ diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c index 84c5fe406..1502e0c1c 100644 --- a/src/gui_gtk_x11.c +++ b/src/gui_gtk_x11.c @@ -2328,7 +2328,6 @@ sm_client_die(GnomeClient *client, gpointer data) vim_strncpy(IObuff, _("Vim: Received \"die\" request from session manager\n"), IOSIZE - 1); - deadly_exit = TRUE; preserve_exit(); } diff --git a/src/structs.h b/src/structs.h index 5420b4e4b..b71f592b0 100644 --- a/src/structs.h +++ b/src/structs.h @@ -401,6 +401,10 @@ typedef struct expand int xp_scriptID; /* SID for completion function */ #endif int xp_backslash; /* one of the XP_BS_ values */ +#ifndef BACKSLASH_IN_FILENAME + int xp_shell; /* for a shell command more characters + need to be escaped */ +#endif int xp_numfiles; /* number of files found by file name completion */ char_u **xp_files; /* list of files */ diff --git a/src/undo.c b/src/undo.c index 34e1f400d..1b69cf111 100644 --- a/src/undo.c +++ b/src/undo.c @@ -52,6 +52,7 @@ static u_entry_T *u_get_headentry __ARGS((void)); static void u_getbot __ARGS((void)); +static int undo_allowed __ARGS((void)); static int u_savecommon __ARGS((linenr_T, linenr_T, linenr_T)); static void u_doit __ARGS((int count)); static void u_undoredo __ARGS((void)); @@ -156,40 +157,57 @@ u_savedel(lnum, nlines) nlines == curbuf->b_ml.ml_line_count ? 2 : lnum)); } +/* + * Return TRUE when undo is allowed. Otherwise give an error message and + * return FALSE. + */ static int -u_savecommon(top, bot, newbot) - linenr_T top, bot; - linenr_T newbot; +undo_allowed() { - linenr_T lnum; - long i; - struct u_header *uhp; - u_entry_T *uep; - u_entry_T *prev_uep; - long size; - - /* - * Don't allow changes when 'modifiable' is off. Letting the - * undo fail is a crude way to make all change commands fail. - */ + /* Don't allow changes when 'modifiable' is off. */ if (!curbuf->b_p_ma) { EMSG(_(e_modifiable)); - return FAIL; + return FALSE; } #ifdef HAVE_SANDBOX - /* - * In the sandbox it's not allowed to change the text. Letting the - * undo fail is a crude way to make all change commands fail. - */ + /* In the sandbox it's not allowed to change the text. */ if (sandbox != 0) { EMSG(_(e_sandbox)); - return FAIL; + return FALSE; } #endif + /* Don't allow changes in the buffer while editing the cmdline. The + * caller of getcmdline() may get confused. */ + if (cmdline_busy) + { + EMSG(_(e_secure)); + return FALSE; + } + + return TRUE; +} + + static int +u_savecommon(top, bot, newbot) + linenr_T top, bot; + linenr_T newbot; +{ + linenr_T lnum; + long i; + struct u_header *uhp; + u_entry_T *uep; + u_entry_T *prev_uep; + long size; + + /* When making changes is not allowed return FAIL. It's a crude way to + * make all change commands fail. */ + if (!undo_allowed()) + return FAIL; + #ifdef FEAT_NETBEANS_INTG /* * Netbeans defines areas that cannot be modified. Bail out here when @@ -484,20 +502,8 @@ u_redo(count) u_doit(count) int count; { - /* Don't allow changes when 'modifiable' is off. */ - if (!curbuf->b_p_ma) - { - EMSG(_(e_modifiable)); - return; - } -#ifdef HAVE_SANDBOX - /* In the sandbox it's not allowed to change the text. */ - if (sandbox != 0) - { - EMSG(_(e_sandbox)); + if (!undo_allowed()) return; - } -#endif u_newcount = 0; u_oldcount = 0; diff --git a/src/version.h b/src/version.h index 3cb3dd984..0251f806c 100644 --- a/src/version.h +++ b/src/version.h @@ -36,5 +36,5 @@ #define VIM_VERSION_NODOT "vim70aa" #define VIM_VERSION_SHORT "7.0aa" #define VIM_VERSION_MEDIUM "7.0aa ALPHA" -#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2006 Jan 14)" -#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2006 Jan 14, compiled " +#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2006 Jan 19)" +#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2006 Jan 19, compiled " |