This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [obv] Handle var_string_noescape and var_optional_filename together.
On Wednesday, July 18, 2012 03:56:55 PM Jan Kratochvil wrote:
> On Wed, 18 Jul 2012 20:40:14 +0200, Yao Qi wrote:
> > I notice that the code in case var_string_noescape and
> > var_optional_filename are exactly the same, so this patch is to combine
> > them together. I'll commit it in two days.
>
> I do not agree, this will hide an existing bug.
>
Oh, I didn't realize that there may be a bug when handling var_optional_filename here.
> Correct it to fix var_optional_filename to be more like var_filename
> (clearing whitespaces + doing tilde_expand); except sure without that:
> if (arg == NULL)
> error_no_arg (_("filename to set it to."));
How about this one?
--
Yao (éå)
gdb:
2012-07-18 Yao Qi <yao@codesourcery.com>
* cli/cli-setshow.c (do_setshow_command): Handle case 'var_filename'
and case 'var_optional_filename' together.
---
gdb/cli/cli-setshow.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
index 521ac0e..e44a35e 100644
--- a/gdb/cli/cli-setshow.c
+++ b/gdb/cli/cli-setshow.c
@@ -183,15 +183,15 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c)
*(char **) c->var = xstrdup (arg);
break;
case var_optional_filename:
- if (arg == NULL)
- arg = "";
- if (*(char **) c->var != NULL)
- xfree (*(char **) c->var);
- *(char **) c->var = xstrdup (arg);
- break;
case var_filename:
if (arg == NULL)
- error_no_arg (_("filename to set it to."));
+ {
+ if (c->var_type == var_filename)
+ error_no_arg (_("filename to set it to."));
+ else
+ arg = "";
+ }
+
if (*(char **) c->var != NULL)
xfree (*(char **) c->var);
{
--
1.7.7.6