25
25
#include "readline_cli.h"
26
26
#include "readline_arginfo.h"
27
27
28
- #if HAVE_LIBREADLINE || HAVE_LIBEDIT
28
+ #ifdef HAVE_LIBEDIT
29
29
30
30
#ifndef HAVE_RL_COMPLETION_MATCHES
31
31
#define rl_completion_matches completion_matches
32
32
#endif
33
33
34
- #ifdef HAVE_LIBEDIT
35
34
#include <editline/readline.h>
36
- #else
37
- #include <readline/readline.h>
38
- #include <readline/history.h>
39
- #endif
40
35
41
36
#if HAVE_RL_CALLBACK_READ_CHAR
42
37
@@ -74,10 +69,6 @@ ZEND_GET_MODULE(readline)
74
69
75
70
PHP_MINIT_FUNCTION (readline )
76
71
{
77
- #if HAVE_LIBREADLINE
78
- /* libedit don't need this call which set the tty in cooked mode */
79
- using_history ();
80
- #endif
81
72
ZVAL_UNDEF (& _readline_completion );
82
73
#if HAVE_RL_CALLBACK_READ_CHAR
83
74
ZVAL_UNDEF (& _prepped_callback );
@@ -158,23 +149,6 @@ PHP_FUNCTION(readline_info)
158
149
add_assoc_long (return_value ,"point" ,rl_point );
159
150
#ifndef PHP_WIN32
160
151
add_assoc_long (return_value ,"end" ,rl_end );
161
- #endif
162
- #ifdef HAVE_LIBREADLINE
163
- add_assoc_long (return_value ,"mark" ,rl_mark );
164
- add_assoc_long (return_value ,"done" ,rl_done );
165
- add_assoc_long (return_value ,"pending_input" ,rl_pending_input );
166
- add_assoc_string (return_value ,"prompt" ,SAFE_STRING (rl_prompt ));
167
- add_assoc_string (return_value ,"terminal_name" ,(char * )SAFE_STRING (rl_terminal_name ));
168
- add_assoc_str (return_value , "completion_append_character" ,
169
- rl_completion_append_character == 0
170
- ? ZSTR_EMPTY_ALLOC ()
171
- : ZSTR_CHAR (rl_completion_append_character ));
172
- add_assoc_bool (return_value ,"completion_suppress_append" ,rl_completion_suppress_append );
173
- #endif
174
- #if HAVE_ERASE_EMPTY_LINE
175
- add_assoc_long (return_value ,"erase_empty_line" ,rl_erase_empty_line );
176
- #endif
177
- #ifndef PHP_WIN32
178
152
add_assoc_string (return_value ,"library_version" ,(char * )SAFE_STRING (rl_library_version ));
179
153
#endif
180
154
add_assoc_string (return_value ,"readline_name" ,(char * )SAFE_STRING (rl_readline_name ));
@@ -195,55 +169,6 @@ PHP_FUNCTION(readline_info)
195
169
#ifndef PHP_WIN32
196
170
} else if (zend_string_equals_literal_ci (what , "end" )) {
197
171
RETVAL_LONG (rl_end );
198
- #endif
199
- #ifdef HAVE_LIBREADLINE
200
- } else if (zend_string_equals_literal_ci (what , "mark" )) {
201
- RETVAL_LONG (rl_mark );
202
- } else if (zend_string_equals_literal_ci (what , "done" )) {
203
- oldval = rl_done ;
204
- if (value ) {
205
- rl_done = zval_get_long (value );
206
- }
207
- RETVAL_LONG (oldval );
208
- } else if (zend_string_equals_literal_ci (what , "pending_input" )) {
209
- oldval = rl_pending_input ;
210
- if (value ) {
211
- if (!try_convert_to_string (value )) {
212
- RETURN_THROWS ();
213
- }
214
- rl_pending_input = Z_STRVAL_P (value )[0 ];
215
- }
216
- RETVAL_LONG (oldval );
217
- } else if (zend_string_equals_literal_ci (what , "prompt" )) {
218
- RETVAL_STRING (SAFE_STRING (rl_prompt ));
219
- } else if (zend_string_equals_literal_ci (what , "terminal_name" )) {
220
- RETVAL_STRING ((char * )SAFE_STRING (rl_terminal_name ));
221
- } else if (zend_string_equals_literal_ci (what , "completion_suppress_append" )) {
222
- oldval = rl_completion_suppress_append ;
223
- if (value ) {
224
- rl_completion_suppress_append = zend_is_true (value );
225
- }
226
- RETVAL_BOOL (oldval );
227
- } else if (zend_string_equals_literal_ci (what , "completion_append_character" )) {
228
- oldval = rl_completion_append_character ;
229
- if (value ) {
230
- if (!try_convert_to_string (value )) {
231
- RETURN_THROWS ();
232
- }
233
- rl_completion_append_character = (int )Z_STRVAL_P (value )[0 ];
234
- }
235
- RETVAL_INTERNED_STR (
236
- oldval == 0 ? ZSTR_EMPTY_ALLOC () : ZSTR_CHAR (oldval ));
237
- #endif
238
- #if HAVE_ERASE_EMPTY_LINE
239
- } else if (zend_string_equals_literal_ci (what , "erase_empty_line" )) {
240
- oldval = rl_erase_empty_line ;
241
- if (value ) {
242
- rl_erase_empty_line = zval_get_long (value );
243
- }
244
- RETVAL_LONG (oldval );
245
- #endif
246
- #ifndef PHP_WIN32
247
172
} else if (zend_string_equals_literal_ci (what ,"library_version" )) {
248
173
RETVAL_STRING ((char * )SAFE_STRING (rl_library_version ));
249
174
#endif
@@ -291,11 +216,9 @@ PHP_FUNCTION(readline_clear_history)
291
216
RETURN_THROWS ();
292
217
}
293
218
294
- #if HAVE_LIBEDIT
295
219
/* clear_history is the only function where rl_initialize
296
220
is not call to ensure correct allocation */
297
221
using_history ();
298
- #endif
299
222
clear_history ();
300
223
301
224
RETURN_TRUE ;
@@ -315,7 +238,7 @@ PHP_FUNCTION(readline_list_history)
315
238
316
239
array_init (return_value );
317
240
318
- #if defined( HAVE_LIBEDIT ) && defined( PHP_WIN32 ) /* Winedit on Windows */
241
+ #ifdef PHP_WIN32 /* Winedit on Windows */
319
242
history = history_list ();
320
243
321
244
if (history ) {
@@ -325,7 +248,7 @@ PHP_FUNCTION(readline_list_history)
325
248
}
326
249
}
327
250
328
- #elif defined( HAVE_LIBEDIT ) /* libedit */
251
+ #else
329
252
{
330
253
HISTORY_STATE * hs ;
331
254
int i ;
@@ -342,16 +265,6 @@ PHP_FUNCTION(readline_list_history)
342
265
}
343
266
free (hs );
344
267
}
345
-
346
- #else /* readline */
347
- history = history_list ();
348
-
349
- if (history ) {
350
- int i ;
351
- for (i = 0 ; history [i ]; i ++ ) {
352
- add_next_index_string (return_value , history [i ]-> line );
353
- }
354
- }
355
268
#endif
356
269
}
357
270
/* }}} */
@@ -572,11 +485,9 @@ PHP_FUNCTION(readline_redisplay)
572
485
RETURN_THROWS ();
573
486
}
574
487
575
- #if HAVE_LIBEDIT
576
488
/* seems libedit doesn't take care of rl_initialize in rl_redisplay
577
489
* see bug #72538 */
578
490
using_history ();
579
- #endif
580
491
rl_redisplay ();
581
492
}
582
493
/* }}} */
@@ -598,4 +509,4 @@ PHP_FUNCTION(readline_on_new_line)
598
509
#endif
599
510
600
511
601
- #endif /* HAVE_LIBREADLINE */
512
+ #endif /* HAVE_LIBEDIT */
0 commit comments