commit 38801a4bfd04d88424c4f6e517626df055aeb55f
parent 6c48e7f91f57a70b1b4ff6ee6c6aeb4f71bcfd14
Author: nsz@tpx <unknown>
Date: Thu, 6 Aug 2009 09:56:38 +0200
deflate cleaning
Diffstat:
deflate.c | | | 36 | +++++++++++++++--------------------- |
1 file changed, 15 insertions(+), 21 deletions(-)
diff --git a/deflate.c b/deflate.c
@@ -586,14 +586,6 @@ static int deflate_state(State *s) {
int head;
switch (s->state) {
- case FlateHasOutput:
- if (s->lastblock && s->dstbegin == s->dst) /* todo.. */
- return FlateOk;
- else
- goto block;
- case FlateNeedInput:
- goto filled;
- }
do {
/* messy.. */
if (s->avail < MaxMatch || s->rend - s->rbuf >= RbufSize - 2) {
@@ -605,31 +597,32 @@ static int deflate_state(State *s) {
prevm.len = 0;
}
fprintf(stderr, "avail %d pos %d lastpos %d srcavail %d\n", s->avail, pos, s->pos, s->srcend - s->src);
+ deflate_block(s, pos - s->blockstart);
s->pos = pos;
s->prevm = prevm;
s->state = FlateHasOutput;
- deflate_block(s, pos - s->blockstart);
return FlateHasOutput;
-block:
+ case FlateHasOutput:
if (s->dstbegin < s->dst)
return FlateHasOutput;
+ if (s->lastblock)
+ return FlateOk;
newblock(s);
- pos = s->pos;
+ s->blockstart = pos = s->pos;
prevm = s->prevm;
- s->blockstart = pos;
}
s->pos = pos;
- s->prevm = prevm;
- s->state = FlateNeedInput;
- if (fillwin(s))
+ if (fillwin(s)) {
+ s->prevm = prevm;
+ s->state = FlateNeedInput;
return FlateNeedInput;
-/* TODO: .. */
-filled:
- if (fillwin(s))
- /* tralala */;
-fprintf(stderr, "avail %d pos %d srcavail %d\n", s->avail, s->pos, s->srcend - s->src);
+ case FlateNeedInput:
+ if (fillwin(s))
+ /* tralala */;
+ prevm = s->prevm;
+ }
pos = s->pos;
- prevm = s->prevm;
+fprintf(stderr, "avail %d pos %d srcavail %d\n", s->avail, s->pos, s->srcend - s->src);
}
head = addtochain(s, pos);
if (head >= pos || pos - head >= MaxDist)
@@ -653,6 +646,7 @@ fprintf(stderr, "avail %d pos %d srcavail %d\n", s->avail, s->pos, s->srcend - s
pos++;
s->avail--;
} while (s->avail);
+ }
flushlit(s);
s->lastblock = 1;
s->state = FlateHasOutput;