@@ -153,7 +153,7 @@ void phpdbg_init(char *init_file, size_t init_file_len, zend_bool use_default TS
153
153
}
154
154
goto next_line ;
155
155
}
156
-
156
+
157
157
switch (phpdbg_do_cmd (phpdbg_prompt_commands , cmd , cmd_len TSRMLS_CC )) {
158
158
case FAILURE :
159
159
phpdbg_error (
@@ -914,26 +914,29 @@ static PHPDBG_COMMAND(list) /* {{{ */
914
914
915
915
static inline int phpdbg_call_register (phpdbg_input_t * input TSRMLS_DC ) /* {{{ */
916
916
{
917
- /* temporary, until we can handle arrays of strings */
918
- const char * cmd = input -> string ;
919
- size_t cmd_len = input -> length ;
920
- const char * start = (const char * ) input -> start ;
921
- size_t offset = strlen (cmd )+ (sizeof (" " )- 1 );
917
+ phpdbg_input_t * function = input -> argv [0 ];
922
918
923
- if (zend_hash_exists (& PHPDBG_G (registered ), cmd , strlen (cmd )+ 1 )) {
924
- zval fname , * fretval , * farg = NULL ;
919
+ if (zend_hash_exists (
920
+ & PHPDBG_G (registered ), function -> string , function -> length + 1 )) {
921
+ zval fname , * fretval ;
925
922
zend_fcall_info fci ;
926
- zend_fcall_info_cache fcic ;
927
-
928
- zval * * params [1 ];
923
+ zval * * params = NULL ;
929
924
930
- if (offset < cmd_len ) {
931
- ALLOC_INIT_ZVAL (farg );
932
- ZVAL_STRING (farg , & start [offset ], 1 );
933
- params [0 ] = & farg ;
925
+ if (input -> argc > 1 ) {
926
+ int arg ;
927
+
928
+ params = emalloc (sizeof (zval * ) * input -> argc );
929
+
930
+ for (arg = 1 ; arg <= (input -> argc - 1 ); arg ++ ) {
931
+ MAKE_STD_ZVAL ((params [arg - 1 ]));
932
+ ZVAL_STRINGL (
933
+ (params [arg - 1 ]),
934
+ input -> argv [arg ]-> string ,
935
+ input -> argv [arg ]-> length , 1 );
936
+ }
934
937
}
935
938
936
- ZVAL_STRINGL (& fname , cmd , strlen ( cmd ) , 1 );
939
+ ZVAL_STRINGL (& fname , function -> string , function -> length , 1 );
937
940
938
941
fci .size = sizeof (fci );
939
942
fci .function_table = & PHPDBG_G (registered );
@@ -942,17 +945,22 @@ static inline int phpdbg_call_register(phpdbg_input_t *input TSRMLS_DC) /* {{{ *
942
945
fci .object_ptr = NULL ;
943
946
fci .retval_ptr_ptr = & fretval ;
944
947
945
- /* todo parse parameters better */
946
- fci .param_count = (offset < cmd_len ) ? 1 : 0 ;
947
- fci .params = (offset < cmd_len ) ? params : NULL ;
948
+ fci .param_count = (input -> argc > 1 ) ? (input -> argc - 1 ) : 0 ;
949
+ fci .params = (input -> argc > 1 ) ? & params : NULL ;
948
950
fci .no_separation = 1 ;
949
951
950
952
zend_call_function (
951
953
& fci , NULL TSRMLS_CC );
952
954
953
955
zval_dtor (& fname );
954
- if (offset < cmd_len ) {
955
- zval_ptr_dtor (& farg );
956
+
957
+ if (input -> argc > 1 ) {
958
+ int arg ;
959
+
960
+ for (arg = 1 ; arg <= (input -> argc - 1 ); arg ++ ) {
961
+ zval_ptr_dtor (& params [arg - 1 ]);
962
+ }
963
+ efree (params );
956
964
}
957
965
if (fretval ) {
958
966
zend_print_zval_r (
@@ -973,9 +981,7 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */
973
981
974
982
if (input && input -> length > 0L ) {
975
983
do {
976
- phpdbg_do_cmd_ex (phpdbg_prompt_commands , input TSRMLS_CC );
977
-
978
- switch (ret = phpdbg_do_cmd (phpdbg_prompt_commands , input -> string , input -> length TSRMLS_CC )) {
984
+ switch (ret = phpdbg_do_cmd_ex (phpdbg_prompt_commands , input TSRMLS_CC )) {
979
985
case FAILURE :
980
986
if (!(PHPDBG_G (flags ) & PHPDBG_IS_QUITTING )) {
981
987
if (phpdbg_call_register (input TSRMLS_CC ) == FAILURE ) {
0 commit comments