The R Project SVN R

Rev

Rev 55623 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 55623 Rev 67382
Line 283... Line 283...
283
    Bytef *start = (Bytef*) buf; /* starting point for crc computation */
283
    Bytef *start = (Bytef*) buf; /* starting point for crc computation */
284
    Byte  *next_out; /* == stream.next_out but not forced far (for MSDOS) */
284
    Byte  *next_out; /* == stream.next_out but not forced far (for MSDOS) */
285
 
285
 
286
    if (s == NULL || s->mode != 'r') return Z_STREAM_ERROR;
286
    if (s == NULL || s->mode != 'r') return Z_STREAM_ERROR;
287
 
287
 
288
    if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) return -1;
288
    if (s->z_err == Z_DATA_ERROR) {
-
 
289
	warning("invalid or incomplete compressed data");
-
 
290
	return -1;
-
 
291
    } else if(s->z_err == Z_ERRNO) {
-
 
292
	warning("error reading the file");
-
 
293
	return -1;
-
 
294
    }
289
    if (s->z_err == Z_STREAM_END) return 0;  /* EOF */
295
    if (s->z_err == Z_STREAM_END) return 0;  /* EOF */
290
 
296
 
291
    next_out = (Byte*) buf;
297
    next_out = (Byte*) buf;
292
    s->stream.next_out = (Bytef*) buf;
298
    s->stream.next_out = (Bytef*) buf;
293
    s->stream.avail_out = len;
299
    s->stream.avail_out = len;
Line 338... Line 344...
338
            /* Check CRC and original size */
344
            /* Check CRC and original size */
339
            s->crc = crc32(s->crc, start, (uInt) (s->stream.next_out - start));
345
            s->crc = crc32(s->crc, start, (uInt) (s->stream.next_out - start));
340
            start = s->stream.next_out;
346
            start = s->stream.next_out;
341
 
347
 
342
            if (getLong(s) != s->crc) {
348
            if (getLong(s) != s->crc) {
-
 
349
		warning("invalid or incomplete compressed data");
343
                s->z_err = Z_DATA_ERROR;
350
                s->z_err = Z_DATA_ERROR;
344
            } else {
351
            } else {
345
                (void)getLong(s);
352
                (void)getLong(s);
346
                /* The uncompressed length returned by above getlong() may be
353
                /* The uncompressed length returned by above getlong() may be
347
                 * different from s->out in case of concatenated .gz files.
354
                 * different from s->out in case of concatenated .gz files.
Line 357... Line 364...
357
        if (s->z_err != Z_OK || s->z_eof) break;
364
        if (s->z_err != Z_OK || s->z_eof) break;
358
    }
365
    }
359
    s->crc = crc32(s->crc, start, (uInt) (s->stream.next_out - start));
366
    s->crc = crc32(s->crc, start, (uInt) (s->stream.next_out - start));
360
 
367
 
361
    if (len == s->stream.avail_out &&
368
    if (len == s->stream.avail_out &&
362
        (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO))
369
        (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO)) {
-
 
370
	if(s->z_err == Z_DATA_ERROR)
-
 
371
	    warning("invalid or incomplete compressed data");
-
 
372
	else if(s->z_err == Z_ERRNO)
-
 
373
	    warning("error reading the file");
363
        return -1;
374
	return -1;
-
 
375
    }
364
    return (int)(len - s->stream.avail_out);
376
    return (int)(len - s->stream.avail_out);
365
}
377
}
366
 
378
 
367
/* for devPS.c */
379
/* for devPS.c */
368
char *R_gzgets(gzFile file, char *buf, int len)
380
char *R_gzgets(gzFile file, char *buf, int len)