@@ -48,26 +48,16 @@ static size_t zend_stream_stdio_fsizer(void *handle) /* {{{ */
48
48
#endif
49
49
return buf .st_size ;
50
50
}
51
- return 0 ;
51
+ return -1 ;
52
52
} /* }}} */
53
53
54
54
static size_t zend_stream_fsize (zend_file_handle * file_handle ) /* {{{ */
55
55
{
56
- zend_stat_t buf ;
57
-
58
- if (file_handle -> type == ZEND_HANDLE_STREAM ) {
59
- return file_handle -> handle .stream .fsizer (file_handle -> handle .stream .handle );
60
- }
61
- if (file_handle -> handle .fp && zend_fstat (fileno (file_handle -> handle .fp ), & buf ) == 0 ) {
62
- #ifdef S_ISREG
63
- if (!S_ISREG (buf .st_mode )) {
64
- return 0 ;
65
- }
66
- #endif
67
- return buf .st_size ;
56
+ ZEND_ASSERT (file_handle -> type == ZEND_HANDLE_STREAM );
57
+ if (file_handle -> handle .stream .isatty ) {
58
+ return 0 ;
68
59
}
69
-
70
- return -1 ;
60
+ return file_handle -> handle .stream .fsizer (file_handle -> handle .stream .handle );
71
61
} /* }}} */
72
62
73
63
ZEND_API void zend_stream_init_fp (zend_file_handle * handle , FILE * fp , const char * filename ) {
@@ -126,7 +116,6 @@ static size_t zend_stream_read(zend_file_handle *file_handle, char *buf, size_t
126
116
ZEND_API int zend_stream_fixup (zend_file_handle * file_handle , char * * buf , size_t * len ) /* {{{ */
127
117
{
128
118
size_t size ;
129
- zend_bool is_fp = 0 ;
130
119
131
120
if (file_handle -> buf ) {
132
121
* buf = file_handle -> buf ;
@@ -145,7 +134,6 @@ ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t
145
134
return FAILURE ;
146
135
}
147
136
148
- is_fp = 1 ;
149
137
file_handle -> type = ZEND_HANDLE_STREAM ;
150
138
file_handle -> handle .stream .handle = file_handle -> handle .fp ;
151
139
file_handle -> handle .stream .isatty = isatty (fileno ((FILE * )file_handle -> handle .stream .handle ));
@@ -159,7 +147,7 @@ ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t
159
147
return FAILURE ;
160
148
}
161
149
162
- if (is_fp && ! file_handle -> handle . stream . isatty && size ) {
150
+ if (size ) {
163
151
file_handle -> buf = * buf = safe_emalloc (1 , size , ZEND_MMAP_AHEAD );
164
152
file_handle -> len = zend_stream_read (file_handle , * buf , size );
165
153
} else {
0 commit comments