af9dc8
diff -up php-5.4.15/ext/zip/config.m4.systzip php-5.4.15/ext/zip/config.m4
af9dc8
--- php-5.4.15/ext/zip/config.m4.systzip	2013-05-08 07:41:20.000000000 +0200
af9dc8
+++ php-5.4.15/ext/zip/config.m4	2013-05-09 06:46:26.084673644 +0200
af9dc8
@@ -13,65 +13,116 @@ fi
af9dc8
 PHP_ARG_WITH(pcre-dir, pcre install prefix,
af9dc8
 [  --with-pcre-dir           ZIP: pcre install prefix], no, no)
af9dc8
 
af9dc8
+PHP_ARG_WITH(libzip, libzip,
af9dc8
+[ --with-libzip[=DIR]        ZIP: use libzip], no, no)
af9dc8
+
af9dc8
 if test "$PHP_ZIP" != "no"; then
af9dc8
+  if test "$PHP_LIBZIP" != "no"; then
af9dc8
+
af9dc8
+    AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
af9dc8
+
af9dc8
+    dnl system libzip, depends on libzip
af9dc8
+    AC_MSG_CHECKING(for libzip)
af9dc8
+    if test -r $PHP_LIBZIP/include/zip.h; then
af9dc8
+      LIBZIP_CFLAGS="-I$PHP_LIBZIP/include"
af9dc8
+      LIBZIP_LIBDIR="$PHP_LIBZIP/$PHP_LIBDIR"
af9dc8
+      AC_MSG_RESULT(from option: found in $PHP_LIBZIP)
af9dc8
+
af9dc8
+    elif test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libzip; then
af9dc8
+      LIBZIP_CFLAGS=`$PKG_CONFIG libzip --cflags`
af9dc8
+      LIBZIP_LIBDIR=`$PKG_CONFIG libzip --variable=libdir`
af9dc8
+      AC_MSG_RESULT(from pkgconfig: found in $LIBZIP_LIBDIR)
af9dc8
 
af9dc8
-  if test "$PHP_ZLIB_DIR" != "no" && test "$PHP_ZLIB_DIR" != "yes"; then
af9dc8
-    if test -f "$PHP_ZLIB_DIR/include/zlib/zlib.h"; then
af9dc8
-      PHP_ZLIB_DIR="$PHP_ZLIB_DIR"
af9dc8
-      PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include/zlib"
af9dc8
-    elif test -f "$PHP_ZLIB_DIR/include/zlib.h"; then
af9dc8
-      PHP_ZLIB_DIR="$PHP_ZLIB_DIR"
af9dc8
-      PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include"
af9dc8
     else
af9dc8
-      AC_MSG_ERROR([Can not find zlib headers under "$PHP_ZLIB_DIR"])
af9dc8
+      for i in /usr/local /usr; do
af9dc8
+        if test -r $i/include/zip.h; then
af9dc8
+          LIBZIP_CFLAGS="-I$i/include"
af9dc8
+          LIBZIP_LIBDIR="$i/$PHP_LIBDIR"
af9dc8
+          AC_MSG_RESULT(in default path: found in $i)
af9dc8
+          break
af9dc8
+        fi
af9dc8
+      done
af9dc8
     fi
af9dc8
+
af9dc8
+    if test -z "$LIBZIP_LIBDIR"; then
af9dc8
+      AC_MSG_RESULT(not found)
af9dc8
+      AC_MSG_ERROR(Please reinstall the libzip distribution)
af9dc8
+    fi
af9dc8
+
af9dc8
+    dnl Could not think of a simple way to check libzip for overwrite support
af9dc8
+    PHP_CHECK_LIBRARY(zip, zip_open,
af9dc8
+    [
af9dc8
+      PHP_ADD_LIBRARY_WITH_PATH(zip, $LIBZIP_LIBDIR, ZIP_SHARED_LIBADD)
af9dc8
+      AC_DEFINE(HAVE_LIBZIP,1,[ ])
af9dc8
+    ], [
af9dc8
+      AC_MSG_ERROR(could not find usable libzip)
af9dc8
+    ], [
af9dc8
+      -L$LIBZIP_LIBDIR
af9dc8
+    ])
af9dc8
+
af9dc8
+    AC_DEFINE(HAVE_ZIP,1,[ ]) 
af9dc8
+    PHP_NEW_EXTENSION(zip, php_zip.c zip_stream.c, $ext_shared,, $LIBZIP_CFLAGS)
af9dc8
+    PHP_SUBST(ZIP_SHARED_LIBADD)
af9dc8
   else
af9dc8
-    for i in /usr/local /usr; do
af9dc8
-      if test -f "$i/include/zlib/zlib.h"; then
af9dc8
-        PHP_ZLIB_DIR="$i"
af9dc8
-        PHP_ZLIB_INCDIR="$i/include/zlib"
af9dc8
-      elif test -f "$i/include/zlib.h"; then
af9dc8
-        PHP_ZLIB_DIR="$i"
af9dc8
-        PHP_ZLIB_INCDIR="$i/include"
af9dc8
+
af9dc8
+  dnl bundled libzip, depends on zlib
af9dc8
+    if test "$PHP_ZLIB_DIR" != "no" && test "$PHP_ZLIB_DIR" != "yes"; then
af9dc8
+      if test -f "$PHP_ZLIB_DIR/include/zlib/zlib.h"; then
af9dc8
+        PHP_ZLIB_DIR="$PHP_ZLIB_DIR"
af9dc8
+        PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include/zlib"
af9dc8
+      elif test -f "$PHP_ZLIB_DIR/include/zlib.h"; then
af9dc8
+        PHP_ZLIB_DIR="$PHP_ZLIB_DIR"
af9dc8
+        PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include"
af9dc8
+      else
af9dc8
+        AC_MSG_ERROR([Can not find zlib headers under "$PHP_ZLIB_DIR"])
af9dc8
       fi
af9dc8
-    done
af9dc8
-  fi
af9dc8
+    else
af9dc8
+      for i in /usr/local /usr; do
af9dc8
+        if test -f "$i/include/zlib/zlib.h"; then
af9dc8
+          PHP_ZLIB_DIR="$i"
af9dc8
+          PHP_ZLIB_INCDIR="$i/include/zlib"
af9dc8
+        elif test -f "$i/include/zlib.h"; then
af9dc8
+          PHP_ZLIB_DIR="$i"
af9dc8
+          PHP_ZLIB_INCDIR="$i/include"
af9dc8
+        fi
af9dc8
+      done
af9dc8
+    fi
af9dc8
 
af9dc8
-  dnl # zlib
af9dc8
-  AC_MSG_CHECKING([for the location of zlib])
af9dc8
-  if test "$PHP_ZLIB_DIR" = "no"; then
af9dc8
-    AC_MSG_ERROR([zip support requires ZLIB. Use --with-zlib-dir=<DIR> to specify prefix where ZLIB include and library are located])
af9dc8
-  else
af9dc8
-    AC_MSG_RESULT([$PHP_ZLIB_DIR])
af9dc8
-    PHP_ADD_LIBRARY_WITH_PATH(z, $PHP_ZLIB_DIR/$PHP_LIBDIR, ZIP_SHARED_LIBADD)
af9dc8
-    PHP_ADD_INCLUDE($PHP_ZLIB_INCDIR)
af9dc8
-  fi
af9dc8
+    dnl # zlib
af9dc8
+    AC_MSG_CHECKING([for the location of zlib])
af9dc8
+    if test "$PHP_ZLIB_DIR" = "no"; then
af9dc8
+      AC_MSG_ERROR([zip support requires ZLIB. Use --with-zlib-dir=<DIR> to specify prefix where ZLIB include and library are located])
af9dc8
+    else
af9dc8
+      AC_MSG_RESULT([$PHP_ZLIB_DIR])
af9dc8
+      PHP_ADD_LIBRARY_WITH_PATH(z, $PHP_ZLIB_DIR/$PHP_LIBDIR, ZIP_SHARED_LIBADD)
af9dc8
+      PHP_ADD_INCLUDE($PHP_ZLIB_INCDIR)
af9dc8
+    fi
af9dc8
 
af9dc8
-  dnl This is PECL build, check if bundled PCRE library is used
af9dc8
-  old_CPPFLAGS=$CPPFLAGS
af9dc8
-  CPPFLAGS=$INCLUDES
af9dc8
-  AC_EGREP_CPP(yes,[
af9dc8
+    dnl This is PECL build, check if bundled PCRE library is used
af9dc8
+    old_CPPFLAGS=$CPPFLAGS
af9dc8
+    CPPFLAGS=$INCLUDES
af9dc8
+    AC_EGREP_CPP(yes,[
af9dc8
 #include <main/php_config.h>
af9dc8
 #if defined(HAVE_BUNDLED_PCRE) && !defined(COMPILE_DL_PCRE)
af9dc8
 yes
af9dc8
 #endif
af9dc8
-  ],[
af9dc8
-    PHP_PCRE_REGEX=yes
af9dc8
-  ],[
af9dc8
-    AC_EGREP_CPP(yes,[
af9dc8
+    ],[
af9dc8
+      PHP_PCRE_REGEX=yes
af9dc8
+    ],[
af9dc8
+      AC_EGREP_CPP(yes,[
af9dc8
 #include <main/php_config.h>
af9dc8
 #if defined(HAVE_PCRE) && !defined(COMPILE_DL_PCRE)
af9dc8
 yes
af9dc8
 #endif
af9dc8
-    ],[
af9dc8
-      PHP_PCRE_REGEX=pecl
af9dc8
-    ],[
af9dc8
-      PHP_PCRE_REGEX=no
af9dc8
+      ],[
af9dc8
+        PHP_PCRE_REGEX=pecl
af9dc8
+      ],[
af9dc8
+        PHP_PCRE_REGEX=no
af9dc8
+      ])
af9dc8
     ])
af9dc8
-  ])
af9dc8
-  CPPFLAGS=$old_CPPFLAGS
af9dc8
+    CPPFLAGS=$old_CPPFLAGS
af9dc8
 
af9dc8
-  PHP_ZIP_SOURCES="$PHP_ZIP_SOURCES lib/zip_add.c lib/zip_error.c lib/zip_fclose.c \
af9dc8
+    PHP_ZIP_SOURCES="$PHP_ZIP_SOURCES lib/zip_add.c lib/zip_error.c lib/zip_fclose.c \
af9dc8
                          lib/zip_fread.c lib/zip_open.c lib/zip_source_filep.c  \
af9dc8
                          lib/zip_strerror.c lib/zip_close.c lib/zip_error_get.c \
af9dc8
                          lib/zip_file_error_get.c lib/zip_free.c lib/zip_rename.c \
af9dc8
@@ -98,10 +149,11 @@ yes
af9dc8
 						 lib/zip_source_open.c lib/zip_source_pkware.c lib/zip_source_pop.c \
af9dc8
 						 lib/zip_source_read.c lib/zip_source_stat.c"
af9dc8
 
af9dc8
-  AC_DEFINE(HAVE_ZIP,1,[ ])
af9dc8
-  PHP_NEW_EXTENSION(zip, php_zip.c zip_stream.c $PHP_ZIP_SOURCES, $ext_shared)
af9dc8
-  PHP_ADD_BUILD_DIR($ext_builddir/lib, 1)
af9dc8
-  PHP_SUBST(ZIP_SHARED_LIBADD)
af9dc8
+    AC_DEFINE(HAVE_ZIP,1,[ ])
af9dc8
+    PHP_NEW_EXTENSION(zip, php_zip.c zip_stream.c $PHP_ZIP_SOURCES, $ext_shared)
af9dc8
+    PHP_ADD_BUILD_DIR($ext_builddir/lib, 1)
af9dc8
+    PHP_SUBST(ZIP_SHARED_LIBADD)
af9dc8
+  fi
af9dc8
 
af9dc8
   dnl so we always include the known-good working hack.
af9dc8
   PHP_ADD_MAKEFILE_FRAGMENT
af9dc8
diff -up php-5.4.15/ext/zip/php_zip.c.systzip php-5.4.15/ext/zip/php_zip.c
af9dc8
--- php-5.4.15/ext/zip/php_zip.c.systzip	2013-05-08 07:41:20.000000000 +0200
af9dc8
+++ php-5.4.15/ext/zip/php_zip.c	2013-05-09 06:50:33.286058049 +0200
af9dc8
@@ -30,8 +30,232 @@
af9dc8
 #include "ext/pcre/php_pcre.h"
af9dc8
 #include "ext/standard/php_filestat.h"
af9dc8
 #include "php_zip.h"
af9dc8
+#if defined(HAVE_LIBZIP)
af9dc8
+#include <zip.h>
af9dc8
+
af9dc8
+/* Copied from libzip 0.10 */
af9dc8
+
af9dc8
+/* state of change of a file in zip archive */
af9dc8
+
af9dc8
+enum zip_state { ZIP_ST_UNCHANGED, ZIP_ST_DELETED, ZIP_ST_REPLACED,
af9dc8
+                 ZIP_ST_ADDED, ZIP_ST_RENAMED };
af9dc8
+
af9dc8
+/* error source for layered sources */
af9dc8
+
af9dc8
+enum zip_les { ZIP_LES_NONE, ZIP_LES_UPPER, ZIP_LES_LOWER, ZIP_LES_INVAL };
af9dc8
+
af9dc8
+typedef zip_int64_t (*zip_source_layered_callback)(struct zip_source *, void *,
af9dc8
+                                                   void *, zip_uint64_t,
af9dc8
+                                                   enum zip_source_cmd);
af9dc8
+
af9dc8
+struct zip_error {
af9dc8
+    int zip_err;        /* libzip error code (ZIP_ER_*) */
af9dc8
+    int sys_err;        /* copy of errno (E*) or zlib error code */
af9dc8
+    char *str;          /* string representation or NULL */
af9dc8
+};
af9dc8
+
af9dc8
+/* zip archive, part of API */
af9dc8
+
af9dc8
+struct zip {
af9dc8
+    char *zn;                   /* file name */
af9dc8
+    FILE *zp;                   /* file */
af9dc8
+    struct zip_error error;     /* error information */
af9dc8
+
af9dc8
+    unsigned int flags;         /* archive global flags */
af9dc8
+    unsigned int ch_flags;	/* changed archive global flags */
af9dc8
+
af9dc8
+    char *default_password;     /* password used when no other supplied */
af9dc8
+
af9dc8
+    struct zip_cdir *cdir;	/* central directory */
af9dc8
+    char *ch_comment;           /* changed archive comment */
af9dc8
+    int ch_comment_len;         /* length of changed zip archive
af9dc8
+                                 * comment, -1 if unchanged */
af9dc8
+    zip_uint64_t nentry;        /* number of entries */
af9dc8
+    zip_uint64_t nentry_alloc;  /* number of entries allocated */
af9dc8
+    struct zip_entry *entry;    /* entries */
af9dc8
+    int nfile;                  /* number of opened files within archive */
af9dc8
+    int nfile_alloc;            /* number of files allocated */
af9dc8
+    struct zip_file **file;     /* opened files within archive */
af9dc8
+};
af9dc8
+
af9dc8
+/* file in zip archive, part of API */
af9dc8
+
af9dc8
+struct zip_file {
af9dc8
+    struct zip *za;             /* zip archive containing this file */
af9dc8
+    struct zip_error error;     /* error information */
af9dc8
+    int eof;
af9dc8
+    struct zip_source *src;     /* data source */
af9dc8
+};
af9dc8
+
af9dc8
+/* zip archive directory entry (central or local) */
af9dc8
+
af9dc8
+struct zip_dirent {
af9dc8
+    unsigned short version_madeby;	/* (c)  version of creator */
af9dc8
+    unsigned short version_needed;	/* (cl) version needed to extract */
af9dc8
+    unsigned short bitflags;            /* (cl) general purpose bit flag */
af9dc8
+    unsigned short comp_method;         /* (cl) compression method used */
af9dc8
+    time_t last_mod;                    /* (cl) time of last modification */
af9dc8
+    unsigned int crc;                   /* (cl) CRC-32 of uncompressed data */
af9dc8
+    unsigned int comp_size;             /* (cl) size of commpressed data */
af9dc8
+    unsigned int uncomp_size;           /* (cl) size of uncommpressed data */
af9dc8
+    char *filename;                     /* (cl) file name (NUL-terminated) */
af9dc8
+    unsigned short filename_len;        /* (cl) length of filename (w/o NUL) */
af9dc8
+    char *extrafield;                   /* (cl) extra field */
af9dc8
+    unsigned short extrafield_len;	/* (cl) length of extra field */
af9dc8
+    char *comment;                      /* (c)  file comment */
af9dc8
+    unsigned short comment_len;         /* (c)  length of file comment */
af9dc8
+    unsigned short disk_number;         /* (c)  disk number start */
af9dc8
+    unsigned short int_attrib;          /* (c)  internal file attributes */
af9dc8
+    unsigned int ext_attrib;            /* (c)  external file attributes */
af9dc8
+    unsigned int offset;                /* (c)  offset of local header  */
af9dc8
+};
af9dc8
+
af9dc8
+/* zip archive central directory */
af9dc8
+
af9dc8
+struct zip_cdir {
af9dc8
+    struct zip_dirent *entry;   /* directory entries */
af9dc8
+    int nentry;                 /* number of entries */
af9dc8
+
af9dc8
+    unsigned int size;          /* size of central direcotry */
af9dc8
+    unsigned int offset;        /* offset of central directory in file */
af9dc8
+    char *comment;              /* zip archive comment */
af9dc8
+    unsigned short comment_len; /* length of zip archive comment */
af9dc8
+};
af9dc8
+
af9dc8
+struct zip_source {
af9dc8
+    struct zip_source *src;
af9dc8
+    union {
af9dc8
+	zip_source_callback f;
af9dc8
+        zip_source_layered_callback l;
af9dc8
+    } cb;
af9dc8
+    void *ud;
af9dc8
+    enum zip_les error_source;
af9dc8
+    int is_open;
af9dc8
+};
af9dc8
+
af9dc8
+/* entry in zip archive directory */
af9dc8
+
af9dc8
+struct zip_entry {
af9dc8
+    enum zip_state state;
af9dc8
+    struct zip_source *source;
af9dc8
+    char *ch_filename;
af9dc8
+    char *ch_extra;
af9dc8
+    int ch_extra_len;
af9dc8
+    char *ch_comment;
af9dc8
+    int ch_comment_len;
af9dc8
+};
af9dc8
+
af9dc8
+void _zip_dirent_finalize(struct zip_dirent *zde)
af9dc8
+{
af9dc8
+    free(zde->filename);
af9dc8
+    zde->filename = NULL;
af9dc8
+    free(zde->extrafield);
af9dc8
+    zde->extrafield = NULL;
af9dc8
+    free(zde->comment);
af9dc8
+    zde->comment = NULL;
af9dc8
+}
af9dc8
+
af9dc8
+void _zip_cdir_free(struct zip_cdir *cd)
af9dc8
+{
af9dc8
+    int i;
af9dc8
+
af9dc8
+    if (!cd)
af9dc8
+        return;
af9dc8
+
af9dc8
+    for (i=0; i<cd->nentry; i++)
af9dc8
+        _zip_dirent_finalize(cd->entry+i);
af9dc8
+    free(cd->comment);
af9dc8
+    free(cd->entry);
af9dc8
+    free(cd);
af9dc8
+}
af9dc8
+
af9dc8
+void _zip_error_fini(struct zip_error *err)
af9dc8
+{
af9dc8
+    free(err->str);
af9dc8
+    err->str = NULL;
af9dc8
+}
af9dc8
+
af9dc8
+void _zip_error_init(struct zip_error *err)
af9dc8
+{
af9dc8
+    err->zip_err = ZIP_ER_OK;
af9dc8
+    err->sys_err = 0;
af9dc8
+    err->str = NULL;
af9dc8
+}
af9dc8
+
af9dc8
+void _zip_unchange_data(struct zip_entry *ze)
af9dc8
+{
af9dc8
+    if (ze->source) {
af9dc8
+        zip_source_free(ze->source);
af9dc8
+        ze->source = NULL;
af9dc8
+    }
af9dc8
+
af9dc8
+    ze->state = ze->ch_filename ? ZIP_ST_RENAMED : ZIP_ST_UNCHANGED;
af9dc8
+}
af9dc8
+
af9dc8
+void _zip_entry_free(struct zip_entry *ze)
af9dc8
+{
af9dc8
+    free(ze->ch_filename);
af9dc8
+    ze->ch_filename = NULL;
af9dc8
+    free(ze->ch_extra);
af9dc8
+    ze->ch_extra = NULL;
af9dc8
+    ze->ch_extra_len = -1;
af9dc8
+    free(ze->ch_comment);
af9dc8
+    ze->ch_comment = NULL;
af9dc8
+    ze->ch_comment_len = -1;
af9dc8
+
af9dc8
+    _zip_unchange_data(ze);
af9dc8
+}
af9dc8
+
af9dc8
+void
af9dc8
+_zip_error_set(struct zip_error *err, int ze, int se)
af9dc8
+{
af9dc8
+    if (err) {
af9dc8
+	err->zip_err = ze;
af9dc8
+        err->sys_err = se;
af9dc8
+    }
af9dc8
+}
af9dc8
+
af9dc8
+void _zip_free(struct zip *za)
af9dc8
+{
af9dc8
+    int i;
af9dc8
+
af9dc8
+    if (za == NULL)
af9dc8
+        return;
af9dc8
+
af9dc8
+    if (za->zn)
af9dc8
+        free(za->zn);
af9dc8
+
af9dc8
+    if (za->zp)
af9dc8
+       	fclose(za->zp);
af9dc8
+
af9dc8
+    free(za->default_password);
af9dc8
+    _zip_cdir_free(za->cdir);
af9dc8
+    free(za->ch_comment);
af9dc8
+
af9dc8
+    if (za->entry) {
af9dc8
+        for (i=0; i<za->nentry; i++) {
af9dc8
+            _zip_entry_free(za->entry+i);
af9dc8
+        }
af9dc8
+        free(za->entry);
af9dc8
+    }
af9dc8
+
af9dc8
+    for (i=0; i<za->nfile; i++) {
af9dc8
+        if (za->file[i]->error.zip_err == ZIP_ER_OK) {
af9dc8
+            _zip_error_set(&za->file[i]->error, ZIP_ER_ZIPCLOSED, 0);
af9dc8
+            za->file[i]->za = NULL;
af9dc8
+        }
af9dc8
+    }
af9dc8
+
af9dc8
+    free(za->file);
af9dc8
+    free(za);
af9dc8
+    return;
af9dc8
+} 
af9dc8
+
af9dc8
+
af9dc8
+#else
af9dc8
 #include "lib/zip.h"
af9dc8
 #include "lib/zipint.h"
af9dc8
+#endif
af9dc8
 
af9dc8
 /* zip_open is a macro for renaming libzip zipopen, so we need to use PHP_NAMED_FUNCTION */
af9dc8
 static PHP_NAMED_FUNCTION(zif_zip_open);
af9dc8
@@ -1631,6 +1855,10 @@ static ZIPARCHIVE_METHOD(addEmptyDir)
af9dc8
 	}
af9dc8
 
af9dc8
 	idx = zip_stat(intern, s, 0, &sb);
af9dc8
+	/* We don't care about the NOENT status	error here. */
af9dc8
+	if (intern->error.zip_err == ZIP_ER_NOENT) {
af9dc8
+		_zip_error_set(&intern->error, ZIP_ER_OK, 0);
af9dc8
+	}
af9dc8
 	if (idx >= 0) {
af9dc8
 		RETVAL_FALSE;
af9dc8
 	} else {
af9dc8
@@ -1853,6 +2081,10 @@ static ZIPARCHIVE_METHOD(addFromString)
af9dc8
 	}
af9dc8
 
af9dc8
 	cur_idx = zip_name_locate(intern, (const char *)name, 0);
af9dc8
+	/* We don't care about the NOENT status error here. */
af9dc8
+	if (intern->error.zip_err == ZIP_ER_NOENT) {
af9dc8
+		_zip_error_set(&intern->error, ZIP_ER_OK, 0);
af9dc8
+	}
af9dc8
 	/* TODO: fix  _zip_replace */
af9dc8
 	if (cur_idx >= 0) {
af9dc8
 		if (zip_delete(intern, cur_idx) == -1) {
af9dc8
@@ -2877,5 +3109,9 @@ static PHP_MINFO_FUNCTION(zip)
af9dc8
 	php_info_print_table_row(2, "Zip version", PHP_ZIP_VERSION_STRING);
af9dc8
-	php_info_print_table_row(2, "Libzip version", LIBZIP_VERSION);
af9dc8
+#if defined(HAVE_LIBZIP)
af9dc8
+	php_info_print_table_row(2, "Compiled against libzip version", LIBZIP_VERSION);
af9dc8
+#else
af9dc8
+	php_info_print_table_row(2, "Bundled libzip version", LIBZIP_VERSION);
af9dc8
+#endif
af9dc8
 
af9dc8
 	php_info_print_table_end();
af9dc8
 }
af9dc8
diff -up php-5.4.15/ext/zip/php_zip.h.systzip php-5.4.15/ext/zip/php_zip.h
af9dc8
--- php-5.4.15/ext/zip/php_zip.h.systzip	2013-05-08 07:41:20.000000000 +0200
af9dc8
+++ php-5.4.15/ext/zip/php_zip.h	2013-05-09 06:46:26.086673656 +0200
af9dc8
@@ -28,7 +28,11 @@ extern zend_module_entry zip_module_entr
af9dc8
 #include "TSRM.h"
af9dc8
 #endif
af9dc8
 
af9dc8
+#if defined(HAVE_LIBZIP)
af9dc8
+#include <zip.h>
af9dc8
+#else
af9dc8
 #include "lib/zip.h"
af9dc8
+#endif
af9dc8
 
af9dc8
 #define PHP_ZIP_VERSION_STRING "1.11.0"
af9dc8
 
af9dc8
diff -up php-5.4.15/ext/zip/tests/bug38943.phpt.systzip php-5.4.15/ext/zip/tests/bug38943.phpt
af9dc8
--- php-5.4.15/ext/zip/tests/bug38943.phpt.systzip	2013-05-08 07:41:20.000000000 +0200
af9dc8
+++ php-5.4.15/ext/zip/tests/bug38943.phpt	2013-05-09 06:46:26.088673667 +0200
af9dc8
@@ -27,7 +27,7 @@ array(1) {
af9dc8
   [0]=>
af9dc8
   int(1)
af9dc8
 }
af9dc8
-object(myZip)#1 (%d) {
af9dc8
+object(myZip)#%d (%d) {
af9dc8
   ["test":"myZip":private]=>
af9dc8
   int(0)
af9dc8
   ["testp"]=>
af9dc8
diff -up php-5.4.15/ext/zip/tests/pecl12414.phpt.systzip php-5.4.15/ext/zip/tests/pecl12414.phpt
af9dc8
--- php-5.4.15/ext/zip/tests/pecl12414.phpt.systzip	2013-05-08 07:41:20.000000000 +0200
af9dc8
+++ php-5.4.15/ext/zip/tests/pecl12414.phpt	2013-05-09 06:46:26.088673667 +0200
af9dc8
@@ -5,6 +5,8 @@ Bug #12414 ( extracting files from damag
af9dc8
 /*$ */
af9dc8
 if(!extension_loaded('zip')) die('skip');
af9dc8
  ?>
af9dc8
+--XFAIL--
af9dc8
+Doesn't work with system libzip (zip_readfile could not read from ...)
af9dc8
 --FILE--
af9dc8
 
af9dc8
 $filename = 'MYLOGOV2.GFX';
af9dc8
diff -up php-5.4.15/ext/zip/zip_stream.c.systzip php-5.4.15/ext/zip/zip_stream.c
af9dc8
--- php-5.4.15/ext/zip/zip_stream.c.systzip	2013-05-08 07:41:20.000000000 +0200
af9dc8
+++ php-5.4.15/ext/zip/zip_stream.c	2013-05-09 06:46:26.088673667 +0200
af9dc8
@@ -6,7 +6,11 @@
af9dc8
 #if HAVE_ZIP
af9dc8
 #ifdef ZEND_ENGINE_2
af9dc8
 
af9dc8
+#if defined(HAVE_LIBZIP)
af9dc8
+#include <zip.h>
af9dc8
+#else
af9dc8
 #include "lib/zip.h"
af9dc8
+#endif
af9dc8
 
af9dc8
 #include "php_streams.h"
af9dc8
 #include "ext/standard/file.h"