-#include "gras_config.h"
/*
* snprintf.c - a portable implementation of snprintf
*/
-\f
/* ============================================= */
/* NO USER SERVICABLE PARTS FOLLOWING THIS POINT */
/* ============================================= */
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
-#include "gras_config.h" /* to get a working stdarg.h */
+
+#include "portable.h" /* to get a working stdarg.h */
+
#include <assert.h>
#include <errno.h>
+#include "xbt/str.h"
#ifdef isdigit
#undef isdigit
/* prototypes */
+
#if defined(NEED_ASPRINTF)
int asprintf (char **ptr, const char *fmt, /*args*/ ...);
#endif
-#if defined(NEED_VASPRINTF)
+#if defined(NEED_VASPRINTF)
int vasprintf (char **ptr, const char *fmt, va_list ap);
#endif
+
#if defined(NEED_ASNPRINTF)
int asnprintf (char **ptr, size_t str_m, const char *fmt, /*args*/ ...);
#endif
else if (precision == 0) str_arg_l = 0;
else {
/* memchr on HP does not like n > 2^31 !!! */
- const char *q = memchr(str_arg, '\0',
+ char *q = (char *) memchr(str_arg, '\0',
precision <= 0x7fffffff ? precision : 0x7fffffff);
str_arg_l = !q ? precision : (q-str_arg);
}
int n = min_field_width - (str_arg_l+number_of_zeros_to_pad);
if (n > 0) {
if (str_l < str_m) {
- size_t avail = str_m-str_l;
+ int avail = str_m-str_l;
fast_memset(str+str_l, (zero_padding?'0':' '), (n>avail?avail:n));
}
str_l += n;
int n = zero_padding_insertion_ind;
if (n > 0) {
if (str_l < str_m) {
- size_t avail = str_m-str_l;
+ int avail = str_m-str_l;
fast_memcpy(str+str_l, str_arg, (n>avail?avail:n));
}
str_l += n;
n = number_of_zeros_to_pad;
if (n > 0) {
if (str_l < str_m) {
- size_t avail = str_m-str_l;
+ int avail = str_m-str_l;
fast_memset(str+str_l, '0', (n>avail?avail:n));
}
str_l += n;
{ int n = str_arg_l - zero_padding_insertion_ind;
if (n > 0) {
if (str_l < str_m) {
- size_t avail = str_m-str_l;
+ int avail = str_m-str_l;
fast_memcpy(str+str_l, str_arg+zero_padding_insertion_ind,
(n>avail?avail:n));
}
int n = min_field_width - (str_arg_l+number_of_zeros_to_pad);
if (n > 0) {
if (str_l < str_m) {
- size_t avail = str_m-str_l;
+ int avail = str_m-str_l;
fast_memset(str+str_l, ' ', (n>avail?avail:n));
}
str_l += n;
char *res;
va_start(ap, fmt);
- vasprintf(&res,fmt,ap);
+
+
+ vasprintf(&res,fmt,ap);
+
va_end(ap);
return res;
}