files.c:do_insertfile() - Add some more checks and fix recursion when toggling multibuffer (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1416 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
0eab236580
commit
434d686ee4
|
@ -48,6 +48,9 @@ CVS Code -
|
|||
- Fix goto directory operating dir check and tilde expansion
|
||||
(David Benbennick).
|
||||
- Even more checks and operating dir fixes (David Benbennick).
|
||||
do_insertfile()
|
||||
- Add some more checks and fix recursion when toggling
|
||||
multibuffer (David Benbennick).
|
||||
open_file()
|
||||
- Fix FD leak with file load error (David Benbennick).
|
||||
add_open_file()
|
||||
|
|
3
TODO
3
TODO
|
@ -22,6 +22,9 @@ For version 1.4:
|
|||
- Remindable keys?
|
||||
- Keystroke to implement "Add next sequence as raw" like vi's ^V.
|
||||
- Spell check selected text only.
|
||||
- Make "To line" (^W^T) and "Read from Command" (^R^X) re-enter their
|
||||
parent menu when their keystroke is entered a second time (^W^T^T and
|
||||
(^R^X^X)(requires figuring out when to keep cursor pos and when not to).
|
||||
|
||||
Old requests:
|
||||
|
||||
|
|
73
files.c
73
files.c
|
@ -427,6 +427,10 @@ int do_insertfile(int loading_file)
|
|||
|
||||
wrap_reset();
|
||||
|
||||
#if !defined(DISABLE_BROWSER) || !defined(NANO_SMALL) && defined(ENABLE_MULTIBUFFER)
|
||||
start_again: /* Goto here when the user cancels the file browser. */
|
||||
#endif
|
||||
|
||||
#if !defined(DISABLE_BROWSER) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION))
|
||||
currshortcut = insertfile_list;
|
||||
#endif
|
||||
|
@ -473,55 +477,46 @@ int do_insertfile(int loading_file)
|
|||
fprintf(stderr, _("filename is %s\n"), answer);
|
||||
#endif
|
||||
|
||||
realname = real_dir_from_tilde(answer);
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
if (i == NANO_TOFILES_KEY) {
|
||||
char *tmp = do_browse_from(realname);
|
||||
|
||||
#if !defined(DISABLE_HELP) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION))
|
||||
currshortcut = insertfile_list;
|
||||
#endif
|
||||
#ifdef DISABLE_TABCOMP
|
||||
realname = NULL;
|
||||
#endif
|
||||
if (tmp != NULL) {
|
||||
free(realname);
|
||||
realname = tmp;
|
||||
} else
|
||||
return do_insertfile(loading_file);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
if (operating_dir != NULL && check_operating_dir(realname, 0)) {
|
||||
statusbar(_("Can't insert file from outside of %s"),
|
||||
operating_dir);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
if (i == TOGGLE_LOAD_KEY) {
|
||||
/* don't allow toggling if we're in both view mode and
|
||||
multibuffer mode now */
|
||||
if (!ISSET(VIEW_MODE) || !ISSET(MULTIBUFFER))
|
||||
/* Don't allow toggling if we're in view mode. */
|
||||
if (!ISSET(VIEW_MODE))
|
||||
TOGGLE(MULTIBUFFER);
|
||||
return do_insertfile(ISSET(MULTIBUFFER));
|
||||
loading_file = ISSET(MULTIBUFFER);
|
||||
goto start_again;
|
||||
}
|
||||
#endif /* ENABLE_MULTIBUFFER */
|
||||
|
||||
if (i == NANO_EXTCMD_KEY) {
|
||||
int ts;
|
||||
ts = statusq(1, extcmd_list, "", 0, _("Command to execute "));
|
||||
int ts = statusq(TRUE, extcmd_list, "", NULL,
|
||||
_("Command to execute"));
|
||||
if (ts == -1 || answer == NULL || answer[0] == '\0') {
|
||||
statusbar(_("Cancelled"));
|
||||
statusbar("Cancelled");
|
||||
UNSET(KEEP_CUTBUFFER);
|
||||
display_main_list();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif /* !NANO_SMALL */
|
||||
#ifndef DISABLE_BROWSER
|
||||
if (i == NANO_TOFILES_KEY) {
|
||||
char *tmp = do_browse_from(answer);
|
||||
|
||||
if (tmp != NULL)
|
||||
answer = tmp;
|
||||
else
|
||||
goto start_again;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
if (i != NANO_EXTCMD_KEY && check_operating_dir(answer, FALSE)) {
|
||||
statusbar(_("Can't insert file from outside of %s"),
|
||||
operating_dir);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
if (loading_file) {
|
||||
|
@ -536,11 +531,15 @@ int do_insertfile(int loading_file)
|
|||
#endif
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
if (i == NANO_EXTCMD_KEY)
|
||||
if (i == NANO_EXTCMD_KEY) {
|
||||
realname = mallocstrcpy(realname, "");
|
||||
i = open_pipe(answer);
|
||||
else
|
||||
} else
|
||||
#endif /* NANO_SMALL */
|
||||
{
|
||||
realname = real_dir_from_tilde(answer);
|
||||
i = open_file(realname, 1, loading_file);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
if (loading_file) {
|
||||
|
|
Loading…
Reference in New Issue