Merge pull request #16 from dgryski/uint32-fix
Fix max block size check
diff --git a/AUTHORS b/AUTHORS
index ca7061c..824bf2e 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -8,6 +8,7 @@
# Please keep the list sorted.
+Damian Gryski <dgryski@gmail.com>
Google Inc.
Jan Mercl <0xjnml@gmail.com>
Sebastien Binet <seb.binet@gmail.com>
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index d3b9430..9f54f21 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -26,6 +26,7 @@
# Please keep the list sorted.
+Damian Gryski <dgryski@gmail.com>
Jan Mercl <0xjnml@gmail.com>
Kai Backman <kaib@golang.org>
Marc-Antoine Ruel <maruel@chromium.org>
diff --git a/decode.go b/decode.go
index f3c9941..e7f1259 100644
--- a/decode.go
+++ b/decode.go
@@ -60,7 +60,7 @@
x := uint(src[s] >> 2)
switch {
case x < 60:
- s += 1
+ s++
case x == 60:
s += 2
if s > len(src) {
@@ -134,7 +134,7 @@
// NewReader returns a new Reader that decompresses from r, using the framing
// format described at
-// https://code.google.com/p/snappy/source/browse/trunk/framing_format.txt
+// https://github.com/google/snappy/blob/master/framing_format.txt
func NewReader(r io.Reader) *Reader {
return &Reader{
r: r,
@@ -204,7 +204,7 @@
}
// The chunk types are specified at
- // https://code.google.com/p/snappy/source/browse/trunk/framing_format.txt
+ // https://github.com/google/snappy/blob/master/framing_format.txt
switch chunkType {
case chunkTypeCompressedData:
// Section 4.2. Compressed data (chunk type 0x00).
@@ -284,13 +284,11 @@
// Section 4.5. Reserved unskippable chunks (chunk types 0x02-0x7f).
r.err = ErrUnsupported
return 0, r.err
-
- } else {
- // Section 4.4 Padding (chunk type 0xfe).
- // Section 4.6. Reserved skippable chunks (chunk types 0x80-0xfd).
- if !r.readFull(r.buf[:chunkLen]) {
- return 0, r.err
- }
+ }
+ // Section 4.4 Padding (chunk type 0xfe).
+ // Section 4.6. Reserved skippable chunks (chunk types 0x80-0xfd).
+ if !r.readFull(r.buf[:chunkLen]) {
+ return 0, r.err
}
}
}
diff --git a/encode.go b/encode.go
index 2116951..f3b5484 100644
--- a/encode.go
+++ b/encode.go
@@ -176,7 +176,7 @@
// NewWriter returns a new Writer that compresses to w, using the framing
// format described at
-// https://code.google.com/p/snappy/source/browse/trunk/framing_format.txt
+// https://github.com/google/snappy/blob/master/framing_format.txt
func NewWriter(w io.Writer) *Writer {
return &Writer{
w: w,
diff --git a/snappy.go b/snappy.go
index b22f457..15af18d 100644
--- a/snappy.go
+++ b/snappy.go
@@ -5,7 +5,7 @@
// Package snappy implements the snappy block-based compression format.
// It aims for very high speeds and reasonable compression.
//
-// The C++ snappy implementation is at http://code.google.com/p/snappy/
+// The C++ snappy implementation is at https://github.com/google/snappy
package snappy // import "github.com/golang/snappy"
import (
@@ -46,7 +46,7 @@
chunkHeaderSize = 4
magicChunk = "\xff\x06\x00\x00" + magicBody
magicBody = "sNaPpY"
- // https://code.google.com/p/snappy/source/browse/trunk/framing_format.txt says
+ // https://github.com/google/snappy/blob/master/framing_format.txt says
// that "the uncompressed data in a chunk must be no longer than 65536 bytes".
maxUncompressedChunkLen = 65536
)
@@ -61,7 +61,7 @@
var crcTable = crc32.MakeTable(crc32.Castagnoli)
// crc implements the checksum specified in section 3 of
-// https://code.google.com/p/snappy/source/browse/trunk/framing_format.txt
+// https://github.com/google/snappy/blob/master/framing_format.txt
func crc(b []byte) uint32 {
c := crc32.Update(0, crcTable, b)
return uint32(c>>15|c<<17) + 0xa282ead8