Noticed language.c:*.cfunc?

Andrew Cagney ac131313@cygnus.com
Tue Jun 6 23:45:00 GMT 2000


Happened across this (language.c happens to be the example I've chosen):

  set = add_set_cmd ("language", class_support, var_string_noescape,
		     (char *) &language,
		     "Set the current source language.",
		     &setlist);
  ...
  set->function.cfunc = set_language_command;

where ->function is:

    union
      {
	/* If type is not_set_cmd, call it like this:  */
	void (*cfunc) (char *args, int from_tty);
	/* If type is cmd_set or show_cmd, first set the variables, and
	   then call this.  */
	void (*sfunc) (char *args, int from_tty, struct cmd_list_element * c);
      }
    function;

Notice how ->function.sfunc() is called when a ``set'' command is
encountered .....

If anything, I think this illustrates how an innocent mistake can breed
over time :-)

Rather than rush out and ``fix'' it (If it an't broke then don't fix it
:-), I'd like to suggest that instead both those callbacks be deprecated
in favour of a single useful and generic callback function and the
function be set using an extended versions of the ``add_*_cmd()''
interface.

With that in mind I'll adding a few notes and a pointer to this e-mail
to TODO.

	enjoy,
		Andrew


More information about the Gdb-patches mailing list