/* proto.c
* Routines for protocol tree
*
- * $Id: proto.c,v 1.93 2003/06/12 08:33:31 guy Exp $
+ * $Id: proto.c,v 1.94 2003/07/04 03:41:00 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
#include <stdio.h>
#include <string.h>
#include <glib.h>
+#include <float.h>
#ifdef NEED_SNPRINTF_H
# include "snprintf.h"
case FT_FLOAT:
ret = snprintf(label_str, ITEM_LABEL_LENGTH,
- "%s: %.9g", hfinfo->name, fvalue_get_floating(fi->value));
+ "%s: %." STRINGIFY(FLT_DIG) "f",
+ hfinfo->name, fvalue_get_floating(fi->value));
if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH))
label_str[ITEM_LABEL_LENGTH - 1] = '\0';
break;
case FT_DOUBLE:
ret = snprintf(label_str, ITEM_LABEL_LENGTH,
- "%s: %.14g", hfinfo->name, fvalue_get_floating(fi->value));
+ "%s: %." STRINGIFY(DBL_DIG) "g",
+ hfinfo->name, fvalue_get_floating(fi->value));
if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH))
label_str[ITEM_LABEL_LENGTH - 1] = '\0';
break;
*/
dfilter_len = abbrev_len + 4 + 1 + 26 + 1;
buf = g_malloc0(dfilter_len);
- snprintf(buf, dfilter_len, "%s == %f", hfinfo->abbrev,
+ snprintf(buf, dfilter_len, "%s == %." STRINGIFY(FLT_DIG) "f",
+ hfinfo->abbrev,
fvalue_get_floating(finfo->value));
break;
*/
dfilter_len = abbrev_len + 4 + 1 + 26 + 1;
buf = g_malloc0(dfilter_len);
- snprintf(buf, dfilter_len, "%s == %f", hfinfo->abbrev,
+ snprintf(buf, dfilter_len, "%s == %." STRINGIFY(DBL_DIG) "g",
+ hfinfo->abbrev,
fvalue_get_floating(finfo->value));
break;
/* strutil.h
* String utility definitions
*
- * $Id: strutil.h,v 1.9 2002/08/28 20:40:45 jmayer Exp $
+ * $Id: strutil.h,v 1.10 2003/07/04 03:41:00 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
gchar* format_text(const guchar *line, int len);
gchar* bytes_to_str(const guint8 *, int);
gchar* bytes_to_str_punct(const guint8 *, int, gchar punct);
+
+/* Surround a string or a macro, resolved to a string, with double quotes */
+#define _STRINGIFY(a) # a
+#define STRINGIFY(a) _STRINGIFY(a)
+
#endif /* __STRUTIL_H__ */