diff options
author | Wez Furlong <wez@php.net> | 2002-03-16 02:39:39 +0000 |
---|---|---|
committer | Wez Furlong <wez@php.net> | 2002-03-16 02:39:39 +0000 |
commit | 7da30fa08c7fdd18aa3c2625e2ad802df2729368 (patch) | |
tree | 7aee5a945e9b7f88845c9e5f486e50ba8babb3dd | |
parent | 52982c422e96c1264ce06474fe8ddb504a54d0f0 (diff) | |
download | php-git-7da30fa08c7fdd18aa3c2625e2ad802df2729368.tar.gz |
some tweaks for seek/read used in image.c (thanks Marcus)
-rwxr-xr-x | main/streams.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/main/streams.c b/main/streams.c index 32905e6f18..5157fe9ce7 100755 --- a/main/streams.c +++ b/main/streams.c @@ -132,7 +132,7 @@ PHPAPI int php_stream_getc(php_stream *stream) char buf; if (php_stream_read(stream, &buf, 1) > 0) { - return buf; + return buf & 0xff; } return EOF; } @@ -210,10 +210,15 @@ PHPAPI int php_stream_seek(php_stream *stream, off_t offset, int whence) /* emulate forward moving seeks with reads */ if (whence == SEEK_CUR && offset > 0) { - while(offset-- > 0) { - if (php_stream_getc(stream) == EOF) { + char tmp[1024]; + while(offset >= sizeof(tmp)) { + if (php_stream_read(stream, tmp, sizeof(tmp)) == 0) + return -1; + offset -= sizeof(tmp); + } + if (offset) { + if (php_stream_read(stream, tmp, offset) == 0) return -1; - } } return 0; } |