Mercurial > vim
comparison src/eval.c @ 8451:c0b5c2b0a5ee v7.4.1516
commit https://github.com/vim/vim/commit/8049253b96838b3584600e5ad229abad37a95b10
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Mar 8 17:08:53 2016 +0100
patch 7.4.1516
Problem: Cannot change file permissions.
Solution: Add setfperm().
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 08 Mar 2016 17:15:04 +0100 |
parents | 0e6fd2f802b3 |
children | d0717262d802 |
comparison
equal
deleted
inserted
replaced
8450:198586538c01 | 8451:c0b5c2b0a5ee |
---|---|
733 static void f_server2client(typval_T *argvars, typval_T *rettv); | 733 static void f_server2client(typval_T *argvars, typval_T *rettv); |
734 static void f_serverlist(typval_T *argvars, typval_T *rettv); | 734 static void f_serverlist(typval_T *argvars, typval_T *rettv); |
735 static void f_setbufvar(typval_T *argvars, typval_T *rettv); | 735 static void f_setbufvar(typval_T *argvars, typval_T *rettv); |
736 static void f_setcharsearch(typval_T *argvars, typval_T *rettv); | 736 static void f_setcharsearch(typval_T *argvars, typval_T *rettv); |
737 static void f_setcmdpos(typval_T *argvars, typval_T *rettv); | 737 static void f_setcmdpos(typval_T *argvars, typval_T *rettv); |
738 static void f_setfperm(typval_T *argvars, typval_T *rettv); | |
738 static void f_setline(typval_T *argvars, typval_T *rettv); | 739 static void f_setline(typval_T *argvars, typval_T *rettv); |
739 static void f_setloclist(typval_T *argvars, typval_T *rettv); | 740 static void f_setloclist(typval_T *argvars, typval_T *rettv); |
740 static void f_setmatches(typval_T *argvars, typval_T *rettv); | 741 static void f_setmatches(typval_T *argvars, typval_T *rettv); |
741 static void f_setpos(typval_T *argvars, typval_T *rettv); | 742 static void f_setpos(typval_T *argvars, typval_T *rettv); |
742 static void f_setqflist(typval_T *argvars, typval_T *rettv); | 743 static void f_setqflist(typval_T *argvars, typval_T *rettv); |
8444 {"server2client", 2, 2, f_server2client}, | 8445 {"server2client", 2, 2, f_server2client}, |
8445 {"serverlist", 0, 0, f_serverlist}, | 8446 {"serverlist", 0, 0, f_serverlist}, |
8446 {"setbufvar", 3, 3, f_setbufvar}, | 8447 {"setbufvar", 3, 3, f_setbufvar}, |
8447 {"setcharsearch", 1, 1, f_setcharsearch}, | 8448 {"setcharsearch", 1, 1, f_setcharsearch}, |
8448 {"setcmdpos", 1, 1, f_setcmdpos}, | 8449 {"setcmdpos", 1, 1, f_setcmdpos}, |
8450 {"setfperm", 2, 2, f_setfperm}, | |
8449 {"setline", 2, 2, f_setline}, | 8451 {"setline", 2, 2, f_setline}, |
8450 {"setloclist", 2, 3, f_setloclist}, | 8452 {"setloclist", 2, 3, f_setloclist}, |
8451 {"setmatches", 1, 1, f_setmatches}, | 8453 {"setmatches", 1, 1, f_setmatches}, |
8452 {"setpos", 2, 2, f_setpos}, | 8454 {"setpos", 2, 2, f_setpos}, |
8453 {"setqflist", 1, 2, f_setqflist}, | 8455 {"setqflist", 1, 2, f_setqflist}, |
18417 { | 18419 { |
18418 int pos = (int)get_tv_number(&argvars[0]) - 1; | 18420 int pos = (int)get_tv_number(&argvars[0]) - 1; |
18419 | 18421 |
18420 if (pos >= 0) | 18422 if (pos >= 0) |
18421 rettv->vval.v_number = set_cmdline_pos(pos); | 18423 rettv->vval.v_number = set_cmdline_pos(pos); |
18424 } | |
18425 | |
18426 /* | |
18427 * "setfperm({fname}, {mode})" function | |
18428 */ | |
18429 static void | |
18430 f_setfperm(typval_T *argvars, typval_T *rettv) | |
18431 { | |
18432 char_u *fname; | |
18433 char_u modebuf[NUMBUFLEN]; | |
18434 char_u *mode_str; | |
18435 int i; | |
18436 int mask; | |
18437 int mode = 0; | |
18438 | |
18439 rettv->vval.v_number = 0; | |
18440 fname = get_tv_string_chk(&argvars[0]); | |
18441 if (fname == NULL) | |
18442 return; | |
18443 mode_str = get_tv_string_buf_chk(&argvars[1], modebuf); | |
18444 if (mode_str == NULL) | |
18445 return; | |
18446 if (STRLEN(mode_str) != 9) | |
18447 { | |
18448 EMSG2(_(e_invarg2), mode_str); | |
18449 return; | |
18450 } | |
18451 | |
18452 mask = 1; | |
18453 for (i = 8; i >= 0; --i) | |
18454 { | |
18455 if (mode_str[i] != '-') | |
18456 mode |= mask; | |
18457 mask = mask << 1; | |
18458 } | |
18459 rettv->vval.v_number = mch_setperm(fname, mode) == OK; | |
18422 } | 18460 } |
18423 | 18461 |
18424 /* | 18462 /* |
18425 * "setline()" function | 18463 * "setline()" function |
18426 */ | 18464 */ |