gecko-dev/modules/brotli
Nicholas Nethercote 5b34a25af2 Bug 1216020 - Comment all ALLOW_COMPILER_WARNINGS lines. r=glandium.
DONTBUILD because it only changes comments.

This will hopefully prevent confusion like that in bug 1215903.

--HG--
extra : rebase_source : f0a601d77b5f42b4fbe090693234f934e3becc42
2015-10-19 18:05:20 -07:00
..
dec Bug 1213136 - Declare BrotliPullByte before it is used. r=mcmanus 2015-10-11 18:13:10 +02:00
moz.build Bug 1216020 - Comment all ALLOW_COMPILER_WARNINGS lines. r=glandium. 2015-10-19 18:05:20 -07:00
README.mozilla Bug 1213136 - Declare BrotliPullByte before it is used. r=mcmanus 2015-10-11 18:13:10 +02:00
update.sh Bug 1142953 - Update Brotli decompressor to latest upstream revision from GitHub; now at ca29aa22c295daac15baf5d85427ecc7808b515c. r=jdaggett 2015-03-19 11:11:28 +00:00

This is the Brotli data compression library from
https://github.com/google/brotli.

Currently, we import only the Brotli decoder (the /dec/ subdirectory), not the
encoder (/enc/ subdirectory).

Upstream code can be viewed at
  https://github.com/google/brotli/tree/master/dec

and cloned by
  git clone https://github.com/google/brotli

The in-tree copy is updated by running
  sh update.sh
from within the modules/brotli directory.

Current version: [commit 933bb9bd800c8f5f7f6a02382d33c902a98ef73a].

this trivial patch is added to preserve no-warnings behavior in code
that includes the brotli interface. future imports are expected to
have an equivalent change made upstream already.

diff --git a/modules/brotli/dec/bit_reader.h b/modules/brotli/dec/bit_reader.h
--- a/modules/brotli/dec/bit_reader.h
+++ b/modules/brotli/dec/bit_reader.h
@@ -284,17 +284,17 @@ static BROTLI_INLINE int BrotliPeekByte(
   int bytes_left = (int)(sizeof(br->val_) - (br->bit_pos_ >> 3));
   if (br->bit_pos_ & 7) {
     return -1;
   }
   if (offset < bytes_left) {
     return (br->val_ >> (br->bit_pos_ + (unsigned)(offset << 3))) & 0xFF;
   }
   offset -= bytes_left;
-  if (offset < br->avail_in) {
+  if (offset < (long)br->avail_in) {
     return br->next_in[offset];
   }
   return -1;
 }
 
 /* Copies remaining input bytes stored in the bit reader to the output. Value
    num may not be larger than BrotliGetRemainingBytes. The bit reader must be
    warmed up again after this. */


This patch fixes a use-before declare error on big endian platforms
in bit_reader.h.  Upstream has already fixed this error by re-arranging 
some functions in the file.

diff --git a/modules/brotli/dec/bit_reader.h b/modules/brotli/dec/bit_reader.h
--- a/modules/brotli/dec/bit_reader.h
+++ b/modules/brotli/dec/bit_reader.h
@@ -58,17 +58,17 @@ typedef struct {
 /* Initializes the bitreader fields. */
 void BrotliInitBitReader(BrotliBitReader* const br, BrotliInput input);
 
 /* Ensures that accumulator is not empty. May consume one byte of input.
    Returns 0 if data is required but there is no input available.
    For BROTLI_BUILD_PORTABLE this function also prepares bit reader for aligned
    reading. */
 int BrotliWarmupBitReader(BrotliBitReader* const br);
-
+static BROTLI_INLINE void BrotliPullByte(BrotliBitReader* const br);
 /* Pulls data from the input to the the read buffer.
 
    Returns 0 if one of:
     - the input callback returned an error, or
     - there is no more input and the position is past the end of the stream.
     - finish is false and less than BROTLI_READ_SIZE are available - a next call
       when more data is available makes it continue including the partially read
       data