(strm, dictionary)
| 7904 | * sequence without producing any compressed output. |
| 7905 | */ |
| 7906 | function deflateSetDictionary(strm, dictionary) { |
| 7907 | var dictLength = dictionary.length; |
| 7908 | |
| 7909 | var s; |
| 7910 | var str, n; |
| 7911 | var wrap; |
| 7912 | var avail; |
| 7913 | var next; |
| 7914 | var input; |
| 7915 | var tmpDict; |
| 7916 | |
| 7917 | if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) { |
| 7918 | return Z_STREAM_ERROR; |
| 7919 | } |
| 7920 | |
| 7921 | s = strm.state; |
| 7922 | wrap = s.wrap; |
| 7923 | |
| 7924 | if (wrap === 2 || (wrap === 1 && s.status !== INIT_STATE) || s.lookahead) { |
| 7925 | return Z_STREAM_ERROR; |
| 7926 | } |
| 7927 | |
| 7928 | /* when using zlib wrappers, compute Adler-32 for provided dictionary */ |
| 7929 | if (wrap === 1) { |
| 7930 | /* adler32(strm->adler, dictionary, dictLength); */ |
| 7931 | strm.adler = adler32(strm.adler, dictionary, dictLength, 0); |
| 7932 | } |
| 7933 | |
| 7934 | s.wrap = 0; /* avoid computing Adler-32 in read_buf */ |
| 7935 | |
| 7936 | /* if dictionary would fill window, just replace the history */ |
| 7937 | if (dictLength >= s.w_size) { |
| 7938 | if (wrap === 0) { /* already empty otherwise */ |
| 7939 | /*** CLEAR_HASH(s); ***/ |
| 7940 | zero(s.head); // Fill with NIL (= 0); |
| 7941 | s.strstart = 0; |
| 7942 | s.block_start = 0; |
| 7943 | s.insert = 0; |
| 7944 | } |
| 7945 | /* use the tail */ |
| 7946 | // dictionary = dictionary.slice(dictLength - s.w_size); |
| 7947 | tmpDict = new utils.Buf8(s.w_size); |
| 7948 | utils.arraySet(tmpDict, dictionary, dictLength - s.w_size, s.w_size, 0); |
| 7949 | dictionary = tmpDict; |
| 7950 | dictLength = s.w_size; |
| 7951 | } |
| 7952 | /* insert dictionary into window and hash */ |
| 7953 | avail = strm.avail_in; |
| 7954 | next = strm.next_in; |
| 7955 | input = strm.input; |
| 7956 | strm.avail_in = dictLength; |
| 7957 | strm.next_in = 0; |
| 7958 | strm.input = dictionary; |
| 7959 | fill_window(s); |
| 7960 | while (s.lookahead >= MIN_MATCH) { |
| 7961 | str = s.strstart; |
| 7962 | n = s.lookahead - (MIN_MATCH - 1); |
| 7963 | do { |
nothing calls this directly
no test coverage detected