com php-src: .phpdbginit also possible in ini dirs: Changelog.md phpdbg.h phpdbg_prompt.c
| From: | Bob Weinand | Date: | Mon, 25 Nov 2013 12:19:01 +0000 |
| Subject: | com php-src: .phpdbginit also possible in ini dirs: Changelog.md phpdbg.h phpdbg_prompt.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-74613@lists.php.net to get a copy of this message | ||
Commit: 4aab420c5f0727df86414c2663935b151928d132
Author: Bob Weinand <bobwei9@hotmail.com> Mon, 25 Nov 2013 13:19:01 +0100
Parents: 36c09510fb1af418691c9b7b8bf5b3cbb8d22f14
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4aab420c5f0727df86414c2663935b151928d132
Log:
.phpdbginit also possible in ini dirs
Changed paths:
M Changelog.md
M phpdbg.h
M phpdbg_prompt.c
Diff:
diff --git a/Changelog.md b/Changelog.md
index bbd9f29..c12915b 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -7,6 +7,7 @@ Version 0.2.0 2013-00-00
1. Added "break delete <id>" command
2. Added "break opcode <opcode>" command
3. Added "set" command
+4. .phpdbginit now searched in (additional) ini dirs
Version 0.1.0 2013-11-23
------------------------
diff --git a/phpdbg.h b/phpdbg.h
index 7b8e0c0..19cf0c4 100644
--- a/phpdbg.h
+++ b/phpdbg.h
@@ -121,7 +121,9 @@
/* {{{ strings */
#define PHPDBG_ISSUES "http://github.com/krakjoe/phpdbg/issues"
-#define PHPDBG_VERSION "0.2.0-dev" /* }}} */
+#define PHPDBG_VERSION "0.2.0-dev"
+#define PHPDBG_INIT_FILENAME ".phpdbginit"
+/* }}} */
/* {{{ output descriptors */
#define PHPDBG_STDIN 0
diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c
index b1e5aec..e9b484f 100644
--- a/phpdbg_prompt.c
+++ b/phpdbg_prompt.c
@@ -66,21 +66,10 @@ const phpdbg_command_t phpdbg_prompt_commands[] = {
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
-void phpdbg_init(char *init_file, size_t init_file_len, zend_bool use_default TSRMLS_DC) /* {{{ */
-{
- zend_bool init_default = 0;
+void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_init TSRMLS_DC) {
+ struct stat sb;
- if (!init_file && use_default) {
- struct stat sb;
-
- if (VCWD_STAT(".phpdbginit", &sb) != -1) {
- init_file = ".phpdbginit";
- init_file_len = strlen(".phpdbginit");
- init_default = 1;
- }
- }
-
- if (init_file) {
+ if (init_file && VCWD_STAT(init_file, &sb) != -1) {
FILE *fp = fopen(init_file, "r");
if (fp) {
int line = 1;
@@ -158,12 +147,32 @@ next_line:
"Failed to open %s for initialization", init_file);
}
- if (!init_default) {
+ if (free_init) {
free(init_file);
}
}
} /* }}} */
+void phpdbg_init(char *init_file, size_t init_file_len, zend_bool use_default TSRMLS_DC) /* {{{ */
+{
+ if (!init_file && use_default) {
+ char *scan_dir = getenv("PHP_INI_SCAN_DIR");
+
+ phpdbg_try_file_init(ZEND_STRS(PHP_CONFIG_FILE_PATH "/" PHPDBG_INIT_FILENAME) - 1 , 0
TSRMLS_CC);
+
+ if (!scan_dir) {
+ scan_dir = PHP_CONFIG_FILE_SCAN_DIR;
+ }
+ init_file = malloc(strlen(scan_dir) + sizeof(PHPDBG_INIT_FILENAME));
+ sprintf(init_file, "%s/%s", scan_dir, PHPDBG_INIT_FILENAME);
+ phpdbg_try_file_init(init_file, strlen(init_file), 1 TSRMLS_CC);
+
+ phpdbg_try_file_init(ZEND_STRS(PHPDBG_INIT_FILENAME) - 1, 0 TSRMLS_CC);
+ } else {
+ phpdbg_try_file_init(init_file, init_file_len, 1 TSRMLS_CC);
+ }
+}
+
PHPDBG_COMMAND(exec) /* {{{ */
{
switch (param->type) {