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.

_______________________________________________
pspp-dev mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/pspp-dev

Reply via email to