diff options
author | Damien Miller <djm@mindrot.org> | 2017-06-10 15:41:25 +0200 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2017-06-10 15:41:25 +0200 |
commit | bcd1485075aa72ba9418003f5cc27af2b049c51b (patch) | |
tree | 122b7024821c2c47b6df71639fe578bf5f571183 /sftp.c | |
parent | upstream commit (diff) | |
download | openssh-bcd1485075aa72ba9418003f5cc27af2b049c51b.tar.xz openssh-bcd1485075aa72ba9418003f5cc27af2b049c51b.zip |
portability for sftp globbed ls sort by mtime
Include replacement timespeccmp() for systems that lack it.
Support time_t struct stat->st_mtime in addition to
timespec stat->st_mtim, as well as unsorted fallback.
Diffstat (limited to 'sftp.c')
-rw-r--r-- | sftp.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -894,9 +894,15 @@ sglob_comp(const void *aa, const void *bb) #define NCMP(a,b) (a == b ? 0 : (a < b ? 1 : -1)) if (sort_flag & LS_NAME_SORT) return (rmul * strcmp(ap, bp)); - else if (sort_flag & LS_TIME_SORT) + else if (sort_flag & LS_TIME_SORT) { +#if defined(HAVE_STRUCT_STAT_ST_MTIM) return (rmul * timespeccmp(&as->st_mtim, &bs->st_mtim, <)); - else if (sort_flag & LS_SIZE_SORT) +#elif defined(HAVE_STRUCT_STAT_ST_MTIME) + return (rmul * NCMP(as->st_mtime, bs->st_mtime)); +#else + return rmul * 1; +#endif + } else if (sort_flag & LS_SIZE_SORT) return (rmul * NCMP(as->st_size, bs->st_size)); fatal("Unknown ls sort type"); |