=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/rusers/rusers.c,v retrieving revision 1.33 retrieving revision 1.34 diff -c -r1.33 -r1.34 *** src/usr.bin/rusers/rusers.c 2014/11/26 18:34:51 1.33 --- src/usr.bin/rusers/rusers.c 2015/01/16 06:40:11 1.34 *************** *** 1,4 **** ! /* $OpenBSD: rusers.c,v 1.33 2014/11/26 18:34:51 millert Exp $ */ /* * Copyright (c) 2001, 2003 Todd C. Miller --- 1,4 ---- ! /* $OpenBSD: rusers.c,v 1.34 2015/01/16 06:40:11 deraadt Exp $ */ /* * Copyright (c) 2001, 2003 Todd C. Miller *************** *** 46,54 **** * POSSIBILITY OF SUCH DAMAGE. */ - #include #include #include #include #include #include --- 46,54 ---- * POSSIBILITY OF SUCH DAMAGE. */ #include #include + #include #include #include #include *************** *** 65,71 **** --- 65,75 ---- #include #include #include + #include + #define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + #define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + /* Preferred formatting */ #define HOST_WIDTH 17 #define LINE_WIDTH 8 *************** *** 535,541 **** outlen[1] = xdr_getpos(&xdr); xdr_destroy(&xdr); ! maxfd = MAX(sock[0], sock[1]) + 1; fds = (fd_set *)calloc(howmany(maxfd, NFDBITS), sizeof(fd_mask)); if (fds == NULL) err(1, NULL); --- 539,545 ---- outlen[1] = xdr_getpos(&xdr); xdr_destroy(&xdr); ! maxfd = MAXIMUM(sock[0], sock[1]) + 1; fds = (fd_set *)calloc(howmany(maxfd, NFDBITS), sizeof(fd_mask)); if (fds == NULL) err(1, NULL); *************** *** 653,668 **** date[sizeof(date) - 1] = '\0'; fmt_idle(ut->ut_idle, idle_time, sizeof(idle_time)); len = termwidth - ! (MAX(strlen(ut->ut_user), NAME_WIDTH) + 1 + HOST_WIDTH + 1 + LINE_WIDTH + 1 + strlen(date) + ! 1 + MAX(8, strlen(idle_time)) + 1 + 2); if (len > 0 && ut->ut_host[0] != '\0') snprintf(remote, sizeof(remote), "(%.*s)", ! MIN(len, RUSERS_MAXHOSTLEN), ut->ut_host); else remote[0] = '\0'; ! len = HOST_WIDTH - MIN(HOST_WIDTH, strlen(entry->host)) + ! LINE_WIDTH - MIN(LINE_WIDTH, strlen(ut->ut_line)); printf("%-*s %.*s:%.*s%-*s %-12s %8s %s\n", NAME_WIDTH, ut->ut_user, HOST_WIDTH, entry->host, LINE_WIDTH, ut->ut_line, len, "", date, --- 657,672 ---- date[sizeof(date) - 1] = '\0'; fmt_idle(ut->ut_idle, idle_time, sizeof(idle_time)); len = termwidth - ! (MAXIMUM(strlen(ut->ut_user), NAME_WIDTH) + 1 + HOST_WIDTH + 1 + LINE_WIDTH + 1 + strlen(date) + ! 1 + MAXIMUM(8, strlen(idle_time)) + 1 + 2); if (len > 0 && ut->ut_host[0] != '\0') snprintf(remote, sizeof(remote), "(%.*s)", ! MINIMUM(len, RUSERS_MAXHOSTLEN), ut->ut_host); else remote[0] = '\0'; ! len = HOST_WIDTH - MINIMUM(HOST_WIDTH, strlen(entry->host)) + ! LINE_WIDTH - MINIMUM(LINE_WIDTH, strlen(ut->ut_line)); printf("%-*s %.*s:%.*s%-*s %-12s %8s %s\n", NAME_WIDTH, ut->ut_user, HOST_WIDTH, entry->host, LINE_WIDTH, ut->ut_line, len, "", date,