vi: code shrink
function old new delta setops 85 73 -12 colon 2965 2915 -50 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-62) Total: -62 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
63d9da322f
commit
70ee23399c
20
editors/vi.c
20
editors/vi.c
@ -2334,15 +2334,12 @@ static char *get_address(char *p, int *b, int *e) // get two colon addrs, if pre
|
|||||||
}
|
}
|
||||||
|
|
||||||
# if ENABLE_FEATURE_VI_SET && ENABLE_FEATURE_VI_SETOPTS
|
# if ENABLE_FEATURE_VI_SET && ENABLE_FEATURE_VI_SETOPTS
|
||||||
static void setops(const char *args, const char *opname, int flg_no,
|
static void setops(const char *args, const char *nm_longname, int flg_no, int opt)
|
||||||
const char *short_opname, int opt)
|
|
||||||
{
|
{
|
||||||
const char *a = args + flg_no;
|
const char *a = args + flg_no;
|
||||||
int l = strlen(opname) - 1; // opname have + ' '
|
|
||||||
|
|
||||||
// maybe strncmp? we had tons of erroneous strncasecmp's...
|
if (strcmp(a, nm_longname) == 0
|
||||||
if (strncasecmp(a, opname, l) == 0
|
|| strcmp(a, nm_longname + 3) == 0
|
||||||
|| strncasecmp(a, short_opname, 2) == 0
|
|
||||||
) {
|
) {
|
||||||
if (flg_no)
|
if (flg_no)
|
||||||
vi_setops &= ~opt;
|
vi_setops &= ~opt;
|
||||||
@ -2734,13 +2731,12 @@ static void colon(char *buf)
|
|||||||
i = 0;
|
i = 0;
|
||||||
if (argp[0] == 'n' && argp[1] == 'o') // "noXXX"
|
if (argp[0] == 'n' && argp[1] == 'o') // "noXXX"
|
||||||
i = 2;
|
i = 2;
|
||||||
setops(argp, "autoindent ", i, "ai", VI_AUTOINDENT);
|
setops(argp, "ai""\0""autoindent", i, VI_AUTOINDENT);
|
||||||
setops(argp, "flash " , i, "fl", VI_ERR_METHOD);
|
setops(argp, "fl""\0""flash" , i, VI_ERR_METHOD);
|
||||||
setops(argp, "ignorecase ", i, "ic", VI_IGNORECASE);
|
setops(argp, "ic""\0""ignorecase", i, VI_IGNORECASE);
|
||||||
setops(argp, "showmatch " , i, "sm", VI_SHOWMATCH );
|
setops(argp, "sm""\0""showmatch" , i, VI_SHOWMATCH );
|
||||||
if (strncmp(argp, "tabstop=", 8) == 0) {
|
if (strncmp(argp, "tabstop=", 8) == 0) {
|
||||||
int t = 0;
|
int t = bb_strtou(argp + 8, NULL, 10);
|
||||||
sscanf(argp + 8, "%u", &t);
|
|
||||||
if (t > 0 && t <= MAX_TABSTOP)
|
if (t > 0 && t <= MAX_TABSTOP)
|
||||||
tabstop = t;
|
tabstop = t;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user