comparison src/ex_eval.c @ 21058:111f877e63d9 v8.2.1080

patch 8.2.1080: Vim9: no line break allowed in a for loop Commit: https://github.com/vim/vim/commit/b7a78f7a6713f07d2fcad0b27dea22925c7b1cdf Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jun 28 18:43:40 2020 +0200 patch 8.2.1080: Vim9: no line break allowed in a for loop Problem: Vim9: no line break allowed in a for loop. Solution: Skip line breaks in for command.
author Bram Moolenaar <Bram@vim.org>
date Sun, 28 Jun 2020 18:45:04 +0200
parents d9e0db9b2b99
children b0baa80cb53f
comparison
equal deleted inserted replaced
21057:77d9be8bbf27 21058:111f877e63d9
897 typval_T tv; 897 typval_T tv;
898 evalarg_T evalarg; 898 evalarg_T evalarg;
899 899
900 CLEAR_FIELD(evalarg); 900 CLEAR_FIELD(evalarg);
901 evalarg.eval_flags = eap->skip ? 0 : EVAL_EVALUATE; 901 evalarg.eval_flags = eap->skip ? 0 : EVAL_EVALUATE;
902 evalarg.eval_cookie = eap->getline == getsourceline ? eap->cookie : NULL; 902 if (getline_equal(eap->getline, eap->cookie, getsourceline))
903 {
904 evalarg.eval_getline = eap->getline;
905 evalarg.eval_cookie = eap->cookie;
906 }
903 907
904 if (eval0(eap->arg, &tv, eap, &evalarg) == OK) 908 if (eval0(eap->arg, &tv, eap, &evalarg) == OK)
905 clear_tv(&tv); 909 clear_tv(&tv);
910
911 clear_evalarg(&evalarg, eap);
906 } 912 }
907 913
908 /* 914 /*
909 * ":if". 915 * ":if".
910 */ 916 */
1106 */ 1112 */
1107 result = eval_to_bool(eap->arg, &error, eap, skip); 1113 result = eval_to_bool(eap->arg, &error, eap, skip);
1108 } 1114 }
1109 else 1115 else
1110 { 1116 {
1111 void *fi; 1117 void *fi;
1118 evalarg_T evalarg;
1119
1120 CLEAR_FIELD(evalarg);
1121 evalarg.eval_flags = skip ? 0 : EVAL_EVALUATE;
1122 if (getline_equal(eap->getline, eap->cookie, getsourceline))
1123 {
1124 evalarg.eval_getline = eap->getline;
1125 evalarg.eval_cookie = eap->cookie;
1126 }
1112 1127
1113 /* 1128 /*
1114 * ":for var in list-expr" 1129 * ":for var in list-expr"
1115 */ 1130 */
1116 if ((cstack->cs_lflags & CSL_HAD_LOOP) != 0) 1131 if ((cstack->cs_lflags & CSL_HAD_LOOP) != 0)
1117 { 1132 {
1118 // Jumping here from a ":continue" or ":endfor": use the 1133 // Jumping here from a ":continue" or ":endfor": use the
1119 // previously evaluated list. 1134 // previously evaluated list.
1120 fi = cstack->cs_forinfo[cstack->cs_idx]; 1135 fi = cstack->cs_forinfo[cstack->cs_idx];
1121 error = FALSE; 1136 error = FALSE;
1137
1138 // the "in expr" is not used, skip over it
1139 skip_for_lines(fi, &evalarg);
1122 } 1140 }
1123 else 1141 else
1124 { 1142 {
1125 // Evaluate the argument and get the info in a structure. 1143 // Evaluate the argument and get the info in a structure.
1126 fi = eval_for_line(eap->arg, &error, eap, skip); 1144 fi = eval_for_line(eap->arg, &error, eap, &evalarg);
1127 cstack->cs_forinfo[cstack->cs_idx] = fi; 1145 cstack->cs_forinfo[cstack->cs_idx] = fi;
1128 } 1146 }
1129 1147
1130 // use the element at the start of the list and advance 1148 // use the element at the start of the list and advance
1131 if (!error && fi != NULL && !skip) 1149 if (!error && fi != NULL && !skip)
1136 if (!result) 1154 if (!result)
1137 { 1155 {
1138 free_for_info(fi); 1156 free_for_info(fi);
1139 cstack->cs_forinfo[cstack->cs_idx] = NULL; 1157 cstack->cs_forinfo[cstack->cs_idx] = NULL;
1140 } 1158 }
1159 clear_evalarg(&evalarg, eap);
1141 } 1160 }
1142 1161
1143 /* 1162 /*
1144 * If this cstack entry was just initialised and is active, set the 1163 * If this cstack entry was just initialised and is active, set the
1145 * loop flag, so do_cmdline() will set the line number in cs_line[]. 1164 * loop flag, so do_cmdline() will set the line number in cs_line[].