Skip to content

Commit af29403

Browse files
authored
Enable erase_empty_line in ext/readline (php#14526)
This wasn't activated due to inconsistent availability over the editline/readline versions and variants. This now checks whether the rl_erase_empty_line variable is available in library headers and enables it based on that. On Windows this is for now still disabled due to wineditline library, which doesn't have this yet. Documentation already mentions the erase_empty_line setting: https://www.php.net/manual/en/function.readline-info.php
1 parent 2ebef11 commit af29403

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

ext/readline/config.m4

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ if test "$PHP_READLINE" && test "$PHP_READLINE" != "no"; then
7575
-L$READLINE_DIR/$PHP_LIBDIR $PHP_READLINE_LIBS
7676
])
7777

78+
AC_CHECK_DECL([rl_erase_empty_line],
79+
[AC_DEFINE([HAVE_ERASE_EMPTY_LINE], [1],
80+
[Define to 1 if readline library has rl_erase_empty_line variable.])],,
81+
[#include <readline/readline.h>])
82+
7883
AC_DEFINE(HAVE_HISTORY_LIST, 1, [ ])
7984
AC_DEFINE(HAVE_LIBREADLINE, 1, [ ])
8085

@@ -133,6 +138,11 @@ elif test "$PHP_LIBEDIT" != "no"; then
133138
$READLINE_SHARED_LIBADD
134139
])
135140

141+
AC_CHECK_DECL([rl_erase_empty_line],
142+
[AC_DEFINE([HAVE_ERASE_EMPTY_LINE], [1],
143+
[Define to 1 if edit library has rl_erase_empty_line variable.])],,
144+
[#include <editline/readline.h>])
145+
136146
AC_DEFINE(HAVE_LIBEDIT, 1, [ ])
137147
fi
138148

ext/readline/readline.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ PHP_FUNCTION(readline_info)
171171
: ZSTR_CHAR(rl_completion_append_character));
172172
add_assoc_bool(return_value,"completion_suppress_append",rl_completion_suppress_append);
173173
#endif
174-
#if HAVE_ERASE_EMPTY_LINE
174+
#ifdef HAVE_ERASE_EMPTY_LINE
175175
add_assoc_long(return_value,"erase_empty_line",rl_erase_empty_line);
176176
#endif
177177
#ifndef PHP_WIN32
@@ -235,7 +235,7 @@ PHP_FUNCTION(readline_info)
235235
RETVAL_INTERNED_STR(
236236
oldval == 0 ? ZSTR_EMPTY_ALLOC() : ZSTR_CHAR(oldval));
237237
#endif
238-
#if HAVE_ERASE_EMPTY_LINE
238+
#ifdef HAVE_ERASE_EMPTY_LINE
239239
} else if (zend_string_equals_literal_ci(what, "erase_empty_line")) {
240240
oldval = rl_erase_empty_line;
241241
if (value) {

ext/readline/tests/libedit_info_001.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ var_dump(readline_info('attempted_completion_over'));
2424

2525
?>
2626
--EXPECTF--
27-
array(6) {
27+
array(%d) {
2828
["line_buffer"]=>
2929
string(0) ""
3030
["point"]=>
3131
int(0)
3232
["end"]=>
33-
int(0)
33+
int(0)%A
3434
["library_version"]=>
3535
string(%d) "%s"
3636
["readline_name"]=>

ext/readline/tests/readline_info_001.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var_dump(readline_info('completion_suppress_append'));
2525

2626
?>
2727
--EXPECTF--
28-
array(13) {
28+
array(%d) {
2929
["line_buffer"]=>
3030
string(0) ""
3131
["point"]=>
@@ -45,7 +45,7 @@ array(13) {
4545
["completion_append_character"]=>
4646
string(1) " "
4747
["completion_suppress_append"]=>
48-
bool(false)
48+
bool(false)%A
4949
["library_version"]=>
5050
string(%d) "%s"
5151
["readline_name"]=>

0 commit comments

Comments
 (0)