#include <vppinfra/error.h>
#include <vppinfra/string.h>
#include <vppinfra/os.h> /* os_puts */
+#include <vppinfra/math.h>
typedef struct
{
if (n_left > 0)
{
vec_insert (s, n_left, i0);
- memset (s + i0, fi->pad_char, n_left);
+ clib_memset (s + i0, fi->pad_char, n_left);
l1 = vec_len (s);
}
if (n_right > 0)
{
vec_resize (s, n_right);
- memset (s + l1, fi->pad_char, n_right);
+ clib_memset (s + l1, fi->pad_char, n_right);
}
}
return s;
}
-static u8 *
-do_percent (u8 ** _s, u8 * fmt, va_list * va)
+static const u8 *
+do_percent (u8 ** _s, const u8 * fmt, va_list * va)
{
u8 *s = *_s;
uword c;
- u8 *f = fmt;
+ const u8 *f = fmt;
format_info_t fi = {
.justify = '+',
u8 *
va_format (u8 * s, const char *fmt, va_list * va)
{
- u8 *f = (u8 *) fmt, *g;
+ const u8 *f = (u8 *) fmt, *g;
u8 c;
g = f;
}
#ifdef CLIB_UNIX
+void
+fformat_append_cr (FILE * ofp, const char *fmt, ...)
+{
+ va_list va;
+
+ va_start (va, fmt);
+ (void) va_fformat (ofp, (char *) fmt, &va);
+ va_end (va);
+ fformat (ofp, "\n");
+}
+
word
fdformat (int fd, char *fmt, ...)
{
sign = 1;
}
+ /* Check for not-a-number. */
+ if (isnan (x))
+ return format (s, "%cNaN", sign ? '-' : '+');
+
/* Check for infinity. */
- if (x == x / 2)
+ if (isinf (x))
return format (s, "%cinfinity", sign ? '-' : '+');
x = normalize (x, &expon, &prec);