From 858f8aafacf93ff4642a2f62dc0d7f0f31f95cce Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 16 Feb 2021 09:09:12 +0000 Subject: diff: code shrink function old new delta diff_main 1515 1495 -20 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-20) Total: -20 bytes Signed-off-by: Ron Yorston Signed-off-by: Denys Vlasenko --- editors/diff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'editors') diff --git a/editors/diff.c b/editors/diff.c index 280091756..1adc4cbc7 100644 --- a/editors/diff.c +++ b/editors/diff.c @@ -1050,7 +1050,7 @@ int diff_main(int argc UNUSED_PARAM, char **argv) /* diffreg can get non-regular files here */ print_status(gotstdin > 1 ? STATUS_SAME : diffreg(file), file); - if (dirfile) + if (ENABLE_FEATURE_CLEAN_UP && dirfile) free(file[dir]); } -- cgit v1.2.3 From 63d9da322f438a98bb654cc4976874fa89f1fa62 Mon Sep 17 00:00:00 2001 From: Alison Winters Date: Sat, 27 Feb 2021 15:18:45 -0800 Subject: vi: restore 0 offset after :set noXXX command Fixes bug where commands after the first noXXX command are ignored. e.g. :set noic tabstop=4 While at it, stop recognizing "notabstop=NNN". function old new delta colon 2990 2965 -25 Signed-off-by: Alison Winters Signed-off-by: Denys Vlasenko --- editors/vi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'editors') diff --git a/editors/vi.c b/editors/vi.c index 458ca6293..e77c348fb 100644 --- a/editors/vi.c +++ b/editors/vi.c @@ -2709,7 +2709,6 @@ static void colon(char *buf) # if ENABLE_FEATURE_VI_SETOPTS char *argp; # endif - i = 0; // offset into args // only blank is regarded as args delimiter. What about tab '\t'? if (!args[0] || strcasecmp(args, "all") == 0) { // print out values of all options @@ -2732,15 +2731,16 @@ static void colon(char *buf) # if ENABLE_FEATURE_VI_SETOPTS argp = args; while (*argp) { - if (strncmp(argp, "no", 2) == 0) - i = 2; // ":set noautoindent" + i = 0; + if (argp[0] == 'n' && argp[1] == 'o') // "noXXX" + i = 2; setops(argp, "autoindent ", i, "ai", VI_AUTOINDENT); setops(argp, "flash " , i, "fl", VI_ERR_METHOD); setops(argp, "ignorecase ", i, "ic", VI_IGNORECASE); setops(argp, "showmatch " , i, "sm", VI_SHOWMATCH ); - if (strncmp(argp + i, "tabstop=", 8) == 0) { + if (strncmp(argp, "tabstop=", 8) == 0) { int t = 0; - sscanf(argp + i+8, "%u", &t); + sscanf(argp + 8, "%u", &t); if (t > 0 && t <= MAX_TABSTOP) tabstop = t; } -- cgit v1.2.3 From 70ee23399cb2c77dec0b6ad3b6030f7cf3105b8f Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 1 Mar 2021 14:41:39 +0100 Subject: 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 --- editors/vi.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'editors') diff --git a/editors/vi.c b/editors/vi.c index e77c348fb..abc0aeae8 100644 --- a/editors/vi.c +++ b/editors/vi.c @@ -2258,7 +2258,7 @@ static char *get_one_address(char *p, int *addr) // get colon addr, if present q = begin_line(dot); *addr = count_lines(text, q); } -#if ENABLE_FEATURE_VI_YANKMARK +# if ENABLE_FEATURE_VI_YANKMARK else if (*p == '\'') { // is this a mark addr p++; c = tolower(*p); @@ -2272,8 +2272,8 @@ static char *get_one_address(char *p, int *addr) // get colon addr, if present } } } -#endif -#if ENABLE_FEATURE_VI_SEARCH +# endif +# if ENABLE_FEATURE_VI_SEARCH else if (*p == '/') { // a search pattern q = strchrnul(p + 1, '/'); if (p + 1 != q) { @@ -2290,7 +2290,7 @@ static char *get_one_address(char *p, int *addr) // get colon addr, if present *addr = count_lines(text, q); } } -#endif +# endif else if (*p == '$') { // the last line in file p++; q = begin_line(end - 1); @@ -2333,16 +2333,13 @@ static char *get_address(char *p, int *b, int *e) // get two colon addrs, if pre return p; } -#if ENABLE_FEATURE_VI_SET && ENABLE_FEATURE_VI_SETOPTS -static void setops(const char *args, const char *opname, int flg_no, - const char *short_opname, int opt) +# if ENABLE_FEATURE_VI_SET && ENABLE_FEATURE_VI_SETOPTS +static void setops(const char *args, const char *nm_longname, int flg_no, int opt) { const char *a = args + flg_no; - int l = strlen(opname) - 1; // opname have + ' ' - // maybe strncmp? we had tons of erroneous strncasecmp's... - if (strncasecmp(a, opname, l) == 0 - || strncasecmp(a, short_opname, 2) == 0 + if (strcmp(a, nm_longname) == 0 + || strcmp(a, nm_longname + 3) == 0 ) { if (flg_no) vi_setops &= ~opt; @@ -2350,7 +2347,7 @@ static void setops(const char *args, const char *opname, int flg_no, vi_setops |= opt; } } -#endif +# endif #endif /* FEATURE_VI_COLON */ @@ -2734,13 +2731,12 @@ static void colon(char *buf) i = 0; if (argp[0] == 'n' && argp[1] == 'o') // "noXXX" i = 2; - setops(argp, "autoindent ", i, "ai", VI_AUTOINDENT); - setops(argp, "flash " , i, "fl", VI_ERR_METHOD); - setops(argp, "ignorecase ", i, "ic", VI_IGNORECASE); - setops(argp, "showmatch " , i, "sm", VI_SHOWMATCH ); + setops(argp, "ai""\0""autoindent", i, VI_AUTOINDENT); + setops(argp, "fl""\0""flash" , i, VI_ERR_METHOD); + setops(argp, "ic""\0""ignorecase", i, VI_IGNORECASE); + setops(argp, "sm""\0""showmatch" , i, VI_SHOWMATCH ); if (strncmp(argp, "tabstop=", 8) == 0) { - int t = 0; - sscanf(argp + 8, "%u", &t); + int t = bb_strtou(argp + 8, NULL, 10); if (t > 0 && t <= MAX_TABSTOP) tabstop = t; } -- cgit v1.2.3