diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-07-16 16:21:45 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-07-16 16:44:37 +0200 |
commit | 46faf8f018e95de27873dbcf7c094af18c4c08e4 (patch) | |
tree | edd85291c8c8070f3182617152098c9289242e6e /sapi/cli/php_cli.c | |
parent | 349a388b90e767da9128efe6da0e4ebf5c752092 (diff) | |
download | php-git-46faf8f018e95de27873dbcf7c094af18c4c08e4.tar.gz |
Introduce zend_stream_init_fp() API
Reduce the amount of code that mucks around with zend_file_handle
initialization.
Diffstat (limited to 'sapi/cli/php_cli.c')
-rw-r--r-- | sapi/cli/php_cli.c | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index c285711d76..4b2af96a5e 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -589,18 +589,13 @@ static const char *param_mode_conflict = "Either execute direct code, process st */ static int cli_seek_file_begin(zend_file_handle *file_handle, char *script_file) { - // TODO: Is this still needed? - file_handle->type = ZEND_HANDLE_FP; - file_handle->opened_path = NULL; - file_handle->free_filename = 0; - if (!(file_handle->handle.fp = VCWD_FOPEN(script_file, "rb"))) { + FILE *fp = VCWD_FOPEN(script_file, "rb"); + if (!fp) { php_printf("Could not open input file: %s\n", script_file); return FAILURE; } - file_handle->filename = script_file; - - rewind(file_handle->handle.fp); + zend_stream_init_fp(file_handle, fp, script_file); return SUCCESS; } /* }}} */ @@ -916,12 +911,8 @@ static int do_cli(int argc, char **argv) /* {{{ */ /* here but this would make things only more complicated. And it */ /* is consitent with the way -R works where the stdin file handle*/ /* is also accessible. */ - file_handle.filename = "Standard input code"; - file_handle.handle.fp = stdin; + zend_stream_init_fp(&file_handle, stdin, "Standard input code"); } - file_handle.type = ZEND_HANDLE_FP; - file_handle.opened_path = NULL; - file_handle.free_filename = 0; php_self = (char*)file_handle.filename; /* before registering argv to module exchange the *new* argv[0] */ |