]> granicus.if.org Git - php/commitdiff
cleanup in list ... last time
authorkrakjoe <joe.watkins@live.co.uk>
Sat, 16 Nov 2013 23:11:39 +0000 (23:11 +0000)
committerkrakjoe <joe.watkins@live.co.uk>
Sat, 16 Nov 2013 23:11:39 +0000 (23:11 +0000)
phpdbg_list.c
phpdbg_list.h
phpdbg_prompt.c

index 7074fb215465065b2d85f99c92bd0700e0ce55b8..ce1a7f1377b5a22bc81ae51a438f611760ea9e80 100644 (file)
 
 ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
 
-static inline void i_phpdbg_list_func(const char *str, size_t len TSRMLS_DC)
-{
-    HashTable *func_table = EG(function_table);
-    zend_function* fbc;
-    char *func_name = str;
-    size_t func_name_len = len;
-    
-    /* search active scope if begins with period */
-    if (func_name[0] == '.') {
-       if (EG(scope)) {
-           func_name++;
-           func_name_len--;
-
-           func_table = &EG(scope)->function_table;
-       } else {
-           phpdbg_error("No active class");
-           return;
-       }
-    } else if (!EG(function_table)) {
-        phpdbg_error("No function table loaded");
-        return;
-    } else {
-        func_table = EG(function_table);
-    }
-    
-    /* use lowercase names, case insensitive */
-    func_name = zend_str_tolower_dup(func_name, func_name_len);
-    
-    if (zend_hash_find(func_table, func_name, func_name_len+1,
-        (void**)&fbc) == SUCCESS) {
-        phpdbg_list_function(fbc TSRMLS_CC);
-    } else {
-        phpdbg_error("Function %s not found", func_name);
-    }
-    
-    efree(func_name);
-}
-
 PHPDBG_LIST(lines) /* {{{ */
 {
     switch (param->type) {
@@ -92,7 +54,7 @@ PHPDBG_LIST(func) /* {{{ */
 {
     switch (param->type) {
         case STR_PARAM:
-            i_phpdbg_list_func(
+            phpdbg_list_function_byname(
                 param->str, param->len TSRMLS_CC);
         break;
         
@@ -163,34 +125,6 @@ PHPDBG_LIST(class) /* {{{ */
     return SUCCESS;
 } /* }}} */
 
-void phpdbg_list_dispatch(phpdbg_param_t *param TSRMLS_DC) /* {{{ */
-{
-    switch (param->type) {
-        case NUMERIC_PARAM:
-           case EMPTY_PARAM: {
-               if (PHPDBG_G(exec) || zend_is_executing(TSRMLS_C)) {
-                   if (param->type == EMPTY_PARAM) {
-                       phpdbg_list_file(phpdbg_current_file(TSRMLS_C), 0, 0 TSRMLS_CC);
-                   } else phpdbg_list_file(phpdbg_current_file(TSRMLS_C), param->num, 0 TSRMLS_CC);
-               } else phpdbg_error("Not executing, and execution context not set");
-           } break;
-           
-               case FILE_PARAM:
-                       phpdbg_list_file(param->file.name, param->file.line, 0 TSRMLS_CC);
-                       break;
-                       
-               case STR_PARAM: {
-                   i_phpdbg_list_func(param->str, param->len TSRMLS_CC);
-               } break;
-               
-               case METHOD_PARAM:
-                   phpdbg_do_list_method(param TSRMLS_CC);
-               break;
-               
-               phpdbg_default_switch_case();
-    }
-} /* }}} */
-
 void phpdbg_list_file(const char *filename, long count, long offset TSRMLS_DC) /* {{{ */
 {
        unsigned char *mem, *pos, *last_pos, *end_pos;
@@ -289,3 +223,41 @@ void phpdbg_list_function(const zend_function *fbc TSRMLS_DC) /* {{{ */
                ops->line_end - ops->line_start + 1, ops->line_start TSRMLS_CC);
 } /* }}} */
 
+void phpdbg_list_function_byname(const char *str, size_t len TSRMLS_DC)
+{
+    HashTable *func_table = EG(function_table);
+    zend_function* fbc;
+    char *func_name = str;
+    size_t func_name_len = len;
+    
+    /* search active scope if begins with period */
+    if (func_name[0] == '.') {
+       if (EG(scope)) {
+           func_name++;
+           func_name_len--;
+
+           func_table = &EG(scope)->function_table;
+       } else {
+           phpdbg_error("No active class");
+           return;
+       }
+    } else if (!EG(function_table)) {
+        phpdbg_error("No function table loaded");
+        return;
+    } else {
+        func_table = EG(function_table);
+    }
+    
+    /* use lowercase names, case insensitive */
+    func_name = zend_str_tolower_dup(func_name, func_name_len);
+    
+    if (zend_hash_find(func_table, func_name, func_name_len+1,
+        (void**)&fbc) == SUCCESS) {
+        phpdbg_list_function(fbc TSRMLS_CC);
+    } else {
+        phpdbg_error("Function %s not found", func_name);
+    }
+    
+    efree(func_name);
+}
+
index 66d0e70baec5335f6397857e6de27143981d6269..5c7e9885ebfdd81d7e64eea63629929c36da12fa 100644 (file)
@@ -39,9 +39,9 @@ PHPDBG_LIST(class);
 PHPDBG_LIST(method);
 PHPDBG_LIST(func);
 
+void phpdbg_list_function_byname(const char *, size_t TSRMLS_DC);
 void phpdbg_list_function(const zend_function* TSRMLS_DC);
 void phpdbg_list_file(const char*, long, long TSRMLS_DC);
-void phpdbg_list_dispatch(phpdbg_param_t *param TSRMLS_DC);
 
 static const phpdbg_command_t phpdbg_list_commands[] = {
     PHPDBG_LIST_EX_D(lines,     "lists the specified lines", 'l'),
index 393485e0da50358aa05542e8d7d378e43d92ea46..451988f003c9d707e71008c3bd947c1f6773a962 100644 (file)
@@ -685,7 +685,30 @@ static PHPDBG_COMMAND(quiet) { /* {{{ */
 
 static PHPDBG_COMMAND(list) /* {{{ */
 {
-       phpdbg_list_dispatch(param TSRMLS_CC);
+       switch (param->type) {
+        case NUMERIC_PARAM:
+           case EMPTY_PARAM: {
+               if (PHPDBG_G(exec) || zend_is_executing(TSRMLS_C)) {
+                   if (param->type == EMPTY_PARAM) {
+                       phpdbg_list_file(phpdbg_current_file(TSRMLS_C), 0, 0 TSRMLS_CC);
+                   } else phpdbg_list_file(phpdbg_current_file(TSRMLS_C), param->num, 0 TSRMLS_CC);
+               } else phpdbg_error("Not executing, and execution context not set");
+           } break;
+           
+               case FILE_PARAM:
+                       phpdbg_list_file(param->file.name, param->file.line, 0 TSRMLS_CC);
+                       break;
+                       
+               case STR_PARAM: {
+                   phpdbg_list_function_byname(param->str, param->len TSRMLS_CC);
+               } break;
+               
+               case METHOD_PARAM:
+                   phpdbg_do_list_method(param TSRMLS_CC);
+               break;
+               
+               phpdbg_default_switch_case();
+    }
 
        return SUCCESS;
 } /* }}} */