summaryrefslogtreecommitdiff
path: root/sapi/cli/php_cli.c
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2003-02-07 21:55:51 +0000
committerMarcus Boerger <helly@php.net>2003-02-07 21:55:51 +0000
commit383aa3c2d199edd9ec4df3db48c60d29da6d2489 (patch)
tree3e0c8f04ca4a0105254c8feae80047ff4aabb750 /sapi/cli/php_cli.c
parentd66bba099b116a422749c58397f5ef5d6a885b98 (diff)
downloadphp-git-383aa3c2d199edd9ec4df3db48c60d29da6d2489.tar.gz
Define STDIN/OUT/ERR for -B -R -F -E (works as expected).
Enable exit in same switches.
Diffstat (limited to 'sapi/cli/php_cli.c')
-rw-r--r--sapi/cli/php_cli.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c
index da433429e3..1bea0aabcd 100644
--- a/sapi/cli/php_cli.c
+++ b/sapi/cli/php_cli.c
@@ -360,6 +360,9 @@ static void php_register_command_line_global_vars(char **arg TSRMLS_DC)
efree(*arg);
}
+static php_stream_context *sc_in_process = NULL;
+static php_stream *s_in_process = NULL;
+
static void cli_register_file_handles(TSRMLS_D)
{
zval *zin, *zout, *zerr;
@@ -378,6 +381,9 @@ static void cli_register_file_handles(TSRMLS_D)
if (s_in==NULL || s_out==NULL || s_err==NULL) {
return;
}
+
+ sc_in_process = sc_in;
+ s_in_process = s_in;
php_stream_to_zval(s_in, zin);
php_stream_to_zval(s_out, zout);
@@ -903,9 +909,9 @@ int main(int argc, char *argv[])
{
char *input;
size_t len, index = 0;
- php_stream_context *sc_in = php_stream_context_alloc();
- php_stream *s_in = php_stream_open_wrapper_ex("php://stdin", "rb", 0, NULL, sc_in);
pval *argn, *argi;
+
+ cli_register_file_handles(TSRMLS_C);
if (exec_begin && zend_eval_string(exec_begin, NULL, "Command line begin code" TSRMLS_CC) == FAILURE) {
exit_status=254;
@@ -915,7 +921,7 @@ int main(int argc, char *argv[])
Z_LVAL_P(argi) = index;
INIT_PZVAL(argi);
zend_hash_update(&EG(symbol_table), "argi", sizeof("argi"), &argi, sizeof(pval *), NULL);
- while (exit_status == SUCCESS && (input=php_stream_gets(s_in, NULL, 0)) != NULL) {
+ while (exit_status == SUCCESS && (input=php_stream_gets(s_in_process, NULL, 0)) != NULL) {
len = strlen(input);
while (len-- && (input[len]=='\n' || input[len]=='\r')) {
input[len] = '\0';
@@ -948,8 +954,6 @@ int main(int argc, char *argv[])
exit_status=254;
}
- php_stream_close(s_in);
- php_stream_context_free(sc_in);
break;
}
}