Skip to content

Commit b2a1065

Browse files
committed
Fix [-Wundef] warning in Readline extension
1 parent e16384d commit b2a1065

File tree

5 files changed

+32
-33
lines changed

5 files changed

+32
-33
lines changed

ext/readline/php_readline.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#ifndef PHP_READLINE_H
1818
#define PHP_READLINE_H
1919

20-
#if HAVE_LIBREADLINE || HAVE_LIBEDIT
20+
#if defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT)
2121

2222
extern zend_module_entry readline_module_entry;
2323
#define phpext_readline_ptr &readline_module_entry

ext/readline/readline.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "readline_cli.h"
2626
#include "readline_arginfo.h"
2727

28-
#if HAVE_LIBREADLINE || HAVE_LIBEDIT
28+
#if defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT)
2929

3030
#ifndef HAVE_RL_COMPLETION_MATCHES
3131
#define rl_completion_matches completion_matches
@@ -38,7 +38,7 @@
3838
#include <readline/history.h>
3939
#endif
4040

41-
#if HAVE_RL_CALLBACK_READ_CHAR
41+
#ifdef HAVE_RL_CALLBACK_READ_CHAR
4242

4343
static zval _prepped_callback;
4444

@@ -74,12 +74,12 @@ ZEND_GET_MODULE(readline)
7474

7575
PHP_MINIT_FUNCTION(readline)
7676
{
77-
#if HAVE_LIBREADLINE
77+
#ifdef HAVE_LIBREADLINE
7878
/* libedit don't need this call which set the tty in cooked mode */
7979
using_history();
8080
#endif
8181
ZVAL_UNDEF(&_readline_completion);
82-
#if HAVE_RL_CALLBACK_READ_CHAR
82+
#ifdef HAVE_RL_CALLBACK_READ_CHAR
8383
ZVAL_UNDEF(&_prepped_callback);
8484
#endif
8585
return PHP_MINIT(cli_readline)(INIT_FUNC_ARGS_PASSTHRU);
@@ -94,7 +94,7 @@ PHP_RSHUTDOWN_FUNCTION(readline)
9494
{
9595
zval_ptr_dtor(&_readline_completion);
9696
ZVAL_UNDEF(&_readline_completion);
97-
#if HAVE_RL_CALLBACK_READ_CHAR
97+
#ifdef HAVE_RL_CALLBACK_READ_CHAR
9898
if (Z_TYPE(_prepped_callback) != IS_UNDEF) {
9999
rl_callback_handler_remove();
100100
zval_ptr_dtor(&_prepped_callback);
@@ -168,7 +168,7 @@ PHP_FUNCTION(readline_info)
168168
: ZSTR_CHAR(rl_completion_append_character));
169169
add_assoc_bool(return_value,"completion_suppress_append",rl_completion_suppress_append);
170170
#endif
171-
#if HAVE_ERASE_EMPTY_LINE
171+
#ifdef HAVE_ERASE_EMPTY_LINE
172172
add_assoc_long(return_value,"erase_empty_line",rl_erase_empty_line);
173173
#endif
174174
#ifndef PHP_WIN32
@@ -232,7 +232,7 @@ PHP_FUNCTION(readline_info)
232232
RETVAL_INTERNED_STR(
233233
oldval == 0 ? ZSTR_EMPTY_ALLOC() : ZSTR_CHAR(oldval));
234234
#endif
235-
#if HAVE_ERASE_EMPTY_LINE
235+
#ifdef HAVE_ERASE_EMPTY_LINE
236236
} else if (!strcasecmp(what, "erase_empty_line")) {
237237
oldval = rl_erase_empty_line;
238238
if (value) {
@@ -288,7 +288,7 @@ PHP_FUNCTION(readline_clear_history)
288288
RETURN_THROWS();
289289
}
290290

291-
#if HAVE_LIBEDIT
291+
#ifdef HAVE_LIBEDIT
292292
/* clear_history is the only function where rl_initialize
293293
is not call to ensure correct allocation */
294294
using_history();
@@ -489,7 +489,7 @@ PHP_FUNCTION(readline_completion_function)
489489

490490
/* }}} */
491491

492-
#if HAVE_RL_CALLBACK_READ_CHAR
492+
#ifdef HAVE_RL_CALLBACK_READ_CHAR
493493

494494
static void php_rl_callback_handler(char *the_line)
495495
{
@@ -568,7 +568,7 @@ PHP_FUNCTION(readline_redisplay)
568568
RETURN_THROWS();
569569
}
570570

571-
#if HAVE_LIBEDIT
571+
#ifdef HAVE_LIBEDIT
572572
/* seems libedit doesn't take care of rl_initialize in rl_redisplay
573573
* see bug #72538 */
574574
using_history();
@@ -579,7 +579,7 @@ PHP_FUNCTION(readline_redisplay)
579579

580580
#endif
581581

582-
#if HAVE_RL_ON_NEW_LINE
582+
#ifdef HAVE_RL_ON_NEW_LINE
583583
/* {{{ Inform readline that the cursor has moved to a new line */
584584
PHP_FUNCTION(readline_on_new_line)
585585
{

ext/readline/readline.stub.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ function readline_write_history(?string $filename = null): bool {}
2424

2525
function readline_completion_function(callable $funcname): bool {}
2626

27-
28-
#if HAVE_RL_CALLBACK_READ_CHAR
27+
#ifdef HAVE_RL_CALLBACK_READ_CHAR
2928
function readline_callback_handler_install(string $prompt, callable $callback): bool {}
3029

3130
function readline_callback_read_char(): void {}
@@ -34,7 +33,7 @@ function readline_callback_handler_remove(): bool {}
3433

3534
function readline_redisplay(): void {}
3635

37-
#if HAVE_RL_ON_NEW_LINE
36+
#ifdef HAVE_RL_ON_NEW_LINE
3837
function readline_on_new_line(): void {}
3938
#endif
4039
#endif

ext/readline/readline_arginfo.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,28 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_readline_completion_function, 0,
3232
ZEND_ARG_TYPE_INFO(0, funcname, IS_CALLABLE, 0)
3333
ZEND_END_ARG_INFO()
3434

35-
#if HAVE_RL_CALLBACK_READ_CHAR
35+
#if defined(HAVE_RL_CALLBACK_READ_CHAR)
3636
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_readline_callback_handler_install, 0, 2, _IS_BOOL, 0)
3737
ZEND_ARG_TYPE_INFO(0, prompt, IS_STRING, 0)
3838
ZEND_ARG_TYPE_INFO(0, callback, IS_CALLABLE, 0)
3939
ZEND_END_ARG_INFO()
4040
#endif
4141

42-
#if HAVE_RL_CALLBACK_READ_CHAR
42+
#if defined(HAVE_RL_CALLBACK_READ_CHAR)
4343
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_readline_callback_read_char, 0, 0, IS_VOID, 0)
4444
ZEND_END_ARG_INFO()
4545
#endif
4646

47-
#if HAVE_RL_CALLBACK_READ_CHAR
47+
#if defined(HAVE_RL_CALLBACK_READ_CHAR)
4848
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_readline_callback_handler_remove, 0, 0, _IS_BOOL, 0)
4949
ZEND_END_ARG_INFO()
5050
#endif
5151

52-
#if HAVE_RL_CALLBACK_READ_CHAR
52+
#if defined(HAVE_RL_CALLBACK_READ_CHAR)
5353
#define arginfo_readline_redisplay arginfo_readline_callback_read_char
5454
#endif
5555

56-
#if HAVE_RL_CALLBACK_READ_CHAR && HAVE_RL_ON_NEW_LINE
56+
#if defined(HAVE_RL_CALLBACK_READ_CHAR) && defined(HAVE_RL_ON_NEW_LINE)
5757
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_readline_on_new_line, 0, 0, IS_VOID, 0)
5858
ZEND_END_ARG_INFO()
5959
#endif
@@ -69,19 +69,19 @@ ZEND_FUNCTION(readline_list_history);
6969
ZEND_FUNCTION(readline_read_history);
7070
ZEND_FUNCTION(readline_write_history);
7171
ZEND_FUNCTION(readline_completion_function);
72-
#if HAVE_RL_CALLBACK_READ_CHAR
72+
#if defined(HAVE_RL_CALLBACK_READ_CHAR)
7373
ZEND_FUNCTION(readline_callback_handler_install);
7474
#endif
75-
#if HAVE_RL_CALLBACK_READ_CHAR
75+
#if defined(HAVE_RL_CALLBACK_READ_CHAR)
7676
ZEND_FUNCTION(readline_callback_read_char);
7777
#endif
78-
#if HAVE_RL_CALLBACK_READ_CHAR
78+
#if defined(HAVE_RL_CALLBACK_READ_CHAR)
7979
ZEND_FUNCTION(readline_callback_handler_remove);
8080
#endif
81-
#if HAVE_RL_CALLBACK_READ_CHAR
81+
#if defined(HAVE_RL_CALLBACK_READ_CHAR)
8282
ZEND_FUNCTION(readline_redisplay);
8383
#endif
84-
#if HAVE_RL_CALLBACK_READ_CHAR && HAVE_RL_ON_NEW_LINE
84+
#if defined(HAVE_RL_CALLBACK_READ_CHAR) && defined(HAVE_RL_ON_NEW_LINE)
8585
ZEND_FUNCTION(readline_on_new_line);
8686
#endif
8787

@@ -97,19 +97,19 @@ static const zend_function_entry ext_functions[] = {
9797
ZEND_FE(readline_read_history, arginfo_readline_read_history)
9898
ZEND_FE(readline_write_history, arginfo_readline_write_history)
9999
ZEND_FE(readline_completion_function, arginfo_readline_completion_function)
100-
#if HAVE_RL_CALLBACK_READ_CHAR
100+
#if defined(HAVE_RL_CALLBACK_READ_CHAR)
101101
ZEND_FE(readline_callback_handler_install, arginfo_readline_callback_handler_install)
102102
#endif
103-
#if HAVE_RL_CALLBACK_READ_CHAR
103+
#if defined(HAVE_RL_CALLBACK_READ_CHAR)
104104
ZEND_FE(readline_callback_read_char, arginfo_readline_callback_read_char)
105105
#endif
106-
#if HAVE_RL_CALLBACK_READ_CHAR
106+
#if defined(HAVE_RL_CALLBACK_READ_CHAR)
107107
ZEND_FE(readline_callback_handler_remove, arginfo_readline_callback_handler_remove)
108108
#endif
109-
#if HAVE_RL_CALLBACK_READ_CHAR
109+
#if defined(HAVE_RL_CALLBACK_READ_CHAR)
110110
ZEND_FE(readline_redisplay, arginfo_readline_redisplay)
111111
#endif
112-
#if HAVE_RL_CALLBACK_READ_CHAR && HAVE_RL_ON_NEW_LINE
112+
#if defined(HAVE_RL_CALLBACK_READ_CHAR) && defined(HAVE_RL_ON_NEW_LINE)
113113
ZEND_FE(readline_on_new_line, arginfo_readline_on_new_line)
114114
#endif
115115
ZEND_FE_END

ext/readline/readline_cli.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#include <unixlib/local.h>
4646
#endif
4747

48-
#if HAVE_LIBEDIT
48+
#ifdef HAVE_LIBEDIT
4949
#include <editline/readline.h>
5050
#else
5151
#include <readline/readline.h>
@@ -670,7 +670,7 @@ static int readline_shell_run(void) /* {{{ */
670670
}
671671

672672
if (history_lines_to_write) {
673-
#if HAVE_LIBEDIT
673+
#ifdef HAVE_LIBEDIT
674674
write_history(history_file);
675675
#else
676676
append_history(history_lines_to_write, history_file);
@@ -753,7 +753,7 @@ PHP_MINIT_FUNCTION(cli_readline)
753753
ZEND_INIT_MODULE_GLOBALS(cli_readline, cli_readline_init_globals, NULL);
754754
REGISTER_INI_ENTRIES();
755755

756-
#if HAVE_LIBEDIT
756+
#ifdef HAVE_LIBEDIT
757757
REGISTER_STRING_CONSTANT("READLINE_LIB", "libedit", CONST_CS|CONST_PERSISTENT);
758758
#else
759759
REGISTER_STRING_CONSTANT("READLINE_LIB", "readline", CONST_CS|CONST_PERSISTENT);

0 commit comments

Comments
 (0)