=========================================================================== * Copy without compression as much as possible from the input stream, return * the current block state. * This function does not insert new strings in the dictionary since * uncompressible data is probably not useful. This function is used * only for the level=0 compression option. * NOTE: this function should be opt
(s, flush)
| 1388 | * window to pending_buf. |
| 1389 | */ |
| 1390 | local block_state deflate_stored(s, flush) |
| 1391 | deflate_state *s; |
| 1392 | int flush; |
| 1393 | { |
| 1394 | /* Stored blocks are limited to 0xffff bytes, pending_buf is limited |
| 1395 | * to pending_buf_size, and each stored block has a 5 byte header: |
| 1396 | */ |
| 1397 | ulg max_block_size = 0xffff; |
| 1398 | ulg max_start; |
| 1399 | |
| 1400 | if (max_block_size > s->pending_buf_size - 5) { |
| 1401 | max_block_size = s->pending_buf_size - 5; |
| 1402 | } |
| 1403 | |
| 1404 | /* Copy as much as possible from input to output: */ |
| 1405 | for (;;) { |
| 1406 | /* Fill the window as much as possible: */ |
| 1407 | if (s->lookahead <= 1) { |
| 1408 | |
| 1409 | Assert(s->strstart < s->w_size+MAX_DIST(s) || |
| 1410 | s->block_start >= (long)s->w_size, "slide too late"); |
| 1411 | |
| 1412 | fill_window(s); |
| 1413 | if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more; |
| 1414 | |
| 1415 | if (s->lookahead == 0) break; /* flush the current block */ |
| 1416 | } |
| 1417 | Assert(s->block_start >= 0L, "block gone"); |
| 1418 | |
| 1419 | s->strstart += s->lookahead; |
| 1420 | s->lookahead = 0; |
| 1421 | |
| 1422 | /* Emit a stored block if pending_buf will be full: */ |
| 1423 | max_start = s->block_start + max_block_size; |
| 1424 | if (s->strstart == 0 || (ulg)s->strstart >= max_start) { |
| 1425 | /* strstart == 0 is possible when wraparound on 16-bit machine */ |
| 1426 | s->lookahead = (uInt)(s->strstart - max_start); |
| 1427 | s->strstart = (uInt)max_start; |
| 1428 | FLUSH_BLOCK(s, 0); |
| 1429 | } |
| 1430 | /* Flush if we may have to slide, otherwise block_start may become |
| 1431 | * negative and the data will be gone: |
| 1432 | */ |
| 1433 | if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) { |
| 1434 | FLUSH_BLOCK(s, 0); |
| 1435 | } |
| 1436 | } |
| 1437 | FLUSH_BLOCK(s, flush == Z_FINISH); |
| 1438 | return flush == Z_FINISH ? finish_done : block_done; |
| 1439 | } |
| 1440 | |
| 1441 | /* =========================================================================== |
| 1442 | * Compress as much as possible from the input stream, return the current |
nothing calls this directly
no test coverage detected