• R/O
  • SSH

vim: Commit

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


Commit MetaInfo

Revisión8fa8d7964cf116fa98895d029808a0d5e1cf201b (tree)
Tiempo2005-05-20 06:08:39
Autorvimboss
Commitervimboss

Log Message

updated for version 7.0073

Cambiar Resumen

Diferencia incremental

diff -r 2463194c8cdd -r 8fa8d7964cf1 runtime/doc/todo.txt
--- a/runtime/doc/todo.txt Thu May 19 21:00:46 2005 +0000
+++ b/runtime/doc/todo.txt Thu May 19 21:08:39 2005 +0000
@@ -1,4 +1,4 @@
1-*todo.txt* For Vim version 7.0aa. Last change: 2005 May 18
1+*todo.txt* For Vim version 7.0aa. Last change: 2005 May 19
22
33
44 VIM REFERENCE MANUAL by Bram Moolenaar
@@ -88,10 +88,6 @@
8888
8989 setline() should accept a List.
9090
91-smsg() uses IObuff. The checks for the result not fitting are complicated,
92-find another solution. Add vsnprintf() and snprintf() functions?
93- http://www.ijs.si/software/snprintf/
94-
9591 Add ":[range]sort" command. Sort on specified field, using a regexp? Remove
9692 duplicates?
9793
diff -r 2463194c8cdd -r 8fa8d7964cf1 runtime/doc/version7.txt
--- a/runtime/doc/version7.txt Thu May 19 21:00:46 2005 +0000
+++ b/runtime/doc/version7.txt Thu May 19 21:08:39 2005 +0000
@@ -1,4 +1,4 @@
1-*version7.txt* For Vim version 7.0aa. Last change: 2005 May 18
1+*version7.txt* For Vim version 7.0aa. Last change: 2005 May 19
22
33
44 VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1068,4 +1068,8 @@
10681068 When "~" is in 'iskeyword' the "gd" doesn't work, it's used for the previous
10691069 substitute pattern. Put "\V" in the pattern to avoid that.
10701070
1071+Use of sprintf() sometimes didn't check properly for buffer overflow. Also
1072+when using smsg(). Included code for snprintf() to avoid having to do size
1073+checks where invoking them
1074+
10711075 vim:tw=78:ts=8:ft=help:norl:
diff -r 2463194c8cdd -r 8fa8d7964cf1 runtime/indent/lisp.vim
--- a/runtime/indent/lisp.vim Thu May 19 21:00:46 2005 +0000
+++ b/runtime/indent/lisp.vim Thu May 19 21:08:39 2005 +0000
@@ -1,7 +1,8 @@
11 " Vim indent file
22 " Language: Lisp
3-" Maintainer: noone
4-" Last Change: 2005 Mar 28
3+" Maintainer: Sergey Khorev <sergey.khorev@gmail.com>
4+" URL: http://iamphet.nm.ru/vim
5+" Last Change: 2005 May 19
56
67 " Only load this indent file when no other was loaded.
78 if exists("b:did_indent")
@@ -9,7 +10,6 @@
910 endif
1011 let b:did_indent = 1
1112
12-" Autoindent is the best we can do.
13-setlocal ai
13+setlocal ai nosi
1414
15-let b:undo_indent = "setl ai<"
15+let b:undo_indent = "setl ai< si<"
diff -r 2463194c8cdd -r 8fa8d7964cf1 runtime/syntax/mma.vim
--- a/runtime/syntax/mma.vim Thu May 19 21:00:46 2005 +0000
+++ b/runtime/syntax/mma.vim Thu May 19 21:08:39 2005 +0000
@@ -14,11 +14,7 @@
1414 " I also recommend setting the default 'Comment' hilighting to something
1515 " other than the color used for 'Function', since both are plentiful in
1616 " most mathematica files, and they are often the same color (when using
17-" background=dark). I use
18-"
19-" hi Comment ctermfg=darkcyan
20-"
21-" darkgreen also looks good on my terminal.
17+" background=dark).
2218 "
2319 " Credits:
2420 " o Original Mathematica syntax version written by
@@ -45,16 +41,6 @@
4541 syntax cluster mmaStrings contains=@mmaCommentStrings,mmaString
4642 syntax cluster mmaTop contains=mmaOperator,mmaGenericFunction,mmaPureFunction,mmaVariable
4743
48-" Variables:
49-" Dollar sign variables
50-syntax match mmaVariable "$\a\+\d*"
51-" Preceding contexts
52-syntax match mmaVariable "`\=\a\+\d*`"
53-
54-" Numbers:
55-syntax match mmaNumber "\<\%(\d\+\.\=\d*\|\d*\.\=\d\+\)\>"
56-syntax match mmaNumber "`\d\+\>"
57-
5844 " Predefined Constants:
5945 " to list all predefined Symbols would be too insane...
6046 " it's probably smarter to define a select few, and get the rest from
@@ -89,41 +75,24 @@
8975 " function attributes
9076 syntax keyword mmaVariable Protected Listable OneIdentity Orderless Flat Constant NumericFunction Locked ReadProtected HoldFirst HoldRest HoldAll HoldAllComplete SequenceHold NHoldFirst NHoldRest NHoldAll Temporary Stub
9177
92-" Strings:
93-" "string"
94-" 'string' is not accepted (until literal strings are supported!)
95-syntax region mmaString start=+\\\@<!"+ skip=+\\\@<!\\\%(\\\\\)*"+ end=+"+
96-syntax region mmaCommentString oneline start=+\\\@<!"+ skip=+\\\@<!\\\%(\\\\\)*"+ end=+"+ contained
97-
98-" Function Usage Messages:
99-" "SymbolName::item"
100-syntax match mmaMessage "$\=\a\+\d*::\a\+\d*"
78+" Comment Sections:
79+" this:
80+" :that:
81+syntax match mmaItem "\%(^[( |*\t]*\)\@<=\%(:\+\|\a\)[a-zA-Z0-9 ]\+:" contained contains=@mmaNotes
10182
102-" Pure Functions:
103-syntax match mmaPureFunction "#\%(#\|\d\+\)\="
104-syntax match mmaPureFunction "&"
105-
106-" Named Functions:
107-" Since everything is pretty much a function, get this straight
108-" from context
109-syntax match mmaGenericFunction "[A-Za-z0-9`]\+\s*\%([@[]\|/:\|/\=/@\)\@=" contains=mmaOperator
110-syntax match mmaGenericFunction "\~\s*[^~]\+\s*\~"hs=s+1,he=e-1 contains=mmaOperator,mmaBoring
111-syntax match mmaGenericFunction "//\s*[A-Za-z0-9`]\+"hs=s+2 contains=mmaOperator
112-
11383 " Comment Keywords:
11484 syntax keyword mmaTodo TODO NOTE HEY contained
11585 syntax match mmaTodo "X\{3,}" contained
11686 syntax keyword mmaFixme FIX[ME] FIXTHIS BROKEN contained
11787 " yay pirates...
11888 syntax match mmaFixme "\%(Y\=A\+R\+G\+\|GRR\+\|CR\+A\+P\+\)\%(!\+\)\=" contained
119-syntax match mmaemPHAsis "\(_\+\)[ a-zA-Z0-9]\+\1" contained
12089
121-" Comment Sections:
122-" this:
123-" :that:
124-syntax match mmaItem "\%(^[( |*\t]*\)\@<=\%(:\+\|\a\)[a-zA-Z0-9 ]\+:" contained contains=@mmaNotes
90+" EmPHAsis:
91+" this unnecessary, but whatever :)
92+syntax match mmaemPHAsis "\%(^\|\s\)\([_/]\)[a-zA-Z0-9]\+\%(\s\+[a-zA-Z0-9]\+\)*\1\%(\s\|$\)" contained contains=mmaemPHAsis
93+syntax match mmaemPHAsis "\%(^\|\s\)(\@<!\*[a-zA-Z0-9]\+\%(\s\+[a-zA-Z0-9]\+\)*)\@!\*\%(\s\|$\)" contained contains=mmaemPHAsis
12594
126-" Actual Mathematica Comments:
95+" Regular Comments:
12796 " (* *)
12897 " allow nesting (* (* *) *) even though the frontend
12998 " won't always like it.
@@ -141,6 +110,19 @@
141110 " catch preceding *
142111 syntax match mmaCommentStar "^\s*\*\+" contained
143112
113+" Variables:
114+" Dollar sign variables
115+syntax match mmaVariable "$\a\+\d*"
116+" Preceding contexts
117+syntax match mmaVariable "`\=\a\+\d*`"
118+
119+" Strings:
120+" "string"
121+" 'string' is not accepted (until literal strings are supported!)
122+syntax region mmaString start=+\\\@<!"+ skip=+\\\@<!\\\%(\\\\\)*"+ end=+"+
123+syntax region mmaCommentString oneline start=+\\\@<!"+ skip=+\\\@<!\\\%(\\\\\)*"+ end=+"+ contained
124+
125+
144126 " Patterns:
145127 " Each pattern marker below can be Blank[] (_), BlankSequence[] (__)
146128 " or BlankNullSequence[] (___). Most examples below can also be
@@ -197,7 +179,25 @@
197179 syntax match mmaOperator "\%(\~\~\=\)"
198180 syntax match mmaOperator "\%(=\{2,3}\|=\=!=\|||\=\|&&\|!\)" contains=ALLBUT,mmaPureFunction
199181
200-
182+" Function Usage Messages:
183+" "SymbolName::item"
184+syntax match mmaMessage "$\=\a\+\d*::\a\+\d*"
185+
186+" Pure Functions:
187+syntax match mmaPureFunction "#\%(#\|\d\+\)\="
188+syntax match mmaPureFunction "&"
189+
190+" Named Functions:
191+" Since everything is pretty much a function, get this straight
192+" from context
193+syntax match mmaGenericFunction "[A-Za-z0-9`]\+\s*\%([@[]\|/:\|/\=/@\)\@=" contains=mmaOperator
194+syntax match mmaGenericFunction "\~\s*[^~]\+\s*\~"hs=s+1,he=e-1 contains=mmaOperator,mmaBoring
195+syntax match mmaGenericFunction "//\s*[A-Za-z0-9`]\+"hs=s+2 contains=mmaOperator
196+
197+" Numbers:
198+syntax match mmaNumber "\<\%(\d\+\.\=\d*\|\d*\.\=\d\+\)\>"
199+syntax match mmaNumber "`\d\+\%(\d\@!\.\|\>\)"
200+
201201 " Special Characters:
202202 " \[Name] named character
203203 " \ooo octal
@@ -243,10 +243,10 @@
243243 HiLink mmaFunctionComment Comment
244244 HiLink mmaLooseQuote Comment
245245 HiLink mmaGenericFunction Function
246+ HiLink mmaVariable Identifier
246247 HiLink mmaOperator Operator
247248 HiLink mmaPatternOp Operator
248249 HiLink mmaPureFunction Operator
249- HiLink mmaVariable Identifier
250250 HiLink mmaString String
251251 HiLink mmaCommentString String
252252 HiLink mmaUnicode String
diff -r 2463194c8cdd -r 8fa8d7964cf1 src/digraph.c
--- a/src/digraph.c Thu May 19 21:00:46 2005 +0000
+++ b/src/digraph.c Thu May 19 21:08:39 2005 +0000
@@ -2459,7 +2459,7 @@
24592459 */
24602460 for (i = 0; i < curbuf->b_kmap_ga.ga_len; ++i)
24612461 {
2462- sprintf((char *)buf, "<buffer> %s %s",
2462+ vim_snprintf((char *)buf, sizeof(buf), "<buffer> %s %s",
24632463 ((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].from,
24642464 ((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].to);
24652465 (void)do_map(2, buf, LANGMAP, FALSE);
@@ -2492,8 +2492,8 @@
24922492 /* clear the ":lmap"s */
24932493 for (i = 0; i < curbuf->b_kmap_ga.ga_len; ++i)
24942494 {
2495- sprintf((char *)buf, "<buffer> %s",
2496- ((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].from);
2495+ vim_snprintf((char *)buf, sizeof(buf), "<buffer> %s",
2496+ ((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].from);
24972497 (void)do_map(1, buf, LANGMAP, FALSE);
24982498 }
24992499
diff -r 2463194c8cdd -r 8fa8d7964cf1 src/edit.c
--- a/src/edit.c Thu May 19 21:00:46 2005 +0000
+++ b/src/edit.c Thu May 19 21:08:39 2005 +0000
@@ -2218,8 +2218,8 @@
22182218 fp = mch_fopen((char *)files[i], "r"); /* open dictionary file */
22192219 if (flags != DICT_EXACT)
22202220 {
2221- sprintf((char*)IObuff, _("Scanning dictionary: %s"),
2222- (char *)files[i]);
2221+ vim_snprintf((char *)IObuff, IOSIZE,
2222+ _("Scanning dictionary: %s"), (char *)files[i]);
22232223 msg_trunc_attr(IObuff, TRUE, hl_attr(HLF_R));
22242224 }
22252225
@@ -2827,7 +2827,7 @@
28272827 dict = ins_buf->b_fname;
28282828 dict_f = DICT_EXACT;
28292829 }
2830- sprintf((char *)IObuff, _("Scanning: %s"),
2830+ vim_snprintf((char *)IObuff, IOSIZE, _("Scanning: %s"),
28312831 ins_buf->b_fname == NULL
28322832 ? buf_spname(ins_buf)
28332833 : ins_buf->b_sfname == NULL
diff -r 2463194c8cdd -r 8fa8d7964cf1 src/eval.c
--- a/src/eval.c Thu May 19 21:00:46 2005 +0000
+++ b/src/eval.c Thu May 19 21:08:39 2005 +0000
@@ -11414,7 +11414,7 @@
1141411414 if (argvars[2].v_type != VAR_UNKNOWN)
1141511415 {
1141611416 dictitem_T v;
11417- char_u str[30];
11417+ char_u str[30];
1141811418
1141911419 sprintf((char *)str, "0x%x", (unsigned int)w);
1142011420 v.di_tv.v_type = VAR_STRING;
@@ -16867,7 +16867,7 @@
1686716867 {
1686816868 ++no_wait_return;
1686916869 msg_scroll = TRUE; /* always scroll up, don't overwrite */
16870- msg_str((char_u *)_("calling %s"), sourcing_name);
16870+ smsg((char_u *)_("calling %s"), sourcing_name);
1687116871 if (p_verbose >= 14)
1687216872 {
1687316873 char_u buf[MSG_BUF_LEN];
@@ -16950,30 +16950,26 @@
1695016950 /* when being verbose, mention the return value */
1695116951 if (p_verbose >= 12)
1695216952 {
16953- char_u *sn;
16954-
1695516953 ++no_wait_return;
1695616954 msg_scroll = TRUE; /* always scroll up, don't overwrite */
1695716955
16958- /* Make sure the output fits in IObuff. */
16959- sn = sourcing_name;
16960- if (STRLEN(sourcing_name) > IOSIZE / 2 - 50)
16961- sn = sourcing_name + STRLEN(sourcing_name) - (IOSIZE / 2 - 50);
16962-
1696316956 if (aborting())
16964- smsg((char_u *)_("%s aborted"), sn);
16957+ smsg((char_u *)_("%s aborted"), sourcing_name);
1696516958 else if (fc.rettv->v_type == VAR_NUMBER)
16966- smsg((char_u *)_("%s returning #%ld"), sn,
16967- (long)fc.rettv->vval.v_number);
16959+ smsg((char_u *)_("%s returning #%ld"), sourcing_name,
16960+ (long)fc.rettv->vval.v_number);
1696816961 else
1696916962 {
1697016963 char_u buf[MSG_BUF_LEN];
1697116964 char_u numbuf[NUMBUFLEN];
1697216965 char_u *tofree;
1697316966
16967+ /* The value may be very long. Skip the middle part, so that we
16968+ * have some idea how it starts and ends. smsg() would always
16969+ * truncate it at the end. */
1697416970 trunc_string(tv2string(fc.rettv, &tofree, numbuf),
1697516971 buf, MSG_BUF_CLEN);
16976- smsg((char_u *)_("%s returning %s"), sn, buf);
16972+ smsg((char_u *)_("%s returning %s"), sourcing_name, buf);
1697716973 vim_free(tofree);
1697816974 }
1697916975 msg_puts((char_u *)"\n"); /* don't overwrite this either */
@@ -16994,7 +16990,7 @@
1699416990 {
1699516991 ++no_wait_return;
1699616992 msg_scroll = TRUE; /* always scroll up, don't overwrite */
16997- msg_str((char_u *)_("continuing in %s"), sourcing_name);
16993+ smsg((char_u *)_("continuing in %s"), sourcing_name);
1699816994 msg_puts((char_u *)"\n"); /* don't overwrite this either */
1699916995 cmdline_row = msg_row;
1700016996 --no_wait_return;
diff -r 2463194c8cdd -r 8fa8d7964cf1 src/ex_cmds.c
--- a/src/ex_cmds.c Thu May 19 21:00:46 2005 +0000
+++ b/src/ex_cmds.c Thu May 19 21:08:39 2005 +0000
@@ -89,8 +89,9 @@
8989 else
9090 #endif
9191 buf2[0] = NUL;
92- sprintf((char *)IObuff, _("<%s>%s%s %d, Hex %02x, Octal %03o"),
93- transchar(c), buf1, buf2, c, c, c);
92+ vim_snprintf((char *)IObuff, IOSIZE,
93+ _("<%s>%s%s %d, Hex %02x, Octal %03o"),
94+ transchar(c), buf1, buf2, c, c, c);
9495 #ifdef FEAT_MBYTE
9596 c = c1;
9697 c1 = c2;
@@ -113,8 +114,8 @@
113114 #endif
114115 )
115116 IObuff[len++] = ' '; /* draw composing char on top of a space */
116- IObuff[len + (*mb_char2bytes)(c, IObuff + len)] = NUL;
117- sprintf((char *)IObuff + STRLEN(IObuff),
117+ len += (*mb_char2bytes)(c, IObuff + len);
118+ vim_snprintf((char *)IObuff + len, IOSIZE - len,
118119 c < 0x10000 ? _("> %d, Hex %04x, Octal %o")
119120 : _("> %d, Hex %08x, Octal %o"), c, c, c);
120121 c = c1;
@@ -974,8 +975,8 @@
974975 {
975976 if (do_in)
976977 {
977- sprintf((char *)msg_buf, _("%ld lines filtered"),
978- (long)linecount);
978+ vim_snprintf((char *)msg_buf, sizeof(msg_buf),
979+ _("%ld lines filtered"), (long)linecount);
979980 if (msg(msg_buf) && !msg_scroll)
980981 {
981982 /* save message to display it after redraw */
@@ -1337,7 +1338,8 @@
13371338 char *message;
13381339 char_u *line;
13391340 {
1340- sprintf((char *)IObuff, _("%sviminfo: %s in line: "), errnum, message);
1341+ vim_snprintf((char *)IObuff, IOSIZE, _("%sviminfo: %s in line: "),
1342+ errnum, message);
13411343 STRNCAT(IObuff, line, IOSIZE - STRLEN(IObuff));
13421344 if (IObuff[STRLEN(IObuff) - 1] == '\n')
13431345 IObuff[STRLEN(IObuff) - 1] = NUL;
@@ -1373,17 +1375,11 @@
13731375 fp = mch_fopen((char *)fname, READBIN);
13741376
13751377 if (p_verbose > 0)
1376- {
1377- char_u *s;
1378-
1379- s = fname;
1380- if (STRLEN(fname) > IOSIZE - 100)
1381- s = fname + STRLEN(fname) - (IOSIZE - 100);
1382- smsg((char_u *)_("Reading viminfo file \"%s\"%s%s%s"), s,
1383- want_info ? _(" info") : "",
1384- want_marks ? _(" marks") : "",
1385- fp == NULL ? _(" FAILED") : "");
1386- }
1378+ smsg((char_u *)_("Reading viminfo file \"%s\"%s%s%s"),
1379+ fname,
1380+ want_info ? _(" info") : "",
1381+ want_marks ? _(" marks") : "",
1382+ fp == NULL ? _(" FAILED") : "");
13871383
13881384 vim_free(fname);
13891385 if (fp == NULL)
@@ -1607,7 +1603,7 @@
16071603 }
16081604
16091605 if (p_verbose > 0)
1610- msg_str((char_u *)_("Writing viminfo file \"%s\""), fname);
1606+ smsg((char_u *)_("Writing viminfo file \"%s\""), fname);
16111607
16121608 viminfo_errcnt = 0;
16131609 do_viminfo(fp_in, fp_out, !forceit, !forceit, FALSE);
@@ -4529,6 +4525,8 @@
45294525 do_sub_msg(count_only)
45304526 int count_only; /* used 'n' flag for ":s" */
45314527 {
4528+ int len = 0;
4529+
45324530 /*
45334531 * Only report substitutions when:
45344532 * - more than 'report' substitutions
@@ -4540,20 +4538,24 @@
45404538 && messaging())
45414539 {
45424540 if (got_int)
4541+ {
45434542 STRCPY(msg_buf, _("(Interrupted) "));
4543+ len = STRLEN(msg_buf);
4544+ }
4545+ if (sub_nsubs == 1)
4546+ vim_snprintf((char *)msg_buf + len, sizeof(msg_buf) - len,
4547+ "%s", count_only ? _("1 match") : _("1 substitution"));
45444548 else
4545- msg_buf[0] = NUL;
4546- if (sub_nsubs == 1)
4547- STRCAT(msg_buf, count_only ? _("1 match") : _("1 substitution"));
4548- else
4549- sprintf((char *)msg_buf + STRLEN(msg_buf),
4549+ vim_snprintf((char *)msg_buf + len, sizeof(msg_buf) - len,
45504550 count_only ? _("%ld matches") : _("%ld substitutions"),
45514551 sub_nsubs);
4552+ len = STRLEN(msg_buf);
45524553 if (sub_nlines == 1)
4553- STRCAT(msg_buf, _(" on 1 line"));
4554+ vim_snprintf((char *)msg_buf + len, sizeof(msg_buf) - len,
4555+ "%s", _(" on 1 line"));
45544556 else
4555- sprintf((char *)msg_buf + STRLEN(msg_buf), _(" on %ld lines"),
4556- (long)sub_nlines);
4557+ vim_snprintf((char *)msg_buf + len, sizeof(msg_buf) - len,
4558+ _(" on %ld lines"), (long)sub_nlines);
45574559 if (msg(msg_buf))
45584560 {
45594561 /* save message to display it after redraw */
@@ -4686,9 +4688,9 @@
46864688 else if (ndone == 0)
46874689 {
46884690 if (type == 'v')
4689- msg_str((char_u *)_("Pattern found in every line: %s"), pat);
4691+ smsg((char_u *)_("Pattern found in every line: %s"), pat);
46904692 else
4691- msg_str((char_u *)_(e_patnotf2), pat);
4693+ smsg((char_u *)_(e_patnotf2), pat);
46924694 }
46934695 else
46944696 global_exe(cmd);
@@ -4955,8 +4957,7 @@
49554957 */
49564958 if ((helpfd = mch_fopen((char *)p_hf, READBIN)) == NULL)
49574959 {
4958- msg_str((char_u *)_("Sorry, help file \"%s\" not found"),
4959- p_hf);
4960+ smsg((char_u *)_("Sorry, help file \"%s\" not found"), p_hf);
49604961 goto erret;
49614962 }
49624963 fclose(helpfd);
@@ -5660,7 +5661,7 @@
56605661 got_int = TRUE;
56615662 else
56625663 {
5663- s = alloc(30);
5664+ s = alloc(18 + STRLEN(tagfname));
56645665 if (s == NULL)
56655666 got_int = TRUE;
56665667 else
@@ -5793,7 +5794,7 @@
57935794 if (*p2 == '\t')
57945795 {
57955796 *p2 = NUL;
5796- sprintf((char *)NameBuff,
5797+ vim_snprintf((char *)NameBuff, MAXPATHL,
57975798 _("E154: Duplicate tag \"%s\" in file %s/%s"),
57985799 ((char_u **)ga.ga_data)[i], dir, p2 + 1);
57995800 EMSG(NameBuff);
@@ -6307,7 +6308,7 @@
63076308 {
63086309 char_u *p;
63096310
6310- msg_str((char_u *)"sign %s", sp->sn_name);
6311+ smsg((char_u *)"sign %s", sp->sn_name);
63116312 if (sp->sn_icon != NULL)
63126313 {
63136314 MSG_PUTS(" icon=");
diff -r 2463194c8cdd -r 8fa8d7964cf1 src/ex_cmds.h
--- a/src/ex_cmds.h Thu May 19 21:00:46 2005 +0000
+++ b/src/ex_cmds.h Thu May 19 21:08:39 2005 +0000
@@ -532,7 +532,7 @@
532532 EX(CMD_mode, "mode", ex_mode,
533533 WORD1|TRLBAR|CMDWIN),
534534 EX(CMD_mzscheme, "mzscheme", ex_mzscheme,
535- RANGE|EXTRA|DFLALL|NEEDARG|CMDWIN),
535+ RANGE|EXTRA|DFLALL|NEEDARG|CMDWIN|SBOXOK),
536536 EX(CMD_mzfile, "mzfile", ex_mzfile,
537537 RANGE|FILE1|NEEDARG|CMDWIN),
538538 EX(CMD_next, "next", ex_next,
diff -r 2463194c8cdd -r 8fa8d7964cf1 src/ex_cmds2.c
--- a/src/ex_cmds2.c Thu May 19 21:00:46 2005 +0000
+++ b/src/ex_cmds2.c Thu May 19 21:08:39 2005 +0000
@@ -141,16 +141,9 @@
141141 if (sourcing_name != NULL)
142142 msg(sourcing_name);
143143 if (sourcing_lnum != 0)
144- {
145- char_u buf[IOSIZE];
146-
147- /* Truncate the command, the whole must fit in IObuff. */
148- STRNCPY(buf, cmd, IOSIZE - 50);
149- buf[IOSIZE - 50] = NUL;
150- smsg((char_u *)_("line %ld: %s"), (long)sourcing_lnum, buf);
151- }
144+ smsg((char_u *)_("line %ld: %s"), (long)sourcing_lnum, cmd);
152145 else
153- msg_str((char_u *)_("cmd: %s"), cmd);
146+ smsg((char_u *)_("cmd: %s"), cmd);
154147
155148 /*
156149 * Repeat getting a command and executing it.
@@ -342,7 +335,8 @@
342335 p = (char_u *)"<SNR>";
343336 else
344337 p = (char_u *)"";
345- smsg((char_u *)_("Breakpoint in \"%s%s\" line %ld"), p,
338+ smsg((char_u *)_("Breakpoint in \"%s%s\" line %ld"),
339+ p,
346340 debug_breakpoint_name + (*p == NUL ? 0 : 3),
347341 (long)debug_breakpoint_lnum);
348342 debug_breakpoint_name = NULL;
@@ -2473,13 +2467,8 @@
24732467 if (buf != NULL && rtp_copy != NULL)
24742468 {
24752469 if (p_verbose > 1)
2476- {
2477- if (STRLEN(name) + STRLEN(p_rtp) > IOSIZE - 100)
2478- MSG(_("Searching for a long name in 'runtimepath'"));
2479- else
2480- smsg((char_u *)_("Searching for \"%s\" in \"%s\""),
2470+ smsg((char_u *)_("Searching for \"%s\" in \"%s\""),
24812471 (char *)name, (char *)p_rtp);
2482- }
24832472
24842473 /* Loop over all entries in 'runtimepath'. */
24852474 rtp = rtp_copy;
@@ -2501,7 +2490,7 @@
25012490 "\t ");
25022491
25032492 if (p_verbose > 2)
2504- msg_str((char_u *)_("Searching for \"%s\""), buf);
2493+ smsg((char_u *)_("Searching for \"%s\""), buf);
25052494
25062495 /* Expand wildcards, invoke the callback for each match. */
25072496 if (gen_expand_wildcards(1, &buf, &num_files, &files,
@@ -2523,7 +2512,7 @@
25232512 vim_free(buf);
25242513 vim_free(rtp_copy);
25252514 if (p_verbose > 0 && !did_one)
2526- msg_str((char_u *)_("not found in 'runtimepath': \"%s\""), name);
2515+ smsg((char_u *)_("not found in 'runtimepath': \"%s\""), name);
25272516
25282517 #ifdef AMIGA
25292518 proc->pr_WindowPtr = save_winptr;
@@ -2733,7 +2722,7 @@
27332722 #endif
27342723 if (mch_isdir(fname_exp))
27352724 {
2736- msg_str((char_u *)_("Cannot source a directory: \"%s\""), fname);
2725+ smsg((char_u *)_("Cannot source a directory: \"%s\""), fname);
27372726 goto theend;
27382727 }
27392728
@@ -2771,10 +2760,10 @@
27712760 if (p_verbose > 0)
27722761 {
27732762 if (sourcing_name == NULL)
2774- msg_str((char_u *)_("could not source \"%s\""), fname);
2763+ smsg((char_u *)_("could not source \"%s\""), fname);
27752764 else
27762765 smsg((char_u *)_("line %ld: could not source \"%s\""),
2777- sourcing_lnum, fname);
2766+ sourcing_lnum, fname);
27782767 }
27792768 goto theend;
27802769 }
@@ -2787,10 +2776,10 @@
27872776 if (p_verbose > 1)
27882777 {
27892778 if (sourcing_name == NULL)
2790- msg_str((char_u *)_("sourcing \"%s\""), fname);
2779+ smsg((char_u *)_("sourcing \"%s\""), fname);
27912780 else
27922781 smsg((char_u *)_("line %ld: sourcing \"%s\""),
2793- sourcing_lnum, fname);
2782+ sourcing_lnum, fname);
27942783 }
27952784 if (is_vimrc)
27962785 vimrc_found();
@@ -2972,16 +2961,12 @@
29722961 sourcing_lnum = save_sourcing_lnum;
29732962 if (p_verbose > 1)
29742963 {
2975- msg_str((char_u *)_("finished sourcing %s"), fname);
2964+ smsg((char_u *)_("finished sourcing %s"), fname);
29762965 if (sourcing_name != NULL)
2977- msg_str((char_u *)_("continuing in %s"), sourcing_name);
2966+ smsg((char_u *)_("continuing in %s"), sourcing_name);
29782967 }
29792968 #ifdef STARTUPTIME
2980-# ifdef HAVE_SNPRINTF
2981- snprintf(IObuff, IOSIZE, "sourcing %s", fname);
2982-# else
2983- sprintf(IObuff, "sourcing %s", fname);
2984-# endif
2969+ vim_snprintf(IObuff, IOSIZE, "sourcing %s", fname);
29852970 time_msg(IObuff, &tv_start);
29862971 time_pop(&tv_rel);
29872972 #endif
@@ -4263,14 +4248,15 @@
42634248 page_prtpos = prtpos;
42644249 }
42654250
4266- sprintf((char *)IObuff, _("Printed: %s"), settings.jobname);
4251+ vim_snprintf((char *)IObuff, IOSIZE, _("Printed: %s"),
4252+ settings.jobname);
42674253 prt_message(IObuff);
42684254 }
42694255
42704256 print_fail:
42714257 if (got_int || settings.user_abort)
42724258 {
4273- sprintf((char *)IObuff, _("Printing aborted"));
4259+ sprintf((char *)IObuff, "%s", _("Printing aborted"));
42744260 prt_message(IObuff);
42754261 }
42764262 mch_print_end(&settings);
@@ -4954,7 +4940,7 @@
49544940 prt_write_string(s)
49554941 char *s;
49564942 {
4957- sprintf((char *)prt_line_buffer, "%s", s);
4943+ vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer), "%s", s);
49584944 prt_write_file(prt_line_buffer);
49594945 }
49604946
@@ -4990,8 +4976,8 @@
49904976 int height;
49914977 char *font;
49924978 {
4993- sprintf((char *)prt_line_buffer, "/_%s /VIM-%s /%s ref\n",
4994- new_name, encoding, font);
4979+ vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
4980+ "/_%s /VIM-%s /%s ref\n", new_name, encoding, font);
49954981 prt_write_file(prt_line_buffer);
49964982 #ifdef FEAT_MBYTE
49974983 if (prt_out_mbyte)
@@ -4999,8 +4985,8 @@
49994985 new_name, height, 500./prt_ps_courier_font.wx, new_name);
50004986 else
50014987 #endif
5002- sprintf((char *)prt_line_buffer, "/%s %d /_%s ffs\n",
5003- new_name, height, new_name);
4988+ vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
4989+ "/%s %d /_%s ffs\n", new_name, height, new_name);
50044990 prt_write_file(prt_line_buffer);
50054991 }
50064992
@@ -5014,11 +5000,11 @@
50145000 int height;
50155001 char *cidfont;
50165002 {
5017- sprintf((char *)prt_line_buffer, "/_%s /%s[/%s] vim_composefont\n",
5018- new_name, prt_cmap, cidfont);
5003+ vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
5004+ "/_%s /%s[/%s] vim_composefont\n", new_name, prt_cmap, cidfont);
50195005 prt_write_file(prt_line_buffer);
5020- sprintf((char *)prt_line_buffer, "/%s %d /_%s ffs\n", new_name, height,
5021- new_name);
5006+ vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
5007+ "/%s %d /_%s ffs\n", new_name, height, new_name);
50225008 prt_write_file(prt_line_buffer);
50235009 }
50245010
@@ -5030,7 +5016,8 @@
50305016 char *original_name;
50315017 char *new_name;
50325018 {
5033- sprintf((char *)prt_line_buffer, "/%s %s d\n", new_name, original_name);
5019+ vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
5020+ "/%s %s d\n", new_name, original_name);
50345021 prt_write_file(prt_line_buffer);
50355022 }
50365023 #endif
@@ -5105,7 +5092,8 @@
51055092 double value;
51065093 int prec;
51075094 {
5108- sprintf((char *)prt_line_buffer, "/%s ", name);
5095+ vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
5096+ "/%s ", name);
51095097 prt_write_file(prt_line_buffer);
51105098 prt_write_real(value, prec);
51115099 sprintf((char *)prt_line_buffer, "d\n");
@@ -5532,7 +5520,8 @@
55325520 prt_dsc_noarg(comment)
55335521 char *comment;
55345522 {
5535- sprintf((char *)prt_line_buffer, "%%%%%s\n", comment);
5523+ vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
5524+ "%%%%%s\n", comment);
55365525 prt_write_file(prt_line_buffer);
55375526 }
55385527
@@ -5541,7 +5530,8 @@
55415530 char *comment;
55425531 char *text;
55435532 {
5544- sprintf((char *)prt_line_buffer, "%%%%%s: %s\n", comment, text);
5533+ vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
5534+ "%%%%%s: %s\n", comment, text);
55455535 prt_write_file(prt_line_buffer);
55465536 }
55475537
@@ -5551,7 +5541,8 @@
55515541 char *text;
55525542 {
55535543 /* TODO - should scan 'text' for any chars needing escaping! */
5554- sprintf((char *)prt_line_buffer, "%%%%%s: (%s)\n", comment, text);
5544+ vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
5545+ "%%%%%s: (%s)\n", comment, text);
55555546 prt_write_file(prt_line_buffer);
55565547 }
55575548
@@ -5565,7 +5556,8 @@
55655556 {
55665557 int i;
55675558
5568- sprintf((char *)prt_line_buffer, "%%%%%s:", comment);
5559+ vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
5560+ "%%%%%s:", comment);
55695561 prt_write_file(prt_line_buffer);
55705562
55715563 for (i = 0; i < count; i++)
@@ -5584,12 +5576,15 @@
55845576 char *string;
55855577 {
55865578 if (comment != NULL)
5587- sprintf((char *)prt_line_buffer, "%%%%%s: %s", comment, type);
5579+ vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
5580+ "%%%%%s: %s", comment, type);
55885581 else
5589- sprintf((char *)prt_line_buffer, "%%%%+ %s", type);
5582+ vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
5583+ "%%%%+ %s", type);
55905584 prt_write_file(prt_line_buffer);
55915585
5592- sprintf((char *)prt_line_buffer, " %s\n", string);
5586+ vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
5587+ " %s\n", string);
55935588 prt_write_file(prt_line_buffer);
55945589 }
55955590
@@ -5654,7 +5649,8 @@
56545649 char *colour;
56555650 char *type;
56565651 {
5657- sprintf((char *)prt_line_buffer, "%%%%DocumentMedia: %s ", paper_name);
5652+ vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
5653+ "%%%%DocumentMedia: %s ", paper_name);
56585654 prt_write_file(prt_line_buffer);
56595655 prt_write_real(width, 2);
56605656 prt_write_real(height, 2);
diff -r 2463194c8cdd -r 8fa8d7964cf1 src/if_mzsch.c
--- a/src/if_mzsch.c Thu May 19 21:00:46 2005 +0000
+++ b/src/if_mzsch.c Thu May 19 21:08:39 2005 +0000
@@ -93,6 +93,11 @@
9393 * Utility functions for the vim/mzscheme interface
9494 *========================================================================
9595 */
96+#ifdef HAVE_SANDBOX
97+static Scheme_Object *sandbox_file_guard(int, Scheme_Object **);
98+static Scheme_Object *sandbox_network_guard(int, Scheme_Object **);
99+static void sandbox_check();
100+#endif
96101 /* Buffer-related commands */
97102 static Scheme_Object *buffer_new(buf_T *buf);
98103 static Scheme_Object *get_buffer_by_name(void *, int, Scheme_Object **);
@@ -205,11 +210,15 @@
205210 static Scheme_Object *(*dll_scheme_apply)(Scheme_Object *rator, int num_rands,
206211 Scheme_Object **rands);
207212 static Scheme_Object *(*dll_scheme_builtin_value)(const char *name);
213+# if MZSCHEME_VERSION_MAJOR >= 299
214+static Scheme_Object *(*dll_scheme_byte_string_to_char_string)(Scheme_Object *s);
215+# endif
208216 static void (*dll_scheme_close_input_port)(Scheme_Object *port);
209217 static void (*dll_scheme_count_lines)(Scheme_Object *port);
210218 static Scheme_Object *(*dll_scheme_current_continuation_marks)(void);
211219 static void (*dll_scheme_display)(Scheme_Object *obj, Scheme_Object *port);
212220 static char *(*dll_scheme_display_to_string)(Scheme_Object *obj, long *len);
221+static int (*dll_scheme_eq)(Scheme_Object *obj1, Scheme_Object *obj2);
213222 static Scheme_Object *(*dll_scheme_do_eval)(Scheme_Object *obj,
214223 int _num_rands, Scheme_Object **rands, int val);
215224 static void (*dll_scheme_dont_gc_ptr)(void *p);
@@ -225,6 +234,7 @@
225234 # else
226235 static char *(*dll_scheme_format_utf8)(char *format, int flen, int argc,
227236 Scheme_Object **argv, long *rlen);
237+static Scheme_Object *(*dll_scheme_get_param)(Scheme_Config *c, int pos);
228238 # endif
229239 static void (*dll_scheme_gc_ptr_ok)(void *p);
230240 # if MZSCHEME_VERSION_MAJOR < 299
@@ -245,6 +255,8 @@
245255 Scheme_Object *argv[]);
246256 static Scheme_Object *(*dll_scheme_make_pair)(Scheme_Object *car,
247257 Scheme_Object *cdr);
258+static Scheme_Object *(*dll_scheme_make_prim_w_arity)(Scheme_Prim *prim,
259+ const char *name, mzshort mina, mzshort maxa);
248260 # if MZSCHEME_VERSION_MAJOR < 299
249261 static Scheme_Object *(*dll_scheme_make_string)(const char *chars);
250262 static Scheme_Object *(*dll_scheme_make_string_output_port)();
@@ -311,6 +323,9 @@
311323 # define scheme_apply dll_scheme_apply
312324 # define scheme_basic_env dll_scheme_basic_env
313325 # define scheme_builtin_value dll_scheme_builtin_value
326+# if MZSCHEME_VERSION_MAJOR >= 299
327+# define scheme_byte_string_to_char_string dll_scheme_byte_string_to_char_string
328+# endif
314329 # define scheme_check_threads dll_scheme_check_threads
315330 # define scheme_close_input_port dll_scheme_close_input_port
316331 # define scheme_count_lines dll_scheme_count_lines
@@ -320,6 +335,7 @@
320335 # define scheme_display_to_string dll_scheme_display_to_string
321336 # define scheme_do_eval dll_scheme_do_eval
322337 # define scheme_dont_gc_ptr dll_scheme_dont_gc_ptr
338+# define scheme_eq dll_scheme_eq
323339 # define scheme_eval dll_scheme_eval
324340 # define scheme_eval_string dll_scheme_eval_string
325341 # define scheme_eval_string_all dll_scheme_eval_string_all
@@ -335,6 +351,7 @@
335351 # else
336352 # define scheme_get_sized_byte_string_output \
337353 dll_scheme_get_sized_byte_string_output
354+# define scheme_get_param dll_scheme_get_param
338355 # endif
339356 # define scheme_intern_symbol dll_scheme_intern_symbol
340357 # define scheme_lookup_global dll_scheme_lookup_global
@@ -342,6 +359,7 @@
342359 # define scheme_make_integer_value dll_scheme_make_integer_value
343360 # define scheme_make_namespace dll_scheme_make_namespace
344361 # define scheme_make_pair dll_scheme_make_pair
362+# define scheme_make_prim_w_arity dll_scheme_make_prim_w_arity
345363 # if MZSCHEME_VERSION_MAJOR < 299
346364 # define scheme_make_string dll_scheme_make_string
347365 # define scheme_make_string_output_port dll_scheme_make_string_output_port
@@ -399,6 +417,9 @@
399417 {"scheme_add_global_symbol", (void **)&dll_scheme_add_global_symbol},
400418 {"scheme_apply", (void **)&dll_scheme_apply},
401419 {"scheme_basic_env", (void **)&dll_scheme_basic_env},
420+# if MZSCHEME_VERSION_MAJOR >= 299
421+ {"scheme_byte_string_to_char_string", (void **)&dll_scheme_byte_string_to_char_string},
422+# endif
402423 {"scheme_builtin_value", (void **)&dll_scheme_builtin_value},
403424 {"scheme_check_threads", (void **)&dll_scheme_check_threads},
404425 {"scheme_close_input_port", (void **)&dll_scheme_close_input_port},
@@ -409,6 +430,7 @@
409430 {"scheme_display_to_string", (void **)&dll_scheme_display_to_string},
410431 {"scheme_do_eval", (void **)&dll_scheme_do_eval},
411432 {"scheme_dont_gc_ptr", (void **)&dll_scheme_dont_gc_ptr},
433+ {"scheme_eq", (void **)&dll_scheme_eq},
412434 {"scheme_eval", (void **)&dll_scheme_eval},
413435 {"scheme_eval_string", (void **)&dll_scheme_eval_string},
414436 {"scheme_eval_string_all", (void **)&dll_scheme_eval_string_all},
@@ -418,6 +440,7 @@
418440 {"scheme_format", (void **)&dll_scheme_format},
419441 # else
420442 {"scheme_format_utf8", (void **)&dll_scheme_format_utf8},
443+ {"scheme_get_param", (void **)&dll_scheme_get_param},
421444 #endif
422445 {"scheme_gc_ptr_ok", (void **)&dll_scheme_gc_ptr_ok},
423446 # if MZSCHEME_VERSION_MAJOR < 299
@@ -434,6 +457,7 @@
434457 {"scheme_make_integer_value", (void **)&dll_scheme_make_integer_value},
435458 {"scheme_make_namespace", (void **)&dll_scheme_make_namespace},
436459 {"scheme_make_pair", (void **)&dll_scheme_make_pair},
460+ {"scheme_make_prim_w_arity", (void **)&dll_scheme_make_prim_w_arity},
437461 # if MZSCHEME_VERSION_MAJOR < 299
438462 {"scheme_make_string", (void **)&dll_scheme_make_string},
439463 {"scheme_make_string_output_port",
@@ -727,6 +751,8 @@
727751 static void
728752 startup_mzscheme(void)
729753 {
754+ Scheme_Object *proc_make_security_guard;
755+
730756 scheme_set_stack_base(NULL, 1);
731757
732758 MZ_REGISTER_STATIC(environment);
@@ -751,7 +777,24 @@
751777 scheme_make_pair(scheme_make_string(MZSCHEME_COLLECTS),
752778 scheme_null));
753779 #endif
754-
780+#ifdef HAVE_SANDBOX
781+ /* setup sandbox guards */
782+ proc_make_security_guard = scheme_lookup_global(
783+ scheme_intern_symbol("make-security-guard"),
784+ environment);
785+ if (proc_make_security_guard != NULL)
786+ {
787+ Scheme_Object *args[3];
788+ Scheme_Object *guard;
789+ args[0] = scheme_get_param(scheme_config, MZCONFIG_SECURITY_GUARD);
790+ args[1] = scheme_make_prim_w_arity(sandbox_file_guard,
791+ "sandbox-file-guard", 3, 3);
792+ args[2] = scheme_make_prim_w_arity(sandbox_network_guard,
793+ "sandbox-network-guard", 4, 4);
794+ guard = scheme_apply(proc_make_security_guard, 3, args);
795+ scheme_set_param(scheme_config, MZCONFIG_SECURITY_GUARD, guard);
796+ }
797+#endif
755798 /* Create buffer and window types for use in Scheme code */
756799 mz_buffer_type = scheme_make_type("<vim-buffer>");
757800 mz_window_type = scheme_make_type("<vim-window>");
@@ -1579,6 +1622,9 @@
15791622 long lnum = 0;
15801623 long col = 0;
15811624
1625+#ifdef HAVE_SANDBOX
1626+ sandbox_check();
1627+#endif
15821628 win = get_window_arg(prim->name, 1, argc, argv);
15831629 GUARANTEE_PAIR(prim->name, 0);
15841630
@@ -1615,6 +1661,9 @@
16151661 int num = 0;
16161662 Scheme_Object *onum;
16171663
1664+#ifdef HAVE_SANDBOX
1665+ sandbox_check();
1666+#endif
16181667 fname = SCHEME_STR_VAL(GUARANTEE_STRING(prim->name, 0));
16191668 /* TODO make open existing file */
16201669 num = buflist_add(fname, BLN_LISTED | BLN_CURBUF);
@@ -1869,6 +1918,9 @@
18691918 buf_T *savebuf;
18701919 int n;
18711920
1921+#ifdef HAVE_SANDBOX
1922+ sandbox_check();
1923+#endif
18721924 n = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0));
18731925 if (!SCHEME_STRINGP(argv[1]) && !SCHEME_FALSEP(argv[1]))
18741926 scheme_wrong_type(prim->name, "string or #f", 1, argc, argv);
@@ -1958,6 +2010,9 @@
19582010 int i, old_len, new_len, hi, lo;
19592011 long extra;
19602012
2013+#ifdef HAVE_SANDBOX
2014+ sandbox_check();
2015+#endif
19612016 lo = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0));
19622017 hi = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 1));
19632018 if (!SCHEME_PAIRP(argv[2])
@@ -2121,6 +2176,9 @@
21212176 buf_T *savebuf;
21222177 int i, n, size;
21232178
2179+#ifdef HAVE_SANDBOX
2180+ sandbox_check();
2181+#endif
21242182 /*
21252183 * First of all, we check the type of the supplied MzScheme object.
21262184 * It must be a string or a list, or the call is in error.
@@ -2380,8 +2438,9 @@
23802438 if (add_info != NULL)
23812439 {
23822440 Scheme_Object *info = scheme_make_string(add_info);
2383- argv[0] = scheme_make_string(
2384- scheme_format(fmt, strlen(fmt), 1, &info, NULL));
2441+ argv[0] = scheme_byte_string_to_char_string(scheme_make_string(
2442+ scheme_format(fmt, strlen(fmt), 1, &info, NULL)));
2443+ SCHEME_SET_IMMUTABLE(argv[0]);
23852444 }
23862445 else
23872446 argv[0] = scheme_make_string(_("Vim error"));
@@ -2596,3 +2655,66 @@
25962655 scheme_add_global("global-namespace", (Scheme_Object *)environment, mod);
25972656 scheme_finish_primitive_module(mod);
25982657 }
2658+
2659+#ifdef HAVE_SANDBOX
2660+static Scheme_Object *M_write = NULL;
2661+static Scheme_Object *M_read = NULL;
2662+static Scheme_Object *M_execute = NULL;
2663+static Scheme_Object *M_delete = NULL;
2664+
2665+ static void
2666+sandbox_check()
2667+{
2668+ if (sandbox)
2669+ raise_vim_exn(_("not allowed in the Vim sandbox"));
2670+}
2671+
2672+/* security guards to force Vim's sandbox restrictions on MzScheme level */
2673+ static Scheme_Object *
2674+sandbox_file_guard(int argc, Scheme_Object **argv)
2675+{
2676+ if (sandbox)
2677+ {
2678+ Scheme_Object *requested_access = argv[2];
2679+
2680+ if (M_write == NULL)
2681+ {
2682+ MZ_REGISTER_STATIC(M_write);
2683+ M_write = scheme_intern_symbol("write");
2684+ }
2685+ if (M_read == NULL)
2686+ {
2687+ MZ_REGISTER_STATIC(M_read);
2688+ M_read = scheme_intern_symbol("read");
2689+ }
2690+ if (M_execute == NULL)
2691+ {
2692+ MZ_REGISTER_STATIC(M_execute);
2693+ M_execute = scheme_intern_symbol("execute");
2694+ }
2695+ if (M_delete == NULL)
2696+ {
2697+ MZ_REGISTER_STATIC(M_delete);
2698+ M_delete = scheme_intern_symbol("delete");
2699+ }
2700+
2701+ while (!SCHEME_NULLP(requested_access))
2702+ {
2703+ Scheme_Object *item = SCHEME_CAR(requested_access);
2704+ if (scheme_eq(item, M_write) || scheme_eq(item, M_read)
2705+ || scheme_eq(item, M_execute) || scheme_eq(item, M_delete))
2706+ {
2707+ raise_vim_exn(_("not allowed in the Vim sandbox"));
2708+ }
2709+ requested_access = SCHEME_CDR(requested_access);
2710+ }
2711+ }
2712+ return scheme_void;
2713+}
2714+
2715+ static Scheme_Object *
2716+sandbox_network_guard(int argc, Scheme_Object **argv)
2717+{
2718+ return scheme_void;
2719+}
2720+#endif
diff -r 2463194c8cdd -r 8fa8d7964cf1 src/if_mzsch.h
--- a/src/if_mzsch.h Thu May 19 21:00:46 2005 +0000
+++ b/src/if_mzsch.h Thu May 19 21:08:39 2005 +0000
@@ -34,12 +34,13 @@
3434 # endif
3535 # define scheme_format scheme_format_utf8
3636
37-# define GET_BYTE_STRING(obj) (SCHEME_BYTE_STRINGP(obj) ? obj : \
37+# define SCHEME_GET_BYTE_STRING(obj) (SCHEME_BYTE_STRINGP(obj) ? obj : \
3838 scheme_char_string_to_byte_string(obj))
3939 #else
40-# define GET_BYTE_STRING(obj) (obj)
40+# define SCHEME_GET_BYTE_STRING(obj) (obj)
4141 # define SCHEME_BYTE_STRLEN_VAL SCHEME_STRLEN_VAL
4242 # define SCHEME_BYTE_STR_VAL SCHEME_STR_VAL
43+# define scheme_byte_string_to_char_string(obj) (obj)
4344 #endif
4445
4546 #endif /* _IF_MZSCH_H_ */
diff -r 2463194c8cdd -r 8fa8d7964cf1 src/if_python.c
--- a/src/if_python.c Thu May 19 21:00:46 2005 +0000
+++ b/src/if_python.c Thu May 19 21:08:39 2005 +0000
@@ -1369,12 +1369,13 @@
13691369 static PyObject *
13701370 BufferRepr(PyObject *self)
13711371 {
1372- static char repr[50];
1372+ static char repr[100];
13731373 BufferObject *this = (BufferObject *)(self);
13741374
13751375 if (this->buf == INVALID_BUFFER_VALUE)
13761376 {
1377- sprintf(repr, _("<buffer object (deleted) at %8lX>"), (long)(self));
1377+ vim_snprintf(repr, 100, _("<buffer object (deleted) at %8lX>"),
1378+ (long)(self));
13781379 return PyString_FromString(repr);
13791380 }
13801381 else
@@ -1389,7 +1390,7 @@
13891390 if (len > 35)
13901391 name = name + (35 - len);
13911392
1392- sprintf(repr, "<buffer %s%s>", len > 35 ? "..." : "", name);
1393+ vim_snprintf(repr, 100, "<buffer %s%s>", len > 35 ? "..." : "", name);
13931394
13941395 return PyString_FromString(repr);
13951396 }
@@ -1588,12 +1589,12 @@
15881589 static PyObject *
15891590 RangeRepr(PyObject *self)
15901591 {
1591- static char repr[75];
1592+ static char repr[100];
15921593 RangeObject *this = (RangeObject *)(self);
15931594
15941595 if (this->buf->buf == INVALID_BUFFER_VALUE)
15951596 {
1596- sprintf(repr, "<range object (for deleted buffer) at %8lX>",
1597+ vim_snprintf(repr, 100, "<range object (for deleted buffer) at %8lX>",
15971598 (long)(self));
15981599 return PyString_FromString(repr);
15991600 }
@@ -1609,7 +1610,7 @@
16091610 if (len > 45)
16101611 name = name + (45 - len);
16111612
1612- sprintf(repr, "<range %s%s (%d:%d)>",
1613+ vim_snprintf(repr, 100, "<range %s%s (%d:%d)>",
16131614 len > 45 ? "..." : "", name,
16141615 this->start, this->end);
16151616
@@ -1963,12 +1964,13 @@
19631964 static PyObject *
19641965 WindowRepr(PyObject *self)
19651966 {
1966- static char repr[50];
1967+ static char repr[100];
19671968 WindowObject *this = (WindowObject *)(self);
19681969
19691970 if (this->win == INVALID_WINDOW_VALUE)
19701971 {
1971- sprintf(repr, _("<window object (deleted) at %.8lX>"), (long)(self));
1972+ vim_snprintf(repr, 100, _("<window object (deleted) at %.8lX>"),
1973+ (long)(self));
19721974 return PyString_FromString(repr);
19731975 }
19741976 else
@@ -1980,9 +1982,10 @@
19801982 ++i;
19811983
19821984 if (w == NULL)
1983- sprintf(repr, _("<window object (unknown) at %.8lX>"), (long)(self));
1985+ vim_snprintf(repr, 100, _("<window object (unknown) at %.8lX>"),
1986+ (long)(self));
19841987 else
1985- sprintf(repr, _("<window %d>"), i);
1988+ vim_snprintf(repr, 100, _("<window %d>"), i);
19861989
19871990 return PyString_FromString(repr);
19881991 }
diff -r 2463194c8cdd -r 8fa8d7964cf1 src/if_tcl.c
--- a/src/if_tcl.c Thu May 19 21:00:46 2005 +0000
+++ b/src/if_tcl.c Thu May 19 21:08:39 2005 +0000
@@ -852,7 +852,9 @@
852852 else
853853 {
854854 char rbuf[64];
855- sprintf(rbuf, _("row %d column %d"), (int)row2tcl(pos->lnum), (int)col2tcl(pos->col));
855+
856+ sprintf(rbuf, _("row %d column %d"),
857+ (int)row2tcl(pos->lnum), (int)col2tcl(pos->col));
856858 Tcl_SetResult(interp, rbuf, TCL_VOLATILE);
857859 }
858860 break;
@@ -874,7 +876,8 @@
874876 --val1;
875877 if (u_save((linenr_T)val1, (linenr_T)(val1+1)) != OK)
876878 {
877- Tcl_SetResult(interp, _("cannot save undo information"), TCL_STATIC);
879+ Tcl_SetResult(interp, _("cannot save undo information"),
880+ TCL_STATIC);
878881 err = TCL_ERROR;
879882 break;
880883 }
@@ -882,7 +885,8 @@
882885 line = Tcl_GetStringFromObj(objv[3], NULL);
883886 if (ml_append((linenr_T)val1, (char_u *)line, 0, FALSE) != OK)
884887 {
885- Tcl_SetResult(interp, _("cannot insert/append line"), TCL_STATIC);
888+ Tcl_SetResult(interp, _("cannot insert/append line"),
889+ TCL_STATIC);
886890 err = TCL_ERROR;
887891 break;
888892 }
@@ -1067,6 +1071,7 @@
10671071 if (objc == 2)
10681072 {
10691073 char buf[64];
1074+
10701075 sprintf(buf, _("row %d column %d"), (int)row2tcl(win->w_cursor.lnum), (int)col2tcl(win->w_cursor.col));
10711076 Tcl_SetResult(interp, buf, TCL_VOLATILE);
10721077 break;
@@ -1486,7 +1491,8 @@
14861491 }
14871492
14881493 if (ref)
1489- sprintf(name, "::vim::%s", Tcl_GetCommandName(interp, ref->cmd));
1494+ vim_snprintf(name, sizeof(name), "::vim::%s",
1495+ Tcl_GetCommandName(interp, ref->cmd));
14901496 else
14911497 {
14921498 if (unused)
@@ -1507,7 +1513,8 @@
15071513 }
15081514
15091515 /* This might break on some exotic systems... */
1510- sprintf(name, "::vim::%s_%lx", prefix, (unsigned long)vimobj);
1516+ vim_snprintf(name, sizeof(name), "::vim::%s_%lx",
1517+ prefix, (unsigned long)vimobj);
15111518 cmd = Tcl_CreateObjCommand(interp, name, proc,
15121519 (ClientData)ref, (Tcl_CmdDeleteProc *)delref);
15131520 if (!cmd)
@@ -1881,7 +1888,7 @@
18811888 if (error == TCL_EXIT )
18821889 {
18831890 int retval;
1884- char buf[32];
1891+ char buf[50];
18851892 Tcl_Obj *robj;
18861893
18871894 robj = Tcl_GetObjResult(tclinfo.interp);
@@ -1892,7 +1899,7 @@
18921899 }
18931900 else
18941901 {
1895- sprintf(buf, "E572: exit code %d", retval);
1902+ sprintf(buf, _("E572: exit code %d"), retval);
18961903 tclerrmsg(buf);
18971904 if (retval == 0 )
18981905 {
diff -r 2463194c8cdd -r 8fa8d7964cf1 src/memline.c
--- a/src/memline.c Thu May 19 21:00:46 2005 +0000
+++ b/src/memline.c Thu May 19 21:08:39 2005 +0000
@@ -1015,13 +1015,13 @@
10151015 }
10161016
10171017 home_replace(NULL, mfp->mf_fname, NameBuff, MAXPATHL, TRUE);
1018- msg_str((char_u *)_("Using swap file \"%s\""), NameBuff);
1018+ smsg((char_u *)_("Using swap file \"%s\""), NameBuff);
10191019
10201020 if (buf_spname(curbuf) != NULL)
10211021 STRCPY(NameBuff, buf_spname(curbuf));
10221022 else
10231023 home_replace(NULL, curbuf->b_ffname, NameBuff, MAXPATHL, TRUE);
1024- msg_str((char_u *)_("Original file \"%s\""), NameBuff);
1024+ smsg((char_u *)_("Original file \"%s\""), NameBuff);
10251025 msg_putchar('\n');
10261026
10271027 /*
diff -r 2463194c8cdd -r 8fa8d7964cf1 src/misc1.c
--- a/src/misc1.c Thu May 19 21:00:46 2005 +0000
+++ b/src/misc1.c Thu May 19 21:08:39 2005 +0000
@@ -3295,7 +3295,7 @@
32953295 if (exp != NULL && *exp != NUL
32963296 && STRLEN(exp) + STRLEN(p) < MAXPATHL)
32973297 {
3298- sprintf((char *)NameBuff, "%s%s", exp, p + 1);
3298+ vim_snprintf((char *)NameBuff, MAXPATHL, "%s%s", exp, p + 1);
32993299 var = NameBuff;
33003300 /* Also set $HOME, it's needed for _viminfo. */
33013301 vim_setenv((char_u *)"HOME", NameBuff);
diff -r 2463194c8cdd -r 8fa8d7964cf1 src/ops.c
--- a/src/ops.c Thu May 19 21:00:46 2005 +0000
+++ b/src/ops.c Thu May 19 21:08:39 2005 +0000
@@ -5226,7 +5226,7 @@
52265226 #endif
52275227 default:
52285228 sprintf((char *)IObuff, _("E574: Unknown register type %d"),
5229- y_regs[i].y_type);
5229+ y_regs[i].y_type);
52305230 emsg(IObuff);
52315231 type = (char_u *)"LINE";
52325232 break;
@@ -5943,8 +5943,8 @@
59435943 cursor_pos_info()
59445944 {
59455945 char_u *p;
5946- char_u buf1[20];
5947- char_u buf2[20];
5946+ char_u buf1[50];
5947+ char_u buf2[40];
59485948 linenr_T lnum;
59495949 long byte_count = 0;
59505950 long byte_count_cursor = 0;
@@ -6106,7 +6106,7 @@
61066106 buf1[0] = NUL;
61076107
61086108 if (char_count_cursor == byte_count_cursor
6109- && char_count == byte_count)
6109+ && char_count == byte_count)
61106110 sprintf((char *)IObuff, _("Selected %s%ld of %ld Lines; %ld of %ld Words; %ld of %ld Bytes"),
61116111 buf1, line_count_selected,
61126112 (long)curbuf->b_ml.ml_line_count,
diff -r 2463194c8cdd -r 8fa8d7964cf1 src/option.c
--- a/src/option.c Thu May 19 21:00:46 2005 +0000
+++ b/src/option.c Thu May 19 21:08:39 2005 +0000
@@ -2571,7 +2571,7 @@
25712571 static char_u *check_clipboard_option __ARGS((void));
25722572 #endif
25732573 static char_u *set_bool_option __ARGS((int opt_idx, char_u *varp, int value, int opt_flags));
2574-static char_u *set_num_option __ARGS((int opt_idx, char_u *varp, long value, char_u *errbuf, int opt_flags));
2574+static char_u *set_num_option __ARGS((int opt_idx, char_u *varp, long value, char_u *errbuf, size_t errbuflen, int opt_flags));
25752575 static void check_redraw __ARGS((long_u flags));
25762576 static int findoption __ARGS((char_u *));
25772577 static int find_key_option __ARGS((char_u *));
@@ -3881,7 +3881,7 @@
38813881 if (removing)
38823882 value = *(long *)varp - value;
38833883 errmsg = set_num_option(opt_idx, varp, value,
3884- errbuf, opt_flags);
3884+ errbuf, sizeof(errbuf), opt_flags);
38853885 }
38863886 else if (opt_idx >= 0) /* string */
38873887 {
@@ -4287,7 +4287,7 @@
42874287 if (errbuf == NULL)
42884288 return (char_u *)"";
42894289 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
4290- (char *)transchar(c));
4290+ (char *)transchar(c));
42914291 return errbuf;
42924292 }
42934293
@@ -6822,11 +6822,12 @@
68226822 * Returns NULL for success, or an error message for an error.
68236823 */
68246824 static char_u *
6825-set_num_option(opt_idx, varp, value, errbuf, opt_flags)
6825+set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags)
68266826 int opt_idx; /* index in options[] table */
68276827 char_u *varp; /* pointer to the option variable */
68286828 long value; /* new value */
68296829 char_u *errbuf; /* buffer for error messages */
6830+ size_t errbuflen; /* length of "errbuf" */
68306831 int opt_flags; /* OPT_LOCAL, OPT_GLOBAL and
68316832 OPT_MODELINE */
68326833 {
@@ -7116,8 +7117,8 @@
71167117 {
71177118 if (errbuf != NULL)
71187119 {
7119- sprintf((char *)errbuf, _("E593: Need at least %d lines"),
7120- min_rows());
7120+ vim_snprintf((char *)errbuf, errbuflen,
7121+ _("E593: Need at least %d lines"), min_rows());
71217122 errmsg = errbuf;
71227123 }
71237124 Rows = min_rows();
@@ -7126,8 +7127,8 @@
71267127 {
71277128 if (errbuf != NULL)
71287129 {
7129- sprintf((char *)errbuf, _("E594: Need at least %d columns"),
7130- MIN_COLUMNS);
7130+ vim_snprintf((char *)errbuf, errbuflen,
7131+ _("E594: Need at least %d columns"), MIN_COLUMNS);
71317132 errmsg = errbuf;
71327133 }
71337134 Columns = MIN_COLUMNS;
@@ -7453,7 +7454,8 @@
74537454 if (varp != NULL) /* hidden option is not changed */
74547455 {
74557456 if (flags & P_NUM)
7456- (void)set_num_option(opt_idx, varp, number, NULL, opt_flags);
7457+ (void)set_num_option(opt_idx, varp, number,
7458+ NULL, 0, opt_flags);
74577459 else
74587460 (void)set_bool_option(opt_idx, varp, (int)number, opt_flags);
74597461 }
diff -r 2463194c8cdd -r 8fa8d7964cf1 src/po/it.po
--- a/src/po/it.po Thu May 19 21:00:46 2005 +0000
+++ b/src/po/it.po Thu May 19 21:08:39 2005 +0000
@@ -1309,7 +1309,7 @@
13091309 msgstr "1 sostituzione"
13101310
13111311 #: ex_cmds.c:4550
1312-#, fuzzy, c-format
1312+#, c-format
13131313 msgid "%ld matches"
13141314 msgstr "%ld corrisp."
13151315
@@ -1608,7 +1608,6 @@
16081608 msgstr "In aggiunta al File"
16091609
16101610 #: ex_docmd.c:7225
1611-#, fuzzy
16121611 msgid "E747: Cannot change directory, buffer is modifed (add ! to override)"
16131612 msgstr ""
16141613 "E747: Non posso cambiare directory, buffer modificato (aggiungi ! per "
@@ -2271,7 +2270,6 @@
22712270 msgstr "W16: Attenzione: Modo File \"%s\" modificato dopo l'apertura"
22722271
22732272 #: fileio.c:6066
2274-#, fuzzy
22752273 msgid "See \":help W16\" for more info."
22762274 msgstr "Vedere \":help W16\" per ulteriori informazioni."
22772275
@@ -5600,7 +5598,6 @@
56005598 msgstr "E382: Non posso scrivere, l'opzione 'buftype' è impostata"
56015599
56025600 #: quickfix.c:2379
5603-#, fuzzy
56045601 msgid "E682: Invalid search pattern or delimiter"
56055602 msgstr "E682: Espressione o delimitatore di ricerca non validi"
56065603
@@ -6688,7 +6685,6 @@
66886685 msgstr "con GUI (classica)."
66896686
66906687 #: version.c:876
6691-#, fuzzy
66926688 msgid "with KDE GUI."
66936689 msgstr "con GUI KDE."
66946690
@@ -7002,7 +6998,6 @@
70026998 msgstr "E588: :endwhile senza :while"
70036999
70047000 #: globals.h:1276
7005-#, fuzzy
70067001 msgid "E588: :endfor without :for"
70077002 msgstr "E588: :endfor senza :for"
70087003
diff -r 2463194c8cdd -r 8fa8d7964cf1 src/proto/misc2.pro
--- a/src/proto/misc2.pro Thu May 19 21:00:46 2005 +0000
+++ b/src/proto/misc2.pro Thu May 19 21:08:39 2005 +0000
@@ -92,5 +92,4 @@
9292 void sort_strings __ARGS((char_u **files, int count));
9393 int pathcmp __ARGS((const char *p, const char *q, int maxlen));
9494 char_u *parse_list_options __ARGS((char_u *option_str, option_table_T *table, int table_size));
95-void msg_str __ARGS((char_u *s, char_u *arg));
9695 /* vim: set ft=c : */
diff -r 2463194c8cdd -r 8fa8d7964cf1 src/search.c
--- a/src/search.c Thu May 19 21:00:46 2005 +0000
+++ b/src/search.c Thu May 19 21:08:39 2005 +0000
@@ -4278,8 +4278,9 @@
42784278 #ifdef FEAT_INS_EXPAND
42794279 if (action == ACTION_EXPAND)
42804280 {
4281- sprintf((char*)IObuff, _("Scanning included file: %s"),
4282- (char *)new_fname);
4281+ vim_snprintf((char*)IObuff, IOSIZE,
4282+ _("Scanning included file: %s"),
4283+ (char *)new_fname);
42834284 msg_trunc_attr(IObuff, TRUE, hl_attr(HLF_R));
42844285 }
42854286 #endif
diff -r 2463194c8cdd -r 8fa8d7964cf1 src/syntax.c
--- a/src/syntax.c Thu May 19 21:00:46 2005 +0000
+++ b/src/syntax.c Thu May 19 21:08:39 2005 +0000
@@ -3433,7 +3433,7 @@
34333433 if (!eap->skip)
34343434 {
34353435 STRCPY(buf, "so ");
3436- sprintf((char *)buf + 3, SYNTAX_FNAME, name);
3436+ vim_snprintf((char *)buf + 3, sizeof(buf) - 3, SYNTAX_FNAME, name);
34373437 do_cmdline_cmd(buf);
34383438 }
34393439 }
diff -r 2463194c8cdd -r 8fa8d7964cf1 src/ui.c
--- a/src/ui.c Thu May 19 21:00:46 2005 +0000
+++ b/src/ui.c Thu May 19 21:08:39 2005 +0000
@@ -2140,7 +2140,7 @@
21402140 clip_yank_selection(MCHAR, buffer, (long)nbytes, cbd);
21412141 XFree((void *)buffer);
21422142 if (p_verbose > 0)
2143- smsg((char_u *)_("Used CUT_BUFFER0 instead of empty selection") );
2143+ MSG(_("Used CUT_BUFFER0 instead of empty selection"));
21442144 }
21452145 }
21462146
Show on old repository browser