util.c (315433) | util.c (358090) |
---|---|
1/*- 2 * Copyright (c) 2003-2007 Tim Kientzle 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 10 unchanged lines hidden (view full) --- 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#include "bsdtar_platform.h" | 1/*- 2 * Copyright (c) 2003-2007 Tim Kientzle 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 10 unchanged lines hidden (view full) --- 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#include "bsdtar_platform.h" |
27__FBSDID("$FreeBSD: stable/10/contrib/libarchive/tar/util.c 315433 2017-03-16 23:08:18Z mm $"); | 27__FBSDID("$FreeBSD: stable/10/contrib/libarchive/tar/util.c 358090 2020-02-19 01:51:44Z mm $"); |
28 29#ifdef HAVE_SYS_STAT_H 30#include <sys/stat.h> 31#endif 32#ifdef HAVE_SYS_TYPES_H 33#include <sys/types.h> /* Linux doesn't define mode_t, etc. in sys/stat.h. */ 34#endif 35#include <ctype.h> --- 625 unchanged lines hidden (view full) --- 661list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry) 662{ 663 char tmp[100]; 664 size_t w; 665 const char *p; 666 const char *fmt; 667 time_t tim; 668 static time_t now; | 28 29#ifdef HAVE_SYS_STAT_H 30#include <sys/stat.h> 31#endif 32#ifdef HAVE_SYS_TYPES_H 33#include <sys/types.h> /* Linux doesn't define mode_t, etc. in sys/stat.h. */ 34#endif 35#include <ctype.h> --- 625 unchanged lines hidden (view full) --- 661list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry) 662{ 663 char tmp[100]; 664 size_t w; 665 const char *p; 666 const char *fmt; 667 time_t tim; 668 static time_t now; |
669 struct tm *ltime; 670#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) 671 struct tm tmbuf; 672#endif 673#if defined(HAVE__LOCALTIME64_S) 674 errno_t terr; 675 __time64_t tmptime; 676#endif |
|
669 670 /* 671 * We avoid collecting the entire list in memory at once by 672 * listing things as we see them. However, that also means we can't 673 * just pre-compute the field widths. Instead, we start with guesses 674 * and just widen them as necessary. These numbers are completely 675 * arbitrary. 676 */ --- 55 unchanged lines hidden (view full) --- 732#define DAY_FMT "%d" /* Windows' strftime function does not support %e format. */ 733#else 734#define DAY_FMT "%e" /* Day number without leading zeros */ 735#endif 736 if (tim < now - HALF_YEAR || tim > now + HALF_YEAR) 737 fmt = bsdtar->day_first ? DAY_FMT " %b %Y" : "%b " DAY_FMT " %Y"; 738 else 739 fmt = bsdtar->day_first ? DAY_FMT " %b %H:%M" : "%b " DAY_FMT " %H:%M"; | 677 678 /* 679 * We avoid collecting the entire list in memory at once by 680 * listing things as we see them. However, that also means we can't 681 * just pre-compute the field widths. Instead, we start with guesses 682 * and just widen them as necessary. These numbers are completely 683 * arbitrary. 684 */ --- 55 unchanged lines hidden (view full) --- 740#define DAY_FMT "%d" /* Windows' strftime function does not support %e format. */ 741#else 742#define DAY_FMT "%e" /* Day number without leading zeros */ 743#endif 744 if (tim < now - HALF_YEAR || tim > now + HALF_YEAR) 745 fmt = bsdtar->day_first ? DAY_FMT " %b %Y" : "%b " DAY_FMT " %Y"; 746 else 747 fmt = bsdtar->day_first ? DAY_FMT " %b %H:%M" : "%b " DAY_FMT " %H:%M"; |
740 strftime(tmp, sizeof(tmp), fmt, localtime(&tim)); | 748#if defined(HAVE_LOCALTIME_R) 749 ltime = localtime_r(&tim, &tmbuf); 750#elif defined(HAVE__LOCALTIME64_S) 751 tmptime = tim; 752 terr = _localtime64_s(&tmbuf, &tmptime); 753 if (terr) 754 ltime = NULL; 755 else 756 ltime = &tmbuf; 757#else 758 ltime = localtime(&tim); 759#endif 760 strftime(tmp, sizeof(tmp), fmt, ltime); |
741 fprintf(out, " %s ", tmp); 742 safe_fprintf(out, "%s", archive_entry_pathname(entry)); 743 744 /* Extra information for links. */ 745 if (archive_entry_hardlink(entry)) /* Hard link */ 746 safe_fprintf(out, " link to %s", 747 archive_entry_hardlink(entry)); 748 else if (archive_entry_symlink(entry)) /* Symbolic link */ 749 safe_fprintf(out, " -> %s", archive_entry_symlink(entry)); 750} | 761 fprintf(out, " %s ", tmp); 762 safe_fprintf(out, "%s", archive_entry_pathname(entry)); 763 764 /* Extra information for links. */ 765 if (archive_entry_hardlink(entry)) /* Hard link */ 766 safe_fprintf(out, " link to %s", 767 archive_entry_hardlink(entry)); 768 else if (archive_entry_symlink(entry)) /* Symbolic link */ 769 safe_fprintf(out, " -> %s", archive_entry_symlink(entry)); 770} |