Clean up capinfos output.
authorGuy Harris <guy@alum.mit.edu>
Sun, 24 Aug 2014 08:56:36 +0000 (01:56 -0700)
committerGuy Harris <guy@alum.mit.edu>
Sun, 24 Aug 2014 08:57:13 +0000 (08:57 +0000)
Make sure there's always a space between a number and "[TGMK]bytes",
"[TGMK]bits", and "[TGMK]packets".

Change-Id: I710385303e451e9aea6fc9bbea562f59ca0d22c9
Reviewed-on: https://code.wireshark.org/review/3810
Reviewed-by: Guy Harris <guy@alum.mit.edu>
capinfos.c
wsutil/str_util.c
wsutil/str_util.h

index 571c419047f4cc5d00e98cbe4f12f77b9c437ad2..724b3e85a8518e8221de5ceb3ad4e7e165d614bf 100644 (file)
@@ -549,8 +549,8 @@ print_stats(const gchar *filename, capture_info *cf_info)
       if (machine_readable) {
         print_value("", 2, " packets/sec", cf_info->packet_rate);
       } else {
-        size_string = format_size((gint64)cf_info->packet_rate, format_size_unit_none);
-        printf ("%spackets/sec\n", size_string);
+        size_string = format_size((gint64)cf_info->packet_rate, format_size_unit_packets_s);
+        printf ("%s\n", size_string);
         g_free(size_string);
       }
     }
index 696e861ccbc929978fd8bb85fa0a085a631c2048..c171edfa6e3fffa94ab84ad03c5c0230636c860a 100644 (file)
@@ -153,16 +153,22 @@ gchar *format_size(gint64 size, format_size_flags_e flags) {
                case format_size_unit_none:
                        break;
                case format_size_unit_bytes:
-                       g_string_append(human_str, is_small ? "bytes" : "B");
+                       g_string_append(human_str, is_small ? " bytes" : "B");
                        break;
                case format_size_unit_bits:
-                       g_string_append(human_str, is_small ? "bits" : "b");
+                       g_string_append(human_str, is_small ? " bits" : "b");
                        break;
                case format_size_unit_bits_s:
-                       g_string_append(human_str, is_small ? "bits/s" : "bps");
+                       g_string_append(human_str, is_small ? " bits/s" : "bps");
                        break;
                case format_size_unit_bytes_s:
-                       g_string_append(human_str, is_small ? "bytes/s" : "Bps");
+                       g_string_append(human_str, is_small ? " bytes/s" : "Bps");
+                       break;
+               case format_size_unit_packets:
+                       g_string_append(human_str, is_small ? " packets" : "packets");
+                       break;
+               case format_size_unit_packets_s:
+                       g_string_append(human_str, is_small ? " packets/s" : "packets/s");
                        break;
                default:
                        g_assert_not_reached();
index 04e33c445e155422d77fb4017dd3f463fe2b0d64..971fa3542d133444da78bb74c4accfcf97031e3c 100644 (file)
@@ -86,11 +86,13 @@ WS_DLL_PUBLIC
 int ws_xton(char ch);
 
 typedef enum {
-    format_size_unit_none    = 0,       /**< No unit will be appended. You must supply your own. */
-    format_size_unit_bytes   = 1,       /**< "bytes" for un-prefixed sizes, "B" otherwise. */
-    format_size_unit_bits    = 2,       /**< "bits" for un-prefixed sizes, "b" otherwise. */
-    format_size_unit_bits_s  = 3,       /**< "bits/s" for un-prefixed sizes, "bps" otherwise. */
-    format_size_unit_bytes_s = 4,       /**< "bytes/s" for un-prefixed sizes, "Bps" otherwise. */
+    format_size_unit_none      = 0,     /**< No unit will be appended. You must supply your own. */
+    format_size_unit_bytes     = 1,     /**< "bytes" for un-prefixed sizes, "B" otherwise. */
+    format_size_unit_bits      = 2,     /**< "bits" for un-prefixed sizes, "b" otherwise. */
+    format_size_unit_bits_s    = 3,     /**< "bits/s" for un-prefixed sizes, "bps" otherwise. */
+    format_size_unit_bytes_s   = 4,     /**< "bytes/s" for un-prefixed sizes, "Bps" otherwise. */
+    format_size_unit_packets   = 5,     /**< "packets" */
+    format_size_unit_packets_s = 6,     /**< "packets/s" */
     format_size_prefix_si    = 0 << 8,  /**< SI (power of 1000) prefixes will be used. */
     format_size_prefix_iec   = 1 << 8   /**< IEC (power of 1024) prefixes will be used. */
     /* XXX format_size_prefix_default_for_this_particular_os ? */