]> mj.ucw.cz Git - ywho.git/blobdiff - ywho.c
make release: Reorganized my directory structure
[ywho.git] / ywho.c
diff --git a/ywho.c b/ywho.c
index 09e8cc55b718ed9df93b12490293570f82124446..15d1b46da203a6b38e3ea269b3220f0c45df286c 100644 (file)
--- a/ywho.c
+++ b/ywho.c
@@ -1,7 +1,7 @@
 /*
- *     Extended `who' command, version 1.11.
+ *     Extended `who' command, version 1.12.
  *
- *     (c) 1996--2003 Martin Mares <mj@ucw.cz>
+ *     (c) 1996--2010 Martin Mares <mj@ucw.cz>
  *
  *     This software may be freely distributed and used according to the terms
  *     of the GNU General Public License. See file COPYING in any of the GNU packages.
@@ -256,13 +256,10 @@ line1(void)
     }
 
   {
-    struct tm *tm;
-    char *days[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
     now = time(NULL);
-    tm = localtime(&now);
-    printf(" on %s %02d-%02d-%02d %02d.%02d:%02d", days[tm->tm_wday], tm->tm_mday, tm->tm_mon+1,
-          tm->tm_year%100, tm->tm_hour, tm->tm_min, tm->tm_sec);
-    printf(" (%u UE)\n", (unsigned int) now);
+    struct tm *tm = localtime(&now);
+    strftime(line, sizeof(line), "%a %Y-%m-%d %H.%M:%S", tm);
+    printf(" on %s\n", line);
   }
 }
 
@@ -277,11 +274,14 @@ line2(void)
     {
       int i = 3;
       fgets(line, 256, f);
-      *strchr(line, '\n') = 0;
-      z = line-1;
+      z = strchr(line, '\n');
+      if (z)
+       *z = 0;
+      z = line;
       while (i-- && z)
        {
-         *z = '/';
+         if (z > line)
+           *z = '/';
          z = strchr(z, ' ');
        }
       if (z)
@@ -566,7 +566,7 @@ show(void)
          putchar(' ');
          puttime((unsigned)u->total_time/(unsigned)HZ);
          putchar(' ');
-         for (c = u->proc->cmd_line; *c; c++)
+         for (c = (unsigned char *) u->proc->cmd_line; *c; c++)
            {
              if (*c < 0x20 || (*c >= 0x7f && *c < 0xa0))
                putchar(' ');