2010-11-19 Marcus Brinkmann <mb@g10code.com>
authorMarcus Brinkmann <mb@g10code.com>
Fri, 19 Nov 2010 16:06:43 +0000 (16:06 +0000)
committerMarcus Brinkmann <mb@g10code.com>
Fri, 19 Nov 2010 16:06:43 +0000 (16:06 +0000)
* engine-gpgconf.c (_gpgme_conf_opt_change): Support
self-assignment.  Requested by Marc Mutz.

src/ChangeLog
src/engine-gpgconf.c

index 2215329a5712ddc841f87498493b0a827aafa110..37a1e2dcb4248d483d460d336067d0467c5d6672 100644 (file)
@@ -1,3 +1,8 @@
+2010-11-19  Marcus Brinkmann  <mb@g10code.com>
+
+       * engine-gpgconf.c (_gpgme_conf_opt_change): Support
+       self-assignment.  Requested by Marc Mutz.
+
 2010-11-17  Marcus Brinkmann  <mb@g10code.com>
 
        * vasprintf.c (int_vasprintf) [HAVE_W32CE_SYSTEM]: Just use a
index 990b1b945cf82dfe88d89976ece86bc51a7e473e..44967f5608a073d09b62aa25cd2f90c0900f5ae6 100644 (file)
@@ -618,17 +618,22 @@ _gpgme_conf_arg_release (gpgme_conf_arg_t arg, gpgme_conf_type_t type)
 gpgme_error_t
 _gpgme_conf_opt_change (gpgme_conf_opt_t opt, int reset, gpgme_conf_arg_t arg)
 {
-  if (opt->new_value)
-    release_arg (opt->new_value, opt->alt_type);
-
   if (reset)
     {
-      opt->new_value = NULL;
+      if (opt->new_value)
+       release_arg (opt->new_value, opt->alt_type);
+     opt->new_value = NULL;
       opt->change_value = 0;
     }
   else
     {
-      opt->new_value = arg;
+      /* Support self-assignment, for example for adding an item to an
+        existing list.  */
+      if (opt->new_value && arg != opt->new_value)
+       {
+         release_arg (opt->new_value, opt->alt_type);
+         opt->new_value = arg;
+       }
       opt->change_value = 1;
     }
   return 0;