IGMP: proxy device
[vpp.git] / src / vppinfra / format.c
index 999b093..e2fd84b 100644 (file)
@@ -62,6 +62,7 @@
 #include <vppinfra/error.h>
 #include <vppinfra/string.h>
 #include <vppinfra/os.h>       /* os_puts */
+#include <vppinfra/math.h>
 
 typedef struct
 {
@@ -462,6 +463,17 @@ fformat (FILE * f, char *fmt, ...)
 }
 
 #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, ...)
 {
@@ -708,8 +720,12 @@ format_float (u8 * s, f64 x, uword n_fraction_digits, uword output_style)
       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);