Skip to content

Commit 9601475

Browse files
authored
Minimal refactoring of CLI SAPI (#8519)
More specific types, some cleanup and voidifying functions which always return ``SUCCESS``
1 parent f590782 commit 9601475

File tree

2 files changed

+110
-109
lines changed

2 files changed

+110
-109
lines changed

sapi/cli/php_cli.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ static void print_extensions(void) /* {{{ */
234234
#define STDERR_FILENO 2
235235
#endif
236236

237-
static inline int sapi_cli_select(php_socket_t fd)
237+
static inline bool sapi_cli_select(php_socket_t fd)
238238
{
239239
fd_set wfd;
240240
struct timeval tv;
@@ -572,7 +572,7 @@ static void cli_register_file_handles(bool no_close) /* {{{ */
572572
static const char *param_mode_conflict = "Either execute direct code, process stdin or use a file.\n";
573573

574574
/* {{{ cli_seek_file_begin */
575-
static int cli_seek_file_begin(zend_file_handle *file_handle, char *script_file)
575+
static zend_result cli_seek_file_begin(zend_file_handle *file_handle, char *script_file)
576576
{
577577
FILE *fp = VCWD_FOPEN(script_file, "rb");
578578
if (!fp) {
@@ -609,9 +609,9 @@ static int do_cli(int argc, char **argv) /* {{{ */
609609
char *exec_direct=NULL, *exec_run=NULL, *exec_begin=NULL, *exec_end=NULL;
610610
char *arg_free=NULL, **arg_excp=&arg_free;
611611
char *script_file=NULL, *translated_path = NULL;
612-
int interactive=0;
612+
bool interactive = false;
613613
const char *param_error=NULL;
614-
int hide_argv = 0;
614+
bool hide_argv = false;
615615
int num_repeats = 1;
616616
pid_t pid = getpid();
617617

@@ -698,7 +698,7 @@ static int do_cli(int argc, char **argv) /* {{{ */
698698
break;
699699
}
700700

701-
interactive=1;
701+
interactive = true;
702702
}
703703
break;
704704

@@ -818,7 +818,7 @@ static int do_cli(int argc, char **argv) /* {{{ */
818818
zend_load_extension(php_optarg);
819819
break;
820820
case 'H':
821-
hide_argv = 1;
821+
hide_argv = true;
822822
break;
823823
case 10:
824824
behavior=PHP_MODE_REFLECTION_FUNCTION;
@@ -894,7 +894,7 @@ static int do_cli(int argc, char **argv) /* {{{ */
894894
}
895895
if (script_file) {
896896
virtual_cwd_activate();
897-
if (cli_seek_file_begin(&file_handle, script_file) != SUCCESS) {
897+
if (cli_seek_file_begin(&file_handle, script_file) == FAILURE) {
898898
goto err;
899899
} else {
900900
char real_path[MAXPATHLEN];
@@ -1022,7 +1022,7 @@ static int do_cli(int argc, char **argv) /* {{{ */
10221022
zend_eval_string_ex(exec_run, NULL, "Command line run code", 1);
10231023
} else {
10241024
if (script_file) {
1025-
if (cli_seek_file_begin(&file_handle, script_file) != SUCCESS) {
1025+
if (cli_seek_file_begin(&file_handle, script_file) == FAILURE) {
10261026
EG(exit_status) = 1;
10271027
} else {
10281028
CG(skip_shebang) = 1;

0 commit comments

Comments
 (0)