#endif
/* some other values of possible interest: */
- /* #define breakeven_point 8 *//* VAX 4000 - vaxc */
- /* #define breakeven_point 19 *//* VAX 4000 - gcc 2.7.0 */
+ /* #define breakeven_point 8 *//* VAX 4000 - vaxc */
+ /* #define breakeven_point 19 *//* VAX 4000 - gcc 2.7.0 */
#ifndef breakeven_point
# define breakeven_point 6 /* some reasonable one-size-fits-all value */
int portable_snprintf(char *str, size_t str_m, const char *fmt, /*args */
...);
#if !defined(NEED_SNPRINTF_ONLY)
-int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap);
+int portable_vsnprintf(char *str, size_t str_m, const char *fmt,
+ va_list ap);
#endif
#endif
#if !defined(HAVE_SNPRINTF) || defined(PREFER_PORTABLE_SNPRINTF)
#if !defined(NEED_SNPRINTF_ONLY)
-int portable_snprintf(char *str, size_t str_m, const char *fmt, /*args */ ...)
+int portable_snprintf(char *str, size_t str_m, const char *fmt, /*args */
+ ...)
{
va_list ap;
int str_l;
#endif
#if defined(NEED_SNPRINTF_ONLY)
-int portable_snprintf(char *str, size_t str_m, const char *fmt, /*args */ ...)
+int portable_snprintf(char *str, size_t str_m, const char *fmt, /*args */
+ ...)
{
#else
-int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap)
+int portable_vsnprintf(char *str, size_t str_m, const char *fmt,
+ va_list ap)
{
#endif
/* Actually it uses 0x prefix even for a zero value. */
&& arg_sign != 0
#endif
- ) {
+ ) {
tmp[str_arg_l++] = '0';
tmp[str_arg_l++] = 'x';
}
* converting a zero value with a precision of zero is a null string.
* Actually HP returns all zeroes, and Linux returns "(nil)". */
#endif
- ) {
+ ) {
/* converted to null string */
/* When zero value is formatted with an explicit precision 0,
the resulting formatted string is empty (d, i, u, o, x, X, p). */
&& !(zero_padding_insertion_ind < str_arg_l
&& tmp[zero_padding_insertion_ind] == '0')
#endif
- ) { /* assure leading zero for alternate-form octal numbers */
+ ) { /* assure leading zero for alternate-form octal numbers */
if (!precision_specified || precision < num_of_digits + 1) {
/* precision is increased to force the first character to be zero,
except if a zero value is formatted with an explicit precision
/* FIXME: better place */
#include "xbt/sysdep.h"
+char *bvprintf(const char *fmt, va_list ap)
+{
+ char *res;
+
+ if (vasprintf(&res, fmt, ap) < 0) {
+ /* Do not want to use xbt_die() here, as it uses the logging
+ * infrastucture and may fail to allocate memory too. */
+ fprintf(stderr, "bprintf: vasprintf failed. Aborting.\n");
+ abort();
+ }
+ return res;
+}
+
char *bprintf(const char *fmt, ...)
{
va_list ap;
char *res;
- int len;
va_start(ap, fmt);
-
- len = vasprintf(&res, fmt, ap);
-
+ res = bvprintf(fmt, ap);
va_end(ap);
return res;
}