comparison src/scriptfile.c @ 20536:8fa783f2c69c v8.2.0822

patch 8.2.0822: Vim9: code left over from discovery phase Commit: https://github.com/vim/vim/commit/2eec37926db6d31beb36f162ac00357a30c093c8 Author: Bram Moolenaar <Bram@vim.org> Date: Mon May 25 20:33:55 2020 +0200 patch 8.2.0822: Vim9: code left over from discovery phase Problem: Vim9: code left over from discovery phase. Solution: Remove the dead code.
author Bram Moolenaar <Bram@vim.org>
date Mon, 25 May 2020 20:45:04 +0200
parents b0242bcc74e7
children 9f921ba86d05
comparison
equal deleted inserted replaced
20535:ec872c8a09ff 20536:8fa783f2c69c
996 #ifdef USE_CRNL 996 #ifdef USE_CRNL
997 int fileformat; // EOL_UNKNOWN, EOL_UNIX or EOL_DOS 997 int fileformat; // EOL_UNKNOWN, EOL_UNIX or EOL_DOS
998 int error; // TRUE if LF found after CR-LF 998 int error; // TRUE if LF found after CR-LF
999 #endif 999 #endif
1000 #ifdef FEAT_EVAL 1000 #ifdef FEAT_EVAL
1001 garray_T lines_ga; // lines read in previous pass
1002 int use_lines_ga; // next line to get from "lines_ga"
1003 linenr_T breakpoint; // next line with breakpoint or zero 1001 linenr_T breakpoint; // next line with breakpoint or zero
1004 char_u *fname; // name of sourced file 1002 char_u *fname; // name of sourced file
1005 int dbg_tick; // debug_tick when breakpoint was set 1003 int dbg_tick; // debug_tick when breakpoint was set
1006 int level; // top nesting level of sourced file 1004 int level; // top nesting level of sourced file
1007 #endif 1005 #endif
1014 */ 1012 */
1015 linenr_T * 1013 linenr_T *
1016 source_breakpoint(void *cookie) 1014 source_breakpoint(void *cookie)
1017 { 1015 {
1018 return &((struct source_cookie *)cookie)->breakpoint; 1016 return &((struct source_cookie *)cookie)->breakpoint;
1019 }
1020
1021 /*
1022 * Get the grow array to store script lines in.
1023 */
1024 garray_T *
1025 source_get_line_ga(void *cookie)
1026 {
1027 return &((struct source_cookie *)cookie)->lines_ga;
1028 }
1029
1030 /*
1031 * Set the index to start reading from the grow array with script lines.
1032 */
1033 void
1034 source_use_line_ga(void *cookie)
1035 {
1036 ((struct source_cookie *)cookie)->use_lines_ga = 0;
1037 } 1017 }
1038 1018
1039 /* 1019 /*
1040 * Return the address holding the debug tick for a source cookie. 1020 * Return the address holding the debug tick for a source cookie.
1041 */ 1021 */
1253 cookie.nextline = NULL; 1233 cookie.nextline = NULL;
1254 cookie.sourcing_lnum = 0; 1234 cookie.sourcing_lnum = 0;
1255 cookie.finished = FALSE; 1235 cookie.finished = FALSE;
1256 1236
1257 #ifdef FEAT_EVAL 1237 #ifdef FEAT_EVAL
1258 ga_init2(&cookie.lines_ga, sizeof(char_u *), 200);
1259 cookie.use_lines_ga = -1;
1260
1261 // Check if this script has a breakpoint. 1238 // Check if this script has a breakpoint.
1262 cookie.breakpoint = dbg_find_breakpoint(TRUE, fname_exp, (linenr_T)0); 1239 cookie.breakpoint = dbg_find_breakpoint(TRUE, fname_exp, (linenr_T)0);
1263 cookie.fname = fname_exp; 1240 cookie.fname = fname_exp;
1264 cookie.dbg_tick = debug_tick; 1241 cookie.dbg_tick = debug_tick;
1265 1242
1300 // loading the same script again 1277 // loading the same script again
1301 si->sn_had_command = FALSE; 1278 si->sn_had_command = FALSE;
1302 si->sn_version = 1; 1279 si->sn_version = 1;
1303 current_sctx.sc_sid = sid; 1280 current_sctx.sc_sid = sid;
1304 1281
1282 // In Vim9 script all script-local variables are removed when reloading
1283 // the same script. In legacy script they remain but "const" can be
1284 // set again.
1305 ht = &SCRIPT_VARS(sid); 1285 ht = &SCRIPT_VARS(sid);
1306 if (is_vim9) 1286 if (is_vim9)
1307 hashtab_free_contents(ht); 1287 hashtab_free_contents(ht);
1308 else 1288 else
1309 { 1289 {
1473 #endif 1453 #endif
1474 fclose(cookie.fp); 1454 fclose(cookie.fp);
1475 vim_free(cookie.nextline); 1455 vim_free(cookie.nextline);
1476 vim_free(firstline); 1456 vim_free(firstline);
1477 convert_setup(&cookie.conv, NULL, NULL); 1457 convert_setup(&cookie.conv, NULL, NULL);
1478 #ifdef FEAT_EVAL
1479 ga_clear_strings(&cookie.lines_ga);
1480 #endif
1481 1458
1482 if (trigger_source_post) 1459 if (trigger_source_post)
1483 apply_autocmds(EVENT_SOURCEPOST, fname_exp, fname_exp, FALSE, curbuf); 1460 apply_autocmds(EVENT_SOURCEPOST, fname_exp, fname_exp, FALSE, curbuf);
1484 1461
1485 theend: 1462 theend:
1731 1708
1732 // Get current line. If there is a read-ahead line, use it, otherwise get 1709 // Get current line. If there is a read-ahead line, use it, otherwise get
1733 // one now. 1710 // one now.
1734 if (sp->finished) 1711 if (sp->finished)
1735 line = NULL; 1712 line = NULL;
1736 #ifdef FEAT_EVAL
1737 else if (sp->use_lines_ga >= 0)
1738 {
1739 // Get a line that was read in ex_vim9script().
1740 for (;;)
1741 {
1742 if (sp->use_lines_ga >= sp->lines_ga.ga_len)
1743 {
1744 line = NULL;
1745 break;
1746 }
1747 else
1748 {
1749 line = ((char_u **)(sp->lines_ga.ga_data))[sp->use_lines_ga];
1750 ((char_u **)(sp->lines_ga.ga_data))[sp->use_lines_ga] = NULL;
1751 ++sp->use_lines_ga;
1752 if (line != NULL)
1753 break;
1754 // Skip NULL lines, they are equivalent to blank lines.
1755 ++sp->sourcing_lnum;
1756 }
1757 }
1758 SOURCING_LNUM = sp->sourcing_lnum + 1;
1759 }
1760 #endif
1761 else if (sp->nextline == NULL) 1713 else if (sp->nextline == NULL)
1762 line = get_one_sourceline(sp); 1714 line = get_one_sourceline(sp);
1763 else 1715 else
1764 { 1716 {
1765 line = sp->nextline; 1717 line = sp->nextline;
1771 script_line_start(); 1723 script_line_start();
1772 #endif 1724 #endif
1773 1725
1774 // Only concatenate lines starting with a \ when 'cpoptions' doesn't 1726 // Only concatenate lines starting with a \ when 'cpoptions' doesn't
1775 // contain the 'C' flag. 1727 // contain the 'C' flag.
1776 if (line != NULL && do_concat && vim_strchr(p_cpo, CPO_CONCAT) == NULL 1728 if (line != NULL && do_concat && vim_strchr(p_cpo, CPO_CONCAT) == NULL)
1777 #ifdef FEAT_EVAL
1778 && sp->use_lines_ga < 0
1779 #endif
1780 )
1781 { 1729 {
1782 // compensate for the one line read-ahead 1730 // compensate for the one line read-ahead
1783 --sp->sourcing_lnum; 1731 --sp->sourcing_lnum;
1784 1732
1785 // Get the next line and concatenate it when it starts with a 1733 // Get the next line and concatenate it when it starts with a