aboutsummaryrefslogtreecommitdiff
path: root/gdb/top.c
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2006-03-29 22:53:33 +0000
committerDaniel Jacobowitz <drow@false.org>2006-03-29 22:53:33 +0000
commit698ba9341ed2a509079635b532aa3593d86aa047 (patch)
tree5c212d9af6dba536a1d4624988f3df206be050cb /gdb/top.c
parent2f00de94cba65aea58efe910d1b4970220d0bb5f (diff)
downloadgdb-698ba9341ed2a509079635b532aa3593d86aa047.zip
gdb-698ba9341ed2a509079635b532aa3593d86aa047.tar.gz
gdb-698ba9341ed2a509079635b532aa3593d86aa047.tar.bz2
* Makefile.in (utils.o): Update.
* top.c (in_user_command): New. (command_line_input): Use input_from_terminal_p. (input_from_terminal_p): Don't check caution. Handle stdin == NULL for Insight. * top.h (in_user_command, caution): New declarations. * utils.c: Include "top.h". (query, defaulted_query): Check caution here. Move the call to input_from_terminal_p higher. * cli/cli-script.c (do_restore_user_call_depth): Only decrement the depth. Update in_user_command if necessary. (execute_user_command): Don't clobber old_chain. Set in_user_command. Let do_restore_user_call_depth handle user_call_depth. (read_command_lines): Check whether to prompt before calling Insight hooks. * tui/tui-hooks.c (tui_query_hook): Remove newly unnecessary input_from_terminal_p check.
Diffstat (limited to 'gdb/top.c')
-rw-r--r--gdb/top.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/gdb/top.c b/gdb/top.c
index 61968af..e129722 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -112,6 +112,10 @@ Whether to confirm potentially dangerous operations is %s.\n"),
FILE *instream;
+/* Flag to indicate whether a user defined command is currently running. */
+
+int in_user_command;
+
/* Current working directory. */
char *current_directory;
@@ -909,11 +913,11 @@ command_line_input (char *prompt_arg, int repeat, char *annotation_suffix)
}
/* Don't use fancy stuff if not talking to stdin. */
- if (deprecated_readline_hook && instream == NULL)
+ if (deprecated_readline_hook && input_from_terminal_p ())
{
rl = (*deprecated_readline_hook) (local_prompt);
}
- else if (command_editing_p && instream == stdin && ISATTY (instream))
+ else if (command_editing_p && input_from_terminal_p ())
{
rl = gdb_readline_wrapper (local_prompt);
}
@@ -1197,13 +1201,22 @@ quit_force (char *args, int from_tty)
exit (exit_code);
}
-/* Returns whether GDB is running on a terminal and whether the user
- desires that questions be asked of them on that terminal. */
+/* Returns whether GDB is running on a terminal and input is
+ currently coming from that terminal. */
int
input_from_terminal_p (void)
{
- return gdb_has_a_terminal () && (instream == stdin) & caution;
+ if (gdb_has_a_terminal () && instream == stdin)
+ return 1;
+
+ /* If INSTREAM is unset, and we are not in a user command, we
+ must be in Insight. That's like having a terminal, for our
+ purposes. */
+ if (instream == NULL && !in_user_command)
+ return 1;
+
+ return 0;
}
static void