mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/zlib/zlib.c: GzipReader#ungetc caused crc error.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c59f1e6c90
commit
47778e27f9
2 changed files with 24 additions and 17 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Fri Aug 20 11:46:43 2004 UENO Katsuhiro <katsu@blue.sky.or.jp>
|
||||||
|
|
||||||
|
* ext/zlib/zlib.c: GzipReader#ungetc caused crc error.
|
||||||
|
|
||||||
Thu Aug 19 16:29:45 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
Thu Aug 19 16:29:45 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||||
|
|
||||||
* ext/tk/lib/tk.rb: Fail to treat a hash value of 'font' option.
|
* ext/tk/lib/tk.rb: Fail to treat a hash value of 'font' option.
|
||||||
|
|
|
@ -119,6 +119,7 @@ static void gzfile_read_header _((struct gzfile*));
|
||||||
static void gzfile_check_footer _((struct gzfile*));
|
static void gzfile_check_footer _((struct gzfile*));
|
||||||
static void gzfile_write _((struct gzfile*, Bytef*, uInt));
|
static void gzfile_write _((struct gzfile*, Bytef*, uInt));
|
||||||
static long gzfile_read_more _((struct gzfile*));
|
static long gzfile_read_more _((struct gzfile*));
|
||||||
|
static void gzfile_calc_crc _((struct gzfile*, VALUE));
|
||||||
static VALUE gzfile_read _((struct gzfile*, int));
|
static VALUE gzfile_read _((struct gzfile*, int));
|
||||||
static VALUE gzfile_read_all _((struct gzfile*));
|
static VALUE gzfile_read_all _((struct gzfile*));
|
||||||
static void gzfile_ungetc _((struct gzfile*, int));
|
static void gzfile_ungetc _((struct gzfile*, int));
|
||||||
|
@ -2068,6 +2069,21 @@ gzfile_read_more(gz)
|
||||||
return gz->z.buf_filled;
|
return gz->z.buf_filled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gzfile_calc_crc(gz, str)
|
||||||
|
struct gzfile *gz;
|
||||||
|
VALUE str;
|
||||||
|
{
|
||||||
|
if (RSTRING(str)->len <= gz->ungetc) {
|
||||||
|
gz->ungetc -= RSTRING(str)->len;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
gz->crc = crc32(gz->crc, RSTRING(str)->ptr + gz->ungetc,
|
||||||
|
RSTRING(str)->len - gz->ungetc);
|
||||||
|
gz->ungetc = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
gzfile_read(gz, len)
|
gzfile_read(gz, len)
|
||||||
struct gzfile *gz;
|
struct gzfile *gz;
|
||||||
|
@ -2090,13 +2106,7 @@ gzfile_read(gz, len)
|
||||||
}
|
}
|
||||||
|
|
||||||
dst = zstream_shift_buffer(&gz->z, len);
|
dst = zstream_shift_buffer(&gz->z, len);
|
||||||
if (RSTRING(dst)->len <= gz->ungetc) {
|
gzfile_calc_crc(gz, dst);
|
||||||
gz->ungetc -= RSTRING(dst)->len;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
gz->crc = crc32(gz->crc, RSTRING(dst)->ptr + gz->ungetc,
|
|
||||||
RSTRING(dst)->len - gz->ungetc);
|
|
||||||
}
|
|
||||||
|
|
||||||
OBJ_TAINT(dst); /* for safe */
|
OBJ_TAINT(dst); /* for safe */
|
||||||
return dst;
|
return dst;
|
||||||
|
@ -2119,13 +2129,7 @@ gzfile_read_all(gz)
|
||||||
}
|
}
|
||||||
|
|
||||||
dst = zstream_detach_buffer(&gz->z);
|
dst = zstream_detach_buffer(&gz->z);
|
||||||
if (RSTRING(dst)->len <= gz->ungetc) {
|
gzfile_calc_crc(gz, dst);
|
||||||
gz->ungetc -= RSTRING(dst)->len;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
gz->crc = crc32(gz->crc, RSTRING(dst)->ptr + gz->ungetc,
|
|
||||||
RSTRING(dst)->len - gz->ungetc);
|
|
||||||
}
|
|
||||||
|
|
||||||
OBJ_TAINT(dst); /* for safe */
|
OBJ_TAINT(dst); /* for safe */
|
||||||
return dst;
|
return dst;
|
||||||
|
@ -3008,8 +3012,7 @@ gzreader_skip_linebreaks(gz)
|
||||||
while (n++, *(p++) == '\n') {
|
while (n++, *(p++) == '\n') {
|
||||||
if (n >= gz->z.buf_filled) {
|
if (n >= gz->z.buf_filled) {
|
||||||
str = zstream_detach_buffer(&gz->z);
|
str = zstream_detach_buffer(&gz->z);
|
||||||
gz->crc = crc32(gz->crc, RSTRING(str)->ptr,
|
gzfile_calc_crc(gz, str);
|
||||||
RSTRING(str)->len);
|
|
||||||
while (gz->z.buf_filled == 0) {
|
while (gz->z.buf_filled == 0) {
|
||||||
if (GZFILE_IS_FINISHED(gz)) return;
|
if (GZFILE_IS_FINISHED(gz)) return;
|
||||||
gzfile_read_more(gz);
|
gzfile_read_more(gz);
|
||||||
|
@ -3020,7 +3023,7 @@ gzreader_skip_linebreaks(gz)
|
||||||
}
|
}
|
||||||
|
|
||||||
str = zstream_shift_buffer(&gz->z, n - 1);
|
str = zstream_shift_buffer(&gz->z, n - 1);
|
||||||
gz->crc = crc32(gz->crc, RSTRING(str)->ptr, RSTRING(str)->len);
|
gzfile_calc_crc(gz, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
|
Loading…
Add table
Reference in a new issue