diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2011-09-09 23:26:29 -0700 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2011-09-09 23:26:29 -0700 |
commit | 639be997883d9016baaf46017a2802b2ce1698bd (patch) | |
tree | db90fc577d10564b335980824111e8d11c5527e2 /infback.c | |
parent | d6231142d2b883a8c3b253fa34992b5cdb4ac2fe (diff) | |
download | zlib-639be997883d9016baaf46017a2802b2ce1698bd.tar.gz zlib-639be997883d9016baaf46017a2802b2ce1698bd.tar.bz2 zlib-639be997883d9016baaf46017a2802b2ce1698bd.zip |
zlib 1.2.3.3v1.2.3.3
Diffstat (limited to 'infback.c')
-rw-r--r-- | infback.c | 80 |
1 files changed, 40 insertions, 40 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* infback.c -- inflate using a call-back interface | 1 | /* infback.c -- inflate using a call-back interface |
2 | * Copyright (C) 1995-2005 Mark Adler | 2 | * Copyright (C) 1995-2006 Mark Adler |
3 | * For conditions of distribution and use, see copyright notice in zlib.h | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
4 | */ | 4 | */ |
5 | 5 | ||
@@ -253,7 +253,7 @@ void FAR *out_desc; | |||
253 | unsigned bits; /* bits in bit buffer */ | 253 | unsigned bits; /* bits in bit buffer */ |
254 | unsigned copy; /* number of stored or match bytes to copy */ | 254 | unsigned copy; /* number of stored or match bytes to copy */ |
255 | unsigned char FAR *from; /* where to copy match bytes from */ | 255 | unsigned char FAR *from; /* where to copy match bytes from */ |
256 | code this; /* current decoding table entry */ | 256 | code here; /* current decoding table entry */ |
257 | code last; /* parent table entry */ | 257 | code last; /* parent table entry */ |
258 | unsigned len; /* length to copy for repeats, bits to drop */ | 258 | unsigned len; /* length to copy for repeats, bits to drop */ |
259 | int ret; /* return code */ | 259 | int ret; /* return code */ |
@@ -389,19 +389,19 @@ void FAR *out_desc; | |||
389 | state->have = 0; | 389 | state->have = 0; |
390 | while (state->have < state->nlen + state->ndist) { | 390 | while (state->have < state->nlen + state->ndist) { |
391 | for (;;) { | 391 | for (;;) { |
392 | this = state->lencode[BITS(state->lenbits)]; | 392 | here = state->lencode[BITS(state->lenbits)]; |
393 | if ((unsigned)(this.bits) <= bits) break; | 393 | if ((unsigned)(here.bits) <= bits) break; |
394 | PULLBYTE(); | 394 | PULLBYTE(); |
395 | } | 395 | } |
396 | if (this.val < 16) { | 396 | if (here.val < 16) { |
397 | NEEDBITS(this.bits); | 397 | NEEDBITS(here.bits); |
398 | DROPBITS(this.bits); | 398 | DROPBITS(here.bits); |
399 | state->lens[state->have++] = this.val; | 399 | state->lens[state->have++] = here.val; |
400 | } | 400 | } |
401 | else { | 401 | else { |
402 | if (this.val == 16) { | 402 | if (here.val == 16) { |
403 | NEEDBITS(this.bits + 2); | 403 | NEEDBITS(here.bits + 2); |
404 | DROPBITS(this.bits); | 404 | DROPBITS(here.bits); |
405 | if (state->have == 0) { | 405 | if (state->have == 0) { |
406 | strm->msg = (char *)"invalid bit length repeat"; | 406 | strm->msg = (char *)"invalid bit length repeat"; |
407 | state->mode = BAD; | 407 | state->mode = BAD; |
@@ -411,16 +411,16 @@ void FAR *out_desc; | |||
411 | copy = 3 + BITS(2); | 411 | copy = 3 + BITS(2); |
412 | DROPBITS(2); | 412 | DROPBITS(2); |
413 | } | 413 | } |
414 | else if (this.val == 17) { | 414 | else if (here.val == 17) { |
415 | NEEDBITS(this.bits + 3); | 415 | NEEDBITS(here.bits + 3); |
416 | DROPBITS(this.bits); | 416 | DROPBITS(here.bits); |
417 | len = 0; | 417 | len = 0; |
418 | copy = 3 + BITS(3); | 418 | copy = 3 + BITS(3); |
419 | DROPBITS(3); | 419 | DROPBITS(3); |
420 | } | 420 | } |
421 | else { | 421 | else { |
422 | NEEDBITS(this.bits + 7); | 422 | NEEDBITS(here.bits + 7); |
423 | DROPBITS(this.bits); | 423 | DROPBITS(here.bits); |
424 | len = 0; | 424 | len = 0; |
425 | copy = 11 + BITS(7); | 425 | copy = 11 + BITS(7); |
426 | DROPBITS(7); | 426 | DROPBITS(7); |
@@ -474,28 +474,28 @@ void FAR *out_desc; | |||
474 | 474 | ||
475 | /* get a literal, length, or end-of-block code */ | 475 | /* get a literal, length, or end-of-block code */ |
476 | for (;;) { | 476 | for (;;) { |
477 | this = state->lencode[BITS(state->lenbits)]; | 477 | here = state->lencode[BITS(state->lenbits)]; |
478 | if ((unsigned)(this.bits) <= bits) break; | 478 | if ((unsigned)(here.bits) <= bits) break; |
479 | PULLBYTE(); | 479 | PULLBYTE(); |
480 | } | 480 | } |
481 | if (this.op && (this.op & 0xf0) == 0) { | 481 | if (here.op && (here.op & 0xf0) == 0) { |
482 | last = this; | 482 | last = here; |
483 | for (;;) { | 483 | for (;;) { |
484 | this = state->lencode[last.val + | 484 | here = state->lencode[last.val + |
485 | (BITS(last.bits + last.op) >> last.bits)]; | 485 | (BITS(last.bits + last.op) >> last.bits)]; |
486 | if ((unsigned)(last.bits + this.bits) <= bits) break; | 486 | if ((unsigned)(last.bits + here.bits) <= bits) break; |
487 | PULLBYTE(); | 487 | PULLBYTE(); |
488 | } | 488 | } |
489 | DROPBITS(last.bits); | 489 | DROPBITS(last.bits); |
490 | } | 490 | } |
491 | DROPBITS(this.bits); | 491 | DROPBITS(here.bits); |
492 | state->length = (unsigned)this.val; | 492 | state->length = (unsigned)here.val; |
493 | 493 | ||
494 | /* process literal */ | 494 | /* process literal */ |
495 | if (this.op == 0) { | 495 | if (here.op == 0) { |
496 | Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ? | 496 | Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? |
497 | "inflate: literal '%c'\n" : | 497 | "inflate: literal '%c'\n" : |
498 | "inflate: literal 0x%02x\n", this.val)); | 498 | "inflate: literal 0x%02x\n", here.val)); |
499 | ROOM(); | 499 | ROOM(); |
500 | *put++ = (unsigned char)(state->length); | 500 | *put++ = (unsigned char)(state->length); |
501 | left--; | 501 | left--; |
@@ -504,21 +504,21 @@ void FAR *out_desc; | |||
504 | } | 504 | } |
505 | 505 | ||
506 | /* process end of block */ | 506 | /* process end of block */ |
507 | if (this.op & 32) { | 507 | if (here.op & 32) { |
508 | Tracevv((stderr, "inflate: end of block\n")); | 508 | Tracevv((stderr, "inflate: end of block\n")); |
509 | state->mode = TYPE; | 509 | state->mode = TYPE; |
510 | break; | 510 | break; |
511 | } | 511 | } |
512 | 512 | ||
513 | /* invalid code */ | 513 | /* invalid code */ |
514 | if (this.op & 64) { | 514 | if (here.op & 64) { |
515 | strm->msg = (char *)"invalid literal/length code"; | 515 | strm->msg = (char *)"invalid literal/length code"; |
516 | state->mode = BAD; | 516 | state->mode = BAD; |
517 | break; | 517 | break; |
518 | } | 518 | } |
519 | 519 | ||
520 | /* length code -- get extra bits, if any */ | 520 | /* length code -- get extra bits, if any */ |
521 | state->extra = (unsigned)(this.op) & 15; | 521 | state->extra = (unsigned)(here.op) & 15; |
522 | if (state->extra != 0) { | 522 | if (state->extra != 0) { |
523 | NEEDBITS(state->extra); | 523 | NEEDBITS(state->extra); |
524 | state->length += BITS(state->extra); | 524 | state->length += BITS(state->extra); |
@@ -528,30 +528,30 @@ void FAR *out_desc; | |||
528 | 528 | ||
529 | /* get distance code */ | 529 | /* get distance code */ |
530 | for (;;) { | 530 | for (;;) { |
531 | this = state->distcode[BITS(state->distbits)]; | 531 | here = state->distcode[BITS(state->distbits)]; |
532 | if ((unsigned)(this.bits) <= bits) break; | 532 | if ((unsigned)(here.bits) <= bits) break; |
533 | PULLBYTE(); | 533 | PULLBYTE(); |
534 | } | 534 | } |
535 | if ((this.op & 0xf0) == 0) { | 535 | if ((here.op & 0xf0) == 0) { |
536 | last = this; | 536 | last = here; |
537 | for (;;) { | 537 | for (;;) { |
538 | this = state->distcode[last.val + | 538 | here = state->distcode[last.val + |
539 | (BITS(last.bits + last.op) >> last.bits)]; | 539 | (BITS(last.bits + last.op) >> last.bits)]; |
540 | if ((unsigned)(last.bits + this.bits) <= bits) break; | 540 | if ((unsigned)(last.bits + here.bits) <= bits) break; |
541 | PULLBYTE(); | 541 | PULLBYTE(); |
542 | } | 542 | } |
543 | DROPBITS(last.bits); | 543 | DROPBITS(last.bits); |
544 | } | 544 | } |
545 | DROPBITS(this.bits); | 545 | DROPBITS(here.bits); |
546 | if (this.op & 64) { | 546 | if (here.op & 64) { |
547 | strm->msg = (char *)"invalid distance code"; | 547 | strm->msg = (char *)"invalid distance code"; |
548 | state->mode = BAD; | 548 | state->mode = BAD; |
549 | break; | 549 | break; |
550 | } | 550 | } |
551 | state->offset = (unsigned)this.val; | 551 | state->offset = (unsigned)here.val; |
552 | 552 | ||
553 | /* get distance extra bits, if any */ | 553 | /* get distance extra bits, if any */ |
554 | state->extra = (unsigned)(this.op) & 15; | 554 | state->extra = (unsigned)(here.op) & 15; |
555 | if (state->extra != 0) { | 555 | if (state->extra != 0) { |
556 | NEEDBITS(state->extra); | 556 | NEEDBITS(state->extra); |
557 | state->offset += BITS(state->extra); | 557 | state->offset += BITS(state->extra); |