X-Git-Url: http://git.itanic.dy.fi/?p=log-plotter;a=blobdiff_plain;f=config.c;fp=config.c;h=8b84d58a27f7bfa7f1f7b6305342d8b1bc5d0fea;hp=1dcc9c859224d394fd30d64e369417470cea1dbf;hb=0a59c3e87ef985e0af68e552500de1c3a022b53b;hpb=e7ce6c43fe34b6f5fd6b3abfeb3e121c6d9bbc0c diff --git a/config.c b/config.c index 1dcc9c8..8b84d58 100644 --- a/config.c +++ b/config.c @@ -247,7 +247,7 @@ static char *get_value_for_variable(char *variable, static int replace_variable_with_value(char *str, size_t len, char *variable_start, char *variable_end, - const char *value) + const char *value, char **endptr) { int value_len = strlen(value); char *from, *to; @@ -265,6 +265,8 @@ static int replace_variable_with_value(char *str, size_t len, from = variable_end + 1; to = variable_start + value_len; + *endptr = to; + while (*from) { *to = *from; from++; @@ -301,6 +303,8 @@ static int replace_variable_with_value(char *str, size_t len, to--; } + *endptr = from; + /* * use memcpy to avoid NULL terminating prematurely * the target string @@ -343,7 +347,6 @@ int replace_variables_with_values(char *str, size_t len, variable_end = ptr; *ptr = 0; - ptr++; value = get_value_for_variable(variable_start, cfg); if (!value) { @@ -358,7 +361,7 @@ int replace_variables_with_values(char *str, size_t len, continue; } overflow = replace_variable_with_value(str, len, replace_start, - variable_end, value); + variable_end, value, &ptr); } if (overflow)