Commit Graph

138 Commits

Author SHA1 Message Date
Wez Furlong
05ea039144 MFB: fpos_t -> off_t 2002-12-23 02:56:46 +00:00
Wez Furlong
efea12fec5 Fix for Bug #21131: fopen($file, 'a+') would incorrectly assume that
the stream position was at offset 0.
This corrects that assumption by querying the stream for it's position
when it detects the 'a' "flag" in the mode parameter to fopen.
Also added a test for plain files and amended the userstreams test to
take this into account.
2002-12-22 18:05:36 +00:00
Wez Furlong
602734c7d9 Correct mistake introduced by my last commit on these files;
*_from_pipe() is for process-pipes created by fopen, not generic pipes
created from proc_open().
Correctly implemented the fifo/pipe check for *_from_file() and it seems
to be working correctly now.
2002-12-19 20:23:50 +00:00
Wez Furlong
c5d4e4b321 MFB: popen/pclose and proc_open/proc_close fixes. 2002-12-12 17:51:25 +00:00
Ilia Alshanetsky
e982d5c7f0 MFB 2002-12-10 16:39:59 +00:00
Wez Furlong
5029c73096 Emulate fopencookie on *BSD systems.
Patch mostly from Melvyn Sopacua <msopacua@idg.nl>
2002-12-09 16:14:28 +00:00
Wez Furlong
164130ed22 MFB: #20831 fix 2002-12-09 10:38:35 +00:00
Marcus Boerger
517af84b0a MFB: Fix memleak in debug mode 2002-11-23 01:24:08 +00:00
Marcus Boerger
f0daa5c6d9 Fix warning as discussed with Wez. 2002-11-18 17:23:21 +00:00
Wez Furlong
039d6a1668 wb -> r+b 2002-11-18 12:40:12 +00:00
Wez Furlong
ca58966a0d Merge streams changes from branch. 2002-11-18 11:39:42 +00:00
Ilia Alshanetsky
3bef247fcc Fixed a problem that would cause include/require("/dir/file") to fail on
Windows.
2002-11-17 00:06:50 +00:00
Derick Rethans
bab4957d1c - MFB: Fixed bug #20484 (stream_get_meta_data crashes on a normal file
stream). (Derick, Wez)
2002-11-14 10:56:35 +00:00
Ilia Alshanetsky
91a203e8cd Fixed a bug that in many situations would cause open_basedir restriction to
be bypassed. Most notable exception, is the inclusion of files via include(),
with a partial path.
2002-11-10 05:14:26 +00:00
Marcus Boerger
1f0b200188 php_stream replacement for fprintf
#Agreed by Wez - I will use this mysel soon.
2002-11-06 00:15:24 +00:00
Wez Furlong
ae4c3c22e1 Probable fix for #20180. 2002-11-01 04:58:23 +00:00
Ilia Alshanetsky
e300e0df59 Fix win32 build. 2002-10-28 12:37:31 +00:00
Ilia Alshanetsky
728eacbf52 A better fix for bug #20110. 2002-10-28 03:45:21 +00:00
Ilia Alshanetsky
f76b9649cd Fixed bug #20110. 2002-10-28 00:28:11 +00:00
Shane Caraveo
5ef76f6707 dont memmove a null pointer. caught by bounds checker. 2002-10-27 23:34:48 +00:00
Shane Caraveo
bb55b3a420 fix Bug #20126
write returns an int, with < 0 being a failure.
2002-10-27 23:01:45 +00:00
Sascha Schumann
2909e5c9c9 centralize #include "build-defs.h" and drop (sometimes inconsistent) other
instances
2002-10-24 13:15:49 +00:00
Ilia Alshanetsky
a5d3427251 When doing automatic line end detection, pick the line end that is found
first.
2002-10-22 15:34:50 +00:00
Wez Furlong
dabf1053cd Refine stream_select() to work with streams that have data in their read
buffers.
When selecting for read, the streams are examined; if any of them have
pending read data, no actual select(2) call is performed; instead the
streams with buffered data are returned; just like a regular select
call.
Prevent erroneous warning in stream_select when obtaining the fd.
2002-10-21 22:54:37 +00:00
Moriyoshi Koizumi
890aee56d1 MFH 2002-10-21 01:33:31 +00:00
Ilia Alshanetsky
fef922307c Fixed incorrect handling of files starting with a . 2002-10-20 20:44:10 +00:00
Wez Furlong
829f1855fd made fgets() binary safe.
php_stream_gets is now a macro which calls php_stream_get_line. The latter
has an option argument to return the number of bytes in the line.
Functions like fgetcsv(), fgetss() can be made binary safe by calling
php_stream_get_line directly.

# HEADS UP: You will need to make clean after updating your CVS, as the
# binary signature has changed.
2002-10-19 13:11:48 +00:00
Wez Furlong
f42b26bc22 Probable fix for #19944 2002-10-19 10:34:10 +00:00
Ilia Alshanetsky
4b83b189fe Fixed bug #19971 (optimized the file() function).
The file() function is now also binary safe.
2002-10-18 20:39:49 +00:00
Wez Furlong
e0c0264935 Improve EOF detection. Fixes #19970. 2002-10-18 12:15:04 +00:00
Wez Furlong
2f6952c936 Nope, that last one wasn't a leak in main/streams.c, it was
file_get_contents misinterpreting the result...
2002-10-15 16:45:26 +00:00
Wez Furlong
fa1f06b69f Fix mem leak for zero-byte files. 2002-10-15 16:38:11 +00:00
Wez Furlong
842b5554e0 Some buffer paranoia.
Also, make feof() detection safer (ala recent changes to zlib extension).
2002-10-15 16:04:46 +00:00
Wez Furlong
106631fce1 *cough*
Fix inverted logic for the assert.
2002-10-14 05:38:50 +00:00
Wez Furlong
86e60a2d7a @- fgets($fp) (with no length parameter) now uses a buffer as long as the
@  the next line available from the $fp. Previously, there was a 1KB limit.
@  (Wez)
2002-10-14 02:28:35 +00:00
Wez Furlong
2d97f4d4c7 Remove some old code. 2002-10-13 23:43:46 +00:00
Wez Furlong
5f7c347f17 Fix a nasty nasty bug:
When not enough data to satisfy a read was found in the buffer, fgets modifies
the buf pointer to point to the position to store the next chunk.  It then
returned the modified buf pointer, instead of a pointer to the start of the
buffer.

Also added some infrastructure for making fgets grow the buffer on-demand to
the correct line-size.  Since streams uses reasonable chunk sizes, the
performance of the realloc's should be pretty good; in the best case, the line
is already found completely in the buffer, so the returned buffer will be
allocated to precisely the correct size.

In the worst case, where the buffer only contains part of the line, we get a
realloc per buffer fill. The reallocs are either the size of the remainder
of the line, or the chunk_size (if the buffer sill does not contain a complete
line).  Each realloc adds an extra byte for a NUL terminator.

I think this will perform quite well using the default chunk size of 8K.
2002-10-13 22:52:33 +00:00
Wez Furlong
4308a399b9 paranoia 2002-10-12 02:56:34 +00:00
Wez Furlong
258aa4d239 Write in blocks of the current chunk_size for a stream.
Should resolve problems with network writes.
2002-10-12 02:31:42 +00:00
Sascha Schumann
88b2d8bb8f stdio buffers data in user land. By calling fflush(3), this
data is sent to the kernel using write(2). fsync'ing a
file descriptor is not required -- writing to a fd has the same
affect as calling fflush after each fwrite.
2002-10-07 03:12:06 +00:00
Wez Furlong
510f3b0305 Try to ensure that we return the number of bytes requested during fread(). 2002-10-06 23:27:53 +00:00
Wez Furlong
9d5bab5a0d EOF related fixes. 2002-10-05 10:59:35 +00:00
Wez Furlong
077fe52d8b This seems to resolve the issues with fgets.
I've moved EOF detection into the streams layer; a stream reader
implementation should set stream->eof when it detects EOF.
Fixed test for user streams - it still fails but that is due to an output
buffering bug.
2002-10-05 10:35:13 +00:00
Sascha Schumann
bfd2a857b2 Fix EOF cases
Noticed by: Ilia
2002-10-04 19:48:59 +00:00
Sascha Schumann
1918011c01 Interrupt loop, if the stream op fails. 2002-10-04 19:36:09 +00:00
Sascha Schumann
a4ec211e9e Add a few notes 2002-10-04 19:08:43 +00:00
Wez Furlong
9c5883bdf6 replace dont_block with a flag. 2002-10-04 18:59:34 +00:00
Ilia Alshanetsky
08645d53c0 Fixed bug #19746 2002-10-04 18:44:47 +00:00
Sascha Schumann
4f7e6dadd8 Improve the general behaviour of stream_gets and fix its semantics
with regard to sockets. The behaviour should be aligned with PHP 4.2 now.
This has been verified to some degree.

If the underlying stream operations block when no new data is readable,
we need to take extra precautions.

If there is buffered data available, we check for a EOL. If it exists,
we pass the data immediately back to the caller. This saves a call
to the read implementation and will not block where blocking
is not necessary at all.

If the stream buffer contains more data than the caller requested,
we can also avoid that costly step and simply return that data.
2002-10-04 18:21:40 +00:00
Marcus Boerger
3ee8172674 fix position handling 2002-10-03 16:06:41 +00:00