diff options
author | deraadt@openbsd.org <deraadt@openbsd.org> | 2016-09-12 01:22:38 +0000 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2016-09-12 13:46:29 +1000 |
commit | 9136ec134c97a8aff2917760c03134f52945ff3c (patch) | |
tree | bfcab357e6e0f510d9b63bac43b18097e89fa58a /sftp.c | |
parent | f219fc8f03caca7ac82a38ed74bbd6432a1195e7 (diff) |
upstream commit
Add MAXIMUM(), MINIMUM(), and ROUNDUP() to misc.h, then
use those definitions rather than pulling <sys/param.h> and unknown namespace
pollution. ok djm markus dtucker
Upstream-ID: 712cafa816c9f012a61628b66b9fbd5687223fb8
Diffstat (limited to 'sftp.c')
-rw-r--r-- | sftp.c | 19 |
1 files changed, 9 insertions, 10 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sftp.c,v 1.175 2016/07/22 03:47:36 djm Exp $ */ | 1 | /* $OpenBSD: sftp.c,v 1.176 2016/09/12 01:22:38 deraadt Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> | 3 | * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> |
4 | * | 4 | * |
@@ -17,7 +17,6 @@ | |||
17 | 17 | ||
18 | #include "includes.h" | 18 | #include "includes.h" |
19 | 19 | ||
20 | #include <sys/param.h> /* MIN MAX */ | ||
21 | #include <sys/types.h> | 20 | #include <sys/types.h> |
22 | #include <sys/ioctl.h> | 21 | #include <sys/ioctl.h> |
23 | #ifdef HAVE_SYS_STAT_H | 22 | #ifdef HAVE_SYS_STAT_H |
@@ -802,7 +801,7 @@ do_ls_dir(struct sftp_conn *conn, const char *path, | |||
802 | /* Count entries for sort and find longest filename */ | 801 | /* Count entries for sort and find longest filename */ |
803 | for (n = 0; d[n] != NULL; n++) { | 802 | for (n = 0; d[n] != NULL; n++) { |
804 | if (d[n]->filename[0] != '.' || (lflag & LS_SHOW_ALL)) | 803 | if (d[n]->filename[0] != '.' || (lflag & LS_SHOW_ALL)) |
805 | m = MAX(m, strlen(d[n]->filename)); | 804 | m = MAXIMUM(m, strlen(d[n]->filename)); |
806 | } | 805 | } |
807 | 806 | ||
808 | /* Add any subpath that also needs to be counted */ | 807 | /* Add any subpath that also needs to be counted */ |
@@ -814,9 +813,9 @@ do_ls_dir(struct sftp_conn *conn, const char *path, | |||
814 | width = ws.ws_col; | 813 | width = ws.ws_col; |
815 | 814 | ||
816 | columns = width / (m + 2); | 815 | columns = width / (m + 2); |
817 | columns = MAX(columns, 1); | 816 | columns = MAXIMUM(columns, 1); |
818 | colspace = width / columns; | 817 | colspace = width / columns; |
819 | colspace = MIN(colspace, width); | 818 | colspace = MINIMUM(colspace, width); |
820 | } | 819 | } |
821 | 820 | ||
822 | if (lflag & SORT_FLAGS) { | 821 | if (lflag & SORT_FLAGS) { |
@@ -915,10 +914,10 @@ do_globbed_ls(struct sftp_conn *conn, const char *path, | |||
915 | if (!(lflag & LS_SHORT_VIEW)) { | 914 | if (!(lflag & LS_SHORT_VIEW)) { |
916 | /* Count entries for sort and find longest filename */ | 915 | /* Count entries for sort and find longest filename */ |
917 | for (i = 0; g.gl_pathv[i]; i++) | 916 | for (i = 0; g.gl_pathv[i]; i++) |
918 | m = MAX(m, strlen(g.gl_pathv[i])); | 917 | m = MAXIMUM(m, strlen(g.gl_pathv[i])); |
919 | 918 | ||
920 | columns = width / (m + 2); | 919 | columns = width / (m + 2); |
921 | columns = MAX(columns, 1); | 920 | columns = MAXIMUM(columns, 1); |
922 | colspace = width / columns; | 921 | colspace = width / columns; |
923 | } | 922 | } |
924 | 923 | ||
@@ -1669,16 +1668,16 @@ complete_display(char **list, u_int len) | |||
1669 | 1668 | ||
1670 | /* Count entries for sort and find longest */ | 1669 | /* Count entries for sort and find longest */ |
1671 | for (y = 0; list[y]; y++) | 1670 | for (y = 0; list[y]; y++) |
1672 | m = MAX(m, strlen(list[y])); | 1671 | m = MAXIMUM(m, strlen(list[y])); |
1673 | 1672 | ||
1674 | if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1) | 1673 | if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1) |
1675 | width = ws.ws_col; | 1674 | width = ws.ws_col; |
1676 | 1675 | ||
1677 | m = m > len ? m - len : 0; | 1676 | m = m > len ? m - len : 0; |
1678 | columns = width / (m + 2); | 1677 | columns = width / (m + 2); |
1679 | columns = MAX(columns, 1); | 1678 | columns = MAXIMUM(columns, 1); |
1680 | colspace = width / columns; | 1679 | colspace = width / columns; |
1681 | colspace = MIN(colspace, width); | 1680 | colspace = MINIMUM(colspace, width); |
1682 | 1681 | ||
1683 | printf("\n"); | 1682 | printf("\n"); |
1684 | m = 1; | 1683 | m = 1; |