diff -urN nano/ChangeLog nano-fixed/ChangeLog --- nano/ChangeLog 2003-01-30 01:57:33.000000000 +0100 +++ nano-fixed/ChangeLog 2003-01-30 20:25:57.000000000 +0100 @@ -39,8 +39,18 @@ (David Benbennick). open_file() - Fix FD leak with file load error (David Benbennick). + add_open_file() + - Revert the fix for the supposed minor logic error from before; + it was keeping some updates from happening when they should, + which was leading to segfaults with both multibuffer and view + mode on. (DLR; found by David Benbennick) save_history() - Fix nrealloc return value being ignored (David Benbennick). +- global.c: + shortcut_init() + - Rework the code allowing Insert File in view mode if + multibuffer support is enabled so it takes up a little less + room. (DLR) - nano.c: do_char() - Remove unneeded check_statblank() (David Benbennick). @@ -60,6 +70,10 @@ - Call load_file with arg 0 for insert, as we aren't really doing an insert, allows new_file() to run if we open a non-file at startup. + - Check for an error when opening the filename; if there was + one, blank out the filename. (DLR; found by David Benbennick) + - Make sure edittop is set when we're opening a file and + starting on its first line. (DLR) usage() - Remove gettext markings from -p/--preserve (Jordi). - Revamp -H option message to fit in 80 column terminal. diff -urN nano/files.c nano-fixed/files.c --- nano/files.c 2003-01-30 01:57:33.000000000 +0100 +++ nano-fixed/files.c 2003-01-30 20:25:57.000000000 +0100 @@ -780,10 +780,9 @@ #endif } - /* if we're in view mode and updating, the file contents won't - have changed, so we won't bother resaving the filestruct - then; otherwise, we will */ - if (!(ISSET(VIEW_MODE) || !update)) { + /* if we're not in view mode and not updating, the file contents + might have changed, so save the filestruct; otherwise, don't */ + if (!(ISSET(VIEW_MODE) && !update)) { /* save current file buffer */ open_files->fileage = fileage; open_files->filebot = filebot; @@ -2010,7 +2009,7 @@ return matches; } -/* This was originally called exe_n_cwd_tab_completion, but we're not +/* This was originally called exe_n_cwd_tab_completion(), but we're not worried about executables, only filenames :> */ char **cwd_tab_completion(char *buf, int *num_matches) @@ -2066,7 +2065,6 @@ fprintf(stderr, "\ntmp = %s\n", tmp); #endif - dir = opendir(dirname); if (dir == NULL) { /* Don't print an error, just shut up and return */ diff -urN nano/global.c nano-fixed/global.c --- nano/global.c 2003-01-15 20:33:27.000000000 +0100 +++ nano-fixed/global.c 2003-01-30 20:25:57.000000000 +0100 @@ -431,16 +431,16 @@ IFHELP(nano_justify_msg, 0), NANO_JUSTIFY_FKEY, 0, NOVIEW, do_justify); -#ifdef ENABLE_MULTIBUFFER - /* this is so we can view multiple files */ - sc_init_one(&main_list, NANO_INSERTFILE_KEY, _("Read File"), + /* this is so we can view multiple files */ + sc_init_one(&main_list, NANO_INSERTFILE_KEY, _("Read File"), IFHELP(nano_insert_msg, 0), - NANO_INSERTFILE_FKEY, 0, VIEW, do_insertfile_void); + NANO_INSERTFILE_FKEY, 0, +#ifdef ENABLE_MULTIBUFFER + VIEW #else - sc_init_one(&main_list, NANO_INSERTFILE_KEY, _("Read File"), - IFHELP(nano_insert_msg, 0), - NANO_INSERTFILE_FKEY, 0, NOVIEW, do_insertfile_void); + NOVIEW #endif + , do_insertfile_void); sc_init_one(&main_list, NANO_WHEREIS_KEY, _("Where Is"), IFHELP(nano_whereis_msg, 0), diff -urN nano/nano.c nano-fixed/nano.c --- nano/nano.c 2003-01-30 01:42:20.000000000 +0100 +++ nano-fixed/nano.c 2003-01-30 20:25:57.000000000 +0100 @@ -3394,9 +3394,6 @@ #endif #endif - - - #ifdef DEBUG fprintf(stderr, _("Main: bottom win\n")); #endif @@ -3407,7 +3404,10 @@ fprintf(stderr, _("Main: open file\n")); #endif - open_file(filename, 0, 1); + /* If there was an error opening the file, blank out the filename */ + if (open_file(filename, 0, 1) == -1) + filename = mallocstrcpy(filename, ""); + #ifdef ENABLE_MULTIBUFFER /* If we're using multibuffers and more than one file is specified on the command line, load them all and switch to the first one @@ -3417,8 +3417,13 @@ add_open_file(1); new_file(); filename = mallocstrcpy(filename, argv[optind]); - open_file(filename, 0, 0); - load_file(0); + if (open_file(filename, 0, 0) == -1) { + load_file(0); + filename = mallocstrcpy(filename, ""); + close_open_file(); + open_prevfile_void(); + } else + load_file(0); } open_nextfile_void(); } @@ -3428,6 +3433,9 @@ if (startline > 0) do_gotoline(startline, 0); + else + /* Make sure edittop is set! */ + edittop = current; /* Return here after a sigwinch */ sigsetjmp(jmpbuf, 1); diff -urN nano/winio.c nano-fixed/winio.c --- nano/winio.c 2003-01-28 02:23:40.000000000 +0100 +++ nano-fixed/winio.c 2003-01-30 20:25:57.000000000 +0100 @@ -87,7 +87,7 @@ i--; #ifdef DEBUG - fprintf(stderr, _("actual_x for xplus=%d returns %d\n"), xplus, i); + fprintf(stderr, _("actual_x() for xplus=%d returns %d\n"), xplus, i); #endif return i; @@ -256,10 +256,6 @@ } #endif - /* We canceled putting in an answer; reset x */ - if (kbinput == NANO_CANCEL_KEY) - x = -1; - return t->val; } } @@ -592,7 +588,7 @@ #ifndef NANO_SMALL else if (s->val == KEY_UP) strncpy(keystr, _("Up"), 8); -#endif /* NANO_SMALL */ +#endif /* !NANO_SMALL */ else if (s->val > 0) { if (s->val < 64) sprintf(keystr, "^%c", s->val + 64); @@ -1134,10 +1130,8 @@ clearok(edit, FALSE); } -/* - * Nice generic routine to update the edit buffer, given a pointer to the - * file struct =) - */ +/* Nice generic routine to update the edit buffer, given a pointer to + * the file struct =). */ void edit_update(filestruct *fileptr, topmidbotnone location) { if (fileptr == NULL)