(strm, dictionary)
| 19994 | * sequence without producing any compressed output. |
| 19995 | */ |
| 19996 | function deflateSetDictionary(strm, dictionary) { |
| 19997 | var dictLength = dictionary.length; |
| 19998 | |
| 19999 | var s; |
| 20000 | var str, n; |
| 20001 | var wrap; |
| 20002 | var avail; |
| 20003 | var next; |
| 20004 | var input; |
| 20005 | var tmpDict; |
| 20006 | |
| 20007 | if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) { |
| 20008 | return Z_STREAM_ERROR; |
| 20009 | } |
| 20010 | |
| 20011 | s = strm.state; |
| 20012 | wrap = s.wrap; |
| 20013 | |
| 20014 | if (wrap === 2 || (wrap === 1 && s.status !== INIT_STATE) || s.lookahead) { |
| 20015 | return Z_STREAM_ERROR; |
| 20016 | } |
| 20017 | |
| 20018 | /* when using zlib wrappers, compute Adler-32 for provided dictionary */ |
| 20019 | if (wrap === 1) { |
| 20020 | /* adler32(strm->adler, dictionary, dictLength); */ |
| 20021 | strm.adler = adler32(strm.adler, dictionary, dictLength, 0); |
| 20022 | } |
| 20023 | |
| 20024 | s.wrap = 0; /* avoid computing Adler-32 in read_buf */ |
| 20025 | |
| 20026 | /* if dictionary would fill window, just replace the history */ |
| 20027 | if (dictLength >= s.w_size) { |
| 20028 | if (wrap === 0) { /* already empty otherwise */ |
| 20029 | /*** CLEAR_HASH(s); ***/ |
| 20030 | zero(s.head); // Fill with NIL (= 0); |
| 20031 | s.strstart = 0; |
| 20032 | s.block_start = 0; |
| 20033 | s.insert = 0; |
| 20034 | } |
| 20035 | /* use the tail */ |
| 20036 | // dictionary = dictionary.slice(dictLength - s.w_size); |
| 20037 | tmpDict = new utils.Buf8(s.w_size); |
| 20038 | utils.arraySet(tmpDict, dictionary, dictLength - s.w_size, s.w_size, 0); |
| 20039 | dictionary = tmpDict; |
| 20040 | dictLength = s.w_size; |
| 20041 | } |
| 20042 | /* insert dictionary into window and hash */ |
| 20043 | avail = strm.avail_in; |
| 20044 | next = strm.next_in; |
| 20045 | input = strm.input; |
| 20046 | strm.avail_in = dictLength; |
| 20047 | strm.next_in = 0; |
| 20048 | strm.input = dictionary; |
| 20049 | fill_window(s); |
| 20050 | while (s.lookahead >= MIN_MATCH) { |
| 20051 | str = s.strstart; |
| 20052 | n = s.lookahead - (MIN_MATCH - 1); |
| 20053 | do { |
nothing calls this directly
no test coverage detected