Mirror of the Vim source from https://github.com/vim/vim
Revisión | 8fa8d7964cf116fa98895d029808a0d5e1cf201b (tree) |
---|---|
Tiempo | 2005-05-20 06:08:39 |
Autor | vimboss |
Commiter | vimboss |
updated for version 7.0073
@@ -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 | |
2 | 2 | |
3 | 3 | |
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
@@ -88,10 +88,6 @@ | ||
88 | 88 | |
89 | 89 | setline() should accept a List. |
90 | 90 | |
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 | - | |
95 | 91 | Add ":[range]sort" command. Sort on specified field, using a regexp? Remove |
96 | 92 | duplicates? |
97 | 93 |
@@ -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 | |
2 | 2 | |
3 | 3 | |
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
@@ -1068,4 +1068,8 @@ | ||
1068 | 1068 | When "~" is in 'iskeyword' the "gd" doesn't work, it's used for the previous |
1069 | 1069 | substitute pattern. Put "\V" in the pattern to avoid that. |
1070 | 1070 | |
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 | + | |
1071 | 1075 | vim:tw=78:ts=8:ft=help:norl: |
@@ -1,7 +1,8 @@ | ||
1 | 1 | " Vim indent file |
2 | 2 | " 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 | |
5 | 6 | |
6 | 7 | " Only load this indent file when no other was loaded. |
7 | 8 | if exists("b:did_indent") |
@@ -9,7 +10,6 @@ | ||
9 | 10 | endif |
10 | 11 | let b:did_indent = 1 |
11 | 12 | |
12 | -" Autoindent is the best we can do. | |
13 | -setlocal ai | |
13 | +setlocal ai nosi | |
14 | 14 | |
15 | -let b:undo_indent = "setl ai<" | |
15 | +let b:undo_indent = "setl ai< si<" |
@@ -14,11 +14,7 @@ | ||
14 | 14 | " I also recommend setting the default 'Comment' hilighting to something |
15 | 15 | " other than the color used for 'Function', since both are plentiful in |
16 | 16 | " 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). | |
22 | 18 | " |
23 | 19 | " Credits: |
24 | 20 | " o Original Mathematica syntax version written by |
@@ -45,16 +41,6 @@ | ||
45 | 41 | syntax cluster mmaStrings contains=@mmaCommentStrings,mmaString |
46 | 42 | syntax cluster mmaTop contains=mmaOperator,mmaGenericFunction,mmaPureFunction,mmaVariable |
47 | 43 | |
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 | - | |
58 | 44 | " Predefined Constants: |
59 | 45 | " to list all predefined Symbols would be too insane... |
60 | 46 | " it's probably smarter to define a select few, and get the rest from |
@@ -89,41 +75,24 @@ | ||
89 | 75 | " function attributes |
90 | 76 | syntax keyword mmaVariable Protected Listable OneIdentity Orderless Flat Constant NumericFunction Locked ReadProtected HoldFirst HoldRest HoldAll HoldAllComplete SequenceHold NHoldFirst NHoldRest NHoldAll Temporary Stub |
91 | 77 | |
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 | |
101 | 82 | |
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 | - | |
113 | 83 | " Comment Keywords: |
114 | 84 | syntax keyword mmaTodo TODO NOTE HEY contained |
115 | 85 | syntax match mmaTodo "X\{3,}" contained |
116 | 86 | syntax keyword mmaFixme FIX[ME] FIXTHIS BROKEN contained |
117 | 87 | " yay pirates... |
118 | 88 | syntax match mmaFixme "\%(Y\=A\+R\+G\+\|GRR\+\|CR\+A\+P\+\)\%(!\+\)\=" contained |
119 | -syntax match mmaemPHAsis "\(_\+\)[ a-zA-Z0-9]\+\1" contained | |
120 | 89 | |
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 | |
125 | 94 | |
126 | -" Actual Mathematica Comments: | |
95 | +" Regular Comments: | |
127 | 96 | " (* *) |
128 | 97 | " allow nesting (* (* *) *) even though the frontend |
129 | 98 | " won't always like it. |
@@ -141,6 +110,19 @@ | ||
141 | 110 | " catch preceding * |
142 | 111 | syntax match mmaCommentStar "^\s*\*\+" contained |
143 | 112 | |
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 | + | |
144 | 126 | " Patterns: |
145 | 127 | " Each pattern marker below can be Blank[] (_), BlankSequence[] (__) |
146 | 128 | " or BlankNullSequence[] (___). Most examples below can also be |
@@ -197,7 +179,25 @@ | ||
197 | 179 | syntax match mmaOperator "\%(\~\~\=\)" |
198 | 180 | syntax match mmaOperator "\%(=\{2,3}\|=\=!=\|||\=\|&&\|!\)" contains=ALLBUT,mmaPureFunction |
199 | 181 | |
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 | + | |
201 | 201 | " Special Characters: |
202 | 202 | " \[Name] named character |
203 | 203 | " \ooo octal |
@@ -243,10 +243,10 @@ | ||
243 | 243 | HiLink mmaFunctionComment Comment |
244 | 244 | HiLink mmaLooseQuote Comment |
245 | 245 | HiLink mmaGenericFunction Function |
246 | + HiLink mmaVariable Identifier | |
246 | 247 | HiLink mmaOperator Operator |
247 | 248 | HiLink mmaPatternOp Operator |
248 | 249 | HiLink mmaPureFunction Operator |
249 | - HiLink mmaVariable Identifier | |
250 | 250 | HiLink mmaString String |
251 | 251 | HiLink mmaCommentString String |
252 | 252 | HiLink mmaUnicode String |
@@ -2459,7 +2459,7 @@ | ||
2459 | 2459 | */ |
2460 | 2460 | for (i = 0; i < curbuf->b_kmap_ga.ga_len; ++i) |
2461 | 2461 | { |
2462 | - sprintf((char *)buf, "<buffer> %s %s", | |
2462 | + vim_snprintf((char *)buf, sizeof(buf), "<buffer> %s %s", | |
2463 | 2463 | ((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].from, |
2464 | 2464 | ((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].to); |
2465 | 2465 | (void)do_map(2, buf, LANGMAP, FALSE); |
@@ -2492,8 +2492,8 @@ | ||
2492 | 2492 | /* clear the ":lmap"s */ |
2493 | 2493 | for (i = 0; i < curbuf->b_kmap_ga.ga_len; ++i) |
2494 | 2494 | { |
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); | |
2497 | 2497 | (void)do_map(1, buf, LANGMAP, FALSE); |
2498 | 2498 | } |
2499 | 2499 |
@@ -2218,8 +2218,8 @@ | ||
2218 | 2218 | fp = mch_fopen((char *)files[i], "r"); /* open dictionary file */ |
2219 | 2219 | if (flags != DICT_EXACT) |
2220 | 2220 | { |
2221 | - sprintf((char*)IObuff, _("Scanning dictionary: %s"), | |
2222 | - (char *)files[i]); | |
2221 | + vim_snprintf((char *)IObuff, IOSIZE, | |
2222 | + _("Scanning dictionary: %s"), (char *)files[i]); | |
2223 | 2223 | msg_trunc_attr(IObuff, TRUE, hl_attr(HLF_R)); |
2224 | 2224 | } |
2225 | 2225 |
@@ -2827,7 +2827,7 @@ | ||
2827 | 2827 | dict = ins_buf->b_fname; |
2828 | 2828 | dict_f = DICT_EXACT; |
2829 | 2829 | } |
2830 | - sprintf((char *)IObuff, _("Scanning: %s"), | |
2830 | + vim_snprintf((char *)IObuff, IOSIZE, _("Scanning: %s"), | |
2831 | 2831 | ins_buf->b_fname == NULL |
2832 | 2832 | ? buf_spname(ins_buf) |
2833 | 2833 | : ins_buf->b_sfname == NULL |
@@ -11414,7 +11414,7 @@ | ||
11414 | 11414 | if (argvars[2].v_type != VAR_UNKNOWN) |
11415 | 11415 | { |
11416 | 11416 | dictitem_T v; |
11417 | - char_u str[30]; | |
11417 | + char_u str[30]; | |
11418 | 11418 | |
11419 | 11419 | sprintf((char *)str, "0x%x", (unsigned int)w); |
11420 | 11420 | v.di_tv.v_type = VAR_STRING; |
@@ -16867,7 +16867,7 @@ | ||
16867 | 16867 | { |
16868 | 16868 | ++no_wait_return; |
16869 | 16869 | 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); | |
16871 | 16871 | if (p_verbose >= 14) |
16872 | 16872 | { |
16873 | 16873 | char_u buf[MSG_BUF_LEN]; |
@@ -16950,30 +16950,26 @@ | ||
16950 | 16950 | /* when being verbose, mention the return value */ |
16951 | 16951 | if (p_verbose >= 12) |
16952 | 16952 | { |
16953 | - char_u *sn; | |
16954 | - | |
16955 | 16953 | ++no_wait_return; |
16956 | 16954 | msg_scroll = TRUE; /* always scroll up, don't overwrite */ |
16957 | 16955 | |
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 | - | |
16963 | 16956 | if (aborting()) |
16964 | - smsg((char_u *)_("%s aborted"), sn); | |
16957 | + smsg((char_u *)_("%s aborted"), sourcing_name); | |
16965 | 16958 | 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); | |
16968 | 16961 | else |
16969 | 16962 | { |
16970 | 16963 | char_u buf[MSG_BUF_LEN]; |
16971 | 16964 | char_u numbuf[NUMBUFLEN]; |
16972 | 16965 | char_u *tofree; |
16973 | 16966 | |
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. */ | |
16974 | 16970 | trunc_string(tv2string(fc.rettv, &tofree, numbuf), |
16975 | 16971 | buf, MSG_BUF_CLEN); |
16976 | - smsg((char_u *)_("%s returning %s"), sn, buf); | |
16972 | + smsg((char_u *)_("%s returning %s"), sourcing_name, buf); | |
16977 | 16973 | vim_free(tofree); |
16978 | 16974 | } |
16979 | 16975 | msg_puts((char_u *)"\n"); /* don't overwrite this either */ |
@@ -16994,7 +16990,7 @@ | ||
16994 | 16990 | { |
16995 | 16991 | ++no_wait_return; |
16996 | 16992 | 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); | |
16998 | 16994 | msg_puts((char_u *)"\n"); /* don't overwrite this either */ |
16999 | 16995 | cmdline_row = msg_row; |
17000 | 16996 | --no_wait_return; |
@@ -89,8 +89,9 @@ | ||
89 | 89 | else |
90 | 90 | #endif |
91 | 91 | 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); | |
94 | 95 | #ifdef FEAT_MBYTE |
95 | 96 | c = c1; |
96 | 97 | c1 = c2; |
@@ -113,8 +114,8 @@ | ||
113 | 114 | #endif |
114 | 115 | ) |
115 | 116 | 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, | |
118 | 119 | c < 0x10000 ? _("> %d, Hex %04x, Octal %o") |
119 | 120 | : _("> %d, Hex %08x, Octal %o"), c, c, c); |
120 | 121 | c = c1; |
@@ -974,8 +975,8 @@ | ||
974 | 975 | { |
975 | 976 | if (do_in) |
976 | 977 | { |
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); | |
979 | 980 | if (msg(msg_buf) && !msg_scroll) |
980 | 981 | { |
981 | 982 | /* save message to display it after redraw */ |
@@ -1337,7 +1338,8 @@ | ||
1337 | 1338 | char *message; |
1338 | 1339 | char_u *line; |
1339 | 1340 | { |
1340 | - sprintf((char *)IObuff, _("%sviminfo: %s in line: "), errnum, message); | |
1341 | + vim_snprintf((char *)IObuff, IOSIZE, _("%sviminfo: %s in line: "), | |
1342 | + errnum, message); | |
1341 | 1343 | STRNCAT(IObuff, line, IOSIZE - STRLEN(IObuff)); |
1342 | 1344 | if (IObuff[STRLEN(IObuff) - 1] == '\n') |
1343 | 1345 | IObuff[STRLEN(IObuff) - 1] = NUL; |
@@ -1373,17 +1375,11 @@ | ||
1373 | 1375 | fp = mch_fopen((char *)fname, READBIN); |
1374 | 1376 | |
1375 | 1377 | 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") : ""); | |
1387 | 1383 | |
1388 | 1384 | vim_free(fname); |
1389 | 1385 | if (fp == NULL) |
@@ -1607,7 +1603,7 @@ | ||
1607 | 1603 | } |
1608 | 1604 | |
1609 | 1605 | if (p_verbose > 0) |
1610 | - msg_str((char_u *)_("Writing viminfo file \"%s\""), fname); | |
1606 | + smsg((char_u *)_("Writing viminfo file \"%s\""), fname); | |
1611 | 1607 | |
1612 | 1608 | viminfo_errcnt = 0; |
1613 | 1609 | do_viminfo(fp_in, fp_out, !forceit, !forceit, FALSE); |
@@ -4529,6 +4525,8 @@ | ||
4529 | 4525 | do_sub_msg(count_only) |
4530 | 4526 | int count_only; /* used 'n' flag for ":s" */ |
4531 | 4527 | { |
4528 | + int len = 0; | |
4529 | + | |
4532 | 4530 | /* |
4533 | 4531 | * Only report substitutions when: |
4534 | 4532 | * - more than 'report' substitutions |
@@ -4540,20 +4538,24 @@ | ||
4540 | 4538 | && messaging()) |
4541 | 4539 | { |
4542 | 4540 | if (got_int) |
4541 | + { | |
4543 | 4542 | 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")); | |
4544 | 4548 | 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, | |
4550 | 4550 | count_only ? _("%ld matches") : _("%ld substitutions"), |
4551 | 4551 | sub_nsubs); |
4552 | + len = STRLEN(msg_buf); | |
4552 | 4553 | 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")); | |
4554 | 4556 | 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); | |
4557 | 4559 | if (msg(msg_buf)) |
4558 | 4560 | { |
4559 | 4561 | /* save message to display it after redraw */ |
@@ -4686,9 +4688,9 @@ | ||
4686 | 4688 | else if (ndone == 0) |
4687 | 4689 | { |
4688 | 4690 | 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); | |
4690 | 4692 | else |
4691 | - msg_str((char_u *)_(e_patnotf2), pat); | |
4693 | + smsg((char_u *)_(e_patnotf2), pat); | |
4692 | 4694 | } |
4693 | 4695 | else |
4694 | 4696 | global_exe(cmd); |
@@ -4955,8 +4957,7 @@ | ||
4955 | 4957 | */ |
4956 | 4958 | if ((helpfd = mch_fopen((char *)p_hf, READBIN)) == NULL) |
4957 | 4959 | { |
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); | |
4960 | 4961 | goto erret; |
4961 | 4962 | } |
4962 | 4963 | fclose(helpfd); |
@@ -5660,7 +5661,7 @@ | ||
5660 | 5661 | got_int = TRUE; |
5661 | 5662 | else |
5662 | 5663 | { |
5663 | - s = alloc(30); | |
5664 | + s = alloc(18 + STRLEN(tagfname)); | |
5664 | 5665 | if (s == NULL) |
5665 | 5666 | got_int = TRUE; |
5666 | 5667 | else |
@@ -5793,7 +5794,7 @@ | ||
5793 | 5794 | if (*p2 == '\t') |
5794 | 5795 | { |
5795 | 5796 | *p2 = NUL; |
5796 | - sprintf((char *)NameBuff, | |
5797 | + vim_snprintf((char *)NameBuff, MAXPATHL, | |
5797 | 5798 | _("E154: Duplicate tag \"%s\" in file %s/%s"), |
5798 | 5799 | ((char_u **)ga.ga_data)[i], dir, p2 + 1); |
5799 | 5800 | EMSG(NameBuff); |
@@ -6307,7 +6308,7 @@ | ||
6307 | 6308 | { |
6308 | 6309 | char_u *p; |
6309 | 6310 | |
6310 | - msg_str((char_u *)"sign %s", sp->sn_name); | |
6311 | + smsg((char_u *)"sign %s", sp->sn_name); | |
6311 | 6312 | if (sp->sn_icon != NULL) |
6312 | 6313 | { |
6313 | 6314 | MSG_PUTS(" icon="); |
@@ -532,7 +532,7 @@ | ||
532 | 532 | EX(CMD_mode, "mode", ex_mode, |
533 | 533 | WORD1|TRLBAR|CMDWIN), |
534 | 534 | EX(CMD_mzscheme, "mzscheme", ex_mzscheme, |
535 | - RANGE|EXTRA|DFLALL|NEEDARG|CMDWIN), | |
535 | + RANGE|EXTRA|DFLALL|NEEDARG|CMDWIN|SBOXOK), | |
536 | 536 | EX(CMD_mzfile, "mzfile", ex_mzfile, |
537 | 537 | RANGE|FILE1|NEEDARG|CMDWIN), |
538 | 538 | EX(CMD_next, "next", ex_next, |
@@ -141,16 +141,9 @@ | ||
141 | 141 | if (sourcing_name != NULL) |
142 | 142 | msg(sourcing_name); |
143 | 143 | 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); | |
152 | 145 | else |
153 | - msg_str((char_u *)_("cmd: %s"), cmd); | |
146 | + smsg((char_u *)_("cmd: %s"), cmd); | |
154 | 147 | |
155 | 148 | /* |
156 | 149 | * Repeat getting a command and executing it. |
@@ -342,7 +335,8 @@ | ||
342 | 335 | p = (char_u *)"<SNR>"; |
343 | 336 | else |
344 | 337 | 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, | |
346 | 340 | debug_breakpoint_name + (*p == NUL ? 0 : 3), |
347 | 341 | (long)debug_breakpoint_lnum); |
348 | 342 | debug_breakpoint_name = NULL; |
@@ -2473,13 +2467,8 @@ | ||
2473 | 2467 | if (buf != NULL && rtp_copy != NULL) |
2474 | 2468 | { |
2475 | 2469 | 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\""), | |
2481 | 2471 | (char *)name, (char *)p_rtp); |
2482 | - } | |
2483 | 2472 | |
2484 | 2473 | /* Loop over all entries in 'runtimepath'. */ |
2485 | 2474 | rtp = rtp_copy; |
@@ -2501,7 +2490,7 @@ | ||
2501 | 2490 | "\t "); |
2502 | 2491 | |
2503 | 2492 | if (p_verbose > 2) |
2504 | - msg_str((char_u *)_("Searching for \"%s\""), buf); | |
2493 | + smsg((char_u *)_("Searching for \"%s\""), buf); | |
2505 | 2494 | |
2506 | 2495 | /* Expand wildcards, invoke the callback for each match. */ |
2507 | 2496 | if (gen_expand_wildcards(1, &buf, &num_files, &files, |
@@ -2523,7 +2512,7 @@ | ||
2523 | 2512 | vim_free(buf); |
2524 | 2513 | vim_free(rtp_copy); |
2525 | 2514 | 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); | |
2527 | 2516 | |
2528 | 2517 | #ifdef AMIGA |
2529 | 2518 | proc->pr_WindowPtr = save_winptr; |
@@ -2733,7 +2722,7 @@ | ||
2733 | 2722 | #endif |
2734 | 2723 | if (mch_isdir(fname_exp)) |
2735 | 2724 | { |
2736 | - msg_str((char_u *)_("Cannot source a directory: \"%s\""), fname); | |
2725 | + smsg((char_u *)_("Cannot source a directory: \"%s\""), fname); | |
2737 | 2726 | goto theend; |
2738 | 2727 | } |
2739 | 2728 |
@@ -2771,10 +2760,10 @@ | ||
2771 | 2760 | if (p_verbose > 0) |
2772 | 2761 | { |
2773 | 2762 | if (sourcing_name == NULL) |
2774 | - msg_str((char_u *)_("could not source \"%s\""), fname); | |
2763 | + smsg((char_u *)_("could not source \"%s\""), fname); | |
2775 | 2764 | else |
2776 | 2765 | smsg((char_u *)_("line %ld: could not source \"%s\""), |
2777 | - sourcing_lnum, fname); | |
2766 | + sourcing_lnum, fname); | |
2778 | 2767 | } |
2779 | 2768 | goto theend; |
2780 | 2769 | } |
@@ -2787,10 +2776,10 @@ | ||
2787 | 2776 | if (p_verbose > 1) |
2788 | 2777 | { |
2789 | 2778 | if (sourcing_name == NULL) |
2790 | - msg_str((char_u *)_("sourcing \"%s\""), fname); | |
2779 | + smsg((char_u *)_("sourcing \"%s\""), fname); | |
2791 | 2780 | else |
2792 | 2781 | smsg((char_u *)_("line %ld: sourcing \"%s\""), |
2793 | - sourcing_lnum, fname); | |
2782 | + sourcing_lnum, fname); | |
2794 | 2783 | } |
2795 | 2784 | if (is_vimrc) |
2796 | 2785 | vimrc_found(); |
@@ -2972,16 +2961,12 @@ | ||
2972 | 2961 | sourcing_lnum = save_sourcing_lnum; |
2973 | 2962 | if (p_verbose > 1) |
2974 | 2963 | { |
2975 | - msg_str((char_u *)_("finished sourcing %s"), fname); | |
2964 | + smsg((char_u *)_("finished sourcing %s"), fname); | |
2976 | 2965 | if (sourcing_name != NULL) |
2977 | - msg_str((char_u *)_("continuing in %s"), sourcing_name); | |
2966 | + smsg((char_u *)_("continuing in %s"), sourcing_name); | |
2978 | 2967 | } |
2979 | 2968 | #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); | |
2985 | 2970 | time_msg(IObuff, &tv_start); |
2986 | 2971 | time_pop(&tv_rel); |
2987 | 2972 | #endif |
@@ -4263,14 +4248,15 @@ | ||
4263 | 4248 | page_prtpos = prtpos; |
4264 | 4249 | } |
4265 | 4250 | |
4266 | - sprintf((char *)IObuff, _("Printed: %s"), settings.jobname); | |
4251 | + vim_snprintf((char *)IObuff, IOSIZE, _("Printed: %s"), | |
4252 | + settings.jobname); | |
4267 | 4253 | prt_message(IObuff); |
4268 | 4254 | } |
4269 | 4255 | |
4270 | 4256 | print_fail: |
4271 | 4257 | if (got_int || settings.user_abort) |
4272 | 4258 | { |
4273 | - sprintf((char *)IObuff, _("Printing aborted")); | |
4259 | + sprintf((char *)IObuff, "%s", _("Printing aborted")); | |
4274 | 4260 | prt_message(IObuff); |
4275 | 4261 | } |
4276 | 4262 | mch_print_end(&settings); |
@@ -4954,7 +4940,7 @@ | ||
4954 | 4940 | prt_write_string(s) |
4955 | 4941 | char *s; |
4956 | 4942 | { |
4957 | - sprintf((char *)prt_line_buffer, "%s", s); | |
4943 | + vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer), "%s", s); | |
4958 | 4944 | prt_write_file(prt_line_buffer); |
4959 | 4945 | } |
4960 | 4946 |
@@ -4990,8 +4976,8 @@ | ||
4990 | 4976 | int height; |
4991 | 4977 | char *font; |
4992 | 4978 | { |
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); | |
4995 | 4981 | prt_write_file(prt_line_buffer); |
4996 | 4982 | #ifdef FEAT_MBYTE |
4997 | 4983 | if (prt_out_mbyte) |
@@ -4999,8 +4985,8 @@ | ||
4999 | 4985 | new_name, height, 500./prt_ps_courier_font.wx, new_name); |
5000 | 4986 | else |
5001 | 4987 | #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); | |
5004 | 4990 | prt_write_file(prt_line_buffer); |
5005 | 4991 | } |
5006 | 4992 |
@@ -5014,11 +5000,11 @@ | ||
5014 | 5000 | int height; |
5015 | 5001 | char *cidfont; |
5016 | 5002 | { |
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); | |
5019 | 5005 | 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); | |
5022 | 5008 | prt_write_file(prt_line_buffer); |
5023 | 5009 | } |
5024 | 5010 |
@@ -5030,7 +5016,8 @@ | ||
5030 | 5016 | char *original_name; |
5031 | 5017 | char *new_name; |
5032 | 5018 | { |
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); | |
5034 | 5021 | prt_write_file(prt_line_buffer); |
5035 | 5022 | } |
5036 | 5023 | #endif |
@@ -5105,7 +5092,8 @@ | ||
5105 | 5092 | double value; |
5106 | 5093 | int prec; |
5107 | 5094 | { |
5108 | - sprintf((char *)prt_line_buffer, "/%s ", name); | |
5095 | + vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer), | |
5096 | + "/%s ", name); | |
5109 | 5097 | prt_write_file(prt_line_buffer); |
5110 | 5098 | prt_write_real(value, prec); |
5111 | 5099 | sprintf((char *)prt_line_buffer, "d\n"); |
@@ -5532,7 +5520,8 @@ | ||
5532 | 5520 | prt_dsc_noarg(comment) |
5533 | 5521 | char *comment; |
5534 | 5522 | { |
5535 | - sprintf((char *)prt_line_buffer, "%%%%%s\n", comment); | |
5523 | + vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer), | |
5524 | + "%%%%%s\n", comment); | |
5536 | 5525 | prt_write_file(prt_line_buffer); |
5537 | 5526 | } |
5538 | 5527 |
@@ -5541,7 +5530,8 @@ | ||
5541 | 5530 | char *comment; |
5542 | 5531 | char *text; |
5543 | 5532 | { |
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); | |
5545 | 5535 | prt_write_file(prt_line_buffer); |
5546 | 5536 | } |
5547 | 5537 |
@@ -5551,7 +5541,8 @@ | ||
5551 | 5541 | char *text; |
5552 | 5542 | { |
5553 | 5543 | /* 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); | |
5555 | 5546 | prt_write_file(prt_line_buffer); |
5556 | 5547 | } |
5557 | 5548 |
@@ -5565,7 +5556,8 @@ | ||
5565 | 5556 | { |
5566 | 5557 | int i; |
5567 | 5558 | |
5568 | - sprintf((char *)prt_line_buffer, "%%%%%s:", comment); | |
5559 | + vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer), | |
5560 | + "%%%%%s:", comment); | |
5569 | 5561 | prt_write_file(prt_line_buffer); |
5570 | 5562 | |
5571 | 5563 | for (i = 0; i < count; i++) |
@@ -5584,12 +5576,15 @@ | ||
5584 | 5576 | char *string; |
5585 | 5577 | { |
5586 | 5578 | 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); | |
5588 | 5581 | else |
5589 | - sprintf((char *)prt_line_buffer, "%%%%+ %s", type); | |
5582 | + vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer), | |
5583 | + "%%%%+ %s", type); | |
5590 | 5584 | prt_write_file(prt_line_buffer); |
5591 | 5585 | |
5592 | - sprintf((char *)prt_line_buffer, " %s\n", string); | |
5586 | + vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer), | |
5587 | + " %s\n", string); | |
5593 | 5588 | prt_write_file(prt_line_buffer); |
5594 | 5589 | } |
5595 | 5590 |
@@ -5654,7 +5649,8 @@ | ||
5654 | 5649 | char *colour; |
5655 | 5650 | char *type; |
5656 | 5651 | { |
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); | |
5658 | 5654 | prt_write_file(prt_line_buffer); |
5659 | 5655 | prt_write_real(width, 2); |
5660 | 5656 | prt_write_real(height, 2); |
@@ -93,6 +93,11 @@ | ||
93 | 93 | * Utility functions for the vim/mzscheme interface |
94 | 94 | *======================================================================== |
95 | 95 | */ |
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 | |
96 | 101 | /* Buffer-related commands */ |
97 | 102 | static Scheme_Object *buffer_new(buf_T *buf); |
98 | 103 | static Scheme_Object *get_buffer_by_name(void *, int, Scheme_Object **); |
@@ -205,11 +210,15 @@ | ||
205 | 210 | static Scheme_Object *(*dll_scheme_apply)(Scheme_Object *rator, int num_rands, |
206 | 211 | Scheme_Object **rands); |
207 | 212 | 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 | |
208 | 216 | static void (*dll_scheme_close_input_port)(Scheme_Object *port); |
209 | 217 | static void (*dll_scheme_count_lines)(Scheme_Object *port); |
210 | 218 | static Scheme_Object *(*dll_scheme_current_continuation_marks)(void); |
211 | 219 | static void (*dll_scheme_display)(Scheme_Object *obj, Scheme_Object *port); |
212 | 220 | static char *(*dll_scheme_display_to_string)(Scheme_Object *obj, long *len); |
221 | +static int (*dll_scheme_eq)(Scheme_Object *obj1, Scheme_Object *obj2); | |
213 | 222 | static Scheme_Object *(*dll_scheme_do_eval)(Scheme_Object *obj, |
214 | 223 | int _num_rands, Scheme_Object **rands, int val); |
215 | 224 | static void (*dll_scheme_dont_gc_ptr)(void *p); |
@@ -225,6 +234,7 @@ | ||
225 | 234 | # else |
226 | 235 | static char *(*dll_scheme_format_utf8)(char *format, int flen, int argc, |
227 | 236 | Scheme_Object **argv, long *rlen); |
237 | +static Scheme_Object *(*dll_scheme_get_param)(Scheme_Config *c, int pos); | |
228 | 238 | # endif |
229 | 239 | static void (*dll_scheme_gc_ptr_ok)(void *p); |
230 | 240 | # if MZSCHEME_VERSION_MAJOR < 299 |
@@ -245,6 +255,8 @@ | ||
245 | 255 | Scheme_Object *argv[]); |
246 | 256 | static Scheme_Object *(*dll_scheme_make_pair)(Scheme_Object *car, |
247 | 257 | Scheme_Object *cdr); |
258 | +static Scheme_Object *(*dll_scheme_make_prim_w_arity)(Scheme_Prim *prim, | |
259 | + const char *name, mzshort mina, mzshort maxa); | |
248 | 260 | # if MZSCHEME_VERSION_MAJOR < 299 |
249 | 261 | static Scheme_Object *(*dll_scheme_make_string)(const char *chars); |
250 | 262 | static Scheme_Object *(*dll_scheme_make_string_output_port)(); |
@@ -311,6 +323,9 @@ | ||
311 | 323 | # define scheme_apply dll_scheme_apply |
312 | 324 | # define scheme_basic_env dll_scheme_basic_env |
313 | 325 | # 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 | |
314 | 329 | # define scheme_check_threads dll_scheme_check_threads |
315 | 330 | # define scheme_close_input_port dll_scheme_close_input_port |
316 | 331 | # define scheme_count_lines dll_scheme_count_lines |
@@ -320,6 +335,7 @@ | ||
320 | 335 | # define scheme_display_to_string dll_scheme_display_to_string |
321 | 336 | # define scheme_do_eval dll_scheme_do_eval |
322 | 337 | # define scheme_dont_gc_ptr dll_scheme_dont_gc_ptr |
338 | +# define scheme_eq dll_scheme_eq | |
323 | 339 | # define scheme_eval dll_scheme_eval |
324 | 340 | # define scheme_eval_string dll_scheme_eval_string |
325 | 341 | # define scheme_eval_string_all dll_scheme_eval_string_all |
@@ -335,6 +351,7 @@ | ||
335 | 351 | # else |
336 | 352 | # define scheme_get_sized_byte_string_output \ |
337 | 353 | dll_scheme_get_sized_byte_string_output |
354 | +# define scheme_get_param dll_scheme_get_param | |
338 | 355 | # endif |
339 | 356 | # define scheme_intern_symbol dll_scheme_intern_symbol |
340 | 357 | # define scheme_lookup_global dll_scheme_lookup_global |
@@ -342,6 +359,7 @@ | ||
342 | 359 | # define scheme_make_integer_value dll_scheme_make_integer_value |
343 | 360 | # define scheme_make_namespace dll_scheme_make_namespace |
344 | 361 | # define scheme_make_pair dll_scheme_make_pair |
362 | +# define scheme_make_prim_w_arity dll_scheme_make_prim_w_arity | |
345 | 363 | # if MZSCHEME_VERSION_MAJOR < 299 |
346 | 364 | # define scheme_make_string dll_scheme_make_string |
347 | 365 | # define scheme_make_string_output_port dll_scheme_make_string_output_port |
@@ -399,6 +417,9 @@ | ||
399 | 417 | {"scheme_add_global_symbol", (void **)&dll_scheme_add_global_symbol}, |
400 | 418 | {"scheme_apply", (void **)&dll_scheme_apply}, |
401 | 419 | {"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 | |
402 | 423 | {"scheme_builtin_value", (void **)&dll_scheme_builtin_value}, |
403 | 424 | {"scheme_check_threads", (void **)&dll_scheme_check_threads}, |
404 | 425 | {"scheme_close_input_port", (void **)&dll_scheme_close_input_port}, |
@@ -409,6 +430,7 @@ | ||
409 | 430 | {"scheme_display_to_string", (void **)&dll_scheme_display_to_string}, |
410 | 431 | {"scheme_do_eval", (void **)&dll_scheme_do_eval}, |
411 | 432 | {"scheme_dont_gc_ptr", (void **)&dll_scheme_dont_gc_ptr}, |
433 | + {"scheme_eq", (void **)&dll_scheme_eq}, | |
412 | 434 | {"scheme_eval", (void **)&dll_scheme_eval}, |
413 | 435 | {"scheme_eval_string", (void **)&dll_scheme_eval_string}, |
414 | 436 | {"scheme_eval_string_all", (void **)&dll_scheme_eval_string_all}, |
@@ -418,6 +440,7 @@ | ||
418 | 440 | {"scheme_format", (void **)&dll_scheme_format}, |
419 | 441 | # else |
420 | 442 | {"scheme_format_utf8", (void **)&dll_scheme_format_utf8}, |
443 | + {"scheme_get_param", (void **)&dll_scheme_get_param}, | |
421 | 444 | #endif |
422 | 445 | {"scheme_gc_ptr_ok", (void **)&dll_scheme_gc_ptr_ok}, |
423 | 446 | # if MZSCHEME_VERSION_MAJOR < 299 |
@@ -434,6 +457,7 @@ | ||
434 | 457 | {"scheme_make_integer_value", (void **)&dll_scheme_make_integer_value}, |
435 | 458 | {"scheme_make_namespace", (void **)&dll_scheme_make_namespace}, |
436 | 459 | {"scheme_make_pair", (void **)&dll_scheme_make_pair}, |
460 | + {"scheme_make_prim_w_arity", (void **)&dll_scheme_make_prim_w_arity}, | |
437 | 461 | # if MZSCHEME_VERSION_MAJOR < 299 |
438 | 462 | {"scheme_make_string", (void **)&dll_scheme_make_string}, |
439 | 463 | {"scheme_make_string_output_port", |
@@ -727,6 +751,8 @@ | ||
727 | 751 | static void |
728 | 752 | startup_mzscheme(void) |
729 | 753 | { |
754 | + Scheme_Object *proc_make_security_guard; | |
755 | + | |
730 | 756 | scheme_set_stack_base(NULL, 1); |
731 | 757 | |
732 | 758 | MZ_REGISTER_STATIC(environment); |
@@ -751,7 +777,24 @@ | ||
751 | 777 | scheme_make_pair(scheme_make_string(MZSCHEME_COLLECTS), |
752 | 778 | scheme_null)); |
753 | 779 | #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 | |
755 | 798 | /* Create buffer and window types for use in Scheme code */ |
756 | 799 | mz_buffer_type = scheme_make_type("<vim-buffer>"); |
757 | 800 | mz_window_type = scheme_make_type("<vim-window>"); |
@@ -1579,6 +1622,9 @@ | ||
1579 | 1622 | long lnum = 0; |
1580 | 1623 | long col = 0; |
1581 | 1624 | |
1625 | +#ifdef HAVE_SANDBOX | |
1626 | + sandbox_check(); | |
1627 | +#endif | |
1582 | 1628 | win = get_window_arg(prim->name, 1, argc, argv); |
1583 | 1629 | GUARANTEE_PAIR(prim->name, 0); |
1584 | 1630 |
@@ -1615,6 +1661,9 @@ | ||
1615 | 1661 | int num = 0; |
1616 | 1662 | Scheme_Object *onum; |
1617 | 1663 | |
1664 | +#ifdef HAVE_SANDBOX | |
1665 | + sandbox_check(); | |
1666 | +#endif | |
1618 | 1667 | fname = SCHEME_STR_VAL(GUARANTEE_STRING(prim->name, 0)); |
1619 | 1668 | /* TODO make open existing file */ |
1620 | 1669 | num = buflist_add(fname, BLN_LISTED | BLN_CURBUF); |
@@ -1869,6 +1918,9 @@ | ||
1869 | 1918 | buf_T *savebuf; |
1870 | 1919 | int n; |
1871 | 1920 | |
1921 | +#ifdef HAVE_SANDBOX | |
1922 | + sandbox_check(); | |
1923 | +#endif | |
1872 | 1924 | n = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0)); |
1873 | 1925 | if (!SCHEME_STRINGP(argv[1]) && !SCHEME_FALSEP(argv[1])) |
1874 | 1926 | scheme_wrong_type(prim->name, "string or #f", 1, argc, argv); |
@@ -1958,6 +2010,9 @@ | ||
1958 | 2010 | int i, old_len, new_len, hi, lo; |
1959 | 2011 | long extra; |
1960 | 2012 | |
2013 | +#ifdef HAVE_SANDBOX | |
2014 | + sandbox_check(); | |
2015 | +#endif | |
1961 | 2016 | lo = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0)); |
1962 | 2017 | hi = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 1)); |
1963 | 2018 | if (!SCHEME_PAIRP(argv[2]) |
@@ -2121,6 +2176,9 @@ | ||
2121 | 2176 | buf_T *savebuf; |
2122 | 2177 | int i, n, size; |
2123 | 2178 | |
2179 | +#ifdef HAVE_SANDBOX | |
2180 | + sandbox_check(); | |
2181 | +#endif | |
2124 | 2182 | /* |
2125 | 2183 | * First of all, we check the type of the supplied MzScheme object. |
2126 | 2184 | * It must be a string or a list, or the call is in error. |
@@ -2380,8 +2438,9 @@ | ||
2380 | 2438 | if (add_info != NULL) |
2381 | 2439 | { |
2382 | 2440 | 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]); | |
2385 | 2444 | } |
2386 | 2445 | else |
2387 | 2446 | argv[0] = scheme_make_string(_("Vim error")); |
@@ -2596,3 +2655,66 @@ | ||
2596 | 2655 | scheme_add_global("global-namespace", (Scheme_Object *)environment, mod); |
2597 | 2656 | scheme_finish_primitive_module(mod); |
2598 | 2657 | } |
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 |
@@ -34,12 +34,13 @@ | ||
34 | 34 | # endif |
35 | 35 | # define scheme_format scheme_format_utf8 |
36 | 36 | |
37 | -# define GET_BYTE_STRING(obj) (SCHEME_BYTE_STRINGP(obj) ? obj : \ | |
37 | +# define SCHEME_GET_BYTE_STRING(obj) (SCHEME_BYTE_STRINGP(obj) ? obj : \ | |
38 | 38 | scheme_char_string_to_byte_string(obj)) |
39 | 39 | #else |
40 | -# define GET_BYTE_STRING(obj) (obj) | |
40 | +# define SCHEME_GET_BYTE_STRING(obj) (obj) | |
41 | 41 | # define SCHEME_BYTE_STRLEN_VAL SCHEME_STRLEN_VAL |
42 | 42 | # define SCHEME_BYTE_STR_VAL SCHEME_STR_VAL |
43 | +# define scheme_byte_string_to_char_string(obj) (obj) | |
43 | 44 | #endif |
44 | 45 | |
45 | 46 | #endif /* _IF_MZSCH_H_ */ |
@@ -1369,12 +1369,13 @@ | ||
1369 | 1369 | static PyObject * |
1370 | 1370 | BufferRepr(PyObject *self) |
1371 | 1371 | { |
1372 | - static char repr[50]; | |
1372 | + static char repr[100]; | |
1373 | 1373 | BufferObject *this = (BufferObject *)(self); |
1374 | 1374 | |
1375 | 1375 | if (this->buf == INVALID_BUFFER_VALUE) |
1376 | 1376 | { |
1377 | - sprintf(repr, _("<buffer object (deleted) at %8lX>"), (long)(self)); | |
1377 | + vim_snprintf(repr, 100, _("<buffer object (deleted) at %8lX>"), | |
1378 | + (long)(self)); | |
1378 | 1379 | return PyString_FromString(repr); |
1379 | 1380 | } |
1380 | 1381 | else |
@@ -1389,7 +1390,7 @@ | ||
1389 | 1390 | if (len > 35) |
1390 | 1391 | name = name + (35 - len); |
1391 | 1392 | |
1392 | - sprintf(repr, "<buffer %s%s>", len > 35 ? "..." : "", name); | |
1393 | + vim_snprintf(repr, 100, "<buffer %s%s>", len > 35 ? "..." : "", name); | |
1393 | 1394 | |
1394 | 1395 | return PyString_FromString(repr); |
1395 | 1396 | } |
@@ -1588,12 +1589,12 @@ | ||
1588 | 1589 | static PyObject * |
1589 | 1590 | RangeRepr(PyObject *self) |
1590 | 1591 | { |
1591 | - static char repr[75]; | |
1592 | + static char repr[100]; | |
1592 | 1593 | RangeObject *this = (RangeObject *)(self); |
1593 | 1594 | |
1594 | 1595 | if (this->buf->buf == INVALID_BUFFER_VALUE) |
1595 | 1596 | { |
1596 | - sprintf(repr, "<range object (for deleted buffer) at %8lX>", | |
1597 | + vim_snprintf(repr, 100, "<range object (for deleted buffer) at %8lX>", | |
1597 | 1598 | (long)(self)); |
1598 | 1599 | return PyString_FromString(repr); |
1599 | 1600 | } |
@@ -1609,7 +1610,7 @@ | ||
1609 | 1610 | if (len > 45) |
1610 | 1611 | name = name + (45 - len); |
1611 | 1612 | |
1612 | - sprintf(repr, "<range %s%s (%d:%d)>", | |
1613 | + vim_snprintf(repr, 100, "<range %s%s (%d:%d)>", | |
1613 | 1614 | len > 45 ? "..." : "", name, |
1614 | 1615 | this->start, this->end); |
1615 | 1616 |
@@ -1963,12 +1964,13 @@ | ||
1963 | 1964 | static PyObject * |
1964 | 1965 | WindowRepr(PyObject *self) |
1965 | 1966 | { |
1966 | - static char repr[50]; | |
1967 | + static char repr[100]; | |
1967 | 1968 | WindowObject *this = (WindowObject *)(self); |
1968 | 1969 | |
1969 | 1970 | if (this->win == INVALID_WINDOW_VALUE) |
1970 | 1971 | { |
1971 | - sprintf(repr, _("<window object (deleted) at %.8lX>"), (long)(self)); | |
1972 | + vim_snprintf(repr, 100, _("<window object (deleted) at %.8lX>"), | |
1973 | + (long)(self)); | |
1972 | 1974 | return PyString_FromString(repr); |
1973 | 1975 | } |
1974 | 1976 | else |
@@ -1980,9 +1982,10 @@ | ||
1980 | 1982 | ++i; |
1981 | 1983 | |
1982 | 1984 | 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)); | |
1984 | 1987 | else |
1985 | - sprintf(repr, _("<window %d>"), i); | |
1988 | + vim_snprintf(repr, 100, _("<window %d>"), i); | |
1986 | 1989 | |
1987 | 1990 | return PyString_FromString(repr); |
1988 | 1991 | } |
@@ -852,7 +852,9 @@ | ||
852 | 852 | else |
853 | 853 | { |
854 | 854 | 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)); | |
856 | 858 | Tcl_SetResult(interp, rbuf, TCL_VOLATILE); |
857 | 859 | } |
858 | 860 | break; |
@@ -874,7 +876,8 @@ | ||
874 | 876 | --val1; |
875 | 877 | if (u_save((linenr_T)val1, (linenr_T)(val1+1)) != OK) |
876 | 878 | { |
877 | - Tcl_SetResult(interp, _("cannot save undo information"), TCL_STATIC); | |
879 | + Tcl_SetResult(interp, _("cannot save undo information"), | |
880 | + TCL_STATIC); | |
878 | 881 | err = TCL_ERROR; |
879 | 882 | break; |
880 | 883 | } |
@@ -882,7 +885,8 @@ | ||
882 | 885 | line = Tcl_GetStringFromObj(objv[3], NULL); |
883 | 886 | if (ml_append((linenr_T)val1, (char_u *)line, 0, FALSE) != OK) |
884 | 887 | { |
885 | - Tcl_SetResult(interp, _("cannot insert/append line"), TCL_STATIC); | |
888 | + Tcl_SetResult(interp, _("cannot insert/append line"), | |
889 | + TCL_STATIC); | |
886 | 890 | err = TCL_ERROR; |
887 | 891 | break; |
888 | 892 | } |
@@ -1067,6 +1071,7 @@ | ||
1067 | 1071 | if (objc == 2) |
1068 | 1072 | { |
1069 | 1073 | char buf[64]; |
1074 | + | |
1070 | 1075 | sprintf(buf, _("row %d column %d"), (int)row2tcl(win->w_cursor.lnum), (int)col2tcl(win->w_cursor.col)); |
1071 | 1076 | Tcl_SetResult(interp, buf, TCL_VOLATILE); |
1072 | 1077 | break; |
@@ -1486,7 +1491,8 @@ | ||
1486 | 1491 | } |
1487 | 1492 | |
1488 | 1493 | 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)); | |
1490 | 1496 | else |
1491 | 1497 | { |
1492 | 1498 | if (unused) |
@@ -1507,7 +1513,8 @@ | ||
1507 | 1513 | } |
1508 | 1514 | |
1509 | 1515 | /* 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); | |
1511 | 1518 | cmd = Tcl_CreateObjCommand(interp, name, proc, |
1512 | 1519 | (ClientData)ref, (Tcl_CmdDeleteProc *)delref); |
1513 | 1520 | if (!cmd) |
@@ -1881,7 +1888,7 @@ | ||
1881 | 1888 | if (error == TCL_EXIT ) |
1882 | 1889 | { |
1883 | 1890 | int retval; |
1884 | - char buf[32]; | |
1891 | + char buf[50]; | |
1885 | 1892 | Tcl_Obj *robj; |
1886 | 1893 | |
1887 | 1894 | robj = Tcl_GetObjResult(tclinfo.interp); |
@@ -1892,7 +1899,7 @@ | ||
1892 | 1899 | } |
1893 | 1900 | else |
1894 | 1901 | { |
1895 | - sprintf(buf, "E572: exit code %d", retval); | |
1902 | + sprintf(buf, _("E572: exit code %d"), retval); | |
1896 | 1903 | tclerrmsg(buf); |
1897 | 1904 | if (retval == 0 ) |
1898 | 1905 | { |
@@ -1015,13 +1015,13 @@ | ||
1015 | 1015 | } |
1016 | 1016 | |
1017 | 1017 | 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); | |
1019 | 1019 | |
1020 | 1020 | if (buf_spname(curbuf) != NULL) |
1021 | 1021 | STRCPY(NameBuff, buf_spname(curbuf)); |
1022 | 1022 | else |
1023 | 1023 | 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); | |
1025 | 1025 | msg_putchar('\n'); |
1026 | 1026 | |
1027 | 1027 | /* |
@@ -3295,7 +3295,7 @@ | ||
3295 | 3295 | if (exp != NULL && *exp != NUL |
3296 | 3296 | && STRLEN(exp) + STRLEN(p) < MAXPATHL) |
3297 | 3297 | { |
3298 | - sprintf((char *)NameBuff, "%s%s", exp, p + 1); | |
3298 | + vim_snprintf((char *)NameBuff, MAXPATHL, "%s%s", exp, p + 1); | |
3299 | 3299 | var = NameBuff; |
3300 | 3300 | /* Also set $HOME, it's needed for _viminfo. */ |
3301 | 3301 | vim_setenv((char_u *)"HOME", NameBuff); |
@@ -5226,7 +5226,7 @@ | ||
5226 | 5226 | #endif |
5227 | 5227 | default: |
5228 | 5228 | sprintf((char *)IObuff, _("E574: Unknown register type %d"), |
5229 | - y_regs[i].y_type); | |
5229 | + y_regs[i].y_type); | |
5230 | 5230 | emsg(IObuff); |
5231 | 5231 | type = (char_u *)"LINE"; |
5232 | 5232 | break; |
@@ -5943,8 +5943,8 @@ | ||
5943 | 5943 | cursor_pos_info() |
5944 | 5944 | { |
5945 | 5945 | char_u *p; |
5946 | - char_u buf1[20]; | |
5947 | - char_u buf2[20]; | |
5946 | + char_u buf1[50]; | |
5947 | + char_u buf2[40]; | |
5948 | 5948 | linenr_T lnum; |
5949 | 5949 | long byte_count = 0; |
5950 | 5950 | long byte_count_cursor = 0; |
@@ -6106,7 +6106,7 @@ | ||
6106 | 6106 | buf1[0] = NUL; |
6107 | 6107 | |
6108 | 6108 | if (char_count_cursor == byte_count_cursor |
6109 | - && char_count == byte_count) | |
6109 | + && char_count == byte_count) | |
6110 | 6110 | sprintf((char *)IObuff, _("Selected %s%ld of %ld Lines; %ld of %ld Words; %ld of %ld Bytes"), |
6111 | 6111 | buf1, line_count_selected, |
6112 | 6112 | (long)curbuf->b_ml.ml_line_count, |
@@ -2571,7 +2571,7 @@ | ||
2571 | 2571 | static char_u *check_clipboard_option __ARGS((void)); |
2572 | 2572 | #endif |
2573 | 2573 | 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)); | |
2575 | 2575 | static void check_redraw __ARGS((long_u flags)); |
2576 | 2576 | static int findoption __ARGS((char_u *)); |
2577 | 2577 | static int find_key_option __ARGS((char_u *)); |
@@ -3881,7 +3881,7 @@ | ||
3881 | 3881 | if (removing) |
3882 | 3882 | value = *(long *)varp - value; |
3883 | 3883 | errmsg = set_num_option(opt_idx, varp, value, |
3884 | - errbuf, opt_flags); | |
3884 | + errbuf, sizeof(errbuf), opt_flags); | |
3885 | 3885 | } |
3886 | 3886 | else if (opt_idx >= 0) /* string */ |
3887 | 3887 | { |
@@ -4287,7 +4287,7 @@ | ||
4287 | 4287 | if (errbuf == NULL) |
4288 | 4288 | return (char_u *)""; |
4289 | 4289 | sprintf((char *)errbuf, _("E539: Illegal character <%s>"), |
4290 | - (char *)transchar(c)); | |
4290 | + (char *)transchar(c)); | |
4291 | 4291 | return errbuf; |
4292 | 4292 | } |
4293 | 4293 |
@@ -6822,11 +6822,12 @@ | ||
6822 | 6822 | * Returns NULL for success, or an error message for an error. |
6823 | 6823 | */ |
6824 | 6824 | 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) | |
6826 | 6826 | int opt_idx; /* index in options[] table */ |
6827 | 6827 | char_u *varp; /* pointer to the option variable */ |
6828 | 6828 | long value; /* new value */ |
6829 | 6829 | char_u *errbuf; /* buffer for error messages */ |
6830 | + size_t errbuflen; /* length of "errbuf" */ | |
6830 | 6831 | int opt_flags; /* OPT_LOCAL, OPT_GLOBAL and |
6831 | 6832 | OPT_MODELINE */ |
6832 | 6833 | { |
@@ -7116,8 +7117,8 @@ | ||
7116 | 7117 | { |
7117 | 7118 | if (errbuf != NULL) |
7118 | 7119 | { |
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()); | |
7121 | 7122 | errmsg = errbuf; |
7122 | 7123 | } |
7123 | 7124 | Rows = min_rows(); |
@@ -7126,8 +7127,8 @@ | ||
7126 | 7127 | { |
7127 | 7128 | if (errbuf != NULL) |
7128 | 7129 | { |
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); | |
7131 | 7132 | errmsg = errbuf; |
7132 | 7133 | } |
7133 | 7134 | Columns = MIN_COLUMNS; |
@@ -7453,7 +7454,8 @@ | ||
7453 | 7454 | if (varp != NULL) /* hidden option is not changed */ |
7454 | 7455 | { |
7455 | 7456 | 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); | |
7457 | 7459 | else |
7458 | 7460 | (void)set_bool_option(opt_idx, varp, (int)number, opt_flags); |
7459 | 7461 | } |
@@ -1309,7 +1309,7 @@ | ||
1309 | 1309 | msgstr "1 sostituzione" |
1310 | 1310 | |
1311 | 1311 | #: ex_cmds.c:4550 |
1312 | -#, fuzzy, c-format | |
1312 | +#, c-format | |
1313 | 1313 | msgid "%ld matches" |
1314 | 1314 | msgstr "%ld corrisp." |
1315 | 1315 |
@@ -1608,7 +1608,6 @@ | ||
1608 | 1608 | msgstr "In aggiunta al File" |
1609 | 1609 | |
1610 | 1610 | #: ex_docmd.c:7225 |
1611 | -#, fuzzy | |
1612 | 1611 | msgid "E747: Cannot change directory, buffer is modifed (add ! to override)" |
1613 | 1612 | msgstr "" |
1614 | 1613 | "E747: Non posso cambiare directory, buffer modificato (aggiungi ! per " |
@@ -2271,7 +2270,6 @@ | ||
2271 | 2270 | msgstr "W16: Attenzione: Modo File \"%s\" modificato dopo l'apertura" |
2272 | 2271 | |
2273 | 2272 | #: fileio.c:6066 |
2274 | -#, fuzzy | |
2275 | 2273 | msgid "See \":help W16\" for more info." |
2276 | 2274 | msgstr "Vedere \":help W16\" per ulteriori informazioni." |
2277 | 2275 |
@@ -5600,7 +5598,6 @@ | ||
5600 | 5598 | msgstr "E382: Non posso scrivere, l'opzione 'buftype' è impostata" |
5601 | 5599 | |
5602 | 5600 | #: quickfix.c:2379 |
5603 | -#, fuzzy | |
5604 | 5601 | msgid "E682: Invalid search pattern or delimiter" |
5605 | 5602 | msgstr "E682: Espressione o delimitatore di ricerca non validi" |
5606 | 5603 |
@@ -6688,7 +6685,6 @@ | ||
6688 | 6685 | msgstr "con GUI (classica)." |
6689 | 6686 | |
6690 | 6687 | #: version.c:876 |
6691 | -#, fuzzy | |
6692 | 6688 | msgid "with KDE GUI." |
6693 | 6689 | msgstr "con GUI KDE." |
6694 | 6690 |
@@ -7002,7 +6998,6 @@ | ||
7002 | 6998 | msgstr "E588: :endwhile senza :while" |
7003 | 6999 | |
7004 | 7000 | #: globals.h:1276 |
7005 | -#, fuzzy | |
7006 | 7001 | msgid "E588: :endfor without :for" |
7007 | 7002 | msgstr "E588: :endfor senza :for" |
7008 | 7003 |
@@ -92,5 +92,4 @@ | ||
92 | 92 | void sort_strings __ARGS((char_u **files, int count)); |
93 | 93 | int pathcmp __ARGS((const char *p, const char *q, int maxlen)); |
94 | 94 | 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)); | |
96 | 95 | /* vim: set ft=c : */ |
@@ -4278,8 +4278,9 @@ | ||
4278 | 4278 | #ifdef FEAT_INS_EXPAND |
4279 | 4279 | if (action == ACTION_EXPAND) |
4280 | 4280 | { |
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); | |
4283 | 4284 | msg_trunc_attr(IObuff, TRUE, hl_attr(HLF_R)); |
4284 | 4285 | } |
4285 | 4286 | #endif |
@@ -3433,7 +3433,7 @@ | ||
3433 | 3433 | if (!eap->skip) |
3434 | 3434 | { |
3435 | 3435 | STRCPY(buf, "so "); |
3436 | - sprintf((char *)buf + 3, SYNTAX_FNAME, name); | |
3436 | + vim_snprintf((char *)buf + 3, sizeof(buf) - 3, SYNTAX_FNAME, name); | |
3437 | 3437 | do_cmdline_cmd(buf); |
3438 | 3438 | } |
3439 | 3439 | } |
@@ -2140,7 +2140,7 @@ | ||
2140 | 2140 | clip_yank_selection(MCHAR, buffer, (long)nbytes, cbd); |
2141 | 2141 | XFree((void *)buffer); |
2142 | 2142 | if (p_verbose > 0) |
2143 | - smsg((char_u *)_("Used CUT_BUFFER0 instead of empty selection") ); | |
2143 | + MSG(_("Used CUT_BUFFER0 instead of empty selection")); | |
2144 | 2144 | } |
2145 | 2145 | } |
2146 | 2146 |