]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/config.c
reduce code duplication
[openldap] / servers / slapd / config.c
index a08242ddf3a07a9f6b4ca1acb75e4689153a1157..bc1e4b486bce10372e4f21d08505b4c199e40d30 100644 (file)
@@ -1458,23 +1458,31 @@ slap_cf_aux_table_unparse( void *src, struct berval *bv, slap_cf_aux_table *tab0
                        break;
 
                case 'x':
-                       *ptr++ = ' ';
-                       ptr = lutil_strcopy( ptr, tab->key.bv_val );
-                       if ( tab->quote ) *ptr++ = '"';
-                       if ( tab->aux != NULL ) {
-                               struct berval value;
-                               slap_cf_aux_table_parse_x *func = (slap_cf_aux_table_parse_x *)tab->aux;
-                               int rc;
+                       {
+                               char *saveptr=ptr;
+                               *ptr++ = ' ';
+                               ptr = lutil_strcopy( ptr, tab->key.bv_val );
+                               if ( tab->quote ) *ptr++ = '"';
+                               if ( tab->aux != NULL ) {
+                                       struct berval value;
+                                       slap_cf_aux_table_parse_x *func = (slap_cf_aux_table_parse_x *)tab->aux;
+                                       int rc;
 
-                               value.bv_val = ptr;
-                               value.bv_len = buf + sizeof( buf ) - ptr;
+                                       value.bv_val = ptr;
+                                       value.bv_len = buf + sizeof( buf ) - ptr;
 
-                               rc = func( &value, (void *)((char *)src + tab->off), tab, "(unparse)", 1 );
-                               if ( rc == 0 ) {
-                                       ptr += value.bv_len;
+                                       rc = func( &value, (void *)((char *)src + tab->off), tab, "(unparse)", 1 );
+                                       if ( rc == 0 ) {
+                                               if (value.bv_len) {
+                                                       ptr += value.bv_len;
+                                               } else {
+                                                       ptr = saveptr;
+                                                       break;
+                                               }
+                                       }
                                }
+                               if ( tab->quote ) *ptr++ = '"';
                        }
-                       if ( tab->quote ) *ptr++ = '"';
                        break;
 
                default: