@@ -45,7 +45,7 @@ PHP_FUNCTION(readline);
45
45
PHP_FUNCTION (readline_add_history );
46
46
PHP_FUNCTION (readline_info );
47
47
PHP_FUNCTION (readline_clear_history );
48
- #ifndef HAVE_LIBEDIT
48
+ #ifdef HAVE_HISTORY_LIST
49
49
PHP_FUNCTION (readline_list_history );
50
50
#endif
51
51
PHP_FUNCTION (readline_read_history );
@@ -90,7 +90,7 @@ ZEND_END_ARG_INFO()
90
90
ZEND_BEGIN_ARG_INFO (arginfo_readline_clear_history , 0 )
91
91
ZEND_END_ARG_INFO ()
92
92
93
- #ifndef HAVE_LIBEDIT
93
+ #ifdef HAVE_HISTORY_LIST
94
94
ZEND_BEGIN_ARG_INFO (arginfo_readline_list_history , 0 )
95
95
ZEND_END_ARG_INFO ()
96
96
#endif
@@ -135,7 +135,7 @@ static const zend_function_entry php_readline_functions[] = {
135
135
PHP_FE (readline_info , arginfo_readline_info )
136
136
PHP_FE (readline_add_history , arginfo_readline_add_history )
137
137
PHP_FE (readline_clear_history , arginfo_readline_clear_history )
138
- #ifndef HAVE_LIBEDIT
138
+ #ifdef HAVE_HISTORY_LIST
139
139
PHP_FE (readline_list_history , arginfo_readline_list_history )
140
140
#endif
141
141
PHP_FE (readline_read_history , arginfo_readline_read_history )
@@ -379,22 +379,35 @@ PHP_FUNCTION(readline_clear_history)
379
379
/* }}} */
380
380
/* {{{ proto array readline_list_history(void)
381
381
Lists the history */
382
- #ifndef HAVE_LIBEDIT
382
+ #ifdef HAVE_HISTORY_LIST
383
383
PHP_FUNCTION (readline_list_history )
384
384
{
385
385
HIST_ENTRY * * history ;
386
+ #ifdef HAVE_LIBEDIT
387
+ HISTORY_STATE * hs ;
388
+ #endif
386
389
387
390
if (zend_parse_parameters_none () == FAILURE ) {
388
391
return ;
389
392
}
390
393
394
+ array_init (return_value );
395
+
396
+ #ifdef HAVE_LIBEDIT
397
+ using_history ();
391
398
history = history_list ();
399
+ hs = history_get_history_state ();
392
400
393
- array_init (return_value );
401
+ if (history && hs ) {
402
+ int i ;
403
+ for (i = 0 ; i < hs -> length ; i ++ ) {
404
+ #else
405
+ history = history_list ();
394
406
395
407
if (history ) {
396
408
int i ;
397
409
for (i = 0 ; history [i ]; i ++ ) {
410
+ #endif
398
411
add_next_index_string (return_value ,history [i ]-> line );
399
412
}
400
413
}
0 commit comments