[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: options.c

From: Ben Pfaff
Subject: Re: options.c
Date: Wed, 9 Jan 2013 08:07:17 -0800
User-agent: Mutt/1.5.21 (2010-09-15)

On Wed, Jan 09, 2013 at 11:23:30AM +0100, John Darrington wrote:
> In src/output/options.c  we have:
> /* Creates and returns a new struct driver_option for output driver DRIVER
>    (which is needed only to the extent that its name will be used in error
>    messages).  The option named NAME is extracted from OPTIONS.  DEFAULT_VALUE
>    is the default value of the option, used if the given option was not
>    supplied or was invalid. */


> Why does it use string_map_find_and_delete ? Why not simply string_map_find?
> Why does it need to delete the item from the string map?

The output drivers delete the options that they process from the string
map so that output_driver_create() can report any options that the
output drivers didn't process:

  driver = f->create (file_name, device_type, options);
  if (driver != NULL)
      const struct string_map_node *node;
      const char *key;

      STRING_MAP_FOR_EACH_KEY (key, node, options)
        error (0, 0, _("%s: unknown option `%s'"), file_name, key);

Other methods are possible but this one is very simple.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]