Print this page
2849 uptime should use locale settings for current time

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/w/w.c
          +++ new/usr/src/cmd/w/w.c
↓ open down ↓ 121 lines elided ↑ open up ↑
 122  122   */
 123  123  static struct uproc     pr_htbl[HSIZE];
 124  124  
 125  125  static struct   uproc   *findhash(pid_t);
 126  126  static time_t   findidle(char *);
 127  127  static void     clnarglist(char *);
 128  128  static void     showtotals(struct uproc *);
 129  129  static void     calctotals(struct uproc *);
 130  130  static void     prttime(time_t, char *);
 131  131  static void     prtat(time_t *time);
 132      -static void     checkampm(char *str);
 133  132  
 134  133  static char     *prog;          /* pointer to invocation name */
 135  134  static int      header = 1;     /* true if -h flag: don't print heading */
 136  135  static int      lflag = 1;      /* set if -l flag; 0 for -s flag: short form */
 137  136  static char     *sel_user;      /* login of particular user selected */
 138  137  static char     firstchar;      /* first char of name of prog invoked as */
 139  138  static int      login;          /* true if invoked as login shell */
 140  139  static time_t   now;            /* current time of day */
 141  140  static time_t   uptime;         /* time of last reboot & elapsed time since */
 142  141  static int      nusers;         /* number of users logged in now */
↓ open down ↓ 526 lines elided ↑ open up ↑
 669  668   */
 670  669  static void
 671  670  prtat(time_t *time)
 672  671  {
 673  672          struct tm       *p;
 674  673  
 675  674          p = localtime(time);
 676  675          if (now - *time <= 18 * HR) {
 677  676                  char timestr[50];
 678  677                  (void) strftime(timestr, sizeof (timestr),
 679      -                    dcgettext(NULL, "%l:%M""%p", LC_TIME), p);
 680      -                checkampm(timestr);
      678 +                    " %R  ", p);
 681  679                  PRINTF((" %s", timestr));
 682  680          } else if (now - *time <= 7 * DAY) {
 683  681                  char weekdaytime[20];
 684  682  
 685  683                  (void) strftime(weekdaytime, sizeof (weekdaytime),
 686      -                    dcgettext(NULL, "%a%l%p", LC_TIME), p);
 687      -                checkampm(weekdaytime);
      684 +                    "%a%H  ", p);
 688  685                  PRINTF((" %s", weekdaytime));
 689  686          } else {
 690  687                  char monthtime[20];
 691  688  
 692  689                  (void) strftime(monthtime, sizeof (monthtime),
 693      -                    dcgettext(NULL, "%e%b%y", LC_TIME), p);
      690 +                    "%e%b%y", p);
 694  691                  PRINTF((" %s", monthtime));
 695  692          }
 696  693  }
 697  694  
 698  695  /*
 699  696   * find & return number of minutes current tty has been idle
 700  697   */
 701  698  static time_t
 702  699  findidle(char *devname)
 703  700  {
↓ open down ↓ 27 lines elided ↑ open up ↑
 731  728          for (c = arglist; *c != NULL; c++) {
 732  729                  if ((*c < ' ') || (*c > 0176)) {
 733  730                          if (err++ > 5) {
 734  731                                  *arglist = NULL;
 735  732                                  break;
 736  733                          }
 737  734                          *c = '?';
 738  735                  }
 739  736          }
 740  737  }
 741      -
 742      -/* replaces all occurences of AM/PM with am/pm */
 743      -static void
 744      -checkampm(char *str)
 745      -{
 746      -        char *ampm;
 747      -        while ((ampm = strstr(str, "AM")) != NULL ||
 748      -            (ampm = strstr(str, "PM")) != NULL) {
 749      -                *ampm = tolower(*ampm);
 750      -                *(ampm+1) = tolower(*(ampm+1));
 751      -        }
 752      -}
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX