summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2014-08-13 07:33:49 +0200
committerSébastien Helleu <flashcode@flashtux.org>2014-08-13 07:33:49 +0200
commit0f363218b6297c0e27748b2a57be3f3790950e72 (patch)
treeb7f843b0afd0256e6cdf09225fd39af778a9ea8a /src
parent3d63ed0eaffdd4af3c6e53e5bb6838a553dc2613 (diff)
downloadweechat-0f363218b6297c0e27748b2a57be3f3790950e72.zip
core: make argument "errors" optional in function string_replace_with_callback
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-eval.c5
-rw-r--r--src/core/wee-string.c15
2 files changed, 11 insertions, 9 deletions
diff --git a/src/core/wee-eval.c b/src/core/wee-eval.c
index ce64139e3..cdee2ec79 100644
--- a/src/core/wee-eval.c
+++ b/src/core/wee-eval.c
@@ -395,16 +395,13 @@ eval_replace_vars (const char *expr, struct t_hashtable *pointers,
struct t_hashtable *extra_vars,
const char *prefix, const char *suffix)
{
- int errors;
void *ptr[2];
ptr[0] = pointers;
ptr[1] = extra_vars;
return string_replace_with_callback (expr, prefix, suffix,
- &eval_replace_vars_cb,
- ptr,
- &errors);
+ &eval_replace_vars_cb, ptr, NULL);
}
/*
diff --git a/src/core/wee-string.c b/src/core/wee-string.c
index dc184b9ca..6d9af0ede 100644
--- a/src/core/wee-string.c
+++ b/src/core/wee-string.c
@@ -2641,7 +2641,8 @@ string_input_for_buffer (const char *string)
*
* Nested variables are supported, for example: "${var1:${var2}}".
*
- * Argument "errors" is set with number of keys not found by callback.
+ * Argument "errors" (if not NULL) is set with number of keys not found by
+ * callback.
*
* Note: result must be freed after use.
*/
@@ -2659,7 +2660,8 @@ string_replace_with_callback (const char *string,
char *result, *result2, *key, *key2, *value;
const char *pos_end_name;
- *errors = 0;
+ if (errors)
+ *errors = 0;
if (!string || !prefix || !prefix[0] || !suffix || !suffix[0] || !callback)
return NULL;
@@ -2710,7 +2712,8 @@ string_replace_with_callback (const char *string,
if (!pos_end_name[0])
{
result[index_result] = '\0';
- (*errors)++;
+ if (errors)
+ (*errors)++;
return result;
}
key = string_strndup (string + index_string + length_prefix,
@@ -2724,7 +2727,8 @@ string_replace_with_callback (const char *string,
suffix, callback,
callback_data,
&sub_errors);
- (*errors) += sub_errors;
+ if (errors)
+ (*errors) += sub_errors;
free (key);
key = key2;
}
@@ -2755,7 +2759,8 @@ string_replace_with_callback (const char *string,
else
{
result[index_result++] = string[index_string++];
- (*errors)++;
+ if (errors)
+ (*errors)++;
}
if (key)
free (key);