cvs: pecl /phar phar_object.c /phar/tests mounteddir.phpt

From: Date: Sun, 23 Mar 2008 06:00:30 +0000
Subject: cvs: pecl /phar phar_object.c /phar/tests mounteddir.phpt
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-10026@lists.php.net to get a copy of this message
cellog Sun Mar 23 06:00:30 2008 UTC Modified files: /pecl/phar phar_object.c /pecl/phar/tests mounteddir.phpt Log: rename Phar::getRunningPhar\(\) to Phar::running\(\) and by default return the full phar url, if optional parameter is false, return the path to the phar on disk. Fix a double free on failed mount http://cvs.php.net/viewvc.cgi/pecl/phar/phar_object.c?r1=1.187&r2=1.188&diff_format=u Index: pecl/phar/phar_object.c diff -u pecl/phar/phar_object.c:1.187 pecl/phar/phar_object.c:1.188 --- pecl/phar/phar_object.c:1.187 Sat Mar 22 22:56:03 2008 +++ pecl/phar/phar_object.c Sun Mar 23 06:00:29 2008 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: phar_object.c,v 1.187 2008/03/22 22:56:03 cellog Exp $ */ +/* $Id: phar_object.c,v 1.188 2008/03/23 06:00:29 cellog Exp $ */ #include "phar_internal.h" #include "func_interceptors.h" @@ -425,22 +425,33 @@ } /* }}} */ -/* {{{ proto void Phar::getRunningPhar() - * return the name of the currently running phar archive +/* {{{ proto void Phar::running([bool retphar = true]) + * return the name of the currently running phar archive. If the optional parameter + * is set to true, return the phar:// URL to the currently running phar */ -PHP_METHOD(Phar, getRunningPhar) +PHP_METHOD(Phar, running) { char *fname, *arch, *entry; int fname_len, arch_len, entry_len; + zend_bool retphar = 1; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &retphar) == FAILURE) { + return; + } fname = zend_get_executed_filename(TSRMLS_C); fname_len = strlen(fname); if (SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len TSRMLS_CC)) { efree(entry); - RETURN_STRINGL(arch, arch_len, 0); + if (retphar) { + RETVAL_STRINGL(fname, arch_len + 7, 1); + efree(arch); + return; + } else { + RETURN_STRINGL(arch, arch_len, 0); + } } - efree(entry); RETURN_STRING("", 0); } /* }}} */ @@ -474,7 +485,6 @@ carry_on: if (SUCCESS != phar_mount_entry(*pphar, actual, actual_len, path, path_len TSRMLS_CC)) { zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Mounting of %s to %s within phar %s failed", path, actual, arch); - efree(arch); } efree(arch); return; @@ -3565,6 +3575,11 @@ ZEND_ARG_INFO(0, maxlen) ZEND_END_ARG_INFO(); +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_running, 0, 0, 1) + ZEND_ARG_INFO(0, retphar) +ZEND_END_ARG_INFO(); + #endif /* HAVE_SPL */ zend_function_entry php_archive_methods[] = { @@ -3619,7 +3634,7 @@ PHP_ME(Phar, isValidPharFilename, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) PHP_ME(Phar, loadPhar, arginfo_phar_loadPhar, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) PHP_ME(Phar, mapPhar, arginfo_phar_mapPhar, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) - PHP_ME(Phar, getRunningPhar, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) + PHP_ME(Phar, running, arginfo_phar_running, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) PHP_ME(Phar, mount, arginfo_phar_mount, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) PHP_ME(Phar, mungServer, arginfo_phar_mungServer, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) PHP_ME(Phar, webPhar, arginfo_phar_webPhar, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) http://cvs.php.net/viewvc.cgi/pecl/phar/tests/mounteddir.phpt?r1=1.2&r2=1.3&diff_format=u Index: pecl/phar/tests/mounteddir.phpt diff -u pecl/phar/tests/mounteddir.phpt:1.2 pecl/phar/tests/mounteddir.phpt:1.3 --- pecl/phar/tests/mounteddir.phpt:1.2 Fri Mar 21 18:50:21 2008 +++ pecl/phar/tests/mounteddir.phpt Sun Mar 23 06:00:30 2008 @@ -9,7 +9,7 @@ $fname = dirname(__FILE__) . '/tempmanifest1.phar.php'; $a = new Phar($fname); $a['index.php'] = '<?php -Phar::mount("testit", dirname(Phar::getRunningPhar()) . "/testit"); +Phar::mount("testit", dirname(Phar::running(0)) . "/testit"); include "testit/extfile.php"; include "testit/extfile2.php"; ?>';

« previous php.pecl.cvs (#10026) next »