]> granicus.if.org Git - procps-ng/commitdiff
w: Show time with TIME_BITS=64 on 32bit env
authorCraig Small <csmall@dropbear.xyz>
Wed, 9 Nov 2022 10:02:09 +0000 (21:02 +1100)
committerCraig Small <csmall@dropbear.xyz>
Wed, 9 Nov 2022 10:02:09 +0000 (21:02 +1100)
Thanks to @kabe-gl for this patch.

w command shows ????? for LOGIN@ column when compiled on 32bit environment with -D_TIME_BITS=64.

References:
 #256

Signed-off-by: Craig Small <csmall@dropbear.xyz>
NEWS
src/w.c

diff --git a/NEWS b/NEWS
index cdbfef9436c153cd4abeec665741d291e95470b2..cdd02a6fe4bc440f69427e2bd0e4b6fc5ed49737 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ procps-ng-NEXT
 ---------------
   * library
     Handle absent 'core_id' in /proc/cpuinfo
+  * w: Show time with D_TIME_BITS=64 on 32bit env          issue #256
  
 procps-ng-4.0.1
 ---------------
diff --git a/src/w.c b/src/w.c
index 8b37179820c9003c01c287e5ebf66921b19750e9..63f81c725f6824a4f38d09cbdb04625382711897 100644 (file)
--- a/src/w.c
+++ b/src/w.c
@@ -251,34 +251,34 @@ static void print_time_ival7(time_t t, int centi_sec, FILE * fout)
        if (oldstyle) {
                if (t >= 48 * 60 * 60)
                        /* > 2 days */
-                       fprintf(fout, _(" %2ludays"), t / (24 * 60 * 60));
+                       fprintf(fout, _(" %2lludays"), (unsigned long long)t / (24 * 60 * 60));
                else if (t >= 60 * 60)
                        /* > 1 hour */
                        /* Translation Hint: Hours:Minutes */
-                       fprintf(fout, " %2lu:%02u ", t / (60 * 60),
+                       fprintf(fout, " %2llu:%02u ", (unsigned long long)t / (60 * 60),
                                (unsigned)((t / 60) % 60));
                else if (t > 60)
                        /* > 1 minute */
                        /* Translation Hint: Minutes:Seconds */
-                       fprintf(fout, _(" %2lu:%02um"), t / 60, (unsigned)t % 60);
+                       fprintf(fout, _(" %2llu:%02um"), (unsigned long long)t / 60, (unsigned)t % 60);
                else
                        fprintf(fout, "       ");
        } else {
                if (t >= 48 * 60 * 60)
                        /* 2 days or more */
-                       fprintf(fout, _(" %2ludays"), t / (24 * 60 * 60));
+                       fprintf(fout, _(" %2lludays"), (unsigned long long)t / (24 * 60 * 60));
                else if (t >= 60 * 60)
                        /* 1 hour or more */
                        /* Translation Hint: Hours:Minutes */
-                       fprintf(fout, _(" %2lu:%02um"), t / (60 * 60),
+                       fprintf(fout, _(" %2llu:%02um"), (unsigned long long)t / (60 * 60),
                                (unsigned)((t / 60) % 60));
                else if (t > 60)
                        /* 1 minute or more */
                        /* Translation Hint: Minutes:Seconds */
-                       fprintf(fout, " %2lu:%02u ", t / 60, (unsigned)t % 60);
+                       fprintf(fout, " %2llu:%02u ", (unsigned long long)t / 60, (unsigned)t % 60);
                else
                        /* Translation Hint: Seconds:Centiseconds */
-                       fprintf(fout, _(" %2lu.%02us"), t, centi_sec);
+                       fprintf(fout, _(" %2llu.%02us"), (unsigned long long)t, centi_sec);
        }
 }