diff options
-rw-r--r-- | cpio/cpio.c | 2 | ||||
-rw-r--r-- | cpio/test/test.h | 1 | ||||
-rw-r--r-- | cpio/test/test_option_version.c | 5 | ||||
-rw-r--r-- | libarchive/archive.h | 5 | ||||
-rw-r--r-- | libarchive/archive_util.c | 36 | ||||
-rw-r--r-- | libarchive/test/main.c | 2 | ||||
-rw-r--r-- | tar/bsdtar.c | 2 | ||||
-rw-r--r-- | tar/test/test.h | 1 | ||||
-rw-r--r-- | tar/test/test_version.c | 5 |
9 files changed, 56 insertions, 3 deletions
diff --git a/cpio/cpio.c b/cpio/cpio.c index 98fd83cc..ac12c8a2 100644 --- a/cpio/cpio.c +++ b/cpio/cpio.c @@ -489,7 +489,7 @@ version(void) { fprintf(stdout,"bsdcpio %s -- %s\n", BSDCPIO_VERSION_STRING, - archive_version_string()); + archive_version_details()); exit(0); } diff --git a/cpio/test/test.h b/cpio/test/test.h index 666bba0e..27813e1e 100644 --- a/cpio/test/test.h +++ b/cpio/test/test.h @@ -66,6 +66,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <ctype.h> #include <time.h> #ifdef HAVE_UNISTD_H #include <unistd.h> diff --git a/cpio/test/test_option_version.c b/cpio/test/test_option_version.c index 7345da1e..2f2c4090 100644 --- a/cpio/test/test_option_version.c +++ b/cpio/test/test_option_version.c @@ -74,6 +74,11 @@ verify(const char *p, size_t s) /* Skip a single trailing a,b,c, or d. */ if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd') ++q; + /* Skip arbitrary third-party version numbers. */ + while (s > 0 && (*q == ' ' || *q == '/' || *q == '.' || isalnum(*q))) { + ++q; + --s; + } /* All terminated by end-of-line: \r, \r\n, or \n */ assert(s >= 1); failure("Version: %s", p); diff --git a/libarchive/archive.h b/libarchive/archive.h index c89f0dce..4a7b2bd3 100644 --- a/libarchive/archive.h +++ b/libarchive/archive.h @@ -133,6 +133,11 @@ __LA_DECL int archive_version_number(void); #define ARCHIVE_VERSION_STRING "libarchive 3.1.2" __LA_DECL const char * archive_version_string(void); +/* + * Detailed textual name/version of the library and its dependencies. + */ +__LA_DECL const char * archive_version_details(void); + /* Declare our basic types. */ struct archive; struct archive_entry; diff --git a/libarchive/archive_util.c b/libarchive/archive_util.c index 0d614077..637022c8 100644 --- a/libarchive/archive_util.c +++ b/libarchive/archive_util.c @@ -45,6 +45,15 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_util.c 201098 2009-12-28 02:58:1 #if defined(HAVE_WINCRYPT_H) && !defined(__CYGWIN__) #include <wincrypt.h> #endif +#ifdef HAVE_ZLIB_H +#include <zlib.h> +#endif +#ifdef HAVE_LZMA_H +#include <lzma.h> +#endif +#ifdef HAVE_BZLIB_H +#include <bzlib.h> +#endif #include "archive.h" #include "archive_private.h" @@ -76,6 +85,33 @@ archive_version_string(void) return (ARCHIVE_VERSION_STRING); } +const char * +archive_version_details(void) +{ + static char version[80]; +#ifdef HAVE_BZLIB_H + char *bzlib_version = strdup(BZ2_bzlibVersion()); + char *ptr = strchr(bzlib_version, ','); + if (ptr) + *ptr = '\0'; +#endif + snprintf(version, sizeof(version), ARCHIVE_VERSION_STRING +#ifdef HAVE_ZLIB_H + " zlib/" ZLIB_VERSION +#endif +#ifdef HAVE_LZMA_H + " liblzma/" LZMA_VERSION_STRING +#endif +#ifdef HAVE_BZLIB_H + " bz2lib/%s", bzlib_version +#endif + ); +#ifdef HAVE_BZLIB_H + free(bzlib_version); +#endif + return (version); +} + int archive_errno(struct archive *a) { diff --git a/libarchive/test/main.c b/libarchive/test/main.c index 20c5f8f2..54ef608b 100644 --- a/libarchive/test/main.c +++ b/libarchive/test/main.c @@ -67,7 +67,7 @@ __FBSDID("$FreeBSD: head/lib/libarchive/test/main.c 201247 2009-12-30 05:59:21Z #define LIBRARY "libarchive" #define EXTRA_DUMP(x) archive_error_string((struct archive *)(x)) #define EXTRA_ERRNO(x) archive_errno((struct archive *)(x)) -#define EXTRA_VERSION archive_version_string() +#define EXTRA_VERSION archive_version_details() /* * diff --git a/tar/bsdtar.c b/tar/bsdtar.c index d743718f..888ba70a 100644 --- a/tar/bsdtar.c +++ b/tar/bsdtar.c @@ -846,7 +846,7 @@ version(void) { printf("bsdtar %s - %s\n", BSDTAR_VERSION_STRING, - archive_version_string()); + archive_version_details()); exit(0); } diff --git a/tar/test/test.h b/tar/test/test.h index a0a9bb6f..0ef255f7 100644 --- a/tar/test/test.h +++ b/tar/test/test.h @@ -66,6 +66,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <ctype.h> #include <time.h> #ifdef HAVE_UNISTD_H #include <unistd.h> diff --git a/tar/test/test_version.c b/tar/test/test_version.c index 42472d1b..5474261d 100644 --- a/tar/test/test_version.c +++ b/tar/test/test_version.c @@ -87,6 +87,11 @@ DEFINE_TEST(test_version) /* Skip a single trailing a,b,c, or d. */ if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd') ++q; + /* Skip arbitrary third-party version numbers. */ + while (s > 0 && (*q == ' ' || *q == '/' || *q == '.' || isalnum(*q))) { + ++q; + --s; + } /* All terminated by end-of-line. */ assert(s >= 1); /* Skip an optional CR character (e.g., Windows) */ |