From 0f363218b6297c0e27748b2a57be3f3790950e72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Wed, 13 Aug 2014 07:33:49 +0200 Subject: core: make argument "errors" optional in function string_replace_with_callback --- src/core/wee-eval.c | 5 +---- src/core/wee-string.c | 15 ++++++++++----- 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); -- cgit v1.2.3