Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: nickrob@snap.net.nz (Nick Roberts)
To: Vladimir Prus <vladimir@codesourcery.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [PATCH:gdb/mi] Update a specified list of variable objects
Date: Tue, 29 Sep 2009 23:36:00 -0000	[thread overview]
Message-ID: <19138.39416.821174.32806@totara.tehura.co.nz> (raw)
In-Reply-To: <200909282032.55055.vladimir@codesourcery.com>

 > > Actually it's probably better to use isdigit like below
 > 
 > In fact, it's probably even easier than than. Note this code from
 > mi_cmd_var_create:
 > 
 >   if (strcmp (name, "-") == 0)
 >     {
 >       xfree (name);
 >       name = varobj_gen_name ();
 >     }
 >   else if (!isalpha (*name))
 >     error (_("mi_cmd_var_create: name of object must begin with a letter"));
 > 
 > with this in mind,
 > 
 > 
 > > +      print_values = PRINT_NO_VALUES;
 > > +  else if (argc == 2 && isdigit (*argv[0]))
 > > +    {
 > > +      optind = 1;
 > > +      print_values = mi_parse_values_option (argv[0]);
 > > +    }
 > 
 > can be written like this:
 > 
 >   else if (argc == 2 && (isdigit (*argv[0]) || *argv[0] == '-'))
 >     {
 >       optind = 1;
 >       print_values = mi_parse_values_option (argv[0]);
 >     }

"-var-update --all-values var1 var2" doesn't work in this case.  I see
a couple of shortcomings with my patch too now:  "-var-update 0 var1 var2" doesn't work
and "-var-update" with no argument givese a segmentation fault.

 > >    else
 > > -    name = (argv[1]);
 > > +    {
 > > +      while (1)
 > > +       {
 > > +         int opt = mi_getopt ("mi_cmd_var_update",
 > > +                              argc, argv, opts, &optind, &optarg);
 > 
 > And this code can be dropped. What do you think?

This is a few lines shorter but what if someone wants to add another option?
mi_getopt provides an extensible solution.

I'm not really worried which approach is used.  Since the general idea seems
to be acceptable, I'll write some tests and documentation.  Then you can code
it a different way if you wish and the only requirement will be that the tests
pass.

-- 
Nick                                           http://users.snap.net.nz/~nickrob


  reply	other threads:[~2009-09-29 23:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-21 12:09 Nick Roberts
2009-09-21 12:39 ` Vladimir Prus
2009-09-21 23:39   ` Nick Roberts
2009-09-22  0:04     ` Nick Roberts
2009-09-28 16:33       ` Vladimir Prus
2009-09-29 23:36         ` Nick Roberts [this message]
2009-09-21 16:58 ` Tom Tromey
2009-09-21 23:39   ` Nick Roberts

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19138.39416.821174.32806@totara.tehura.co.nz \
    --to=nickrob@snap.net.nz \
    --cc=gdb-patches@sources.redhat.com \
    --cc=vladimir@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox