Mercurial > vim
comparison src/search.c @ 25302:4d3c68196d05 v8.2.3188
patch 8.2.3188: Vim9: argument types are not checked at compile time
Commit: https://github.com/vim/vim/commit/83494b4ac61898f687d6ef9dce4bad5802fb8e51
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Tue Jul 20 17:51:51 2021 +0200
patch 8.2.3188: Vim9: argument types are not checked at compile time
Problem: Vim9: argument types are not checked at compile time.
Solution: Add several more type checks, also at runtime. (Yegappan
Lakshmanan, closes #8587)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 20 Jul 2021 18:00:06 +0200 |
parents | 7334bf933510 |
children | 078edc1821bf |
comparison
equal
deleted
inserted
replaced
25301:fe178301fc04 | 25302:4d3c68196d05 |
---|---|
1215 */ | 1215 */ |
1216 int | 1216 int |
1217 do_search( | 1217 do_search( |
1218 oparg_T *oap, // can be NULL | 1218 oparg_T *oap, // can be NULL |
1219 int dirc, // '/' or '?' | 1219 int dirc, // '/' or '?' |
1220 int search_delim, // the delimiter for the search, e.g. '%' in s%regex%replacement% | 1220 int search_delim, // the delimiter for the search, e.g. '%' in |
1221 // s%regex%replacement% | |
1221 char_u *pat, | 1222 char_u *pat, |
1222 long count, | 1223 long count, |
1223 int options, | 1224 int options, |
1224 searchit_arg_T *sia) // optional arguments or NULL | 1225 searchit_arg_T *sia) // optional arguments or NULL |
1225 { | 1226 { |
1474 { | 1475 { |
1475 vim_free(msgbuf); | 1476 vim_free(msgbuf); |
1476 msgbuf = trunc; | 1477 msgbuf = trunc; |
1477 } | 1478 } |
1478 | 1479 |
1479 #ifdef FEAT_RIGHTLEFT | 1480 #ifdef FEAT_RIGHTLEFT |
1480 // The search pattern could be shown on the right in rightleft | 1481 // The search pattern could be shown on the right in |
1481 // mode, but the 'ruler' and 'showcmd' area use it too, thus | 1482 // rightleft mode, but the 'ruler' and 'showcmd' area use |
1482 // it would be blanked out again very soon. Show it on the | 1483 // it too, thus it would be blanked out again very soon. |
1483 // left, but do reverse the text. | 1484 // Show it on the left, but do reverse the text. |
1484 if (curwin->w_p_rl && *curwin->w_p_rlc == 's') | 1485 if (curwin->w_p_rl && *curwin->w_p_rlc == 's') |
1485 { | 1486 { |
1486 char_u *r; | 1487 char_u *r; |
1487 size_t pat_len; | 1488 size_t pat_len; |
1488 | 1489 |
1501 vim_memset(r, ' ', pat_len); | 1502 vim_memset(r, ' ', pat_len); |
1502 else | 1503 else |
1503 vim_memset(msgbuf + pat_len, ' ', r - msgbuf); | 1504 vim_memset(msgbuf + pat_len, ' ', r - msgbuf); |
1504 } | 1505 } |
1505 } | 1506 } |
1506 #endif | 1507 #endif |
1507 msg_outtrans(msgbuf); | 1508 msg_outtrans(msgbuf); |
1508 msg_clr_eos(); | 1509 msg_clr_eos(); |
1509 msg_check(); | 1510 msg_check(); |
1510 | 1511 |
1511 gotocmdline(FALSE); | 1512 gotocmdline(FALSE); |
1546 pos.col = 0; | 1547 pos.col = 0; |
1547 } | 1548 } |
1548 } | 1549 } |
1549 } | 1550 } |
1550 | 1551 |
1552 /* | |
1553 * The actual search. | |
1554 */ | |
1551 c = searchit(curwin, curbuf, &pos, NULL, | 1555 c = searchit(curwin, curbuf, &pos, NULL, |
1552 dirc == '/' ? FORWARD : BACKWARD, | 1556 dirc == '/' ? FORWARD : BACKWARD, |
1553 searchstr, count, spats[0].off.end + (options & | 1557 searchstr, count, spats[0].off.end + (options & |
1554 (SEARCH_KEEP + SEARCH_PEEK + SEARCH_HIS | 1558 (SEARCH_KEEP + SEARCH_PEEK + SEARCH_HIS |
1555 + SEARCH_MSG + SEARCH_START | 1559 + SEARCH_MSG + SEARCH_START |
1556 + ((pat != NULL && *pat == ';') ? 0 : SEARCH_NOOF))), | 1560 + ((pat != NULL && *pat == ';') ? 0 : SEARCH_NOOF))), |
1557 RE_LAST, sia); | 1561 RE_LAST, sia); |
1558 | 1562 |
1559 if (dircp != NULL) | 1563 if (dircp != NULL) |
1560 *dircp = search_delim; // restore second '/' or '?' for normal_cmd() | 1564 *dircp = search_delim; // restore second '/' or '?' for normal_cmd() |
1561 | 1565 |
1562 if (!shortmess(SHM_SEARCH) | 1566 if (!shortmess(SHM_SEARCH) |
1563 && ((dirc == '/' && LT_POS(pos, curwin->w_cursor)) | 1567 && ((dirc == '/' && LT_POS(pos, curwin->w_cursor)) |
1564 || (dirc == '?' && LT_POS(curwin->w_cursor, pos)))) | 1568 || (dirc == '?' && LT_POS(curwin->w_cursor, pos)))) |
1565 show_top_bot_msg = TRUE; | 1569 show_top_bot_msg = TRUE; |
4792 callback_T cb; | 4796 callback_T cb; |
4793 char_u *key = NULL; | 4797 char_u *key = NULL; |
4794 int ret; | 4798 int ret; |
4795 int matchseq = FALSE; | 4799 int matchseq = FALSE; |
4796 | 4800 |
4801 if (in_vim9script() | |
4802 && (check_for_list_arg(argvars, 0) == FAIL | |
4803 || check_for_string_arg(argvars, 1) == FAIL | |
4804 || check_for_opt_dict_arg(argvars, 2) == FAIL)) | |
4805 return; | |
4806 | |
4797 CLEAR_POINTER(&cb); | 4807 CLEAR_POINTER(&cb); |
4798 | 4808 |
4799 // validate and get the arguments | 4809 // validate and get the arguments |
4800 if (argvars[0].v_type != VAR_LIST || argvars[0].vval.v_list == NULL) | 4810 if (argvars[0].v_type != VAR_LIST || argvars[0].vval.v_list == NULL) |
4801 { | 4811 { |