diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-11-02 21:12:13 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-11-02 21:12:13 +0000 |
commit | f0d0be799be9acd5fee5e0b1f39ea196a8f253b6 (patch) | |
tree | 5aa2a873424f7c012a9a2403889c70f48f826a61 | |
parent | fedf9634ae0156c88c2fb9366b0cd54ca0dd230e (diff) | |
download | gnunet-f0d0be799be9acd5fee5e0b1f39ea196a8f253b6.tar.gz gnunet-f0d0be799be9acd5fee5e0b1f39ea196a8f253b6.zip |
fix
-rw-r--r-- | src/util/configuration.c | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/src/util/configuration.c b/src/util/configuration.c index 875fa2f4c..eb201d79b 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c | |||
@@ -1017,7 +1017,8 @@ GNUNET_CONFIGURATION_append_value_filename (struct GNUNET_CONFIGURATION_Handle | |||
1017 | escaped = escape_name (value); | 1017 | escaped = escape_name (value); |
1018 | nw = GNUNET_malloc (strlen (old) + strlen (escaped) + 2); | 1018 | nw = GNUNET_malloc (strlen (old) + strlen (escaped) + 2); |
1019 | strcpy (nw, old); | 1019 | strcpy (nw, old); |
1020 | strcat (nw, " "); | 1020 | if (strlen (old) > 0) |
1021 | strcat (nw, " "); | ||
1021 | strcat (nw, escaped); | 1022 | strcat (nw, escaped); |
1022 | GNUNET_CONFIGURATION_set_value_string (cfg, section, option, nw); | 1023 | GNUNET_CONFIGURATION_set_value_string (cfg, section, option, nw); |
1023 | GNUNET_free (old); | 1024 | GNUNET_free (old); |
@@ -1086,23 +1087,26 @@ GNUNET_CONFIGURATION_remove_value_filename (struct GNUNET_CONFIGURATION_Handle | |||
1086 | } | 1087 | } |
1087 | old = end[0]; | 1088 | old = end[0]; |
1088 | end[0] = '\0'; | 1089 | end[0] = '\0'; |
1089 | if (strlen (pos) > 0) | 1090 | if (0 == strcmp (pos, match)) |
1090 | { | 1091 | { |
1091 | if (0 == strcmp (pos, match)) | 1092 | if (old != '\0') |
1092 | { | 1093 | memmove (pos, &end[1], strlen (&end[1]) + 1); |
1093 | memmove (pos, &end[1], strlen (&end[1]) + 1); | 1094 | else |
1094 | 1095 | { | |
1095 | if (pos != list) | 1096 | if (pos != list) |
1096 | pos[-1] = ' '; /* previously changed to "\0" */ | 1097 | pos[-1] = '\0'; |
1097 | GNUNET_CONFIGURATION_set_value_string (cfg, | 1098 | else |
1098 | section, option, list); | 1099 | pos[0] = '\0'; |
1099 | GNUNET_free (list); | 1100 | } |
1100 | GNUNET_free (match); | 1101 | GNUNET_CONFIGURATION_set_value_string (cfg, |
1101 | return GNUNET_OK; | 1102 | section, option, list); |
1102 | } | 1103 | GNUNET_free (list); |
1103 | } | 1104 | GNUNET_free (match); |
1105 | return GNUNET_OK; | ||
1106 | } | ||
1104 | if (old == '\0') | 1107 | if (old == '\0') |
1105 | break; | 1108 | break; |
1109 | end[0] = old; | ||
1106 | pos = end + 1; | 1110 | pos = end + 1; |
1107 | } | 1111 | } |
1108 | GNUNET_free (list); | 1112 | GNUNET_free (list); |
@@ -1116,7 +1120,7 @@ GNUNET_CONFIGURATION_remove_value_filename (struct GNUNET_CONFIGURATION_Handle | |||
1116 | * system-specific configuration). | 1120 | * system-specific configuration). |
1117 | * | 1121 | * |
1118 | * @param cfg configuration to update | 1122 | * @param cfg configuration to update |
1119 | * @param filename name of the configuration file | 1123 | * @param filename name of the configuration file, NULL to load defaults |
1120 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 1124 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
1121 | */ | 1125 | */ |
1122 | int | 1126 | int |
@@ -1139,7 +1143,7 @@ GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1139 | (GNUNET_OK == GNUNET_CONFIGURATION_parse (cfg, filename))))) | 1143 | (GNUNET_OK == GNUNET_CONFIGURATION_parse (cfg, filename))))) |
1140 | { | 1144 | { |
1141 | GNUNET_free (baseconfig); | 1145 | GNUNET_free (baseconfig); |
1142 | return GNUNET_SYSERR; | 1146 | return (filename == NULL) ? GNUNET_OK : GNUNET_SYSERR; |
1143 | } | 1147 | } |
1144 | GNUNET_free (baseconfig); | 1148 | GNUNET_free (baseconfig); |
1145 | if ( ((GNUNET_YES != GNUNET_CONFIGURATION_have_value (cfg, | 1149 | if ( ((GNUNET_YES != GNUNET_CONFIGURATION_have_value (cfg, |