save_argc = argc;
//----- This is the main file handling loop --------------
- if (optind >= argc) {
- edit_file(0);
- } else {
- for (; optind < argc; optind++) {
- edit_file(argv[optind]);
- }
+ while (1) {
+ edit_file(argv[optind]); /* param might be NULL */
+ if (++optind >= argc)
+ break;
}
//-----------------------------------------------------------
} else if (strncmp(cmd, "quit", i) == 0 // Quit
|| strncmp(cmd, "next", i) == 0 // edit next file
) {
+ int n;
if (useforce) {
// force end of argv list
if (*cmd == 'q') {
goto vc1;
}
// are there other file to edit
- if (*cmd == 'q' && optind < save_argc - 1) {
- status_line_bold("%d more file to edit", (save_argc - optind - 1));
+ n = save_argc - optind - 1;
+ if (*cmd == 'q' && n > 0) {
+ status_line_bold("%d more file(s) to edit", n);
goto vc1;
}
- if (*cmd == 'n' && optind >= save_argc - 1) {
+ if (*cmd == 'n' && n <= 0) {
status_line_bold("No more files to edit");
goto vc1;
}