X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/bf6825cb9ea9bf73c4eb15d331714be14bc4f927..4a69abcc786d029bd2962537f767d12a0f808d11:/src/xbt/xbt_strbuff.c diff --git a/src/xbt/xbt_strbuff.c b/src/xbt/xbt_strbuff.c index a966f309bb..4369aca483 100644 --- a/src/xbt/xbt_strbuff.c +++ b/src/xbt/xbt_strbuff.c @@ -14,7 +14,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(strbuff, xbt, "String buffers"); /** @brief Remove any content from the buffer */ -inline void xbt_strbuff_empty(xbt_strbuff_t b) +inline void xbt_strbuff_clear(xbt_strbuff_t b) { b->used = 0; b->data[0] = '\0'; @@ -26,7 +26,7 @@ xbt_strbuff_t xbt_strbuff_new(void) xbt_strbuff_t res = xbt_malloc(sizeof(s_xbt_strbuff_t)); res->data = xbt_malloc(512); res->size = 512; - xbt_strbuff_empty(res); + xbt_strbuff_clear(res); return res; } @@ -38,7 +38,8 @@ inline xbt_strbuff_t xbt_strbuff_new_from(const char *ctn) { xbt_strbuff_t res = xbt_malloc(sizeof(s_xbt_strbuff_t)); res->data = xbt_strdup(ctn); - res->used = res->size = strlen(ctn); + res->size = strlen(ctn); + res->used = res->size; return res; } @@ -103,7 +104,8 @@ void xbt_strbuff_printf(xbt_strbuff_t b, const char *fmt, ...) void xbt_strbuff_varsubst(xbt_strbuff_t b, xbt_dict_t patterns) { char *end; /* pointers around the parsed chunk */ - int in_simple_quote = 0, in_double_quote = 0; + int in_simple_quote = 0; + int in_double_quote = 0; int done = 0; if (b->data[0] == '\0') @@ -132,11 +134,13 @@ void xbt_strbuff_varsubst(xbt_strbuff_t b, xbt_dict_t patterns) case '$': if (!in_simple_quote) { /* Go for the substitution. First search the variable name */ - char *beg_var, *end_var; /* variable name boundary */ - char *beg_subst, *end_subst = NULL; /* where value should be written to */ - char *value, *default_value = NULL; + char *beg_var; + char *end_var; /* variable name boundary */ + char *beg_subst = end; + char *end_subst = NULL; /* where value should be written to */ + char *value; + char *default_value = NULL; int val_len; - beg_subst = end; if (*(++end) == '{') { /* the variable name is enclosed in braces. */