aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2004-02-23 19:26:14 +0000
committerJeff Johnston <jjohnstn@redhat.com>2004-02-23 19:26:14 +0000
commitcbdeadcaa3b68c48146dd26b5c812d2439cfb0ec (patch)
tree6bff818f38b09d8c76eff97fff0aa81f1f675697 /gdb
parent8ee9a8b2e70a9b650d1a60aa71b61936efa67c6a (diff)
downloadgdb-cbdeadcaa3b68c48146dd26b5c812d2439cfb0ec.zip
gdb-cbdeadcaa3b68c48146dd26b5c812d2439cfb0ec.tar.gz
gdb-cbdeadcaa3b68c48146dd26b5c812d2439cfb0ec.tar.bz2
2004-02-23 Jeff Johnston <jjohnstn@redhat.com>
* defs.h (nquery, yquery): New prototypes. * breakpoint.c (break_command_1): Use new nquery interface. * utils.c (defaulted_query, nquery, yquery): New functions.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog8
-rw-r--r--gdb/breakpoint.c2
-rw-r--r--gdb/defs.h2
-rw-r--r--gdb/utils.c139
4 files changed, 150 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 942be44..3c0a192 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2004-02-23 Jeff Johnston <jjohnstn@redhat.com>
+
+ * defs.h (nquery, yquery): New prototypes.
+ * breakpoint.c (break_command_1): Use new nquery interface.
+ * utils.c (defaulted_query, nquery, yquery): New functions.
+
2004-02-23 Andrew Cagney <cagney@redhat.com>
* hppa-tdep.c (hppa_frame_align): New function.
@@ -303,6 +309,7 @@
* sh-tdep.c (sh_analyze_prologue): Eliminate useless test of
cache->uses_fp prior to setting it.
+>>>>>>> 1.5450
2004-02-19 Fred Fish <fnf@redhat.com>
Fix for PR breakpoint/1558.
@@ -319,6 +326,7 @@
type being greater than sizeof of host's LONGEST. Always use
unpack_long() unless format 'f' chosen.
+>>>>>>> 1.5419
2004-02-19 Joel Brobecker <brobecker@gnat.com>
Committed by Elena Zannoni <ezannoni@redhat.com>
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index a4cfa46..ca5aff5 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -5103,7 +5103,7 @@ break_command_1 (char *arg, int flag, int from_tty, struct breakpoint *pending_b
error_output_message (NULL, err_msg);
xfree (err_msg);
- if (!query ("Make breakpoint pending on future shared library load? "))
+ if (!nquery ("Make breakpoint pending on future shared library load? "))
return rc;
copy_arg = xstrdup (addr_start);
addr_string = &copy_arg;
diff --git a/gdb/defs.h b/gdb/defs.h
index e6d2fec..e49f9e0 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -405,6 +405,8 @@ extern void null_cleanup (void *);
extern int myread (int, char *, int);
extern int query (const char *, ...) ATTR_FORMAT (printf, 1, 2);
+extern int nquery (const char *, ...) ATTR_FORMAT (printf, 1, 2);
+extern int yquery (const char *, ...) ATTR_FORMAT (printf, 1, 2);
extern void init_page_info (void);
diff --git a/gdb/utils.c b/gdb/utils.c
index 34e6777..b925123 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1335,6 +1335,145 @@ query (const char *ctlstr, ...)
}
+/* This function supports the nquery() and yquery() functions.
+ Ask user a y-or-n question and return 0 if answer is no, 1 if
+ answer is yes, or default the answer to the specified default.
+ DEFCHAR is either 'y' or 'n' and refers to the default answer.
+ CTLSTR is the control string and should end in "? ". It should
+ not say how to answer, because we do that.
+ ARGS are the arguments passed along with the CTLSTR argument to
+ printf. */
+
+static int
+defaulted_query (const char *ctlstr, const char defchar, va_list args)
+{
+ int answer;
+ int ans2;
+ int retval;
+ int def_value;
+ char def_answer, not_def_answer;
+ char *y_string, *n_string;
+
+ /* Set up according to which answer is the default. */
+ if (defchar == 'y')
+ {
+ def_value = 1;
+ def_answer = 'Y';
+ not_def_answer = 'N';
+ y_string = "[y]";
+ n_string = "n";
+ }
+ else
+ {
+ def_value = 0;
+ def_answer = 'N';
+ not_def_answer = 'Y';
+ y_string = "y";
+ n_string = "[n]";
+ }
+
+ if (query_hook)
+ {
+ return query_hook (ctlstr, args);
+ }
+
+ /* Automatically answer default value if input is not from a terminal. */
+ if (!input_from_terminal_p ())
+ return def_value;
+
+ while (1)
+ {
+ wrap_here (""); /* Flush any buffered output */
+ gdb_flush (gdb_stdout);
+
+ if (annotation_level > 1)
+ printf_filtered ("\n\032\032pre-%cquery\n", defchar);
+
+ vfprintf_filtered (gdb_stdout, ctlstr, args);
+ printf_filtered ("(%s or %s) ", y_string, n_string);
+
+ if (annotation_level > 1)
+ printf_filtered ("\n\032\032%cquery\n", defchar);
+
+ wrap_here ("");
+ gdb_flush (gdb_stdout);
+
+ answer = fgetc (stdin);
+ clearerr (stdin); /* in case of C-d */
+ if (answer == EOF) /* C-d */
+ {
+ retval = def_value;
+ break;
+ }
+ /* Eat rest of input line, to EOF or newline */
+ if (answer != '\n')
+ do
+ {
+ ans2 = fgetc (stdin);
+ clearerr (stdin);
+ }
+ while (ans2 != EOF && ans2 != '\n' && ans2 != '\r');
+
+ if (answer >= 'a')
+ answer -= 040;
+ /* Check answer. For the non-default, the user must specify
+ the non-default explicitly. */
+ if (answer == not_def_answer)
+ {
+ retval = !def_value;
+ break;
+ }
+ /* Otherwise, for the default, the user may either specify
+ the required input or have it default by entering nothing. */
+ if (answer == def_answer || answer == '\n' ||
+ answer == '\r' || answer == EOF)
+ {
+ retval = def_value;
+ break;
+ }
+ /* Invalid entries are not defaulted and require another selection. */
+ printf_filtered ("Please answer %s or %s.\n",
+ y_string, n_string);
+ }
+
+ if (annotation_level > 1)
+ printf_filtered ("\n\032\032post-%cquery\n", defchar);
+ return retval;
+}
+
+
+/* Ask user a y-or-n question and return 0 if answer is no, 1 if
+ answer is yes, or 0 if answer is defaulted.
+ Takes three args which are given to printf to print the question.
+ The first, a control string, should end in "? ".
+ It should not say how to answer, because we do that. */
+
+int
+nquery (const char *ctlstr, ...)
+{
+ va_list args;
+
+ va_start (args, ctlstr);
+ return defaulted_query (ctlstr, 'n', args);
+ va_end (args);
+}
+
+/* Ask user a y-or-n question and return 0 if answer is no, 1 if
+ answer is yes, or 1 if answer is defaulted.
+ Takes three args which are given to printf to print the question.
+ The first, a control string, should end in "? ".
+ It should not say how to answer, because we do that. */
+
+int
+yquery (const char *ctlstr, ...)
+{
+ va_list args;
+
+ va_start (args, ctlstr);
+ return defaulted_query (ctlstr, 'y', args);
+ va_end (args);
+}
+
/* Print an error message saying that we couldn't make sense of a
\^mumble sequence in a string or character constant. START and END
indicate a substring of some larger string that contains the