comparison src/filepath.c @ 19301:80baa37506d0 v8.2.0209

patch 8.2.0209: function a bit far away from where it's used Commit: https://github.com/vim/vim/commit/80147dda4f5a25c9533bc88583c87dbbb0a0f1f1 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Feb 4 22:32:59 2020 +0100 patch 8.2.0209: function a bit far away from where it's used Problem: Function a bit far away from where it's used. Solution: Move function close to where it's used. (Ken Takata, closes https://github.com/vim/vim/issues/5569)
author Bram Moolenaar <Bram@vim.org>
date Tue, 04 Feb 2020 22:45:04 +0100
parents 8b710057093c
children 782f410c5df3
comparison
equal deleted inserted replaced
19300:1911a4f14ae9 19301:80baa37506d0
1254 { 1254 {
1255 rettv->vval.v_number = mch_isdir(tv_get_string(&argvars[0])); 1255 rettv->vval.v_number = mch_isdir(tv_get_string(&argvars[0]));
1256 } 1256 }
1257 1257
1258 /* 1258 /*
1259 * Evaluate "expr" (= "context") for readdir().
1260 */
1261 static int
1262 readdir_checkitem(void *context, char_u *name)
1263 {
1264 typval_T *expr = (typval_T *)context;
1265 typval_T save_val;
1266 typval_T rettv;
1267 typval_T argv[2];
1268 int retval = 0;
1269 int error = FALSE;
1270
1271 if (expr->v_type == VAR_UNKNOWN)
1272 return 1;
1273
1274 prepare_vimvar(VV_VAL, &save_val);
1275 set_vim_var_string(VV_VAL, name, -1);
1276 argv[0].v_type = VAR_STRING;
1277 argv[0].vval.v_string = name;
1278
1279 if (eval_expr_typval(expr, argv, 1, &rettv) == FAIL)
1280 goto theend;
1281
1282 retval = tv_get_number_chk(&rettv, &error);
1283 if (error)
1284 retval = -1;
1285 clear_tv(&rettv);
1286
1287 theend:
1288 set_vim_var_string(VV_VAL, NULL, 0);
1289 restore_vimvar(VV_VAL, &save_val);
1290 return retval;
1291 }
1292
1293 /*
1294 * Create the directory in which "dir" is located, and higher levels when 1259 * Create the directory in which "dir" is located, and higher levels when
1295 * needed. 1260 * needed.
1296 * Return OK or FAIL. 1261 * Return OK or FAIL.
1297 */ 1262 */
1298 static int 1263 static int
1381 p = vim_strsave(p); 1346 p = vim_strsave(p);
1382 rettv->vval.v_string = p; 1347 rettv->vval.v_string = p;
1383 if (p != NULL) 1348 if (p != NULL)
1384 shorten_dir(p); 1349 shorten_dir(p);
1385 } 1350 }
1351 }
1352
1353 /*
1354 * Evaluate "expr" (= "context") for readdir().
1355 */
1356 static int
1357 readdir_checkitem(void *context, char_u *name)
1358 {
1359 typval_T *expr = (typval_T *)context;
1360 typval_T save_val;
1361 typval_T rettv;
1362 typval_T argv[2];
1363 int retval = 0;
1364 int error = FALSE;
1365
1366 if (expr->v_type == VAR_UNKNOWN)
1367 return 1;
1368
1369 prepare_vimvar(VV_VAL, &save_val);
1370 set_vim_var_string(VV_VAL, name, -1);
1371 argv[0].v_type = VAR_STRING;
1372 argv[0].vval.v_string = name;
1373
1374 if (eval_expr_typval(expr, argv, 1, &rettv) == FAIL)
1375 goto theend;
1376
1377 retval = tv_get_number_chk(&rettv, &error);
1378 if (error)
1379 retval = -1;
1380 clear_tv(&rettv);
1381
1382 theend:
1383 set_vim_var_string(VV_VAL, NULL, 0);
1384 restore_vimvar(VV_VAL, &save_val);
1385 return retval;
1386 } 1386 }
1387 1387
1388 /* 1388 /*
1389 * "readdir()" function 1389 * "readdir()" function
1390 */ 1390 */