Репозитории ALT
5.1: | 5.2.14.20100721-alt0.M51.1 |
4.1: | 5.2.5-alt1.M41.3 |
4.0: | 5.2.2-alt1 |
3.0: | 5.0.5-alt0.cvs20050729 |
Группа :: Разработка/Прочее
Пакет: php5
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: php-sapi-cli.patch
Скачать
Скачать
diff --git a/php5/sapi/cli/php_cli.c b/php5/sapi/cli/php_cli.c
index c441835..c71402d 100644
--- a/php5/sapi/cli/php_cli.c
+++ b/php5/sapi/cli/php_cli.c
@@ -36,6 +36,7 @@
#include "SAPI.h"
#include <stdio.h>
+#include <errno.h>
#include "php.h"
#ifdef PHP_WIN32
#include "win32/time.h"
@@ -181,6 +182,29 @@ static int module_name_cmp(const void *a, const void *b TSRMLS_DC) /* {{{ */
}
/* }}} */
+/* default php.ini path */
+static int php_ini_path_override(char **val)
+{
+ char *buf = NULL;
+
+ if (getenv("PHPRC")) {
+ *val = buf;
+ return 0;
+ }
+
+ if ((buf = (char *) malloc(MAXPATHLEN)) == NULL) {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ snprintf(buf, MAXPATHLEN, "/etc/php/%d.%d.%d/cli",
+ PHP_MAJOR_VERSION,
+ PHP_MINOR_VERSION,
+ PHP_RELEASE_VERSION);
+ *val = buf;
+ return 0;
+}
+
static void print_modules(TSRMLS_D) /* {{{ */
{
HashTable sorted_registry;
@@ -413,6 +437,7 @@ static sapi_module_struct cli_sapi_module = {
sapi_cli_log_message, /* Log message */
NULL, /* Get request time */
+ NULL, /* php.ini path override */
STANDARD_SAPI_MODULE_PROPERTIES
};
/* }}} */
@@ -443,7 +468,7 @@ static void php_cli_usage(char *argv0)
" -a Run interactively\n"
#endif
" -c <path>|<file> Look for php.ini file in this directory\n"
- " -n No php.ini file will be used\n"
+ " -n No php.ini file will be used (deprecated, use -c instead)\n"
" -d foo[=bar] Define INI entry foo with value 'bar'\n"
" -e Generate extended information for debugger/profiler\n"
" -f <file> Parse and execute <file>.\n"
@@ -642,6 +667,15 @@ int main(int argc, char *argv[])
#endif
+ if ( !cli_sapi_module.php_ini_path_override ||
+ !*cli_sapi_module.php_ini_path_override ) {
+ if ( php_ini_path_override(&cli_sapi_module.php_ini_path_override) == -1 ) {
+ perror("Can't override php.ini path");
+ exit_status=1;
+ goto out_err;
+ }
+ }
+
#ifdef ZTS
tsrm_startup(1, 1, 0, NULL);
tsrm_ls = ts_resource(0);
@@ -729,10 +763,16 @@ int main(int argc, char *argv[])
CG(in_compilation) = 0; /* not initialized but needed for several options */
EG(uninitialized_zval_ptr) = NULL;
- if (cli_sapi_module.php_ini_path_override && cli_sapi_module.php_ini_ignore) {
+ if (cli_sapi_module.php_ini_ignore) {
+ /* This is stupid error ! Why we must return error at this time ?
+ * If -n we must simply undef php_ini_path_override ... he is needless
+ * any more. */
+ free(cli_sapi_module.php_ini_path_override);
+#if 0
PUTS("You cannot use both -n and -c switch. Use -h for help.\n");
exit_status=1;
goto out_err;
+#endif
}
while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0)) != -1) {