156845f1295e0fa50397bb97be93803458e32c01
[gentoo.git] /
1 From 3ea7303181e80e188e72a4fcd98b9970fe554b3b Mon Sep 17 00:00:00 2001
2 From: Chris Kühl <chrisk@openismus.com>
3 Date: Sat, 16 Apr 2011 23:07:20 +0000
4 Subject: Added SI prefix tera to network counter
5
6 https://bugzilla.gnome.org/show_bug.cgi?id=639212
7 ---
8 diff --git a/src/util.cpp b/src/util.cpp
9 index 90073fe..234e6fc 100644
10 --- a/src/util.cpp
11 +++ b/src/util.cpp
12 @@ -149,10 +149,12 @@ procman_make_label_for_mmaps_or_ofiles(const char *format,
13  gchar*
14  procman::format_size(guint64 size, guint64 max_size, bool want_bits)
15  {
16 +
17         enum {
18                 K_INDEX,
19                 M_INDEX,
20 -               G_INDEX
21 +               G_INDEX,
22 +                T_INDEX
23         };
24  
25         struct Format {
26 @@ -160,16 +162,18 @@ procman::format_size(guint64 size, guint64 max_size, bool want_bits)
27                 const char* string;
28         };
29  
30 -       const Format all_formats[2][3] = {
31 -               { { 1UL << 10,  N_("%.1f KiB") },
32 -                 { 1UL << 20,  N_("%.1f MiB") },
33 -                 { 1UL << 30,  N_("%.1f GiB") } },
34 -               { { 1000,       N_("%.1f kbit") },
35 -                 { 1000000,    N_("%.1f Mbit") },
36 -                 { 1000000000, N_("%.1f Gbit") } }
37 +       const Format all_formats[2][4] = {
38 +               { { 1UL << 10,     N_("%.1f KiB")  },
39 +                 { 1UL << 20,     N_("%.1f MiB")  },
40 +                 { 1UL << 30,     N_("%.1f GiB")  },
41 +                  { 1UL << 40,     N_("%.1f TiB")  } },
42 +               { { 1000,          N_("%.1f kbit") },
43 +                 { 1000000,       N_("%.1f Mbit") },
44 +                 { 1000000000,    N_("%.1f Gbit") },
45 +                  { 1000000000000, N_("%.1f Tbit") } }
46         };
47  
48 -       const Format (&formats)[3] = all_formats[want_bits ? 1 : 0];
49 +       const Format (&formats)[4] = all_formats[want_bits ? 1 : 0];
50  
51         if (want_bits) {
52           size *= 8;
53 @@ -194,9 +198,12 @@ procman::format_size(guint64 size, guint64 max_size, bool want_bits)
54                 } else if (max_size < formats[G_INDEX].factor) {
55                   factor = formats[M_INDEX].factor;
56                   format = formats[M_INDEX].string;
57 -               } else {
58 +               } else if (max_size < formats[T_INDEX].factor) {
59                   factor = formats[G_INDEX].factor;
60                   format = formats[G_INDEX].string;
61 +               } else {
62 +                 factor = formats[T_INDEX].factor;
63 +                 format = formats[T_INDEX].string;
64                 }
65  
66                 return g_strdup_printf(_(format), size / (double)factor);
67 --
68 cgit v0.9