• R/O
  • SSH

vim: 提交

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

修訂1c586ee8dd452d305bebf633d5b8c78ba1ab170d (tree)
時間2006-01-21 08:10:18
作者vimboss
Commitervimboss

Log Message

updated for version 7.0183

Change Summary

差異

diff -r 7437be625546 -r 1c586ee8dd45 runtime/doc/eval.txt
--- a/runtime/doc/eval.txt Fri Jan 20 23:02:51 2006 +0000
+++ b/runtime/doc/eval.txt Fri Jan 20 23:10:18 2006 +0000
@@ -1,4 +1,4 @@
1-*eval.txt* For Vim version 7.0aa. Last change: 2006 Jan 13
1+*eval.txt* For Vim version 7.0aa. Last change: 2006 Jan 20
22
33
44 VIM REFERENCE MANUAL by Bram Moolenaar
@@ -28,6 +28,7 @@
2828 9. Examples |eval-examples|
2929 10. No +eval feature |no-eval-feature|
3030 11. The sandbox |eval-sandbox|
31+12. Textlock |textlock|
3132
3233 {Vi does not have any of these commands}
3334
@@ -6830,5 +6831,33 @@
68306831 option that may have been set from a modeline, e.g.
68316832 'foldexpr'.
68326833
6834+ *sandbox-option*
6835+A few options contain an expression. When this expression is evaluated it may
6836+have to be done in the sandbox to avoid trouble. But the sandbox is
6837+restrictive, thus this only happens when the option was set from an insecure
6838+location. Insecure in this context are:
6839+- sourcing a .vimrc or .exrc in the current directlry
6840+- while executing in the sandbox
6841+- value coming from a modeline
6842+
6843+Note that when in the sandbox and saving an option value and restoring it, the
6844+option will still be marked as it was set in the sandbox.
6845+
6846+==============================================================================
6847+12. Textlock *textlock*
6848+
6849+In a few situations it is not allowed to change the text in the buffer, jump
6850+to another window and some other things that might confuse or break what Vim
6851+is currently doing. This mostly applies to things that happen when Vim is
6852+actually doing something else. For example, evaluating the 'balloonexpr' may
6853+happen any moment the mouse cursor is resting at some position.
6854+
6855+This is not allowed when the textlock is active:
6856+ - changing the buffer text
6857+ - jumping to another buffer or window
6858+ - editing another file
6859+ - closing a window or quitting Vim
6860+ - etc.
6861+
68336862
68346863 vim:tw=78:ts=8:ft=help:norl:
diff -r 7437be625546 -r 1c586ee8dd45 runtime/doc/options.txt
--- a/runtime/doc/options.txt Fri Jan 20 23:02:51 2006 +0000
+++ b/runtime/doc/options.txt Fri Jan 20 23:10:18 2006 +0000
@@ -1,4 +1,4 @@
1-*options.txt* For Vim version 7.0aa. Last change: 2006 Jan 19
1+*options.txt* For Vim version 7.0aa. Last change: 2006 Jan 20
22
33
44 VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1037,6 +1037,12 @@
10371037 Vim does not try to send a message to an external debugger (Netbeans
10381038 or Sun Workshop).
10391039
1040+ The expression may be evaluated in the |sandbox|, see
1041+ |sandbox-option|.
1042+
1043+ It is not allowed to change text or jump to another window while
1044+ evaluating 'balloonexpr' |textlock|.
1045+
10401046 To check whether line breaks in the balloon text work use this check: >
10411047 if has("balloon_multiline")
10421048 <
@@ -2771,8 +2777,13 @@
27712777 {not available when compiled without the |+folding|
27722778 or |+eval| feature}
27732779 The expression used for when 'foldmethod' is "expr". It is evaluated
2774- for each line to obtain its fold level. See |fold-expr|. Also see
2775- |eval-sandbox|.
2780+ for each line to obtain its fold level. See |fold-expr|.
2781+
2782+ The expression may be evaluated in the |sandbox|, see
2783+ |sandbox-option|.
2784+
2785+ It is not allowed to change text or jump to another window while
2786+ evaluating 'foldexpr' |textlock|.
27762787
27772788 *'foldignore'* *'fdi'*
27782789 'foldignore' 'fdi' string (default: "#")
@@ -2904,6 +2915,12 @@
29042915 An expression which is used to specify the text displayed for a closed
29052916 fold. See |fold-foldtext|.
29062917
2918+ The expression may be evaluated in the |sandbox|, see
2919+ |sandbox-option|.
2920+
2921+ It is not allowed to change text or jump to another window while
2922+ evaluating 'foldtext' |textlock|.
2923+
29072924 *'formatoptions'* *'fo'*
29082925 'formatoptions' 'fo' string (Vim default: "tcq", Vi default: "vt")
29092926 local to buffer
@@ -3696,11 +3713,17 @@
36963713 option to a file name. Mostly useful to change "." to "/" for Java: >
36973714 :set includeexpr=substitute(v:fname,'\\.','/','g')
36983715 < The "v:fname" variable will be set to the file name that was detected.
3699- Evaluated in the |sandbox|.
3716+
37003717 Also used for the |gf| command if an unmodified file name can't be
37013718 found. Allows doing "gf" on the name after an 'include' statement.
37023719 Also used for |<cfile>|.
37033720
3721+ The expression may be evaluated in the |sandbox|, see
3722+ |sandbox-option|.
3723+
3724+ It is not allowed to change text or jump to another window while
3725+ evaluating 'includeexpr' |textlock|.
3726+
37043727 *'incsearch'* *'is'* *'noincsearch'* *'nois'*
37053728 'incsearch' 'is' boolean (default off)
37063729 global
@@ -3746,9 +3769,16 @@
37463769 :set indentexpr=GetMyIndent()
37473770 < Error messages will be suppressed, unless the 'debug' option contains
37483771 "msg".
3749- See |indent-expression|. Also see |eval-sandbox|.
3772+ See |indent-expression|.
37503773 NOTE: This option is made empty when 'compatible' is set.
37513774
3775+ The expression may be evaluated in the |sandbox|, see
3776+ |sandbox-option|.
3777+
3778+ It is not allowed to change text or jump to another window while
3779+ evaluating 'indentexpr' |textlock|.
3780+
3781+
37523782 *'indentkeys'* *'indk'*
37533783 'indentkeys' 'indk' string (default "0{,0},:,0#,!^F,o,O,e")
37543784 local to buffer
@@ -6084,7 +6114,13 @@
60846114 temporarily to that of the window (and buffer) whose statusline is
60856115 currently being drawn. The expression will evaluate in this context.
60866116 The variable "actual_curbuf" is set to the 'bufnr()' number of the
6087- real current buffer. The expression is evaluated in the |sandbox|.
6117+ real current buffer.
6118+
6119+ The 'statusline' option may be evaluated in the |sandbox|, see
6120+ |sandbox-option|.
6121+
6122+ It is not allowed to change text or jump to another window while
6123+ evaluating 'statusline' |textlock|.
60886124
60896125 If the statusline is not updated when you want it (e.g., after setting
60906126 a variable that's used in an expression), you can force an update by
diff -r 7437be625546 -r 1c586ee8dd45 runtime/doc/tags
--- a/runtime/doc/tags Fri Jan 20 23:02:51 2006 +0000
+++ b/runtime/doc/tags Fri Jan 20 23:10:18 2006 +0000
@@ -5349,6 +5349,7 @@
53495349 hebrew.txt hebrew.txt /*hebrew.txt*
53505350 help various.txt /*help*
53515351 help-context help.txt /*help-context*
5352+help-tags tags 1
53525353 help-translated various.txt /*help-translated*
53535354 help-xterm-window various.txt /*help-xterm-window*
53545355 help.txt help.txt /*help.txt*
@@ -6404,6 +6405,7 @@
64046405 s:var eval.txt /*s:var*
64056406 s<CR> change.txt /*s<CR>*
64066407 sandbox eval.txt /*sandbox*
6408+sandbox-option eval.txt /*sandbox-option*
64076409 save-file editing.txt /*save-file*
64086410 save-settings starting.txt /*save-settings*
64096411 scheme.vim syntax.txt /*scheme.vim*
@@ -6929,6 +6931,7 @@
69296931 tex.vim syntax.txt /*tex.vim*
69306932 text-objects motion.txt /*text-objects*
69316933 text-objects-changed version5.txt /*text-objects-changed*
6934+textlock eval.txt /*textlock*
69326935 tf.vim syntax.txt /*tf.vim*
69336936 this_session-variable eval.txt /*this_session-variable*
69346937 throw-catch eval.txt /*throw-catch*
diff -r 7437be625546 -r 1c586ee8dd45 runtime/doc/todo.txt
--- a/runtime/doc/todo.txt Fri Jan 20 23:02:51 2006 +0000
+++ b/runtime/doc/todo.txt Fri Jan 20 23:10:18 2006 +0000
@@ -1,4 +1,4 @@
1-*todo.txt* For Vim version 7.0aa. Last change: 2006 Jan 19
1+*todo.txt* For Vim version 7.0aa. Last change: 2006 Jan 20
22
33
44 VIM REFERENCE MANUAL by Bram Moolenaar
@@ -30,20 +30,6 @@
3030 *known-bugs*
3131 -------------------- Known bugs and current work -----------------------
3232
33-Evaluate 'balloonexpr' in the sandbox only when it was set from an unsafe
34-place (e.g., modeline)? Patch from Sumner Hayes, Jan 12. Also use for other
35-options?
36-
37-":saveas asdf.c" should set 'filetype' to c when it's empty. Also for ":w
38-asdf.c" when it sets the buffer filename.
39-
40-When ":cclose" is used the buffer is not wiped out and is no longer recognized
41-as a quickfix buffer, thus it's not reused either.
42-
43-Patch to support lists and dicts for the Python interface. (G. Sumner Hayes,
44-Jan 12). Docs in a previous patch.
45-Use free_tv() instead of clear_tv() and vim_free().
46-
4733 ccomplete:
4834 - When using page-up/page-down in menu it sometimes jumps more than a page.
4935 - When an option is set: In completion mode and the user types (identifier)
@@ -71,9 +57,9 @@
7157 Can't reproduce it right now...
7258
7359 spelling:
74-- Include script to cleanup a .add file. (Antonio Colombo, Jan 9)
75-- suggestions for "macARONI" doesn't include "macaroni", they are all allcap.
76- suggestion for "KG" to "kg" when it's keepcase.
60+- Use runtime/cleanadd script to cleanup .add files. When to invoke it?
61+ After deleting a word and some timestamp difference perhaps?
62+- suggestion for "KG" to "kg" when it's keepcase.
7763 - Autocommand event for when a spell file is missing. Allows making a plugin
7864 that fetches the file over internet. Pattern == language.
7965 - Using KEEPCASE flag still allows all-upper word, docs say it doesn't.
diff -r 7437be625546 -r 1c586ee8dd45 runtime/doc/version7.txt
--- a/runtime/doc/version7.txt Fri Jan 20 23:02:51 2006 +0000
+++ b/runtime/doc/version7.txt Fri Jan 20 23:10:18 2006 +0000
@@ -1,4 +1,4 @@
1-*version7.txt* For Vim version 7.0aa. Last change: 2006 Jan 19
1+*version7.txt* For Vim version 7.0aa. Last change: 2006 Jan 20
22
33
44 VIM REFERENCE MANUAL by Bram Moolenaar
@@ -154,6 +154,9 @@
154154 With the |:profile| command you can find out where your function or script
155155 wastes its time.
156156
157+In the Python interface vim.eval() also handles Dictionaries and Lists.
158+|python-eval| (G. Sumner Hayes)
159+
157160
158161 Spell checking *new-spell*
159162 --------------
@@ -667,6 +670,15 @@
667670 allocated memory, running out of memory can always be detected. Allows
668671 matching more complex things, but Vim may seem to hang while doing that.
669672
673+Previously some options were always evaluated in the |sandbox|. Now that only
674+happens when the option was set from a modeline or in secure mode. Applies to
675+'balloonexpr', 'foldexpr', 'foldtext' and 'includeexpr'. (Sumner Hayes)
676+
677+Some commands and expressions could have nasty side effects, such as using
678+CTRL-R = while editing a search pattern and the expression invokes a function
679+that jumps to another window. The |textlock| has been added to prevent this
680+from happening.
681+
670682 ":breakadd here" and ":breakdel here" can be used to set or delete a
671683 breakpoint at the cursor.
672684
@@ -925,6 +937,10 @@
925937 Allow using ":global" in the sandbox, it doesn't do anything harmful by
926938 itself.
927939
940+":saveas asdf.c" will set 'filetype' to c when it's empty. Also for ":w
941+asdf.c" when it sets the filename for the buffer.
942+
943+
928944 ==============================================================================
929945 COMPILE TIME CHANGES *compile-changes-7*
930946
@@ -1528,8 +1544,8 @@
15281544
15291545 When evaluating an expression for CTRL-R = on the command line it was possible
15301546 to call a function that opens a new window, resulting in errors for
1531-incremental search, and many other nasty things were possible. Now set
1532-"cmdline_busy" and disallow changing the buffer or jumpting to another window
1547+incremental search, and many other nasty things were possible. Now use the
1548+|textlock| to disallow changing the buffer or jumping to another window
15331549 to protect from unexpected behavior. Same for CTRL-\ e.
15341550
15351551 "d(" deleted the character under the cursor, while the documentation specified
@@ -1574,4 +1590,10 @@
15741590 !cmd foo<Tab>" also escape characters that are special for the shell:
15751591 "!;&()<>".
15761592
1593+When the name of the buffer was set by a ":r fname" command |cpo-f| no
1594+autocommands were triggered to notify about the change in the buffer list.
1595+
1596+In the quickfix buffer 'bufhidden' was set to "delete", which caused closing
1597+the quickfix window to leave an unlisted "No Name" buffer behind every time.
1598+
15771599 vim:tw=78:ts=8:ft=help:norl:
diff -r 7437be625546 -r 1c586ee8dd45 src/edit.c
--- a/src/edit.c Fri Jan 20 23:02:51 2006 +0000
+++ b/src/edit.c Fri Jan 20 23:10:18 2006 +0000
@@ -291,7 +291,7 @@
291291 #endif
292292 /* Don't allow changes in the buffer while editing the cmdline. The
293293 * caller of getcmdline() may get confused. */
294- if (cmdline_busy)
294+ if (textlock != 0)
295295 {
296296 EMSG(_(e_secure));
297297 return FALSE;
diff -r 7437be625546 -r 1c586ee8dd45 src/eval.c
--- a/src/eval.c Fri Jan 20 23:02:51 2006 +0000
+++ b/src/eval.c Fri Jan 20 23:10:18 2006 +0000
@@ -420,8 +420,8 @@
420420 static int list_concat __ARGS((list_T *l1, list_T *l2, typval_T *tv));
421421 static list_T *list_copy __ARGS((list_T *orig, int deep, int copyID));
422422 static void list_remove __ARGS((list_T *l, listitem_T *item, listitem_T *item2));
423-static char_u *list2string __ARGS((typval_T *tv));
424-static int list_join __ARGS((garray_T *gap, list_T *l, char_u *sep, int echo));
423+static char_u *list2string __ARGS((typval_T *tv, int copyID));
424+static int list_join __ARGS((garray_T *gap, list_T *l, char_u *sep, int echo, int copyID));
425425 static void set_ref_in_ht __ARGS((hashtab_T *ht, int copyID));
426426 static void set_ref_in_list __ARGS((list_T *l, int copyID));
427427 static void set_ref_in_item __ARGS((typval_T *tv, int copyID));
@@ -435,10 +435,10 @@
435435 static int dict_add __ARGS((dict_T *d, dictitem_T *item));
436436 static long dict_len __ARGS((dict_T *d));
437437 static dictitem_T *dict_find __ARGS((dict_T *d, char_u *key, int len));
438-static char_u *dict2string __ARGS((typval_T *tv));
438+static char_u *dict2string __ARGS((typval_T *tv, int copyID));
439439 static int get_dict_tv __ARGS((char_u **arg, typval_T *rettv, int evaluate));
440-static char_u *echo_string __ARGS((typval_T *tv, char_u **tofree, char_u *numbuf));
441-static char_u *tv2string __ARGS((typval_T *tv, char_u **tofree, char_u *numbuf));
440+static char_u *echo_string __ARGS((typval_T *tv, char_u **tofree, char_u *numbuf, int copyID));
441+static char_u *tv2string __ARGS((typval_T *tv, char_u **tofree, char_u *numbuf, int copyID));
442442 static char_u *string_quote __ARGS((char_u *str, int function));
443443 static int get_env_tv __ARGS((char_u **arg, typval_T *rettv, int evaluate));
444444 static int find_internal_func __ARGS((char_u *name));
@@ -1175,20 +1175,26 @@
11751175 }
11761176
11771177 /*
1178- * Call eval_to_string() with "sandbox" set and not using local variables.
1178+ * Call eval_to_string() without using current local variables and using
1179+ * textlock. When "use_sandbox" is TRUE use the sandbox.
11791180 */
11801181 char_u *
1181-eval_to_string_safe(arg, nextcmd)
1182+eval_to_string_safe(arg, nextcmd, use_sandbox)
11821183 char_u *arg;
11831184 char_u **nextcmd;
1185+ int use_sandbox;
11841186 {
11851187 char_u *retval;
11861188 void *save_funccalp;
11871189
11881190 save_funccalp = save_funccal();
1189- ++sandbox;
1191+ if (use_sandbox)
1192+ ++sandbox;
1193+ ++textlock;
11901194 retval = eval_to_string(arg, nextcmd);
1191- --sandbox;
1195+ if (use_sandbox)
1196+ --sandbox;
1197+ --textlock;
11921198 restore_funccal(save_funccalp);
11931199 return retval;
11941200 }
@@ -1566,9 +1572,12 @@
15661572 typval_T tv;
15671573 int retval;
15681574 char_u *s;
1575+ int use_sandbox = was_set_insecurely((char_u *)"foldexpr");
15691576
15701577 ++emsg_off;
1571- ++sandbox;
1578+ if (use_sandbox)
1579+ ++sandbox;
1580+ ++textlock;
15721581 *cp = NUL;
15731582 if (eval0(arg, &tv, NULL, TRUE) == FAIL)
15741583 retval = 0;
@@ -1591,7 +1600,9 @@
15911600 clear_tv(&tv);
15921601 }
15931602 --emsg_off;
1594- --sandbox;
1603+ if (use_sandbox)
1604+ --sandbox;
1605+ --textlock;
15951606
15961607 return retval;
15971608 }
@@ -1985,7 +1996,7 @@
19851996 int c;
19861997 char_u *s;
19871998
1988- s = echo_string(&tv, &tf, numbuf);
1999+ s = echo_string(&tv, &tf, numbuf, 0);
19892000 c = *arg;
19902001 *arg = NUL;
19912002 list_one_var_a((char_u *)"",
@@ -5310,6 +5321,18 @@
53105321 return item1 == NULL && item2 == NULL;
53115322 }
53125323
5324+#if defined(FEAT_PYTHON) || defined(PROTO)
5325+/*
5326+ * Return the dictitem that an entry in a hashtable points to.
5327+ */
5328+ dictitem_T *
5329+dict_lookup(hi)
5330+ hashitem_T *hi;
5331+{
5332+ return HI2DI(hi);
5333+}
5334+#endif
5335+
53135336 /*
53145337 * Return TRUE when two dictionaries have exactly the same key/values.
53155338 */
@@ -5777,8 +5800,9 @@
57775800 * May return NULL.
57785801 */
57795802 static char_u *
5780-list2string(tv)
5803+list2string(tv, copyID)
57815804 typval_T *tv;
5805+ int copyID;
57825806 {
57835807 garray_T ga;
57845808
@@ -5786,7 +5810,7 @@
57865810 return NULL;
57875811 ga_init2(&ga, (int)sizeof(char), 80);
57885812 ga_append(&ga, '[');
5789- if (list_join(&ga, tv->vval.v_list, (char_u *)", ", FALSE) == FAIL)
5813+ if (list_join(&ga, tv->vval.v_list, (char_u *)", ", FALSE, copyID) == FAIL)
57905814 {
57915815 vim_free(ga.ga_data);
57925816 return NULL;
@@ -5802,11 +5826,12 @@
58025826 * Return FAIL or OK.
58035827 */
58045828 static int
5805-list_join(gap, l, sep, echo)
5829+list_join(gap, l, sep, echo, copyID)
58065830 garray_T *gap;
58075831 list_T *l;
58085832 char_u *sep;
58095833 int echo;
5834+ int copyID;
58105835 {
58115836 int first = TRUE;
58125837 char_u *tofree;
@@ -5822,9 +5847,9 @@
58225847 ga_concat(gap, sep);
58235848
58245849 if (echo)
5825- s = echo_string(&item->li_tv, &tofree, numbuf);
5826- else
5827- s = tv2string(&item->li_tv, &tofree, numbuf);
5850+ s = echo_string(&item->li_tv, &tofree, numbuf, copyID);
5851+ else
5852+ s = tv2string(&item->li_tv, &tofree, numbuf, copyID);
58285853 if (s != NULL)
58295854 ga_concat(gap, s);
58305855 vim_free(tofree);
@@ -6355,8 +6380,9 @@
63556380 * May return NULL.
63566381 */
63576382 static char_u *
6358-dict2string(tv)
6383+dict2string(tv, copyID)
63596384 typval_T *tv;
6385+ int copyID;
63606386 {
63616387 garray_T ga;
63626388 int first = TRUE;
@@ -6391,7 +6417,7 @@
63916417 vim_free(tofree);
63926418 }
63936419 ga_concat(&ga, (char_u *)": ");
6394- s = tv2string(&HI2DI(hi)->di_tv, &tofree, numbuf);
6420+ s = tv2string(&HI2DI(hi)->di_tv, &tofree, numbuf, copyID);
63956421 if (s != NULL)
63966422 ga_concat(&ga, s);
63976423 vim_free(tofree);
@@ -6535,13 +6561,15 @@
65356561 * If the memory is allocated "tofree" is set to it, otherwise NULL.
65366562 * "numbuf" is used for a number.
65376563 * Does not put quotes around strings, as ":echo" displays values.
6564+ * When "copyID" is not NULL replace recursive lists and dicts with "...".
65386565 * May return NULL;
65396566 */
65406567 static char_u *
6541-echo_string(tv, tofree, numbuf)
6568+echo_string(tv, tofree, numbuf, copyID)
65426569 typval_T *tv;
65436570 char_u **tofree;
65446571 char_u *numbuf;
6572+ int copyID;
65456573 {
65466574 static int recurse = 0;
65476575 char_u *r = NULL;
@@ -6560,19 +6588,51 @@
65606588 *tofree = NULL;
65616589 r = tv->vval.v_string;
65626590 break;
6591+
65636592 case VAR_LIST:
6564- *tofree = list2string(tv);
6565- r = *tofree;
6566- break;
6593+ if (tv->vval.v_list == NULL)
6594+ {
6595+ *tofree = NULL;
6596+ r = NULL;
6597+ }
6598+ else if (copyID != 0 && tv->vval.v_list->lv_copyID == copyID)
6599+ {
6600+ *tofree = NULL;
6601+ r = (char_u *)"[...]";
6602+ }
6603+ else
6604+ {
6605+ tv->vval.v_list->lv_copyID = copyID;
6606+ *tofree = list2string(tv, copyID);
6607+ r = *tofree;
6608+ }
6609+ break;
6610+
65676611 case VAR_DICT:
6568- *tofree = dict2string(tv);
6569- r = *tofree;
6570- break;
6612+ if (tv->vval.v_dict == NULL)
6613+ {
6614+ *tofree = NULL;
6615+ r = NULL;
6616+ }
6617+ else if (copyID != 0 && tv->vval.v_dict->dv_copyID == copyID)
6618+ {
6619+ *tofree = NULL;
6620+ r = (char_u *)"{...}";
6621+ }
6622+ else
6623+ {
6624+ tv->vval.v_dict->dv_copyID = copyID;
6625+ *tofree = dict2string(tv, copyID);
6626+ r = *tofree;
6627+ }
6628+ break;
6629+
65716630 case VAR_STRING:
65726631 case VAR_NUMBER:
65736632 *tofree = NULL;
65746633 r = get_tv_string_buf(tv, numbuf);
65756634 break;
6635+
65766636 default:
65776637 EMSG2(_(e_intern2), "echo_string()");
65786638 *tofree = NULL;
@@ -6590,10 +6650,11 @@
65906650 * May return NULL;
65916651 */
65926652 static char_u *
6593-tv2string(tv, tofree, numbuf)
6653+tv2string(tv, tofree, numbuf, copyID)
65946654 typval_T *tv;
65956655 char_u **tofree;
65966656 char_u *numbuf;
6657+ int copyID;
65976658 {
65986659 switch (tv->v_type)
65996660 {
@@ -6610,7 +6671,7 @@
66106671 default:
66116672 EMSG2(_(e_intern2), "tv2string()");
66126673 }
6613- return echo_string(tv, tofree, numbuf);
6674+ return echo_string(tv, tofree, numbuf, copyID);
66146675 }
66156676
66166677 /*
@@ -11302,7 +11363,7 @@
1130211363 if (sep != NULL)
1130311364 {
1130411365 ga_init2(&ga, (int)sizeof(char), 80);
11305- list_join(&ga, argvars[0].vval.v_list, sep, TRUE);
11366+ list_join(&ga, argvars[0].vval.v_list, sep, TRUE, 0);
1130611367 ga_append(&ga, NUL);
1130711368 rettv->vval.v_string = (char_u *)ga.ga_data;
1130811369 }
@@ -11695,7 +11756,7 @@
1169511756 break;
1169611757 }
1169711758 vim_free(tofree);
11698- str = echo_string(&li->li_tv, &tofree, strbuf);
11759+ str = echo_string(&li->li_tv, &tofree, strbuf,0);
1169911760 if (str == NULL)
1170011761 break;
1170111762 }
@@ -13734,8 +13795,8 @@
1373413795 char_u numbuf1[NUMBUFLEN];
1373513796 char_u numbuf2[NUMBUFLEN];
1373613797
13737- p1 = tv2string(&(*(listitem_T **)s1)->li_tv, &tofree1, numbuf1);
13738- p2 = tv2string(&(*(listitem_T **)s2)->li_tv, &tofree2, numbuf2);
13798+ p1 = tv2string(&(*(listitem_T **)s1)->li_tv, &tofree1, numbuf1, 0);
13799+ p2 = tv2string(&(*(listitem_T **)s2)->li_tv, &tofree2, numbuf2, 0);
1373913800 if (item_compare_ic)
1374013801 res = STRICMP(p1, p2);
1374113802 else
@@ -14212,7 +14273,7 @@
1421214273 char_u numbuf[NUMBUFLEN];
1421314274
1421414275 rettv->v_type = VAR_STRING;
14215- rettv->vval.v_string = tv2string(&argvars[0], &tofree, numbuf);
14276+ rettv->vval.v_string = tv2string(&argvars[0], &tofree, numbuf, 0);
1421614277 if (tofree == NULL)
1421714278 rettv->vval.v_string = vim_strsave(rettv->vval.v_string);
1421814279 }
@@ -16407,7 +16468,7 @@
1640716468 char_u *s;
1640816469 char_u numbuf[NUMBUFLEN];
1640916470
16410- s = echo_string(&v->di_tv, &tofree, numbuf);
16471+ s = echo_string(&v->di_tv, &tofree, numbuf, ++current_copyID);
1641116472 list_one_var_a(prefix, v->di_key, v->di_tv.v_type,
1641216473 s == NULL ? (char_u *)"" : s);
1641316474 vim_free(tofree);
@@ -16782,7 +16843,7 @@
1678216843 }
1678316844 else if (eap->cmdidx == CMD_echo)
1678416845 msg_puts_attr((char_u *)" ", echo_attr);
16785- p = echo_string(&rettv, &tofree, numbuf);
16846+ p = echo_string(&rettv, &tofree, numbuf, ++current_copyID);
1678616847 if (p != NULL)
1678716848 for ( ; *p != NUL && !got_int; ++p)
1678816849 {
@@ -18499,7 +18560,7 @@
1849918560 msg_outnum((long)argvars[i].vval.v_number);
1850018561 else
1850118562 {
18502- trunc_string(tv2string(&argvars[i], &tofree, numbuf),
18563+ trunc_string(tv2string(&argvars[i], &tofree, numbuf, 0),
1850318564 buf, MSG_BUF_CLEN);
1850418565 msg_puts(buf);
1850518566 vim_free(tofree);
@@ -18584,7 +18645,7 @@
1858418645 /* The value may be very long. Skip the middle part, so that we
1858518646 * have some idea how it starts and ends. smsg() would always
1858618647 * truncate it at the end. */
18587- trunc_string(tv2string(fc.rettv, &tofree, numbuf),
18648+ trunc_string(tv2string(fc.rettv, &tofree, numbuf, 0),
1858818649 buf, MSG_BUF_CLEN);
1858918650 smsg((char_u *)_("%s returning %s"), sourcing_name, buf);
1859018651 vim_free(tofree);
@@ -18806,7 +18867,7 @@
1880618867 char_u numbuf[NUMBUFLEN];
1880718868
1880818869 if (rettv != NULL)
18809- s = echo_string((typval_T *)rettv, &tofree, numbuf);
18870+ s = echo_string((typval_T *)rettv, &tofree, numbuf, 0);
1881018871 if (s == NULL)
1881118872 s = (char_u *)"";
1881218873
@@ -19076,7 +19137,7 @@
1907619137 default: continue;
1907719138 }
1907819139 fprintf(fp, "!%s\t%s\t", this_var->di_key, s);
19079- p = echo_string(&this_var->di_tv, &tofree, numbuf);
19140+ p = echo_string(&this_var->di_tv, &tofree, numbuf, 0);
1908019141 if (p != NULL)
1908119142 viminfo_writestring(fp, p);
1908219143 vim_free(tofree);
diff -r 7437be625546 -r 1c586ee8dd45 src/ex_cmds.c
--- a/src/ex_cmds.c Fri Jan 20 23:02:51 2006 +0000
+++ b/src/ex_cmds.c Fri Jan 20 23:10:18 2006 +0000
@@ -2583,11 +2583,19 @@
25832583 retval = FAIL;
25842584 goto theend;
25852585 }
2586+
2587+ /* If 'filetype' was empty try detecting it now. */
2588+ if (*curbuf->b_p_ft == NUL)
2589+ {
2590+ (void)do_doautocmd((char_u *)"filetypedetect BufRead", TRUE);
2591+ do_modelines(FALSE);
2592+ }
25862593 #endif
25872594 }
25882595
25892596 retval = buf_write(curbuf, ffname, fname, eap->line1, eap->line2,
25902597 eap, eap->append, eap->forceit, TRUE, FALSE);
2598+
25912599 }
25922600
25932601 theend:
@@ -2861,7 +2869,7 @@
28612869 int retval;
28622870 char_u *free_me = NULL;
28632871
2864- if (editing_cmdline())
2872+ if (text_locked())
28652873 return 1;
28662874
28672875 if (fnum == 0)
diff -r 7437be625546 -r 1c586ee8dd45 src/ex_getln.c
--- a/src/ex_getln.c Fri Jan 20 23:02:51 2006 +0000
+++ b/src/ex_getln.c Fri Jan 20 23:10:18 2006 +0000
@@ -661,13 +661,13 @@
661661 restore_cmdline(&save_ccline);
662662 if (c == '=')
663663 {
664- /* Need to save and restore ccline. And set cmdline_busy
664+ /* Need to save and restore ccline. And set "textlock"
665665 * to avoid nasty things like going to another buffer when
666666 * evaluating an expression. */
667667 save_cmdline(&save_ccline);
668- ++cmdline_busy;
668+ ++textlock;
669669 p = get_expr_line();
670- --cmdline_busy;
670+ --textlock;
671671 restore_cmdline(&save_ccline);
672672
673673 if (p != NULL && realloc_cmdbuff((int)STRLEN(p) + 1) == OK)
@@ -1875,17 +1875,18 @@
18751875 #endif
18761876
18771877 /*
1878- * Return TRUE when the command line is being edited. That means the current
1879- * buffer and window can't be changed.
1878+ * Return TRUE when the text must not be changed and we can't switch to
1879+ * another window or buffer. Used when editing the command line, evaluating
1880+ * 'balloonexpr', etc.
18801881 */
18811882 int
1882-editing_cmdline()
1883+text_locked()
18831884 {
18841885 #ifdef FEAT_CMDWIN
18851886 if (cmdwin_type != 0)
18861887 return TRUE;
18871888 #endif
1888- return cmdline_busy;
1889+ return textlock != 0;
18891890 }
18901891
18911892 /*
@@ -1893,7 +1894,7 @@
18931894 * window is open or editing the cmdline in another way.
18941895 */
18951896 void
1896-editing_cmdline_msg()
1897+text_locked_msg()
18971898 {
18981899 #ifdef FEAT_CMDWIN
18991900 if (cmdwin_type != 0)
@@ -2814,12 +2815,12 @@
28142815 regname = may_get_selection(regname);
28152816 #endif
28162817
2817- /* Need to save and restore ccline. And set cmdline_busy to avoid nasty
2818+ /* Need to save and restore ccline. And set "textlock" to avoid nasty
28182819 * things like going to another buffer when evaluating an expression. */
28192820 save_cmdline(&save_ccline);
2820- ++cmdline_busy;
2821+ ++textlock;
28212822 i = get_spec_reg(regname, &arg, &allocated, TRUE);
2822- --cmdline_busy;
2823+ --textlock;
28232824 restore_cmdline(&save_ccline);
28242825
28252826 if (i)
@@ -3837,8 +3838,8 @@
38373838
38383839 /* Custom expansion takes care of special things, match
38393840 * backslashes literally (perhaps also for other types?) */
3840- if ((context == EXPAND_USER_DEFINED ||
3841- context == EXPAND_USER_LIST) && fname[i] == '\\')
3841+ if ((context == EXPAND_USER_DEFINED
3842+ || context == EXPAND_USER_LIST) && fname[i] == '\\')
38423843 new_len++; /* '\' becomes "\\" */
38433844 }
38443845 retval = alloc(new_len);
diff -r 7437be625546 -r 1c586ee8dd45 src/fold.c
--- a/src/fold.c Fri Jan 20 23:02:51 2006 +0000
+++ b/src/fold.c Fri Jan 20 23:10:18 2006 +0000
@@ -1938,7 +1938,8 @@
19381938 curbuf = wp->w_buffer;
19391939
19401940 ++emsg_off;
1941- text = eval_to_string_safe(wp->w_p_fdt, NULL);
1941+ text = eval_to_string_safe(wp->w_p_fdt, NULL,
1942+ was_set_insecurely((char_u *)"foldtext"));
19421943 --emsg_off;
19431944
19441945 curwin = save_curwin;
diff -r 7437be625546 -r 1c586ee8dd45 src/globals.h
--- a/src/globals.h Fri Jan 20 23:02:51 2006 +0000
+++ b/src/globals.h Fri Jan 20 23:10:18 2006 +0000
@@ -86,7 +86,6 @@
8686 #if defined(FEAT_CRYPT) || defined(FEAT_EVAL)
8787 EXTERN int cmdline_star INIT(= FALSE); /* cmdline is crypted */
8888 #endif
89-EXTERN int cmdline_busy INIT(= FALSE); /* editing the cmdline */
9089
9190 EXTERN int exec_from_reg INIT(= FALSE); /* executing register */
9291
@@ -547,12 +546,16 @@
547546 * allowed, e.g. when sourcing .exrc or .vimrc
548547 * in current directory */
549548
549+EXTERN int textlock INIT(= 0);
550+ /* non-zero when changing text and jumping to
551+ * another window or buffer is not allowed */
552+
550553 #ifdef FEAT_EVAL
551554 # define HAVE_SANDBOX
552555 EXTERN int sandbox INIT(= 0);
553- /* non-zero when evaluating an expression in a
554- * "sandbox". Not allowed to change the
555- * buffer. */
556+ /* Non-zero when evaluating an expression in a
557+ * "sandbox". Several things are not allowed
558+ * then. */
556559 #endif
557560
558561 EXTERN int silent_mode INIT(= FALSE);
@@ -1413,10 +1416,7 @@
14131416 EXTERN char_u e_guarded[] INIT(= N_("E463: Region is guarded, cannot modify"));
14141417 EXTERN char_u e_nbreadonly[] INIT(= N_("E744: NetBeans does not allow changes in read-only files"));
14151418 #endif
1416-#if defined(FEAT_INS_EXPAND) || defined(FEAT_EVAL) || defined(FEAT_SYN_HL) \
1417- || defined(PROTO)
14181419 EXTERN char_u e_intern2[] INIT(= N_("E685: Internal error: %s"));
1419-#endif
14201420 EXTERN char_u e_maxmempat[] INIT(= N_("E363: pattern uses more memory than 'maxmempattern'"));
14211421 EXTERN char_u e_emptybuf[] INIT(= N_("E749: empty buffer"));
14221422
diff -r 7437be625546 -r 1c586ee8dd45 src/gui_beval.c
--- a/src/gui_beval.c Fri Jan 20 23:02:51 2006 +0000
+++ b/src/gui_beval.c Fri Jan 20 23:10:18 2006 +0000
@@ -23,6 +23,7 @@
2323 {
2424 win_T *wp;
2525 int col;
26+ int use_sandbox;
2627 linenr_T lnum;
2728 char_u *text;
2829 static char_u *result = NULL;
@@ -50,10 +51,17 @@
5051 set_vim_var_string(VV_BEVAL_TEXT, text, -1);
5152 vim_free(text);
5253
53- ++sandbox;
54+ use_sandbox = was_set_insecurely((char_u *)"balloonexpr");
55+ if (use_sandbox)
56+ ++sandbox;
57+ ++textlock;
58+
5459 vim_free(result);
5560 result = eval_to_string(p_bexpr, NULL);
56- --sandbox;
61+
62+ if (use_sandbox)
63+ --sandbox;
64+ --textlock;
5765
5866 set_vim_var_string(VV_BEVAL_TEXT, NULL, -1);
5967 if (result != NULL && result[0] != NUL)
diff -r 7437be625546 -r 1c586ee8dd45 src/if_python.c
--- a/src/if_python.c Fri Jan 20 23:02:51 2006 +0000
+++ b/src/if_python.c Fri Jan 20 23:10:18 2006 +0000
@@ -1082,35 +1082,137 @@
10821082 return result;
10831083 }
10841084
1085+/*
1086+ * Function to translate a typval_T into a PyObject; this will recursively
1087+ * translate lists/dictionaries into their Python equivalents.
1088+ *
1089+ * The depth parameter is too avoid infinite recursion, set it to 1 when
1090+ * you call VimToPython.
1091+ */
1092+ static PyObject *
1093+VimToPython(typval_T *our_tv, int depth, PyObject *lookupDict)
1094+{
1095+ PyObject *result;
1096+ PyObject *newObj;
1097+ char ptrBuf[NUMBUFLEN];
1098+
1099+ /* Avoid infinite recursion */
1100+ if (depth > 100)
1101+ {
1102+ Py_INCREF(Py_None);
1103+ result = Py_None;
1104+ return result;
1105+ }
1106+
1107+ /* Check if we run into a recursive loop. The item must be in lookupDict
1108+ * then and we can use it again. */
1109+ sprintf(ptrBuf, "%ld", (long)our_tv);
1110+ result = PyDict_GetItemString(lookupDict, ptrBuf);
1111+ if (result != NULL)
1112+ Py_INCREF(result);
1113+ else if (our_tv->v_type == VAR_STRING)
1114+ {
1115+ result = Py_BuildValue("s", our_tv->vval.v_string);
1116+ PyDict_SetItemString(lookupDict, ptrBuf, result);
1117+ }
1118+ else if (our_tv->v_type == VAR_NUMBER)
1119+ {
1120+ char buf[NUMBUFLEN];
1121+
1122+ /* For backwards compatibility numbers are stored as strings. */
1123+ sprintf(buf, "%ld", (long)our_tv->vval.v_number);
1124+ result = Py_BuildValue("s", buf);
1125+ PyDict_SetItemString(lookupDict, ptrBuf, result);
1126+ }
1127+ else if (our_tv->v_type == VAR_LIST)
1128+ {
1129+ list_T *list = our_tv->vval.v_list;
1130+ listitem_T *curr;
1131+
1132+ result = PyList_New(0);
1133+ PyDict_SetItemString(lookupDict, ptrBuf, result);
1134+
1135+ if (list != NULL)
1136+ {
1137+ for (curr = list->lv_first; curr != NULL; curr = curr->li_next)
1138+ {
1139+ newObj = VimToPython(&curr->li_tv, depth + 1, lookupDict);
1140+ PyList_Append(result, newObj);
1141+ Py_DECREF(newObj);
1142+ }
1143+ }
1144+ }
1145+ else if (our_tv->v_type == VAR_DICT)
1146+ {
1147+ result = PyDict_New();
1148+ PyDict_SetItemString(lookupDict, ptrBuf, result);
1149+
1150+ if (our_tv->vval.v_dict != NULL)
1151+ {
1152+ hashtab_T *ht = &our_tv->vval.v_dict->dv_hashtab;
1153+ int todo = ht->ht_used;
1154+ hashitem_T *hi;
1155+ dictitem_T *di;
1156+
1157+ for (hi = ht->ht_array; todo > 0; ++hi)
1158+ {
1159+ if (!HASHITEM_EMPTY(hi))
1160+ {
1161+ --todo;
1162+
1163+ di = dict_lookup(hi);
1164+ newObj = VimToPython(&di->di_tv, depth + 1, lookupDict);
1165+ PyDict_SetItemString(result, (char *)hi->hi_key, newObj);
1166+ Py_DECREF(newObj);
1167+ }
1168+ }
1169+ }
1170+ }
1171+ else
1172+ {
1173+ Py_INCREF(Py_None);
1174+ result = Py_None;
1175+ }
1176+
1177+ return result;
1178+}
1179+
10851180 /*ARGSUSED*/
10861181 static PyObject *
10871182 VimEval(PyObject *self, PyObject *args)
10881183 {
10891184 #ifdef FEAT_EVAL
10901185 char *expr;
1091- char *str;
1186+ typval_T *our_tv;
10921187 PyObject *result;
1188+ PyObject *lookup_dict;
10931189
10941190 if (!PyArg_ParseTuple(args, "s", &expr))
10951191 return NULL;
10961192
10971193 Py_BEGIN_ALLOW_THREADS
10981194 Python_Lock_Vim();
1099- str = (char *)eval_to_string((char_u *)expr, NULL);
1195+ our_tv = eval_expr((char_u *)expr, NULL);
1196+
11001197 Python_Release_Vim();
11011198 Py_END_ALLOW_THREADS
11021199
1103- if (str == NULL)
1200+ if (our_tv == NULL)
11041201 {
11051202 PyErr_SetVim(_("invalid expression"));
11061203 return NULL;
11071204 }
11081205
1109- result = Py_BuildValue("s", str);
1206+ /* Convert the Vim type into a Python type. Create a dictionary that's
1207+ * used to check for recursive loops. */
1208+ lookup_dict = PyDict_New();
1209+ result = VimToPython(our_tv, 1, lookup_dict);
1210+ Py_DECREF(lookup_dict);
1211+
11101212
11111213 Py_BEGIN_ALLOW_THREADS
11121214 Python_Lock_Vim();
1113- vim_free(str);
1215+ free_tv(our_tv);
11141216 Python_Release_Vim();
11151217 Py_END_ALLOW_THREADS
11161218
diff -r 7437be625546 -r 1c586ee8dd45 src/misc1.c
--- a/src/misc1.c Fri Jan 20 23:02:51 2006 +0000
+++ b/src/misc1.c Fri Jan 20 23:10:18 2006 +0000
@@ -7673,12 +7673,17 @@
76737673 int indent;
76747674 pos_T pos;
76757675 int save_State;
7676+ int use_sandbox = was_set_insecurely((char_u *)"indentexpr");
76767677
76777678 pos = curwin->w_cursor;
76787679 set_vim_var_nr(VV_LNUM, curwin->w_cursor.lnum);
7679- ++sandbox;
7680+ if (use_sandbox)
7681+ ++sandbox;
7682+ ++textlock;
76807683 indent = eval_to_number(curbuf->b_p_inde);
7681- --sandbox;
7684+ if (use_sandbox)
7685+ --sandbox;
7686+ --textlock;
76827687
76837688 /* Restore the cursor position so that 'indentexpr' doesn't need to.
76847689 * Pretend to be in Insert mode, allow cursor past end of line for "o"
diff -r 7437be625546 -r 1c586ee8dd45 src/option.c
--- a/src/option.c Fri Jan 20 23:02:51 2006 +0000
+++ b/src/option.c Fri Jan 20 23:10:18 2006 +0000
@@ -317,6 +317,7 @@
317317 #define P_GETTEXT 0x80000L/* expand default value with _() */
318318 #define P_NOGLOB 0x100000L/* do not use local value for global vimrc */
319319 #define P_NFNAME 0x200000L/* only normal file name chars allowed */
320+#define P_INSECURE 0x400000L/* option was set from a modeline */
320321
321322 /*
322323 * options[] is initialized here.
@@ -1460,7 +1461,7 @@
14601461 {"magic", NULL, P_BOOL|P_VI_DEF,
14611462 (char_u *)&p_magic, PV_NONE,
14621463 {(char_u *)TRUE, (char_u *)0L}},
1463- {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1464+ {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
14641465 #ifdef FEAT_QUICKFIX
14651466 (char_u *)&p_mef, PV_NONE,
14661467 {(char_u *)"", (char_u *)0L}
@@ -2632,6 +2633,7 @@
26322633
26332634 static void set_option_default __ARGS((int, int opt_flags, int compatible));
26342635 static void set_options_default __ARGS((int opt_flags));
2636+static void did_set_option __ARGS((int opt_idx, int opt_flags, int new_value));
26352637 static char_u *illegal_char __ARGS((char_u *, int));
26362638 static int string_to_key __ARGS((char_u *arg));
26372639 #ifdef FEAT_CMDWIN
@@ -3157,6 +3159,9 @@
31573159 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
31583160 *(int *)varp;
31593161 }
3162+
3163+ /* the default value is not insecure */
3164+ options[opt_idx].flags &= ~P_INSECURE;
31603165 }
31613166
31623167 #ifdef FEAT_EVAL
@@ -3790,6 +3795,12 @@
37903795 }
37913796 }
37923797
3798+ /* Skip all options that are not window-local (used when showing
3799+ * an already loaded buffer in a window). */
3800+ if ((opt_flags & OPT_WINONLY)
3801+ && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
3802+ goto skip;
3803+
37933804 /* Disallow changing some options from modelines */
37943805 if ((opt_flags & OPT_MODELINE) && (flags & P_SECURE))
37953806 {
@@ -3797,15 +3808,9 @@
37973808 goto skip;
37983809 }
37993810
3800- /* Skip all options that are not window-local (used when showing
3801- * an already loaded buffer in a window). */
3802- if ((opt_flags & OPT_WINONLY)
3803- && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
3804- goto skip;
3805-
38063811 #ifdef HAVE_SANDBOX
38073812 /* Disallow changing some options in the sandbox */
3808- if (sandbox > 0 && (flags & P_SECURE))
3813+ if (sandbox != 0 && (flags & P_SECURE))
38093814 {
38103815 errmsg = (char_u *)_(e_sandbox);
38113816 goto skip;
@@ -4343,8 +4348,10 @@
43434348 redraw_all_later(CLEAR);
43444349 }
43454350 }
4351+
43464352 if (opt_idx >= 0)
4347- options[opt_idx].flags |= P_WAS_SET;
4353+ did_set_option(opt_idx, opt_flags,
4354+ !prepending && !adding && !removing);
43484355 }
43494356
43504357 skip:
@@ -4405,6 +4412,31 @@
44054412 return OK;
44064413 }
44074414
4415+/*
4416+ * Call this when an option has been given a new value through a user command.
4417+ * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
4418+ */
4419+ static void
4420+did_set_option(opt_idx, opt_flags, new_value)
4421+ int opt_idx;
4422+ int opt_flags; /* possibly with OPT_MODELINE */
4423+ int new_value; /* value was replaced completely */
4424+{
4425+ options[opt_idx].flags |= P_WAS_SET;
4426+
4427+ /* When an option is set in the sandbox, from a modeline or in secure mode
4428+ * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
4429+ * flag. */
4430+ if (secure
4431+#ifdef HAVE_SANDBOX
4432+ || sandbox != 0
4433+#endif
4434+ || (opt_flags & OPT_MODELINE))
4435+ options[opt_idx].flags |= P_INSECURE;
4436+ else if (new_value)
4437+ options[opt_idx].flags &= ~P_INSECURE;
4438+}
4439+
44084440 static char_u *
44094441 illegal_char(errbuf, c)
44104442 char_u *errbuf;
@@ -4837,6 +4869,25 @@
48374869 return; /* cannot happen: didn't find it! */
48384870 }
48394871
4872+#if defined(FEAT_EVAL) || defined(PROTO)
4873+/*
4874+ * Return TRUE when option "opt" was set from a modeline or in secure mode.
4875+ * Return FALSE when it wasn't.
4876+ * Return -1 for an unknown option.
4877+ */
4878+ int
4879+was_set_insecurely(opt)
4880+ char_u *opt;
4881+{
4882+ int idx = findoption(opt);
4883+
4884+ if (idx >= 0)
4885+ return (options[idx].flags & P_INSECURE) != 0;
4886+ EMSG2(_(e_intern2), "was_set_insecurely()");
4887+ return -1;
4888+}
4889+#endif
4890+
48404891 /*
48414892 * Set a string option to a new value (without checking the effect).
48424893 * The string is copied into allocated memory.
@@ -4938,9 +4989,9 @@
49384989 : opt_flags);
49394990 oldval = *varp;
49404991 *varp = s;
4941- options[opt_idx].flags |= P_WAS_SET;
4942- (void)did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
4943- opt_flags);
4992+ if (did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
4993+ opt_flags) == NULL)
4994+ did_set_option(opt_idx, opt_flags, TRUE);
49444995 }
49454996 }
49464997
@@ -6571,10 +6622,6 @@
65716622 {
65726623 int old_value = *(int *)varp;
65736624
6574-#ifdef FEAT_GUI
6575- need_mouse_correct = TRUE;
6576-#endif
6577-
65786625 /* Disallow changing some options from secure mode */
65796626 if ((secure
65806627 #ifdef HAVE_SANDBOX
@@ -6589,6 +6636,10 @@
65896636 options[opt_idx].scriptID = current_SID;
65906637 #endif
65916638
6639+#ifdef FEAT_GUI
6640+ need_mouse_correct = TRUE;
6641+#endif
6642+
65926643 /* May set global value for local option. */
65936644 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
65946645 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
@@ -7077,15 +7128,22 @@
70777128 long old_Columns = Columns; /* remember old Columns */
70787129 long *pp = (long *)varp;
70797130
7080-#ifdef FEAT_GUI
7081- need_mouse_correct = TRUE;
7082-#endif
7131+ /* Disallow changing some options from secure mode. */
7132+ if ((secure
7133+#ifdef HAVE_SANDBOX
7134+ || sandbox != 0
7135+#endif
7136+ ) && (options[opt_idx].flags & P_SECURE))
7137+ return e_secure;
70837138
70847139 *pp = value;
70857140 #ifdef FEAT_EVAL
70867141 /* Remember where the option was set. */
70877142 options[opt_idx].scriptID = current_SID;
70887143 #endif
7144+#ifdef FEAT_GUI
7145+ need_mouse_correct = TRUE;
7146+#endif
70897147
70907148 if (curbuf->b_p_sw <= 0)
70917149 {
@@ -7690,10 +7748,12 @@
76907748 #ifdef HAVE_SANDBOX
76917749 /* Disallow changing some options in the sandbox */
76927750 if (sandbox > 0 && (flags & P_SECURE))
7751+ {
76937752 EMSG(_(e_sandbox));
7694- else
7695-#endif
7696- if (flags & P_STRING)
7753+ return;
7754+ }
7755+#endif
7756+ if (flags & P_STRING)
76977757 set_string_option(opt_idx, string, opt_flags);
76987758 else
76997759 {
@@ -7704,7 +7764,8 @@
77047764 (void)set_num_option(opt_idx, varp, number,
77057765 NULL, 0, opt_flags);
77067766 else
7707- (void)set_bool_option(opt_idx, varp, (int)number, opt_flags);
7767+ (void)set_bool_option(opt_idx, varp, (int)number,
7768+ opt_flags);
77087769 }
77097770 }
77107771 }
diff -r 7437be625546 -r 1c586ee8dd45 src/proto/eval.pro
--- a/src/proto/eval.pro Fri Jan 20 23:02:51 2006 +0000
+++ b/src/proto/eval.pro Fri Jan 20 23:10:18 2006 +0000
@@ -18,7 +18,7 @@
1818 char_u *eval_to_string_skip __ARGS((char_u *arg, char_u **nextcmd, int skip));
1919 int skip_expr __ARGS((char_u **pp));
2020 char_u *eval_to_string __ARGS((char_u *arg, char_u **nextcmd));
21-char_u *eval_to_string_safe __ARGS((char_u *arg, char_u **nextcmd));
21+char_u *eval_to_string_safe __ARGS((char_u *arg, char_u **nextcmd, int use_sandbox));
2222 int eval_to_number __ARGS((char_u *expr));
2323 list_T *eval_spell_expr __ARGS((char_u *badword, char_u *expr));
2424 int get_spellword __ARGS((list_T *list, char_u **pp));
@@ -43,6 +43,7 @@
4343 void del_menutrans_vars __ARGS((void));
4444 char_u *get_user_var_name __ARGS((expand_T *xp, int idx));
4545 void list_unref __ARGS((list_T *l));
46+dictitem_T *dict_lookup __ARGS((hashitem_T *hi));
4647 int list_append_dict __ARGS((list_T *list, dict_T *dict));
4748 int garbage_collect __ARGS((void));
4849 dict_T *dict_alloc __ARGS((void));
diff -r 7437be625546 -r 1c586ee8dd45 src/quickfix.c
--- a/src/quickfix.c Fri Jan 20 23:02:51 2006 +0000
+++ b/src/quickfix.c Fri Jan 20 23:10:18 2006 +0000
@@ -1880,7 +1880,7 @@
18801880 set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL);
18811881 set_option_value((char_u *)"bt", 0L, (char_u *)"quickfix",
18821882 OPT_LOCAL);
1883- set_option_value((char_u *)"bh", 0L, (char_u *)"delete", OPT_LOCAL);
1883+ set_option_value((char_u *)"bh", 0L, (char_u *)"wipe", OPT_LOCAL);
18841884 set_option_value((char_u *)"diff", 0L, (char_u *)"", OPT_LOCAL);
18851885 }
18861886 else if (buf != curbuf)
diff -r 7437be625546 -r 1c586ee8dd45 src/undo.c
--- a/src/undo.c Fri Jan 20 23:02:51 2006 +0000
+++ b/src/undo.c Fri Jan 20 23:10:18 2006 +0000
@@ -182,7 +182,7 @@
182182
183183 /* Don't allow changes in the buffer while editing the cmdline. The
184184 * caller of getcmdline() may get confused. */
185- if (cmdline_busy)
185+ if (textlock != 0)
186186 {
187187 EMSG(_(e_secure));
188188 return FALSE;
diff -r 7437be625546 -r 1c586ee8dd45 src/version.h
--- a/src/version.h Fri Jan 20 23:02:51 2006 +0000
+++ b/src/version.h Fri Jan 20 23:10:18 2006 +0000
@@ -36,5 +36,5 @@
3636 #define VIM_VERSION_NODOT "vim70aa"
3737 #define VIM_VERSION_SHORT "7.0aa"
3838 #define VIM_VERSION_MEDIUM "7.0aa ALPHA"
39-#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2006 Jan 19)"
40-#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2006 Jan 19, compiled "
39+#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2006 Jan 20)"
40+#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2006 Jan 20, compiled "
Show on old repository browser