Skip to content

Commit c1b6c55

Browse files
committed
Fix [-Wundef] warning in Readline extension
1 parent 48021fa commit c1b6c55

File tree

5 files changed

+32
-32
lines changed

5 files changed

+32
-32
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);
@@ -170,7 +170,7 @@ PHP_FUNCTION(readline_info)
170170
: ZSTR_CHAR(rl_completion_append_character));
171171
add_assoc_bool(return_value,"completion_suppress_append",rl_completion_suppress_append);
172172
#endif
173-
#if HAVE_ERASE_EMPTY_LINE
173+
#ifdef HAVE_ERASE_EMPTY_LINE
174174
add_assoc_long(return_value,"erase_empty_line",rl_erase_empty_line);
175175
#endif
176176
#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 (!strcasecmp(what, "erase_empty_line")) {
240240
oldval = rl_erase_empty_line;
241241
if (value) {
@@ -295,7 +295,7 @@ PHP_FUNCTION(readline_clear_history)
295295
RETURN_THROWS();
296296
}
297297

298-
#if HAVE_LIBEDIT
298+
#ifdef HAVE_LIBEDIT
299299
/* clear_history is the only function where rl_initialize
300300
is not call to ensure correct allocation */
301301
using_history();
@@ -505,7 +505,7 @@ PHP_FUNCTION(readline_completion_function)
505505

506506
/* }}} */
507507

508-
#if HAVE_RL_CALLBACK_READ_CHAR
508+
#ifdef HAVE_RL_CALLBACK_READ_CHAR
509509

510510
static void php_rl_callback_handler(char *the_line)
511511
{
@@ -594,7 +594,7 @@ PHP_FUNCTION(readline_redisplay)
594594
RETURN_THROWS();
595595
}
596596

597-
#if HAVE_LIBEDIT
597+
#ifdef HAVE_LIBEDIT
598598
/* seems libedit doesn't take care of rl_initialize in rl_redisplay
599599
* see bug #72538 */
600600
using_history();
@@ -605,7 +605,7 @@ PHP_FUNCTION(readline_redisplay)
605605

606606
#endif
607607

608-
#if HAVE_RL_ON_NEW_LINE
608+
#ifdef HAVE_RL_ON_NEW_LINE
609609
/* {{{ proto void readline_on_new_line(void)
610610
Inform readline that the cursor has moved to a new line */
611611
PHP_FUNCTION(readline_on_new_line)

ext/readline/readline.stub.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function readline_write_history(string $filename = UNKNOWN): bool {}
2525
function readline_completion_function($funcname): bool {}
2626

2727

28-
#if HAVE_RL_CALLBACK_READ_CHAR
28+
#ifdef HAVE_RL_CALLBACK_READ_CHAR
2929
/**
3030
* @param callable $callback
3131
*/
@@ -37,7 +37,7 @@ function readline_callback_handler_remove(): bool {}
3737

3838
function readline_redisplay(): void {}
3939

40-
#if HAVE_RL_ON_NEW_LINE
40+
#ifdef HAVE_RL_ON_NEW_LINE
4141
function readline_on_new_line(): void {}
4242
#endif
4343
#endif

ext/readline/readline_arginfo.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,28 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_readline_completion_function, 0,
3131
ZEND_ARG_INFO(0, funcname)
3232
ZEND_END_ARG_INFO()
3333

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

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

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

51-
#if HAVE_RL_CALLBACK_READ_CHAR
51+
#if defined(HAVE_RL_CALLBACK_READ_CHAR)
5252
#define arginfo_readline_redisplay arginfo_readline_callback_read_char
5353
#endif
5454

55-
#if HAVE_RL_CALLBACK_READ_CHAR && HAVE_RL_ON_NEW_LINE
55+
#if defined(HAVE_RL_CALLBACK_READ_CHAR) && defined(HAVE_RL_ON_NEW_LINE)
5656
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_readline_on_new_line, 0, 0, IS_VOID, 0)
5757
ZEND_END_ARG_INFO()
5858
#endif
@@ -68,19 +68,19 @@ ZEND_FUNCTION(readline_list_history);
6868
ZEND_FUNCTION(readline_read_history);
6969
ZEND_FUNCTION(readline_write_history);
7070
ZEND_FUNCTION(readline_completion_function);
71-
#if HAVE_RL_CALLBACK_READ_CHAR
71+
#if defined(HAVE_RL_CALLBACK_READ_CHAR)
7272
ZEND_FUNCTION(readline_callback_handler_install);
7373
#endif
74-
#if HAVE_RL_CALLBACK_READ_CHAR
74+
#if defined(HAVE_RL_CALLBACK_READ_CHAR)
7575
ZEND_FUNCTION(readline_callback_read_char);
7676
#endif
77-
#if HAVE_RL_CALLBACK_READ_CHAR
77+
#if defined(HAVE_RL_CALLBACK_READ_CHAR)
7878
ZEND_FUNCTION(readline_callback_handler_remove);
7979
#endif
80-
#if HAVE_RL_CALLBACK_READ_CHAR
80+
#if defined(HAVE_RL_CALLBACK_READ_CHAR)
8181
ZEND_FUNCTION(readline_redisplay);
8282
#endif
83-
#if HAVE_RL_CALLBACK_READ_CHAR && HAVE_RL_ON_NEW_LINE
83+
#if defined(HAVE_RL_CALLBACK_READ_CHAR) && defined(HAVE_RL_ON_NEW_LINE)
8484
ZEND_FUNCTION(readline_on_new_line);
8585
#endif
8686

@@ -96,19 +96,19 @@ static const zend_function_entry ext_functions[] = {
9696
ZEND_FE(readline_read_history, arginfo_readline_read_history)
9797
ZEND_FE(readline_write_history, arginfo_readline_write_history)
9898
ZEND_FE(readline_completion_function, arginfo_readline_completion_function)
99-
#if HAVE_RL_CALLBACK_READ_CHAR
99+
#if defined(HAVE_RL_CALLBACK_READ_CHAR)
100100
ZEND_FE(readline_callback_handler_install, arginfo_readline_callback_handler_install)
101101
#endif
102-
#if HAVE_RL_CALLBACK_READ_CHAR
102+
#if defined(HAVE_RL_CALLBACK_READ_CHAR)
103103
ZEND_FE(readline_callback_read_char, arginfo_readline_callback_read_char)
104104
#endif
105-
#if HAVE_RL_CALLBACK_READ_CHAR
105+
#if defined(HAVE_RL_CALLBACK_READ_CHAR)
106106
ZEND_FE(readline_callback_handler_remove, arginfo_readline_callback_handler_remove)
107107
#endif
108-
#if HAVE_RL_CALLBACK_READ_CHAR
108+
#if defined(HAVE_RL_CALLBACK_READ_CHAR)
109109
ZEND_FE(readline_redisplay, arginfo_readline_redisplay)
110110
#endif
111-
#if HAVE_RL_CALLBACK_READ_CHAR && HAVE_RL_ON_NEW_LINE
111+
#if defined(HAVE_RL_CALLBACK_READ_CHAR) && defined(HAVE_RL_ON_NEW_LINE)
112112
ZEND_FE(readline_on_new_line, arginfo_readline_on_new_line)
113113
#endif
114114
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>
@@ -663,7 +663,7 @@ static int readline_shell_run(void) /* {{{ */
663663
}
664664

665665
if (history_lines_to_write) {
666-
#if HAVE_LIBEDIT
666+
#ifdef HAVE_LIBEDIT
667667
write_history(history_file);
668668
#else
669669
append_history(history_lines_to_write, history_file);
@@ -746,7 +746,7 @@ PHP_MINIT_FUNCTION(cli_readline)
746746
ZEND_INIT_MODULE_GLOBALS(cli_readline, cli_readline_init_globals, NULL);
747747
REGISTER_INI_ENTRIES();
748748

749-
#if HAVE_LIBEDIT
749+
#ifdef HAVE_LIBEDIT
750750
REGISTER_STRING_CONSTANT("READLINE_LIB", "libedit", CONST_CS|CONST_PERSISTENT);
751751
#else
752752
REGISTER_STRING_CONSTANT("READLINE_LIB", "readline", CONST_CS|CONST_PERSISTENT);

0 commit comments

Comments
 (0)