Minor code cleanup.

* src/muscle-tab.c (MUSCLE_USER_NAME_CONVERT): Remove macro and
replace all uses with UNIQSTR_CONCAT.
* src/uniqstr.c (uniqstr_vsprintf): New function.
* src/uniqstr.h (uniqstr_vsprintf): Add prototype.
(UNIQSTR_CONCAT, UNIQSTR_GEN_FORMAT, UNIQSTR_GEN_FORMAT_): New
macros.
This commit is contained in:
Joel E. Denny
2009-10-07 23:09:43 -04:00
parent 3c5362b825
commit 10659d0ec9
4 changed files with 96 additions and 39 deletions

View File

@@ -23,6 +23,7 @@
#include <error.h>
#include <hash.h>
#include <quotearg.h>
#include <stdarg.h>
#include "uniqstr.h"
@@ -53,6 +54,21 @@ uniqstr_new (char const *str)
return res;
}
uniqstr
uniqstr_vsprintf (char const *format, ...)
{
va_list args;
size_t length;
va_start (args, format);
length = vsnprintf (NULL, 0, format, args);
va_end (args);
char res[length + 1];
va_start (args, format);
vsprintf (res, format, args);
va_end (args);
return uniqstr_new (res);
}
/*------------------------------.
| Abort if S is not a uniqstr. |