PERFORCE change 144285 for review
Anselm Strauss
strauss at FreeBSD.org
Sun Jun 29 16:13:58 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=144285
Change 144285 by strauss at strauss_marvelman on 2008/06/29 16:13:42
- integrated latest changes from libarchive-portable
- todos
Affected files ...
.. //depot/projects/soc2008/strauss_libarchive/Makefile.am#4 integrate
.. //depot/projects/soc2008/strauss_libarchive/NEWS#5 integrate
.. //depot/projects/soc2008/strauss_libarchive/TODO#4 edit
.. //depot/projects/soc2008/strauss_libarchive/autogen.sh#6 edit
.. //depot/projects/soc2008/strauss_libarchive/configure.ac#3 integrate
.. //depot/projects/soc2008/strauss_libarchive/cpio/cmdline.c#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/cpio/config_freebsd.h#4 integrate
.. //depot/projects/soc2008/strauss_libarchive/cpio/cpio.c#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/cpio/cpio.h#3 integrate
.. //depot/projects/soc2008/strauss_libarchive/cpio/matching.c#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/cpio/test/main.c#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/cpio/test/test.h#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_entry_link_resolver.c#7 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_entry_strmode.c#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_compression_program.c#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_format_mtree.c#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_format_zip.c#7 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_string.c#7 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_string.h#5 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_disk.c#7 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_set_compression_program.c#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/config_freebsd.h#4 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/config_windows.h#2 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/filter_fork.c#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/test/main.c#7 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test.h#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_link_resolver.c#5 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_read_extract.c#5 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_read_format_isorr_bz2.c#5 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_read_format_isorr_bz2.iso.bz2.uu#1 branch
.. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_read_format_zip.c#5 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_read_format_zip.zip.uu#1 branch
.. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_write_disk.c#5 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_write_disk_perms.c#5 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_write_disk_secure.c#5 integrate
.. //depot/projects/soc2008/strauss_libarchive/tar/bsdtar.c#7 integrate
.. //depot/projects/soc2008/strauss_libarchive/tar/config_freebsd.h#4 integrate
.. //depot/projects/soc2008/strauss_libarchive/tar/read.c#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/tar/subst.c#5 integrate
.. //depot/projects/soc2008/strauss_libarchive/tar/test/main.c#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/tar/test/test.h#7 integrate
.. //depot/projects/soc2008/strauss_libarchive/tar/util.c#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/tar/write.c#6 integrate
Differences ...
==== //depot/projects/soc2008/strauss_libarchive/Makefile.am#4 (text+ko) ====
@@ -254,6 +254,7 @@
libarchive/test/test_read_format_gtar_sparse_1_17_posix01.tgz.uu \
libarchive/test/test_read_format_gtar_sparse_1_17_posix10.tgz.uu \
libarchive/test/test_read_format_gtar_sparse_1_17_posix10_modified.tar.uu \
+ libarchive/test/test_read_format_isorr_bz2.iso.bz2.uu \
libarchive/test/test_read_format_tar_empty_filename.tar.uu
==== //depot/projects/soc2008/strauss_libarchive/NEWS#5 (text+ko) ====
@@ -1,3 +1,6 @@
+Jun 20, 2008: If a -l link fails with EXDEV, copy the file instead
+Jun 19, 2008: Add some additional long options for better GNU cpio compat
+Jun 15, 2008: Many small portability and bugfixes since 2.5.4b.
May 25, 2008: libarchive 2.5.4b released
May 21, 2008: Joerg Sonnenberger: fix bsdtar hardlink handling for newc format
==== //depot/projects/soc2008/strauss_libarchive/TODO#4 (text+ko) ====
@@ -1,6 +1,7 @@
To Be Done
==========
+- About the keywords: of course they always change when integrating ...
- Not all P4 keywords do expand (tested on OS X and FreeBSD)
==== //depot/projects/soc2008/strauss_libarchive/autogen.sh#6 (text+kox) ====
@@ -1,3 +1,3 @@
#!/bin/sh
-autoreconf -i
+autoreconf -i --force
==== //depot/projects/soc2008/strauss_libarchive/configure.ac#3 (text+ko) ====
@@ -9,8 +9,8 @@
dnl bsdtar versioning tracks libarchive
m4_define([BSDTAR_VERSION_S],LIBARCHIVE_VERSION_S())
-dnl bsdcpio is still versioning separately
-m4_define([BSDCPIO_VERSION_S],[0.9.10a])
+dnl bsdcpio is still versioning separately, as it's less mature.
+m4_define([BSDCPIO_VERSION_S],[1.0.0])
#
# Now starts the "real" configure script.
@@ -163,16 +163,7 @@
AC_HEADER_DIRENT
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([bzlib.h errno.h ext2fs/ext2_fs.h fcntl.h grp.h])
-AC_CHECK_HEADERS([inttypes.h langinfo.h limits.h linux/ext2_fs.h linux/fs.h])
-# Include inttypes.h into archive.h only if appropriate.
-# We can't use the HAVE_INTTYPES_H macro here because archive.h
-# gets installed as a system header and then included into client code
-# that doesn't define such macros. (And we should certainly not
-# define such macros in system headers!)
-# Hence the following:
-AC_CHECK_HEADER(inttypes.h,
- [AC_SUBST(ARCHIVE_H_INCLUDE_INTTYPES_H,['#include <inttypes.h> /* For int64_t */'])],
- [AC_SUBST(ARCHIVE_H_INCLUDE_INTTYPES_H,[''])])
+AC_CHECK_HEADERS([inttypes.h langinfo.h limits.h linux/fs.h])
AC_CHECK_HEADERS([locale.h paths.h poll.h pwd.h regex.h stdarg.h])
AC_CHECK_HEADERS([stdint.h stdlib.h string.h sys/acl.h sys/ioctl.h])
AC_CHECK_HEADERS([sys/param.h sys/poll.h sys/select.h sys/time.h sys/utime.h])
@@ -199,8 +190,6 @@
AC_TYPE_SIZE_T
AC_CHECK_TYPE(id_t, [unsigned long])
AC_CHECK_TYPE(uintptr_t, [unsigned int])
-AC_CHECK_MEMBERS([struct stat.st_rdev])
-AC_CHECK_MEMBERS([struct tm.tm_gmtoff])
# Check for high-resolution timestamps in struct stat
AC_CHECK_MEMBERS([struct stat.st_mtimespec.tv_nsec])
AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec])
@@ -239,14 +228,14 @@
AC_FUNC_STRERROR_R
AC_FUNC_STRFTIME
AC_FUNC_VPRINTF
-AC_CHECK_FUNCS([chflags chown fchdir fchflags fchmod fchown fcntl fork])
+AC_CHECK_FUNCS([chflags chown chroot fchdir fchflags fchmod fchown fcntl fork])
AC_CHECK_FUNCS([fstat ftruncate futimes geteuid getopt_long getpid])
AC_CHECK_FUNCS([lchflags lchmod lchown])
AC_CHECK_FUNCS([lutimes memmove memset mkdir mkfifo mknod])
AC_CHECK_FUNCS([nl_langinfo pipe poll select setenv setlocale])
AC_CHECK_FUNCS([strchr strdup strerror strrchr timegm])
AC_CHECK_FUNCS([tzset unsetenv utime utimes vfork])
-AC_CHECK_FUNCS([wcscpy wcslen wmemcmp wmemcpy])
+AC_CHECK_FUNCS([wcscpy wcslen wctomb wmemcmp wmemcpy])
# FreeBSD's nl_langinfo supports an option to specify whether the
# current locale uses month/day or day/month ordering. It makes the
==== //depot/projects/soc2008/strauss_libarchive/cpio/cmdline.c#6 (ktext) ====
@@ -26,7 +26,7 @@
#include "cpio_platform.h"
-__FBSDID("$Id$ $Change: 142961 $ $DateTime$ $Author$");
+__FBSDID("$FreeBSD: src/usr.bin/cpio/cmdline.c,v 1.3 2008/06/21 02:20:20 kientzle Exp $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -82,13 +82,21 @@
* sorted, as the -W logic below relies on it.
*/
static const struct option cpio_longopts[] = {
+ { "create", no_argument, NULL, 'o' },
+ { "extract", no_argument, NULL, 'i' },
{ "file", required_argument, NULL, 'F' },
{ "format", required_argument, NULL, 'H' },
{ "help", no_argument, NULL, 'h' },
{ "insecure", no_argument, NULL, OPTION_INSECURE },
+ { "link", no_argument, NULL, 'l' },
+ { "list", no_argument, NULL, 't' },
+ { "make-directories", no_argument, NULL, 'd' },
{ "null", no_argument, NULL, '0' },
{ "owner", required_argument, NULL, 'R' },
+ { "pass-through", no_argument, NULL, 'p' },
+ { "preserve-modification-time", no_argument, NULL, 'm' },
{ "quiet", no_argument, NULL, OPTION_QUIET },
+ { "unconditional", no_argument, NULL, 'u' },
{ "verbose", no_argument, NULL, 'v' },
{ "version", no_argument, NULL, OPTION_VERSION },
{ NULL, 0, NULL, 0 }
==== //depot/projects/soc2008/strauss_libarchive/cpio/config_freebsd.h#4 (ktext) ====
@@ -22,7 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id$ $Change: 143014 $ $DateTime$ $Author$
+ * $FreeBSD$
*/
/* A default configuration for FreeBSD, used if there is no config.h. */
@@ -91,7 +91,6 @@
#define HAVE_STRRCHR 1
#undef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
#define HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 1
-#define HAVE_STRUCT_STAT_ST_RDEV 1
#define HAVE_SYS_ACL_H 1
#define HAVE_SYS_IOCTL_H 1
#define HAVE_SYS_PARAM_H 1
==== //depot/projects/soc2008/strauss_libarchive/cpio/cpio.c#6 (ktext) ====
@@ -26,7 +26,7 @@
#include "cpio_platform.h"
-__FBSDID("$Id$ $Change: 142961 $ $DateTime$ $Author$");
+__FBSDID("$FreeBSD: src/usr.bin/cpio/cpio.c,v 1.4 2008/06/24 15:18:40 kientzle Exp $");
#include <sys/types.h>
#include <archive.h>
@@ -182,6 +182,7 @@
break;
case 'p': /* POSIX 1997 */
cpio->mode = opt;
+ cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_NODOTDOT;
break;
case OPTION_QUIET: /* GNU cpio */
cpio->quiet = 1;
@@ -537,14 +538,29 @@
* Obviously, this only gets invoked in pass mode.
*/
if (cpio->option_link) {
- /* Note: link(2) doesn't create parent directories. */
- archive_entry_set_hardlink(entry, srcpath);
- r = archive_write_header(cpio->archive, entry);
+ struct archive_entry *t;
+ /* Save the original entry in case we need it later. */
+ t = archive_entry_clone(entry);
+ if (t == NULL)
+ cpio_errc(1, ENOMEM, "Can't create link");
+ /* Note: link(2) doesn't create parent directories,
+ * so we use archive_write_header() instead. */
+ archive_entry_set_hardlink(t, srcpath);
+ archive_entry_set_size(t, 0);
+ r = archive_write_header(cpio->archive, t);
+ archive_entry_free(t);
if (r != ARCHIVE_OK)
cpio_warnc(archive_errno(cpio->archive),
archive_error_string(cpio->archive));
if (r == ARCHIVE_FATAL)
exit(1);
+#ifdef EXDEV
+ if (r != ARCHIVE_OK && archive_errno(cpio->archive) == EXDEV) {
+ /* Cross-device link: Just fall through and use
+ * the original entry to copy the file over. */
+ cpio_warnc(0, "Copying file instead");
+ } else
+#endif
return (0);
}
==== //depot/projects/soc2008/strauss_libarchive/cpio/cpio.h#3 (text+ko) ====
@@ -22,7 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD$
+ * $FreeBSD: src/usr.bin/cpio/cpio.h,v 1.2 2008/06/21 02:20:20 kientzle Exp $
*/
#ifndef CPIO_H_INCLUDED
==== //depot/projects/soc2008/strauss_libarchive/cpio/matching.c#6 (ktext) ====
@@ -24,7 +24,7 @@
*/
#include "cpio_platform.h"
-__FBSDID("$Id$ $Change: 142961 $ $DateTime$ $Author$");
+__FBSDID("$FreeBSD: src/usr.bin/cpio/matching.c,v 1.2 2008/06/21 02:20:20 kientzle Exp $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
==== //depot/projects/soc2008/strauss_libarchive/cpio/test/main.c#6 (ktext) ====
@@ -27,13 +27,13 @@
* Various utility routines useful for test programs.
* Each test program is linked against this file.
*/
+#include "test.h"
+
#include <errno.h>
#include <locale.h>
#include <stdarg.h>
#include <time.h>
-#include "test.h"
-
/*
* This same file is used pretty much verbatim for all test harnesses.
*
@@ -44,7 +44,7 @@
#undef EXTRA_DUMP /* How to dump extra data */
/* How to generate extra version info. */
#define EXTRA_VERSION (systemf("%s --version", testprog) ? "" : "")
-__FBSDID("$Id$ $Change: 142961 $ $DateTime$ $Author$");
+__FBSDID("$FreeBSD: src/usr.bin/cpio/test/main.c,v 1.2 2008/06/21 02:17:18 kientzle Exp $");
/*
* "list.h" is simply created by "grep DEFINE_TEST"; it has
@@ -541,6 +541,48 @@
return (0);
}
+int
+test_assert_file_exists(const char *fpattern, ...)
+{
+ char f[1024];
+ va_list ap;
+
+ va_start(ap, fpattern);
+ vsprintf(f, fpattern, ap);
+ va_end(ap);
+
+ if (!access(f, F_OK))
+ return (1);
+ if (!previous_failures(test_filename, test_line)) {
+ fprintf(stderr, "%s:%d: File doesn't exist\n",
+ test_filename, test_line);
+ fprintf(stderr, " file=\"%s\"\n", f);
+ report_failure(test_extra);
+ }
+ return (0);
+}
+
+int
+test_assert_file_not_exists(const char *fpattern, ...)
+{
+ char f[1024];
+ va_list ap;
+
+ va_start(ap, fpattern);
+ vsprintf(f, fpattern, ap);
+ va_end(ap);
+
+ if (access(f, F_OK))
+ return (1);
+ if (!previous_failures(test_filename, test_line)) {
+ fprintf(stderr, "%s:%d: File exists and shouldn't\n",
+ test_filename, test_line);
+ fprintf(stderr, " file=\"%s\"\n", f);
+ report_failure(test_extra);
+ }
+ return (0);
+}
+
/* assertFileContents() asserts the contents of a file. */
int
test_assert_file_contents(const void *buff, int s, const char *fpattern, ...)
@@ -670,8 +712,11 @@
{
int failures_before = failures;
- if (!quiet_flag)
+ if (!quiet_flag) {
printf("%d: %s\n", i, tests[i].name);
+ fflush(stdout);
+ }
+
/*
* Always explicitly chdir() in case the last test moved us to
* a strange place.
==== //depot/projects/soc2008/strauss_libarchive/cpio/test/test.h#6 (ktext) ====
@@ -22,7 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD$
+ * $FreeBSD: src/usr.bin/cpio/test/test.h,v 1.2 2008/06/21 02:17:18 kientzle Exp $
*/
/* Every test program should #include "test.h" as the first thing. */
@@ -31,8 +31,18 @@
* The goal of this file (and the matching test.c) is to
* simplify the very repetitive test-*.c test programs.
*/
-#ifndef _FILE_OFFSET_BITS
-#define _FILE_OFFSET_BITS 64
+#if defined(HAVE_CONFIG_H)
+/* Most POSIX platforms use the 'configure' script to build config.h */
+#include "../../config.h"
+#elif defined(__FreeBSD__)
+/* Building as part of FreeBSD system requires a pre-built config.h. */
+#include "../config_freebsd.h"
+#elif defined(_WIN32)
+/* Win32 can't run the 'configure' script. */
+#include "../config_windows.h"
+#else
+/* Warn if the library hasn't been (automatically or manually) configured. */
+#error Oops: No config.h and no pre-built configuration in test.h.
#endif
#include <dirent.h>
@@ -51,20 +61,6 @@
#include <dmalloc.h>
#endif
-#if defined(HAVE_CONFIG_H)
-/* Most POSIX platforms use the 'configure' script to build config.h */
-#include "../../config.h"
-#elif defined(__FreeBSD__)
-/* Building as part of FreeBSD system requires a pre-built config.h. */
-#include "../config_freebsd.h"
-#elif defined(_WIN32)
-/* Win32 can't run the 'configure' script. */
-#include "../config_windows.h"
-#else
-/* Warn if the library hasn't been (automatically or manually) configured. */
-#error Oops: No config.h and no pre-built configuration in test.h.
-#endif
-
/* No non-FreeBSD platform will have __FBSDID, so just define it here. */
#ifdef __FreeBSD__
#include <sys/cdefs.h> /* For __FBSDID */
@@ -102,6 +98,12 @@
/* Assert that a file is empty; supports printf-style arguments. */
#define assertEmptyFile \
test_setup(__FILE__, __LINE__);test_assert_empty_file
+/* Assert that a file exists; supports printf-style arguments. */
+#define assertFileExists \
+ test_setup(__FILE__, __LINE__);test_assert_file_exists
+/* Assert that a file exists; supports printf-style arguments. */
+#define assertFileNotExists \
+ test_setup(__FILE__, __LINE__);test_assert_file_not_exists
/* Assert that file contents match a string; supports printf-style arguments. */
#define assertFileContents \
test_setup(__FILE__, __LINE__);test_assert_file_contents
@@ -127,6 +129,8 @@
int test_assert_equal_wstring(const char *, int, const wchar_t *v1, const char *, const wchar_t *v2, const char *, void *);
int test_assert_equal_mem(const char *, int, const char *, const char *, const char *, const char *, size_t, const char *, void *);
int test_assert_file_contents(const void *, int, const char *, ...);
+int test_assert_file_exists(const char *, ...);
+int test_assert_file_not_exists(const char *, ...);
/* Like sprintf, then system() */
int systemf(const char * fmt, ...);
@@ -144,4 +148,3 @@
/* Pathname of exe to be tested. */
char *testprog;
-
==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_entry_link_resolver.c#7 (ktext) ====
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$Id$ $Change: 142961 $ $DateTime$ $Author$");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_entry_link_resolver.c,v 1.3 2008/06/15 04:31:43 kientzle Exp $");
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
@@ -181,6 +181,9 @@
/* If it has only one link, then we're done. */
if (archive_entry_nlink(*e) == 1)
return;
+ /* Directories never have hardlinks. */
+ if (archive_entry_filetype(*e) == AE_IFDIR)
+ return;
switch (res->strategy) {
case ARCHIVE_ENTRY_LINKIFY_LIKE_TAR:
==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_entry_strmode.c#6 (ktext) ====
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$Id$ $Change: 142961 $ $DateTime$ $Author$");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_entry_strmode.c,v 1.4 2008/06/15 05:14:01 kientzle Exp $");
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
@@ -57,6 +57,11 @@
case AE_IFLNK: bp[0] = 'l'; break;
case AE_IFSOCK: bp[0] = 's'; break;
case AE_IFIFO: bp[0] = 'p'; break;
+ default:
+ if (archive_entry_hardlink(entry) != NULL) {
+ bp[0] = 'h';
+ break;
+ }
}
for (i = 0; i < 9; i++)
==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_compression_program.c#6 (ktext) ====
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$Id$ $Change: 142961 $ $DateTime$ $Author$");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_compression_program.c,v 1.4 2008/06/15 10:45:57 kientzle Exp $");
/* This capability is only available on POSIX systems. */
#if !defined(HAVE_PIPE) || !defined(HAVE_FCNTL) || \
==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_format_mtree.c#6 (ktext) ====
@@ -25,7 +25,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$Id$ $Change: 142961 $ $DateTime$ $Author$");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_mtree.c,v 1.9 2008/06/21 19:06:37 kientzle Exp $");
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
@@ -308,7 +308,7 @@
size_t len;
line += 6;
- if ((next = strchr(line, '=')) != NULL) {
+ if (strchr(line, '=') != NULL) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
"/unset shall not contain `='");
return ARCHIVE_FATAL;
@@ -760,7 +760,7 @@
}
++comma1;
comma2 = strchr(comma1, ',');
- if (comma1 == NULL) {
+ if (comma2 == NULL) {
archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT,
"Malformed device attribute");
return (ARCHIVE_WARN);
@@ -1020,7 +1020,7 @@
}
/*
- * Since parsing octal escapes always makes strings shorter,
+ * Since parsing backslash sequences always makes strings shorter,
* we can always do this conversion in-place.
*/
static void
@@ -1041,13 +1041,57 @@
if (c == '/' && mentry != NULL)
mentry->full = 1;
if (c == '\\') {
- if (src[0] >= '0' && src[0] <= '3'
- && src[1] >= '0' && src[1] <= '7'
- && src[2] >= '0' && src[2] <= '7') {
- c = (src[0] - '0') << 6;
- c |= (src[1] - '0') << 3;
- c |= (src[2] - '0');
- src += 3;
+ switch (src[0]) {
+ case '0':
+ if (src[1] < '0' || src[1] > '7') {
+ c = 0;
+ ++src;
+ break;
+ }
+ /* FALLTHROUGH */
+ case '1':
+ case '2':
+ case '3':
+ if (src[1] >= '0' && src[1] <= '7' &&
+ src[2] >= '0' && src[2] <= '7') {
+ c = (src[0] - '0') << 6;
+ c |= (src[1] - '0') << 3;
+ c |= (src[2] - '0');
+ src += 3;
+ }
+ break;
+ case 'a':
+ c = '\a';
+ ++src;
+ break;
+ case 'b':
+ c = '\b';
+ ++src;
+ break;
+ case 'f':
+ c = '\f';
+ ++src;
+ break;
+ case 'n':
+ c = '\n';
+ ++src;
+ break;
+ case 'r':
+ c = '\r';
+ ++src;
+ break;
+ case 's':
+ c = ' ';
+ ++src;
+ break;
+ case 't':
+ c = '\t';
+ ++src;
+ break;
+ case 'v':
+ c = '\v';
+ ++src;
+ break;
}
}
*dest++ = c;
@@ -1190,6 +1234,7 @@
const void *t;
const char *s;
void *p;
+ char *u;
/* Accumulate line in a line buffer. */
for (;;) {
@@ -1222,10 +1267,32 @@
total_size += bytes_read;
/* Null terminate. */
mtree->line.s[total_size] = '\0';
- /* If we found '\n', clean up and return. */
- if (p != NULL) {
- *start = mtree->line.s;
- return (total_size);
+ /* If we found an unescaped '\n', clean up and return. */
+ if (p == NULL)
+ continue;
+ for (u = mtree->line.s; *u; ++u) {
+ if (u[0] == '\n') {
+ *start = mtree->line.s;
+ return total_size;
+ }
+ if (u[0] == '#') {
+ if (p == NULL)
+ break;
+ *start = mtree->line.s;
+ return total_size;
+ }
+ if (u[0] != '\\')
+ continue;
+ if (u[1] == '\\') {
+ ++u;
+ continue;
+ }
+ if (u[1] == '\n') {
+ memmove(u, u + 1,
+ total_size - (u - mtree->line.s) + 1);
+ --total_size;
+ continue;
+ }
}
}
}
==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_format_zip.c#7 (ktext) ====
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$Id$ $Change: 142961 $ $DateTime$ $Author$");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_zip.c,v 1.24 2008/06/15 05:15:53 kientzle Exp $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -564,8 +564,8 @@
*/
r = ARCHIVE_FATAL;
} else {
- /* We know compressed size; just skip it. */
- archive_read_format_zip_read_data_skip(a);
+ /* We can't decompress this entry, but we will
+ * be able to skip() it and try the next entry. */
r = ARCHIVE_WARN;
}
break;
@@ -747,6 +747,10 @@
zip = (struct zip *)(a->format->data);
+ /* If we've already read to end of data, we're done. */
+ if (zip->end_of_entry_cleanup)
+ return (ARCHIVE_OK);
+
/*
* If the length is at the end, we have no choice but
* to decompress all the data to find the end marker.
==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_string.c#7 (ktext) ====
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$Id$ $Change: 142961 $ $DateTime$ $Author$");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_string.c,v 1.16 2008/06/15 11:28:56 kientzle Exp $");
/*
* Basic resizable string support, to simplify manipulating arbitrary-sized
@@ -41,14 +41,6 @@
#include <wchar.h>
#endif
-#ifdef __sgi
-/*
- * The following prototype is missing on IRXI,
- * even though the function is implemented in libc.
- */
-size_t wcrtomb(char *, wchar_t, mbstate_t *);
-#endif
-
#include "archive_private.h"
#include "archive_string.h"
@@ -172,14 +164,13 @@
}
/*
- * Home-grown wcrtomb for UTF-8.
+ * Home-grown wctomb for UTF-8.
*/
-static size_t
-my_wcrtomb_utf8(char *p, wchar_t wc, mbstate_t *s)
+static int
+my_wctomb_utf8(char *p, wchar_t wc)
{
- (void)s; /* UNUSED */
-
if (p == NULL)
+ /* UTF-8 doesn't use shift states. */
return (0);
if (wc <= 0x7f) {
p[0] = (char)wc;
@@ -208,24 +199,25 @@
* Awkward point: UTF-8 <-> wchar_t conversions
* can actually fail.
*/
- return ((size_t)-1);
+ return (-1);
}
static int
my_wcstombs(struct archive_string *as, const wchar_t *w,
- size_t (*func)(char *, wchar_t, mbstate_t *))
+ int (*func)(char *, wchar_t))
{
- size_t n;
+ int n;
char *p;
- mbstate_t shift_state;
char buff[256];
+ /* Clear the shift state before starting. */
+ (*func)(NULL, L'\0');
+
/*
* Convert one wide char at a time into 'buff', whenever that
* fills, append it to the string.
*/
p = buff;
- wcrtomb(NULL, L'\0', &shift_state);
while (*w != L'\0') {
/* Flush the buffer when we have <=16 bytes free. */
/* (No encoding has a single character >16 bytes.) */
@@ -234,8 +226,8 @@
archive_strcat(as, buff);
p = buff;
}
- n = (*func)(p, *w++, &shift_state);
- if (n == (size_t)-1)
+ n = (*func)(p, *w++);
+ if (n == -1)
return (-1);
p += n;
}
@@ -251,7 +243,7 @@
struct archive_string *
__archive_strappend_w_utf8(struct archive_string *as, const wchar_t *w)
{
- if (my_wcstombs(as, w, my_wcrtomb_utf8))
+ if (my_wcstombs(as, w, my_wctomb_utf8))
return (NULL);
return (as);
}
@@ -260,42 +252,40 @@
* Translates a wide character string into current locale character set
* and appends to the archive_string. Note: returns NULL if conversion
* fails.
- *
- * TODO: use my_wcrtomb_utf8 if !HAVE_WCRTOMB (add configure logic first!)
*/
struct archive_string *
__archive_strappend_w_mbs(struct archive_string *as, const wchar_t *w)
{
- if (my_wcstombs(as, w, wcrtomb))
+#if HAVE_WCTOMB
+ if (my_wcstombs(as, w, wctomb))
+ return (NULL);
+#else
+ /* TODO: Can we do better than this? Are there platforms
+ * that have locale support but don't have wctomb()? */
+ if (my_wcstombs(as, w, my_wctomb_utf8))
return (NULL);
+#endif
return (as);
}
/*
- * Home-grown mbrtowc for UTF-8. Some systems lack UTF-8
- * (or even lack mbrtowc()) and we need UTF-8 support for pax
+ * Home-grown mbtowc for UTF-8. Some systems lack UTF-8
+ * (or even lack mbtowc()) and we need UTF-8 support for pax
* format. So please don't replace this with a call to the
- * standard mbrtowc() function!
+ * standard mbtowc() function!
*/
-static size_t
-my_mbrtowc_utf8(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
+static int
+my_mbtowc_utf8(wchar_t *pwc, const char *s, size_t n)
{
int ch;
- /*
- * This argument is here to make the prototype identical to the
- * standard mbrtowc(), so I can build generic string processors
- * that just accept a pointer to a suitable mbrtowc() function.
- */
- (void)ps; /* UNUSED */
-
/* Standard behavior: a NULL value for 's' just resets shift state. */
if (s == NULL)
return (0);
/* If length argument is zero, don't look at the first character. */
if (n <= 0)
- return ((size_t)-2);
+ return (-1);
/*
* Decode 1-4 bytes depending on the value of the first byte.
@@ -310,16 +300,16 @@
}
if ((ch & 0xe0) == 0xc0) {
if (n < 2)
- return ((size_t)-2);
- if ((s[1] & 0xc0) != 0x80) return (size_t)-1;
+ return (-1);
+ if ((s[1] & 0xc0) != 0x80) return (-1);
*pwc = ((ch & 0x1f) << 6) | (s[1] & 0x3f);
return (2);
}
if ((ch & 0xf0) == 0xe0) {
if (n < 3)
- return ((size_t)-2);
- if ((s[1] & 0xc0) != 0x80) return (size_t)-1;
- if ((s[2] & 0xc0) != 0x80) return (size_t)-1;
+ return (-1);
+ if ((s[1] & 0xc0) != 0x80) return (-1);
+ if ((s[2] & 0xc0) != 0x80) return (-1);
*pwc = ((ch & 0x0f) << 12)
| ((s[1] & 0x3f) << 6)
| (s[2] & 0x3f);
@@ -327,10 +317,10 @@
}
if ((ch & 0xf8) == 0xf0) {
if (n < 4)
- return ((size_t)-2);
- if ((s[1] & 0xc0) != 0x80) return (size_t)-1;
- if ((s[2] & 0xc0) != 0x80) return (size_t)-1;
- if ((s[3] & 0xc0) != 0x80) return (size_t)-1;
+ return (-1);
+ if ((s[1] & 0xc0) != 0x80) return (-1);
+ if ((s[2] & 0xc0) != 0x80) return (-1);
+ if ((s[3] & 0xc0) != 0x80) return (-1);
*pwc = ((ch & 0x07) << 18)
| ((s[1] & 0x3f) << 12)
| ((s[2] & 0x3f) << 6)
@@ -338,7 +328,7 @@
return (4);
}
/* Invalid first byte. */
- return ((size_t)-1);
+ return (-1);
}
/*
@@ -350,7 +340,7 @@
{
wchar_t *ws, *dest;
const char *src;
- size_t n;
+ int n;
int err;
ws = (wchar_t *)malloc((as->length + 1) * sizeof(wchar_t));
@@ -360,10 +350,10 @@
dest = ws;
src = as->s;
while (*src != '\0') {
- n = my_mbrtowc_utf8(dest, src, 8, NULL);
+ n = my_mbtowc_utf8(dest, src, 8);
if (n == 0)
break;
- if (n == (size_t)-1 || n == (size_t)-2) {
+ if (n < 0) {
free(ws);
return (NULL);
}
==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_string.h#5 (ktext) ====
@@ -22,7 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id$ $Change: 143014 $ $DateTime$ $Author$
+ * $FreeBSD: src/lib/libarchive/archive_string.h,v 1.12 2008/06/15 05:11:08 kientzle Exp $
*
*/
@@ -30,6 +30,9 @@
#define ARCHIVE_STRING_H_INCLUDED
#include <stdarg.h>
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h> /* required for wchar_t on some systems */
+#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_disk.c#7 (ktext) ====
@@ -25,7 +25,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$Id$ $Change: 142961 $ $DateTime$ $Author$");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_disk.c,v 1.26 2008/06/21 19:05:29 kientzle Exp $");
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
@@ -64,9 +64,6 @@
#ifdef HAVE_LINUX_FS_H
#include <linux/fs.h> /* for Linux file flags */
#endif
-#ifdef HAVE_LINUX_EXT2_FS_H
-#include <linux/ext2_fs.h> /* for Linux file flags */
-#endif
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
@@ -613,8 +610,8 @@
/* Restore metadata. */
/*
- * Look up the "real" UID only if we're going to need it. We
- * need this for TODO_SGID because chown() requires both.
+ * Look up the "real" UID only if we're going to need it.
+ * TODO: the TODO_SGID condition can be dropped here, can't it?
*/
if (a->todo & (TODO_OWNER | TODO_SUID | TODO_SGID)) {
a->uid = a->lookup_uid(a->lookup_uid_data,
@@ -622,6 +619,7 @@
archive_entry_uid(a->entry));
}
/* Look up the "real" GID only if we're going to need it. */
+ /* TODO: the TODO_SUID condition can be dropped here, can't it? */
if (a->todo & (TODO_OWNER | TODO_SGID | TODO_SUID)) {
a->gid = a->lookup_gid(a->lookup_gid_data,
archive_entry_gname(a->entry),
@@ -1023,7 +1021,10 @@
a->deferred |= (a->todo & TODO_TIMES);
a->todo &= ~TODO_TIMES;
/* Never use an immediate chmod(). */
- if (mode != final_mode)
+ /* We can't avoid the chmod() entirely if EXTRACT_PERM
+ * because of SysV SGID inheritance. */
+ if ((mode != final_mode)
+ || (a->flags & ARCHIVE_EXTRACT_PERM))
a->deferred |= (a->todo & TODO_MODE);
a->todo &= ~TODO_MODE;
}
@@ -1351,7 +1352,7 @@
if (*src == '\0') {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
"Invalid empty pathname");
- return (ARCHIVE_WARN);
+ return (ARCHIVE_FAILED);
}
/* Skip leading '/'. */
@@ -1382,7 +1383,7 @@
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list