Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Alfredo Ortega <ortegaalfredo@gmail.com>
Cc: gdb-patches@sourceware.org
Subject: Re: Use external editor in 'commands' command
Date: Tue, 24 Feb 2009 20:20:00 -0000	[thread overview]
Message-ID: <m3bpsrlitf.fsf@fleche.redhat.com> (raw)
In-Reply-To: <e598931c0902190028x47e79037x1746e7c3f0c70726@mail.gmail.com> (Alfredo Ortega's message of "Thu\, 19 Feb 2009 06\:28\:59 -0200")

>>>>> "Alfredo" == Alfredo Ortega <ortegaalfredo@gmail.com> writes:

Alfredo> 2009-01-16 Alfredo Ortega <ortegaalfredo@gmail.com>
Alfredo>   * breakpoint.c (commands_command,_initialize_breakpoint,
Alfredo> edit_command,check_executing_commands, commands_edit_command,
Alfredo> commands_dump_to_file):
Alfredo>   Add the 'edit' keyword to the 'commands' command to allow the
Alfredo>   use of an external editor to add or modify commands.
Alfredo>   Added an utility function to dump breakpoint commands to a file.
Alfredo>   Added an utility function to launch an external editor on breakpoint commands.
Alfredo>   Joined common checks in commands_command and edit_command.

This is wordier than the norm.  Also, a comment describing a change
should be next to the name of the function it describes.  This seems
to list all the function names, then all the changes.

See the existing ChangeLog for a lot of examples.  Also the GNU
standards have a section on writing a ChangeLog entry...

Alfredo> +commands_dump_to_file (char *filename, struct breakpoint *b)
Alfredo> +{
Alfredo> +  struct cleanup *cleanups;
Alfredo> +  struct ui_file *old, *outfile = gdb_fopen (filename, "w");

You have to check for a NULL return from gdb_fopen.

Alfredo> +  do_cleanups (cleanups);
Alfredo> +
Alfredo> +}

Extra blank line in there.

Alfredo> +/* Launches the editor on the breakpoint command.  */
Alfredo> +char *
Alfredo> +commands_edit_command (int bnum)

The header comment should describe the meaning of the return value and
the arguments.  For a string return, like this, it should also
describe how the memory is managed.

Alfredo> +  if (!vitmp)
Alfredo> +      error (_("Can't create temporary file for editing."));

Two extra spaces of indentation on the second line, not four.  This
occurs in a few spots.

Alfredo> +  ALL_BREAKPOINTS (b) if (b->number == bnum)

The 'if' should go on a new line.
This will require some reindentation, as well.

Alfredo> +      cmdline = xmalloc (strlen (editor) + strlen (vitmp) + 50);

Instead of 50, just use the correct number.
Or, use xstrprintf, which is simpler.

Alfredo> +      if (sysret < 0)
Alfredo> +	  error (_("Can't execute external editor."));
Alfredo> +      if (sysret > 0)
Alfredo> +	  error (_("External editor returned non-zero status."));

I think you need to use WEXITSTATUS and friends here.

Alfredo> +  ALL_BREAKPOINTS (b) if (b->number == bnum)

Newline.

Alfredo> +    {
Alfredo> +      /* Redirect instream to the commands temporal file.  */

I think this can be just "Read commands from the temporary file."

Alfredo> +      instream = fopen (vitmp, "r");

Needs error checking.

Alfredo> +      unlink (vitmp);

I suspect this should probably be done via a cleanup.

Alfredo> +/* List of subcommands for "edit".  */
Alfredo> +static struct cmd_list_element *edit_command_list;

I don't think you need this...

Alfredo> +  add_prefix_cmd ("edit", class_breakpoint, edit_command,_("\

... because I don't think "edit" needs to be a prefix command.
It can just be an ordinary command.

Alfredo> +extern char *external_editor( void );

Should be " (void)", not "( void )".

Alfredo> +  add_setshow_filename_cmd ("external-editor", no_class, &external_editor_command, _("\

I don't remember... did we already discuss the name of the option?
Why "external-editor" and not the simpler "editor"?

Alfredo> +/* Returns the external editor */

Needs period and 2 spaces at the end.

Alfredo> +  return editor;
Alfredo> +
Alfredo> +}

Extra blank line.

This is pretty close to ready.  Thanks for persevering.

Tom


  reply	other threads:[~2009-02-24 19:46 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <e598931c0901141343j79164cf6we2bc5307f41f41da@mail.gmail.com>
2009-01-14 21:48 ` Alfredo Ortega
2009-01-14 22:38   ` Eli Zaretskii
2009-01-15  1:55     ` Alfredo Ortega
2009-01-22  3:25       ` dgutson
     [not found]     ` <e598931c0901141632m4f124d85l2452f7e2870cad91@mail.gmail.com>
2009-01-15  4:21       ` Eli Zaretskii
2009-01-16  7:39         ` Alfredo Ortega
2009-01-16  9:07           ` Eli Zaretskii
2009-01-16 22:08             ` Alfredo Ortega
2009-01-16 23:38               ` Daniel Jacobowitz
2009-01-16 23:58                 ` Tom Tromey
2009-01-17  9:27                   ` Eli Zaretskii
2009-01-16 23:56               ` Tom Tromey
2009-01-17  9:29               ` Eli Zaretskii
2009-01-19 11:45                 ` Alfredo Ortega
2009-02-02 22:18                   ` Tom Tromey
2009-02-19 20:05                     ` Alfredo Ortega
2009-02-19 20:26                       ` Alfredo Ortega
2009-02-24 20:20                         ` Tom Tromey [this message]
2009-08-28 23:17                           ` Alfredo Ortega
2009-09-18 21:05                             ` Tom Tromey

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=m3bpsrlitf.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=ortegaalfredo@gmail.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