diff options
author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-03-11 22:11:18 +0000 |
---|---|---|
committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-03-11 22:11:18 +0000 |
commit | 8c16c8c7be08247db45d9fdc459058f148d1dcb9 (patch) | |
tree | f1412386f2b8672f1b5cfdf967e1abcd29d60ca9 /zlib/inffast.c | |
parent | 1fcf59fa4632a4b13bfb40efe6291df786d98926 (diff) | |
download | gcc-8c16c8c7be08247db45d9fdc459058f148d1dcb9.tar.gz |
* ChangeLog.gcj: Imported 1.1.4, while preserving local changes.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@50612 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'zlib/inffast.c')
-rw-r--r-- | zlib/inffast.c | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/zlib/inffast.c b/zlib/inffast.c index 61a78ee933f..aa7f1d4d2ad 100644 --- a/zlib/inffast.c +++ b/zlib/inffast.c @@ -1,5 +1,5 @@ /* inffast.c -- process literals and length/distance pairs fast - * Copyright (C) 1995-1998 Mark Adler + * Copyright (C) 1995-2002 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -93,28 +93,41 @@ z_streamp z; /* do the copy */ m -= c; - if ((uInt)(q - s->window) >= d) /* offset before dest */ - { /* just copy */ - r = q - d; - *q++ = *r++; c--; /* minimum count is three, */ - *q++ = *r++; c--; /* so unroll loop a little */ - } - else /* else offset after destination */ + r = q - d; + if (r < s->window) /* wrap if needed */ { - e = d - (uInt)(q - s->window); /* bytes from offset to end */ - r = s->end - e; /* pointer to offset */ - if (c > e) /* if source crosses, */ + do { + r += s->end - s->window; /* force pointer in window */ + } while (r < s->window); /* covers invalid distances */ + e = s->end - r; + if (c > e) { - c -= e; /* copy to end of window */ + c -= e; /* wrapped copy */ do { - *q++ = *r++; + *q++ = *r++; } while (--e); - r = s->window; /* copy rest from start of window */ + r = s->window; + do { + *q++ = *r++; + } while (--c); } + else /* normal copy */ + { + *q++ = *r++; c--; + *q++ = *r++; c--; + do { + *q++ = *r++; + } while (--c); + } + } + else /* normal copy */ + { + *q++ = *r++; c--; + *q++ = *r++; c--; + do { + *q++ = *r++; + } while (--c); } - do { /* copy all or what's left */ - *q++ = *r++; - } while (--c); break; } else if ((e & 64) == 0) |