aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2019-04-02 12:45:30 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2019-04-02 12:45:30 +0200
commit8939359180ad0d6bfaaca694c4f14cd15cde4788 (patch)
tree0ce42e1e173c6e219d01047b93f246fbfabca8da
parentbbacd03ccc48734fb75fdac90e0bdd6c52c22cd1 (diff)
downloadbusybox-w32-8939359180ad0d6bfaaca694c4f14cd15cde4788.tar.gz
busybox-w32-8939359180ad0d6bfaaca694c4f14cd15cde4788.tar.bz2
busybox-w32-8939359180ad0d6bfaaca694c4f14cd15cde4788.zip
vi: rename save_argc -> cmdline_filecnt
function old new delta vi_main 272 273 +1 colon 2852 2853 +1 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--editors/vi.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/editors/vi.c b/editors/vi.c
index 9d0fc23cf..b41cf451c 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -301,7 +301,7 @@ struct globals {
301 smallint cmd_mode; // 0=command 1=insert 2=replace 301 smallint cmd_mode; // 0=command 1=insert 2=replace
302 int modified_count; // buffer contents changed if !0 302 int modified_count; // buffer contents changed if !0
303 int last_modified_count; // = -1; 303 int last_modified_count; // = -1;
304 int save_argc; // how many file names on cmd line 304 int cmdline_filecnt; // how many file names on cmd line
305 int cmdcnt; // repetition count 305 int cmdcnt; // repetition count
306 unsigned rows, columns; // the terminal screen is this size 306 unsigned rows, columns; // the terminal screen is this size
307#if ENABLE_FEATURE_VI_ASK_TERMINAL 307#if ENABLE_FEATURE_VI_ASK_TERMINAL
@@ -416,7 +416,7 @@ struct globals {
416#define cmd_mode (G.cmd_mode ) 416#define cmd_mode (G.cmd_mode )
417#define modified_count (G.modified_count ) 417#define modified_count (G.modified_count )
418#define last_modified_count (G.last_modified_count) 418#define last_modified_count (G.last_modified_count)
419#define save_argc (G.save_argc ) 419#define cmdline_filecnt (G.cmdline_filecnt )
420#define cmdcnt (G.cmdcnt ) 420#define cmdcnt (G.cmdcnt )
421#define rows (G.rows ) 421#define rows (G.rows )
422#define columns (G.columns ) 422#define columns (G.columns )
@@ -2367,7 +2367,7 @@ static void colon(char *buf)
2367 } else { 2367 } else {
2368 modified_count = 0; 2368 modified_count = 0;
2369 last_modified_count = -1; 2369 last_modified_count = -1;
2370 status_line("'%s' %dL, %dC", 2370 status_line("'%s' %uL, %uC",
2371 current_filename, 2371 current_filename,
2372 count_lines(text, end - 1), cnt 2372 count_lines(text, end - 1), cnt
2373 ); 2373 );
@@ -2538,7 +2538,7 @@ static void colon(char *buf)
2538 li = count_lines(text, end - 1); 2538 li = count_lines(text, end - 1);
2539 status_line("'%s'%s" 2539 status_line("'%s'%s"
2540 IF_FEATURE_VI_READONLY("%s") 2540 IF_FEATURE_VI_READONLY("%s")
2541 " %dL, %dC", 2541 " %uL, %uC",
2542 current_filename, 2542 current_filename,
2543 (size < 0 ? " [New file]" : ""), 2543 (size < 0 ? " [New file]" : ""),
2544 IF_FEATURE_VI_READONLY( 2544 IF_FEATURE_VI_READONLY(
@@ -2604,7 +2604,7 @@ static void colon(char *buf)
2604 if (useforce) { 2604 if (useforce) {
2605 if (*cmd == 'q') { 2605 if (*cmd == 'q') {
2606 // force end of argv list 2606 // force end of argv list
2607 optind = save_argc; 2607 optind = cmdline_filecnt - 1;
2608 } 2608 }
2609 editing = 0; 2609 editing = 0;
2610 goto ret; 2610 goto ret;
@@ -2615,9 +2615,9 @@ static void colon(char *buf)
2615 goto ret; 2615 goto ret;
2616 } 2616 }
2617 // are there other file to edit 2617 // are there other file to edit
2618 n = save_argc - optind - 1; 2618 n = cmdline_filecnt - optind - 1;
2619 if (*cmd == 'q' && n > 0) { 2619 if (*cmd == 'q' && n > 0) {
2620 status_line_bold("%d more file(s) to edit", n); 2620 status_line_bold("%u more file(s) to edit", n);
2621 goto ret; 2621 goto ret;
2622 } 2622 }
2623 if (*cmd == 'n' && n <= 0) { 2623 if (*cmd == 'n' && n <= 0) {
@@ -2662,7 +2662,7 @@ static void colon(char *buf)
2662 li = count_lines(q, q + size - 1); 2662 li = count_lines(q, q + size - 1);
2663 status_line("'%s'" 2663 status_line("'%s'"
2664 IF_FEATURE_VI_READONLY("%s") 2664 IF_FEATURE_VI_READONLY("%s")
2665 " %dL, %dC", 2665 " %uL, %uC",
2666 fn, 2666 fn,
2667 IF_FEATURE_VI_READONLY((readonly_mode ? " [Readonly]" : ""),) 2667 IF_FEATURE_VI_READONLY((readonly_mode ? " [Readonly]" : ""),)
2668 li, size 2668 li, size
@@ -2834,7 +2834,7 @@ static void colon(char *buf)
2834 } else { 2834 } else {
2835 // how many lines written 2835 // how many lines written
2836 li = count_lines(q, q + l - 1); 2836 li = count_lines(q, q + l - 1);
2837 status_line("'%s' %dL, %dC", fn, li, l); 2837 status_line("'%s' %uL, %uC", fn, li, l);
2838 if (l == size) { 2838 if (l == size) {
2839 if (q == text && q + l == end) { 2839 if (q == text && q + l == end) {
2840 modified_count = 0; 2840 modified_count = 0;
@@ -4368,23 +4368,22 @@ int vi_main(int argc, char **argv)
4368 } 4368 }
4369 } 4369 }
4370 4370
4371 // The argv array can be used by the ":next" and ":rewind" commands
4372 argv += optind; 4371 argv += optind;
4373 argc -= optind; 4372 cmdline_filecnt = argc - optind;
4374 4373
4375 //----- This is the main file handling loop --------------
4376 save_argc = argc;
4377 optind = 0;
4378 // "Save cursor, use alternate screen buffer, clear screen" 4374 // "Save cursor, use alternate screen buffer, clear screen"
4379 write1(ESC"[?1049h"); 4375 write1(ESC"[?1049h");
4376 // This is the main file handling loop
4377 optind = 0;
4380 while (1) { 4378 while (1) {
4381 edit_file(argv[optind]); // param might be NULL 4379 edit_file(argv[optind]); // might be NULL on 1st iteration
4382 if (++optind >= argc) 4380 // NB: optind can be changed by ":next" and ":rewind" commands
4381 optind++;
4382 if (!argv[optind])
4383 break; 4383 break;
4384 } 4384 }
4385 // "Use normal screen buffer, restore cursor" 4385 // "Use normal screen buffer, restore cursor"
4386 write1(ESC"[?1049l"); 4386 write1(ESC"[?1049l");
4387 //-----------------------------------------------------------
4388 4387
4389 return 0; 4388 return 0;
4390} 4389}