Noticed language.c:*.cfunc?

Andrew Cagney
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.",
  set->function.cfunc = set_language_command;

where ->function is:

	/* 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);

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()''

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


More information about the Gdb-patches mailing list