diff options
author | Timm Friebe <thekid@thekid.de> | 2014-07-06 17:07:01 +0200 |
---|---|---|
committer | Timm Friebe <thekid@thekid.de> | 2014-07-06 17:07:01 +0200 |
commit | a1554ca6343598c38e4fb4fbcc46419ce0bdf058 (patch) | |
tree | e66e73ff23a340cf7343459a0331a57b8eff65aa /sapi/phpdbg/phpdbg_utils.c | |
parent | e0d51d1cf00d43c57104764b620bb9219889a86d (diff) | |
parent | 5b925824edf3edc951fc41608d5cbd07a0baab08 (diff) | |
download | php-git-a1554ca6343598c38e4fb4fbcc46419ce0bdf058.tar.gz |
Merge in changes from master
Now also includes "on [TYPE]" in "Call to a member function" error
Diffstat (limited to 'sapi/phpdbg/phpdbg_utils.c')
-rw-r--r-- | sapi/phpdbg/phpdbg_utils.c | 70 |
1 files changed, 69 insertions, 1 deletions
diff --git a/sapi/phpdbg/phpdbg_utils.c b/sapi/phpdbg/phpdbg_utils.c index 1effcfccaf..3ce2fade17 100644 --- a/sapi/phpdbg/phpdbg_utils.c +++ b/sapi/phpdbg/phpdbg_utils.c @@ -30,6 +30,11 @@ #ifdef _WIN32 # include "win32/time.h" +#elif defined(HAVE_SYS_IOCTL_H) +# include "sys/ioctl.h" +# ifndef GWINSZ_IN_SYS_IOCTL +# include <termios.h> +# endif #endif ZEND_EXTERN_MODULE_GLOBALS(phpdbg); @@ -65,6 +70,14 @@ const static phpdbg_color_t colors[] = { PHPDBG_COLOR_END }; /* }}} */ +/* {{{ */ +const static phpdbg_element_t elements[] = { + PHPDBG_ELEMENT_D("prompt", PHPDBG_COLOR_PROMPT), + PHPDBG_ELEMENT_D("error", PHPDBG_COLOR_ERROR), + PHPDBG_ELEMENT_D("notice", PHPDBG_COLOR_NOTICE), + PHPDBG_ELEMENT_END +}; /* }}} */ + PHPDBG_API int phpdbg_is_numeric(const char *str) /* {{{ */ { if (!str) @@ -347,6 +360,21 @@ PHPDBG_API const phpdbg_color_t* phpdbg_get_colors(TSRMLS_D) /* {{{ */ return colors; } /* }}} */ +PHPDBG_API int phpdbg_get_element(const char *name, size_t len TSRMLS_DC) { + const phpdbg_element_t *element = elements; + + while (element && element->name) { + if (len == element->name_length) { + if (strncasecmp(name, element->name, len) == SUCCESS) { + return element->id; + } + } + element++; + } + + return PHPDBG_COLOR_INVALID; +} + PHPDBG_API void phpdbg_set_prompt(const char *prompt TSRMLS_DC) /* {{{ */ { /* free formatted prompt */ @@ -372,12 +400,16 @@ PHPDBG_API const char *phpdbg_get_prompt(TSRMLS_D) /* {{{ */ } /* create cached prompt */ +#ifndef HAVE_LIBEDIT + /* TODO: libedit doesn't seems to support coloured prompt */ if ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED)) { asprintf( &PHPDBG_G(prompt)[1], "\033[%sm%s\033[0m ", PHPDBG_G(colors)[PHPDBG_COLOR_PROMPT]->code, PHPDBG_G(prompt)[0]); - } else { + } else +#endif + { asprintf( &PHPDBG_G(prompt)[1], "%s ", PHPDBG_G(prompt)[0]); @@ -385,3 +417,39 @@ PHPDBG_API const char *phpdbg_get_prompt(TSRMLS_D) /* {{{ */ return PHPDBG_G(prompt)[1]; } /* }}} */ + +int phpdbg_rebuild_symtable(TSRMLS_D) { + if (!EG(active_op_array)) { + phpdbg_error("No active op array!"); + return FAILURE; + } + + if (!EG(active_symbol_table)) { + zend_rebuild_symbol_table(TSRMLS_C); + + if (!EG(active_symbol_table)) { + phpdbg_error("No active symbol table!"); + return FAILURE; + } + } + + return SUCCESS; +} + +PHPDBG_API int phpdbg_get_terminal_width(TSRMLS_D) /* {{{ */ +{ + int columns; +#ifdef _WIN32 + CONSOLE_SCREEN_BUFFER_INFO csbi; + + GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); + columns = csbi.srWindow.Right - csbi.srWindow.Left + 1; +#elif defined(HAVE_SYS_IOCTL_H) && defined (TIOCGWINSZ) + struct winsize w; + + columns = ioctl(fileno(stdout), TIOCGWINSZ, &w) == 0 ? w.ws_col : 80; +#else + columns = 80; +#endif + return columns; +} /* }}} */ |