@@ -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 )
@@ -377,9 +377,10 @@ PHP_FUNCTION(readline_clear_history)
377
377
}
378
378
379
379
/* }}} */
380
+
381
+ #ifdef HAVE_HISTORY_LIST
380
382
/* {{{ proto array readline_list_history(void)
381
383
Lists the history */
382
- #ifndef HAVE_LIBEDIT
383
384
PHP_FUNCTION (readline_list_history )
384
385
{
385
386
HIST_ENTRY * * history ;
@@ -388,19 +389,48 @@ PHP_FUNCTION(readline_list_history)
388
389
return ;
389
390
}
390
391
391
- history = history_list ();
392
-
393
392
array_init (return_value );
394
393
394
+ #if defined(HAVE_LIBEDIT ) && defined(PHP_WIN32 ) /* Winedit on Windows */
395
+ hs = history_get_history_state ();
396
+
397
+ if (history ) {
398
+ int i , n = history_length ();
399
+ for (i = 0 ; i < n ; i ++ ) {
400
+ add_next_index_string (return_value , history [i ]-> line );
401
+ }
402
+ }
403
+
404
+ #elif defined(HAVE_LIBEDIT ) /* libedit */
405
+ {
406
+ HISTORY_STATE * hs ;
407
+ int i ;
408
+
409
+ using_history ();
410
+ history = history_list ();
411
+ hs = history_get_history_state ();
412
+
413
+ if (history && hs ) {
414
+ for (i = 0 ; i < hs -> length ; i ++ ) {
415
+ add_next_index_string (return_value , history [i ]-> line );
416
+ }
417
+ }
418
+ }
419
+
420
+ #else /* readline */
421
+ history = history_list ();
422
+
395
423
if (history ) {
396
424
int i ;
397
425
for (i = 0 ; history [i ]; i ++ ) {
398
- add_next_index_string (return_value ,history [i ]-> line );
426
+ add_next_index_string (return_value , history [i ]-> line );
399
427
}
400
428
}
401
- }
402
429
#endif
430
+ }
403
431
/* }}} */
432
+ #endif
433
+
404
434
/* {{{ proto bool readline_read_history([string filename])
405
435
Reads the history */
406
436
PHP_FUNCTION (readline_read_history )
0 commit comments