Skip to content

Commit 3dff2c0

Browse files
committed
Drop support for libreadline
libreadline is GPL, so incompatible with PHP
1 parent 3cfe80d commit 3dff2c0

File tree

6 files changed

+10
-115
lines changed

6 files changed

+10
-115
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ addons:
1010
- locales
1111
- language-pack-de
1212
- re2c
13+
- libedit-dev
1314
- libgmp-dev
1415
- libicu-dev
1516
- libtidy-dev

ext/readline/config.m4

+2-76
Original file line numberDiff line numberDiff line change
@@ -3,79 +3,7 @@ dnl config.m4 for extension readline
33
PHP_ARG_WITH(libedit,for libedit readline replacement,
44
[ --with-libedit Include libedit readline replacement (CLI/CGI only)])
55

6-
if test "$PHP_LIBEDIT" = "no"; then
7-
PHP_ARG_WITH(readline,for readline support,
8-
[ --with-readline[=DIR] Include readline support (CLI/CGI only)])
9-
else
10-
dnl "register" the --with-readline option to preven invalid "unknown configure option" warning
11-
php_with_readline=no
12-
fi
13-
14-
if test "$PHP_READLINE" && test "$PHP_READLINE" != "no"; then
15-
for i in $PHP_READLINE /usr/local /usr; do
16-
test -f $i/include/readline/readline.h && READLINE_DIR=$i && break
17-
done
18-
19-
if test -z "$READLINE_DIR"; then
20-
AC_MSG_ERROR(Please reinstall readline - I cannot find readline.h)
21-
fi
22-
23-
PHP_ADD_INCLUDE($READLINE_DIR/include)
24-
25-
PHP_READLINE_LIBS=""
26-
AC_CHECK_LIB(ncurses, tgetent,
27-
[
28-
PHP_ADD_LIBRARY(ncurses,,READLINE_SHARED_LIBADD)
29-
PHP_READLINE_LIBS="$PHP_READLINE_LIBS -lncurses"
30-
],[
31-
AC_CHECK_LIB(termcap, tgetent,
32-
[
33-
PHP_ADD_LIBRARY(termcap,,READLINE_SHARED_LIBADD)
34-
PHP_READLINE_LIBS="$PHP_READLINE_LIBS -ltermcap"
35-
])
36-
])
37-
38-
PHP_CHECK_LIBRARY(readline, readline,
39-
[
40-
PHP_ADD_LIBRARY_WITH_PATH(readline, $READLINE_DIR/$PHP_LIBDIR, READLINE_SHARED_LIBADD)
41-
], [
42-
AC_MSG_ERROR(readline library not found)
43-
], [
44-
-L$READLINE_DIR/$PHP_LIBDIR $PHP_READLINE_LIBS
45-
])
46-
47-
PHP_CHECK_LIBRARY(readline, rl_pending_input,
48-
[], [
49-
AC_MSG_ERROR([invalid readline installation detected. Try --with-libedit instead.])
50-
], [
51-
-L$READLINE_DIR/$PHP_LIBDIR $PHP_READLINE_LIBS
52-
])
53-
54-
PHP_CHECK_LIBRARY(readline, rl_callback_read_char,
55-
[
56-
AC_DEFINE(HAVE_RL_CALLBACK_READ_CHAR, 1, [ ])
57-
],[],[
58-
-L$READLINE_DIR/$PHP_LIBDIR $PHP_READLINE_LIBS
59-
])
60-
61-
PHP_CHECK_LIBRARY(readline, rl_on_new_line,
62-
[
63-
AC_DEFINE(HAVE_RL_ON_NEW_LINE, 1, [ ])
64-
],[],[
65-
-L$READLINE_DIR/$PHP_LIBDIR $PHP_READLINE_LIBS
66-
])
67-
68-
PHP_CHECK_LIBRARY(readline, rl_completion_matches,
69-
[
70-
AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1, [ ])
71-
],[],[
72-
-L$READLINE_DIR/$PHP_LIBDIR $PHP_READLINE_LIBS
73-
])
74-
75-
AC_DEFINE(HAVE_HISTORY_LIST, 1, [ ])
76-
AC_DEFINE(HAVE_LIBREADLINE, 1, [ ])
77-
78-
elif test "$PHP_LIBEDIT" != "no"; then
6+
if test "$PHP_LIBEDIT" != "no"; then
797
if test "$PHP_LIBEDIT" != "yes"; then
808
AC_MSG_WARN([libedit directory ignored, rely on pkg-config])
819
fi
@@ -131,9 +59,7 @@ elif test "$PHP_LIBEDIT" != "no"; then
13159
])
13260

13361
AC_DEFINE(HAVE_LIBEDIT, 1, [ ])
134-
fi
135-
136-
if test "$PHP_READLINE" != "no" || test "$PHP_LIBEDIT" != "no"; then
13762
PHP_NEW_EXTENSION(readline, readline.c readline_cli.c, $ext_shared, cli)
13863
PHP_SUBST(READLINE_SHARED_LIBADD)
13964
fi
65+

ext/readline/php_readline.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#ifndef PHP_READLINE_H
2020
#define PHP_READLINE_H
2121

22-
#if HAVE_LIBREADLINE || HAVE_LIBEDIT
22+
#if HAVE_LIBEDIT
2323
#ifndef PHP_WIN32
2424
#ifdef ZTS
2525
#warning Readline module will *NEVER* be thread-safe
@@ -36,6 +36,6 @@ extern zend_module_entry readline_module_entry;
3636

3737
#define phpext_readline_ptr NULL
3838

39-
#endif /* HAVE_LIBREADLINE */
39+
#endif /* HAVE_LIBEDIT */
4040

4141
#endif /* PHP_READLINE_H */

ext/readline/readline.c

+4-23
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,13 @@
2626
#include "php_readline.h"
2727
#include "readline_cli.h"
2828

29-
#if HAVE_LIBREADLINE || HAVE_LIBEDIT
29+
#if HAVE_LIBEDIT
3030

3131
#ifndef HAVE_RL_COMPLETION_MATCHES
3232
#define rl_completion_matches completion_matches
3333
#endif
3434

35-
#ifdef HAVE_LIBEDIT
3635
#include <editline/readline.h>
37-
#else
38-
#include <readline/readline.h>
39-
#include <readline/history.h>
40-
#endif
4136

4237
PHP_FUNCTION(readline);
4338
PHP_FUNCTION(readline_add_history);
@@ -383,11 +378,9 @@ PHP_FUNCTION(readline_clear_history)
383378
return;
384379
}
385380

386-
#if HAVE_LIBEDIT
387381
/* clear_history is the only function where rl_initialize
388382
is not call to ensure correct allocation */
389383
using_history();
390-
#endif
391384
clear_history();
392385

393386
RETURN_TRUE;
@@ -408,7 +401,7 @@ PHP_FUNCTION(readline_list_history)
408401

409402
array_init(return_value);
410403

411-
#if defined(HAVE_LIBEDIT) && defined(PHP_WIN32) /* Winedit on Windows */
404+
#if defined(PHP_WIN32) /* Winedit on Windows */
412405
history = history_list();
413406

414407
if (history) {
@@ -418,7 +411,7 @@ PHP_FUNCTION(readline_list_history)
418411
}
419412
}
420413

421-
#elif defined(HAVE_LIBEDIT) /* libedit */
414+
#else /* libedit */
422415
{
423416
HISTORY_STATE *hs;
424417
int i;
@@ -435,16 +428,6 @@ PHP_FUNCTION(readline_list_history)
435428
}
436429
}
437430

438-
#else /* readline */
439-
history = history_list();
440-
441-
if (history) {
442-
int i;
443-
for (i = 0; history[i]; i++) {
444-
add_next_index_string(return_value, history[i]->line);
445-
}
446-
}
447-
#endif
448431
}
449432
/* }}} */
450433
#endif
@@ -669,11 +652,9 @@ PHP_FUNCTION(readline_callback_handler_remove)
669652
Ask readline to redraw the display */
670653
PHP_FUNCTION(readline_redisplay)
671654
{
672-
#if HAVE_LIBEDIT
673655
/* seems libedit doesn't take care of rl_initialize in rl_redisplay
674656
* see bug #72538 */
675657
using_history();
676-
#endif
677658
rl_redisplay();
678659
}
679660
/* }}} */
@@ -692,4 +673,4 @@ PHP_FUNCTION(readline_on_new_line)
692673
#endif
693674

694675

695-
#endif /* HAVE_LIBREADLINE */
676+
#endif /* HAVE_LIBEDIT */

ext/readline/readline_cli.c

-13
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,7 @@
5050
#include <unixlib/local.h>
5151
#endif
5252

53-
#if HAVE_LIBEDIT
5453
#include <editline/readline.h>
55-
#else
56-
#include <readline/readline.h>
57-
#include <readline/history.h>
58-
#endif
5954

6055
#include "zend_compile.h"
6156
#include "zend_execute.h"
@@ -667,11 +662,7 @@ static int readline_shell_run(void) /* {{{ */
667662
}
668663

669664
if (history_lines_to_write) {
670-
#if HAVE_LIBEDIT
671665
write_history(history_file);
672-
#else
673-
append_history(history_lines_to_write, history_file);
674-
#endif
675666
history_lines_to_write = 0;
676667
}
677668

@@ -750,11 +741,7 @@ PHP_MINIT_FUNCTION(cli_readline)
750741
ZEND_INIT_MODULE_GLOBALS(cli_readline, cli_readline_init_globals, NULL);
751742
REGISTER_INI_ENTRIES();
752743

753-
#if HAVE_LIBEDIT
754744
REGISTER_STRING_CONSTANT("READLINE_LIB", "libedit", CONST_CS|CONST_PERSISTENT);
755-
#else
756-
REGISTER_STRING_CONSTANT("READLINE_LIB", "readline", CONST_CS|CONST_PERSISTENT);
757-
#endif
758745

759746
GET_SHELL_CB(cb);
760747
if (cb) {

travis/compile.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ $TS \
5858
--enable-sysvshm \
5959
--enable-shmop \
6060
--enable-pcntl \
61-
--with-readline \
61+
--with-libedit \
6262
--enable-mbstring \
6363
--with-curl \
6464
--with-gettext \

0 commit comments

Comments
 (0)