mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	[Vendor] Update Batch 2020-11 (#13746)
* github.com/alecthomas/chroma v0.8.1 -> v0.8.2 Changelog: https://github.com/alecthomas/chroma/releases/tag/v0.8.2 * github.com/blevesearch/bleve v1.0.12 -> v1.0.13 Changelog: https://github.com/blevesearch/bleve/releases/tag/v1.0.13 * github.com/editorconfig/editorconfig-core-go v2.3.8 -> v2.3.9 Changelog: https://github.com/editorconfig/editorconfig-core-go/releases/tag/v2.3.9 * github.com/klauspost/compress v1.11.2 -> v1.11.3 Changelog: https://github.com/klauspost/compress/releases/tag/v1.11.3 * github.com/minio/minio-go v7.0.5 -> v7.0.6 Changelog: https://github.com/minio/minio-go/releases/tag/v7.0.6 Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
		
							
								
								
									
										496
									
								
								vendor/github.com/klauspost/compress/flate/inflate_gen.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										496
									
								
								vendor/github.com/klauspost/compress/flate/inflate_gen.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -20,16 +20,6 @@ func (f *decompressor) huffmanBytesBuffer() { | ||||
| 		stateDict | ||||
| 	) | ||||
| 	fr := f.r.(*bytes.Buffer) | ||||
| 	moreBits := func() error { | ||||
| 		c, err := fr.ReadByte() | ||||
| 		if err != nil { | ||||
| 			return noEOF(err) | ||||
| 		} | ||||
| 		f.roffset++ | ||||
| 		f.b |= uint32(c) << f.nb | ||||
| 		f.nb += 8 | ||||
| 		return nil | ||||
| 	} | ||||
|  | ||||
| 	switch f.stepState { | ||||
| 	case stateInit: | ||||
| @@ -90,9 +80,7 @@ readLiteral: | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		var n uint // number of bits extra | ||||
| 		var length int | ||||
| 		var err error | ||||
| 		switch { | ||||
| 		case v < 256: | ||||
| 			f.dict.writeByte(byte(v)) | ||||
| @@ -109,25 +97,26 @@ readLiteral: | ||||
| 		// otherwise, reference to older data | ||||
| 		case v < 265: | ||||
| 			length = v - (257 - 3) | ||||
| 			n = 0 | ||||
| 		case v < 269: | ||||
| 			length = v*2 - (265*2 - 11) | ||||
| 			n = 1 | ||||
| 		case v < 273: | ||||
| 			length = v*4 - (269*4 - 19) | ||||
| 			n = 2 | ||||
| 		case v < 277: | ||||
| 			length = v*8 - (273*8 - 35) | ||||
| 			n = 3 | ||||
| 		case v < 281: | ||||
| 			length = v*16 - (277*16 - 67) | ||||
| 			n = 4 | ||||
| 		case v < 285: | ||||
| 			length = v*32 - (281*32 - 131) | ||||
| 			n = 5 | ||||
| 		case v < maxNumLit: | ||||
| 			length = 258 | ||||
| 			n = 0 | ||||
| 			val := decCodeToLen[(v - 257)] | ||||
| 			length = int(val.length) + 3 | ||||
| 			n := uint(val.extra) | ||||
| 			for f.nb < n { | ||||
| 				c, err := fr.ReadByte() | ||||
| 				if err != nil { | ||||
| 					if debugDecode { | ||||
| 						fmt.Println("morebits n>0:", err) | ||||
| 					} | ||||
| 					f.err = err | ||||
| 					return | ||||
| 				} | ||||
| 				f.roffset++ | ||||
| 				f.b |= uint32(c) << f.nb | ||||
| 				f.nb += 8 | ||||
| 			} | ||||
| 			length += int(f.b & uint32(1<<(n®SizeMaskUint32)-1)) | ||||
| 			f.b >>= n & regSizeMaskUint32 | ||||
| 			f.nb -= n | ||||
| 		default: | ||||
| 			if debugDecode { | ||||
| 				fmt.Println(v, ">= maxNumLit") | ||||
| @@ -135,45 +124,70 @@ readLiteral: | ||||
| 			f.err = CorruptInputError(f.roffset) | ||||
| 			return | ||||
| 		} | ||||
| 		if n > 0 { | ||||
| 			for f.nb < n { | ||||
| 				if err = moreBits(); err != nil { | ||||
| 					if debugDecode { | ||||
| 						fmt.Println("morebits n>0:", err) | ||||
| 					} | ||||
| 					f.err = err | ||||
| 					return | ||||
| 				} | ||||
| 			} | ||||
| 			length += int(f.b & uint32(1<<(n®SizeMaskUint32)-1)) | ||||
| 			f.b >>= n & regSizeMaskUint32 | ||||
| 			f.nb -= n | ||||
| 		} | ||||
|  | ||||
| 		var dist uint32 | ||||
| 		if f.hd == nil { | ||||
| 			for f.nb < 5 { | ||||
| 				if err = f.moreBits(); err != nil { | ||||
| 				c, err := fr.ReadByte() | ||||
| 				if err != nil { | ||||
| 					if debugDecode { | ||||
| 						fmt.Println("morebits f.nb<5:", err) | ||||
| 					} | ||||
| 					f.err = err | ||||
| 					return | ||||
| 				} | ||||
| 				f.roffset++ | ||||
| 				f.b |= uint32(c) << f.nb | ||||
| 				f.nb += 8 | ||||
| 			} | ||||
| 			dist = uint32(bits.Reverse8(uint8(f.b & 0x1F << 3))) | ||||
| 			f.b >>= 5 | ||||
| 			f.nb -= 5 | ||||
| 		} else { | ||||
| 			sym, err := f.huffSym(f.hd) | ||||
| 			if err != nil { | ||||
| 				if debugDecode { | ||||
| 					fmt.Println("huffsym:", err) | ||||
| 			// Since a huffmanDecoder can be empty or be composed of a degenerate tree | ||||
| 			// with single element, huffSym must error on these two edge cases. In both | ||||
| 			// cases, the chunks slice will be 0 for the invalid sequence, leading it | ||||
| 			// satisfy the n == 0 check below. | ||||
| 			n := uint(f.hd.maxRead) | ||||
| 			// Optimization. Compiler isn't smart enough to keep f.b,f.nb in registers, | ||||
| 			// but is smart enough to keep local variables in registers, so use nb and b, | ||||
| 			// inline call to moreBits and reassign b,nb back to f on return. | ||||
| 			nb, b := f.nb, f.b | ||||
| 			for { | ||||
| 				for nb < n { | ||||
| 					c, err := fr.ReadByte() | ||||
| 					if err != nil { | ||||
| 						f.b = b | ||||
| 						f.nb = nb | ||||
| 						f.err = noEOF(err) | ||||
| 						return | ||||
| 					} | ||||
| 					f.roffset++ | ||||
| 					b |= uint32(c) << (nb & regSizeMaskUint32) | ||||
| 					nb += 8 | ||||
| 				} | ||||
| 				chunk := f.hd.chunks[b&(huffmanNumChunks-1)] | ||||
| 				n = uint(chunk & huffmanCountMask) | ||||
| 				if n > huffmanChunkBits { | ||||
| 					chunk = f.hd.links[chunk>>huffmanValueShift][(b>>huffmanChunkBits)&f.hd.linkMask] | ||||
| 					n = uint(chunk & huffmanCountMask) | ||||
| 				} | ||||
| 				if n <= nb { | ||||
| 					if n == 0 { | ||||
| 						f.b = b | ||||
| 						f.nb = nb | ||||
| 						if debugDecode { | ||||
| 							fmt.Println("huffsym: n==0") | ||||
| 						} | ||||
| 						f.err = CorruptInputError(f.roffset) | ||||
| 						return | ||||
| 					} | ||||
| 					f.b = b >> (n & regSizeMaskUint32) | ||||
| 					f.nb = nb - n | ||||
| 					dist = uint32(chunk >> huffmanValueShift) | ||||
| 					break | ||||
| 				} | ||||
| 				f.err = err | ||||
| 				return | ||||
| 			} | ||||
| 			dist = uint32(sym) | ||||
| 		} | ||||
|  | ||||
| 		switch { | ||||
| @@ -184,13 +198,17 @@ readLiteral: | ||||
| 			// have 1 bit in bottom of dist, need nb more. | ||||
| 			extra := (dist & 1) << (nb & regSizeMaskUint32) | ||||
| 			for f.nb < nb { | ||||
| 				if err = f.moreBits(); err != nil { | ||||
| 				c, err := fr.ReadByte() | ||||
| 				if err != nil { | ||||
| 					if debugDecode { | ||||
| 						fmt.Println("morebits f.nb<nb:", err) | ||||
| 					} | ||||
| 					f.err = err | ||||
| 					return | ||||
| 				} | ||||
| 				f.roffset++ | ||||
| 				f.b |= uint32(c) << f.nb | ||||
| 				f.nb += 8 | ||||
| 			} | ||||
| 			extra |= f.b & uint32(1<<(nb®SizeMaskUint32)-1) | ||||
| 			f.b >>= nb & regSizeMaskUint32 | ||||
| @@ -246,16 +264,6 @@ func (f *decompressor) huffmanBytesReader() { | ||||
| 		stateDict | ||||
| 	) | ||||
| 	fr := f.r.(*bytes.Reader) | ||||
| 	moreBits := func() error { | ||||
| 		c, err := fr.ReadByte() | ||||
| 		if err != nil { | ||||
| 			return noEOF(err) | ||||
| 		} | ||||
| 		f.roffset++ | ||||
| 		f.b |= uint32(c) << f.nb | ||||
| 		f.nb += 8 | ||||
| 		return nil | ||||
| 	} | ||||
|  | ||||
| 	switch f.stepState { | ||||
| 	case stateInit: | ||||
| @@ -316,9 +324,7 @@ readLiteral: | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		var n uint // number of bits extra | ||||
| 		var length int | ||||
| 		var err error | ||||
| 		switch { | ||||
| 		case v < 256: | ||||
| 			f.dict.writeByte(byte(v)) | ||||
| @@ -335,25 +341,26 @@ readLiteral: | ||||
| 		// otherwise, reference to older data | ||||
| 		case v < 265: | ||||
| 			length = v - (257 - 3) | ||||
| 			n = 0 | ||||
| 		case v < 269: | ||||
| 			length = v*2 - (265*2 - 11) | ||||
| 			n = 1 | ||||
| 		case v < 273: | ||||
| 			length = v*4 - (269*4 - 19) | ||||
| 			n = 2 | ||||
| 		case v < 277: | ||||
| 			length = v*8 - (273*8 - 35) | ||||
| 			n = 3 | ||||
| 		case v < 281: | ||||
| 			length = v*16 - (277*16 - 67) | ||||
| 			n = 4 | ||||
| 		case v < 285: | ||||
| 			length = v*32 - (281*32 - 131) | ||||
| 			n = 5 | ||||
| 		case v < maxNumLit: | ||||
| 			length = 258 | ||||
| 			n = 0 | ||||
| 			val := decCodeToLen[(v - 257)] | ||||
| 			length = int(val.length) + 3 | ||||
| 			n := uint(val.extra) | ||||
| 			for f.nb < n { | ||||
| 				c, err := fr.ReadByte() | ||||
| 				if err != nil { | ||||
| 					if debugDecode { | ||||
| 						fmt.Println("morebits n>0:", err) | ||||
| 					} | ||||
| 					f.err = err | ||||
| 					return | ||||
| 				} | ||||
| 				f.roffset++ | ||||
| 				f.b |= uint32(c) << f.nb | ||||
| 				f.nb += 8 | ||||
| 			} | ||||
| 			length += int(f.b & uint32(1<<(n®SizeMaskUint32)-1)) | ||||
| 			f.b >>= n & regSizeMaskUint32 | ||||
| 			f.nb -= n | ||||
| 		default: | ||||
| 			if debugDecode { | ||||
| 				fmt.Println(v, ">= maxNumLit") | ||||
| @@ -361,45 +368,70 @@ readLiteral: | ||||
| 			f.err = CorruptInputError(f.roffset) | ||||
| 			return | ||||
| 		} | ||||
| 		if n > 0 { | ||||
| 			for f.nb < n { | ||||
| 				if err = moreBits(); err != nil { | ||||
| 					if debugDecode { | ||||
| 						fmt.Println("morebits n>0:", err) | ||||
| 					} | ||||
| 					f.err = err | ||||
| 					return | ||||
| 				} | ||||
| 			} | ||||
| 			length += int(f.b & uint32(1<<(n®SizeMaskUint32)-1)) | ||||
| 			f.b >>= n & regSizeMaskUint32 | ||||
| 			f.nb -= n | ||||
| 		} | ||||
|  | ||||
| 		var dist uint32 | ||||
| 		if f.hd == nil { | ||||
| 			for f.nb < 5 { | ||||
| 				if err = f.moreBits(); err != nil { | ||||
| 				c, err := fr.ReadByte() | ||||
| 				if err != nil { | ||||
| 					if debugDecode { | ||||
| 						fmt.Println("morebits f.nb<5:", err) | ||||
| 					} | ||||
| 					f.err = err | ||||
| 					return | ||||
| 				} | ||||
| 				f.roffset++ | ||||
| 				f.b |= uint32(c) << f.nb | ||||
| 				f.nb += 8 | ||||
| 			} | ||||
| 			dist = uint32(bits.Reverse8(uint8(f.b & 0x1F << 3))) | ||||
| 			f.b >>= 5 | ||||
| 			f.nb -= 5 | ||||
| 		} else { | ||||
| 			sym, err := f.huffSym(f.hd) | ||||
| 			if err != nil { | ||||
| 				if debugDecode { | ||||
| 					fmt.Println("huffsym:", err) | ||||
| 			// Since a huffmanDecoder can be empty or be composed of a degenerate tree | ||||
| 			// with single element, huffSym must error on these two edge cases. In both | ||||
| 			// cases, the chunks slice will be 0 for the invalid sequence, leading it | ||||
| 			// satisfy the n == 0 check below. | ||||
| 			n := uint(f.hd.maxRead) | ||||
| 			// Optimization. Compiler isn't smart enough to keep f.b,f.nb in registers, | ||||
| 			// but is smart enough to keep local variables in registers, so use nb and b, | ||||
| 			// inline call to moreBits and reassign b,nb back to f on return. | ||||
| 			nb, b := f.nb, f.b | ||||
| 			for { | ||||
| 				for nb < n { | ||||
| 					c, err := fr.ReadByte() | ||||
| 					if err != nil { | ||||
| 						f.b = b | ||||
| 						f.nb = nb | ||||
| 						f.err = noEOF(err) | ||||
| 						return | ||||
| 					} | ||||
| 					f.roffset++ | ||||
| 					b |= uint32(c) << (nb & regSizeMaskUint32) | ||||
| 					nb += 8 | ||||
| 				} | ||||
| 				chunk := f.hd.chunks[b&(huffmanNumChunks-1)] | ||||
| 				n = uint(chunk & huffmanCountMask) | ||||
| 				if n > huffmanChunkBits { | ||||
| 					chunk = f.hd.links[chunk>>huffmanValueShift][(b>>huffmanChunkBits)&f.hd.linkMask] | ||||
| 					n = uint(chunk & huffmanCountMask) | ||||
| 				} | ||||
| 				if n <= nb { | ||||
| 					if n == 0 { | ||||
| 						f.b = b | ||||
| 						f.nb = nb | ||||
| 						if debugDecode { | ||||
| 							fmt.Println("huffsym: n==0") | ||||
| 						} | ||||
| 						f.err = CorruptInputError(f.roffset) | ||||
| 						return | ||||
| 					} | ||||
| 					f.b = b >> (n & regSizeMaskUint32) | ||||
| 					f.nb = nb - n | ||||
| 					dist = uint32(chunk >> huffmanValueShift) | ||||
| 					break | ||||
| 				} | ||||
| 				f.err = err | ||||
| 				return | ||||
| 			} | ||||
| 			dist = uint32(sym) | ||||
| 		} | ||||
|  | ||||
| 		switch { | ||||
| @@ -410,13 +442,17 @@ readLiteral: | ||||
| 			// have 1 bit in bottom of dist, need nb more. | ||||
| 			extra := (dist & 1) << (nb & regSizeMaskUint32) | ||||
| 			for f.nb < nb { | ||||
| 				if err = f.moreBits(); err != nil { | ||||
| 				c, err := fr.ReadByte() | ||||
| 				if err != nil { | ||||
| 					if debugDecode { | ||||
| 						fmt.Println("morebits f.nb<nb:", err) | ||||
| 					} | ||||
| 					f.err = err | ||||
| 					return | ||||
| 				} | ||||
| 				f.roffset++ | ||||
| 				f.b |= uint32(c) << f.nb | ||||
| 				f.nb += 8 | ||||
| 			} | ||||
| 			extra |= f.b & uint32(1<<(nb®SizeMaskUint32)-1) | ||||
| 			f.b >>= nb & regSizeMaskUint32 | ||||
| @@ -472,16 +508,6 @@ func (f *decompressor) huffmanBufioReader() { | ||||
| 		stateDict | ||||
| 	) | ||||
| 	fr := f.r.(*bufio.Reader) | ||||
| 	moreBits := func() error { | ||||
| 		c, err := fr.ReadByte() | ||||
| 		if err != nil { | ||||
| 			return noEOF(err) | ||||
| 		} | ||||
| 		f.roffset++ | ||||
| 		f.b |= uint32(c) << f.nb | ||||
| 		f.nb += 8 | ||||
| 		return nil | ||||
| 	} | ||||
|  | ||||
| 	switch f.stepState { | ||||
| 	case stateInit: | ||||
| @@ -542,9 +568,7 @@ readLiteral: | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		var n uint // number of bits extra | ||||
| 		var length int | ||||
| 		var err error | ||||
| 		switch { | ||||
| 		case v < 256: | ||||
| 			f.dict.writeByte(byte(v)) | ||||
| @@ -561,25 +585,26 @@ readLiteral: | ||||
| 		// otherwise, reference to older data | ||||
| 		case v < 265: | ||||
| 			length = v - (257 - 3) | ||||
| 			n = 0 | ||||
| 		case v < 269: | ||||
| 			length = v*2 - (265*2 - 11) | ||||
| 			n = 1 | ||||
| 		case v < 273: | ||||
| 			length = v*4 - (269*4 - 19) | ||||
| 			n = 2 | ||||
| 		case v < 277: | ||||
| 			length = v*8 - (273*8 - 35) | ||||
| 			n = 3 | ||||
| 		case v < 281: | ||||
| 			length = v*16 - (277*16 - 67) | ||||
| 			n = 4 | ||||
| 		case v < 285: | ||||
| 			length = v*32 - (281*32 - 131) | ||||
| 			n = 5 | ||||
| 		case v < maxNumLit: | ||||
| 			length = 258 | ||||
| 			n = 0 | ||||
| 			val := decCodeToLen[(v - 257)] | ||||
| 			length = int(val.length) + 3 | ||||
| 			n := uint(val.extra) | ||||
| 			for f.nb < n { | ||||
| 				c, err := fr.ReadByte() | ||||
| 				if err != nil { | ||||
| 					if debugDecode { | ||||
| 						fmt.Println("morebits n>0:", err) | ||||
| 					} | ||||
| 					f.err = err | ||||
| 					return | ||||
| 				} | ||||
| 				f.roffset++ | ||||
| 				f.b |= uint32(c) << f.nb | ||||
| 				f.nb += 8 | ||||
| 			} | ||||
| 			length += int(f.b & uint32(1<<(n®SizeMaskUint32)-1)) | ||||
| 			f.b >>= n & regSizeMaskUint32 | ||||
| 			f.nb -= n | ||||
| 		default: | ||||
| 			if debugDecode { | ||||
| 				fmt.Println(v, ">= maxNumLit") | ||||
| @@ -587,45 +612,70 @@ readLiteral: | ||||
| 			f.err = CorruptInputError(f.roffset) | ||||
| 			return | ||||
| 		} | ||||
| 		if n > 0 { | ||||
| 			for f.nb < n { | ||||
| 				if err = moreBits(); err != nil { | ||||
| 					if debugDecode { | ||||
| 						fmt.Println("morebits n>0:", err) | ||||
| 					} | ||||
| 					f.err = err | ||||
| 					return | ||||
| 				} | ||||
| 			} | ||||
| 			length += int(f.b & uint32(1<<(n®SizeMaskUint32)-1)) | ||||
| 			f.b >>= n & regSizeMaskUint32 | ||||
| 			f.nb -= n | ||||
| 		} | ||||
|  | ||||
| 		var dist uint32 | ||||
| 		if f.hd == nil { | ||||
| 			for f.nb < 5 { | ||||
| 				if err = f.moreBits(); err != nil { | ||||
| 				c, err := fr.ReadByte() | ||||
| 				if err != nil { | ||||
| 					if debugDecode { | ||||
| 						fmt.Println("morebits f.nb<5:", err) | ||||
| 					} | ||||
| 					f.err = err | ||||
| 					return | ||||
| 				} | ||||
| 				f.roffset++ | ||||
| 				f.b |= uint32(c) << f.nb | ||||
| 				f.nb += 8 | ||||
| 			} | ||||
| 			dist = uint32(bits.Reverse8(uint8(f.b & 0x1F << 3))) | ||||
| 			f.b >>= 5 | ||||
| 			f.nb -= 5 | ||||
| 		} else { | ||||
| 			sym, err := f.huffSym(f.hd) | ||||
| 			if err != nil { | ||||
| 				if debugDecode { | ||||
| 					fmt.Println("huffsym:", err) | ||||
| 			// Since a huffmanDecoder can be empty or be composed of a degenerate tree | ||||
| 			// with single element, huffSym must error on these two edge cases. In both | ||||
| 			// cases, the chunks slice will be 0 for the invalid sequence, leading it | ||||
| 			// satisfy the n == 0 check below. | ||||
| 			n := uint(f.hd.maxRead) | ||||
| 			// Optimization. Compiler isn't smart enough to keep f.b,f.nb in registers, | ||||
| 			// but is smart enough to keep local variables in registers, so use nb and b, | ||||
| 			// inline call to moreBits and reassign b,nb back to f on return. | ||||
| 			nb, b := f.nb, f.b | ||||
| 			for { | ||||
| 				for nb < n { | ||||
| 					c, err := fr.ReadByte() | ||||
| 					if err != nil { | ||||
| 						f.b = b | ||||
| 						f.nb = nb | ||||
| 						f.err = noEOF(err) | ||||
| 						return | ||||
| 					} | ||||
| 					f.roffset++ | ||||
| 					b |= uint32(c) << (nb & regSizeMaskUint32) | ||||
| 					nb += 8 | ||||
| 				} | ||||
| 				chunk := f.hd.chunks[b&(huffmanNumChunks-1)] | ||||
| 				n = uint(chunk & huffmanCountMask) | ||||
| 				if n > huffmanChunkBits { | ||||
| 					chunk = f.hd.links[chunk>>huffmanValueShift][(b>>huffmanChunkBits)&f.hd.linkMask] | ||||
| 					n = uint(chunk & huffmanCountMask) | ||||
| 				} | ||||
| 				if n <= nb { | ||||
| 					if n == 0 { | ||||
| 						f.b = b | ||||
| 						f.nb = nb | ||||
| 						if debugDecode { | ||||
| 							fmt.Println("huffsym: n==0") | ||||
| 						} | ||||
| 						f.err = CorruptInputError(f.roffset) | ||||
| 						return | ||||
| 					} | ||||
| 					f.b = b >> (n & regSizeMaskUint32) | ||||
| 					f.nb = nb - n | ||||
| 					dist = uint32(chunk >> huffmanValueShift) | ||||
| 					break | ||||
| 				} | ||||
| 				f.err = err | ||||
| 				return | ||||
| 			} | ||||
| 			dist = uint32(sym) | ||||
| 		} | ||||
|  | ||||
| 		switch { | ||||
| @@ -636,13 +686,17 @@ readLiteral: | ||||
| 			// have 1 bit in bottom of dist, need nb more. | ||||
| 			extra := (dist & 1) << (nb & regSizeMaskUint32) | ||||
| 			for f.nb < nb { | ||||
| 				if err = f.moreBits(); err != nil { | ||||
| 				c, err := fr.ReadByte() | ||||
| 				if err != nil { | ||||
| 					if debugDecode { | ||||
| 						fmt.Println("morebits f.nb<nb:", err) | ||||
| 					} | ||||
| 					f.err = err | ||||
| 					return | ||||
| 				} | ||||
| 				f.roffset++ | ||||
| 				f.b |= uint32(c) << f.nb | ||||
| 				f.nb += 8 | ||||
| 			} | ||||
| 			extra |= f.b & uint32(1<<(nb®SizeMaskUint32)-1) | ||||
| 			f.b >>= nb & regSizeMaskUint32 | ||||
| @@ -698,16 +752,6 @@ func (f *decompressor) huffmanStringsReader() { | ||||
| 		stateDict | ||||
| 	) | ||||
| 	fr := f.r.(*strings.Reader) | ||||
| 	moreBits := func() error { | ||||
| 		c, err := fr.ReadByte() | ||||
| 		if err != nil { | ||||
| 			return noEOF(err) | ||||
| 		} | ||||
| 		f.roffset++ | ||||
| 		f.b |= uint32(c) << f.nb | ||||
| 		f.nb += 8 | ||||
| 		return nil | ||||
| 	} | ||||
|  | ||||
| 	switch f.stepState { | ||||
| 	case stateInit: | ||||
| @@ -768,9 +812,7 @@ readLiteral: | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		var n uint // number of bits extra | ||||
| 		var length int | ||||
| 		var err error | ||||
| 		switch { | ||||
| 		case v < 256: | ||||
| 			f.dict.writeByte(byte(v)) | ||||
| @@ -787,25 +829,26 @@ readLiteral: | ||||
| 		// otherwise, reference to older data | ||||
| 		case v < 265: | ||||
| 			length = v - (257 - 3) | ||||
| 			n = 0 | ||||
| 		case v < 269: | ||||
| 			length = v*2 - (265*2 - 11) | ||||
| 			n = 1 | ||||
| 		case v < 273: | ||||
| 			length = v*4 - (269*4 - 19) | ||||
| 			n = 2 | ||||
| 		case v < 277: | ||||
| 			length = v*8 - (273*8 - 35) | ||||
| 			n = 3 | ||||
| 		case v < 281: | ||||
| 			length = v*16 - (277*16 - 67) | ||||
| 			n = 4 | ||||
| 		case v < 285: | ||||
| 			length = v*32 - (281*32 - 131) | ||||
| 			n = 5 | ||||
| 		case v < maxNumLit: | ||||
| 			length = 258 | ||||
| 			n = 0 | ||||
| 			val := decCodeToLen[(v - 257)] | ||||
| 			length = int(val.length) + 3 | ||||
| 			n := uint(val.extra) | ||||
| 			for f.nb < n { | ||||
| 				c, err := fr.ReadByte() | ||||
| 				if err != nil { | ||||
| 					if debugDecode { | ||||
| 						fmt.Println("morebits n>0:", err) | ||||
| 					} | ||||
| 					f.err = err | ||||
| 					return | ||||
| 				} | ||||
| 				f.roffset++ | ||||
| 				f.b |= uint32(c) << f.nb | ||||
| 				f.nb += 8 | ||||
| 			} | ||||
| 			length += int(f.b & uint32(1<<(n®SizeMaskUint32)-1)) | ||||
| 			f.b >>= n & regSizeMaskUint32 | ||||
| 			f.nb -= n | ||||
| 		default: | ||||
| 			if debugDecode { | ||||
| 				fmt.Println(v, ">= maxNumLit") | ||||
| @@ -813,45 +856,70 @@ readLiteral: | ||||
| 			f.err = CorruptInputError(f.roffset) | ||||
| 			return | ||||
| 		} | ||||
| 		if n > 0 { | ||||
| 			for f.nb < n { | ||||
| 				if err = moreBits(); err != nil { | ||||
| 					if debugDecode { | ||||
| 						fmt.Println("morebits n>0:", err) | ||||
| 					} | ||||
| 					f.err = err | ||||
| 					return | ||||
| 				} | ||||
| 			} | ||||
| 			length += int(f.b & uint32(1<<(n®SizeMaskUint32)-1)) | ||||
| 			f.b >>= n & regSizeMaskUint32 | ||||
| 			f.nb -= n | ||||
| 		} | ||||
|  | ||||
| 		var dist uint32 | ||||
| 		if f.hd == nil { | ||||
| 			for f.nb < 5 { | ||||
| 				if err = f.moreBits(); err != nil { | ||||
| 				c, err := fr.ReadByte() | ||||
| 				if err != nil { | ||||
| 					if debugDecode { | ||||
| 						fmt.Println("morebits f.nb<5:", err) | ||||
| 					} | ||||
| 					f.err = err | ||||
| 					return | ||||
| 				} | ||||
| 				f.roffset++ | ||||
| 				f.b |= uint32(c) << f.nb | ||||
| 				f.nb += 8 | ||||
| 			} | ||||
| 			dist = uint32(bits.Reverse8(uint8(f.b & 0x1F << 3))) | ||||
| 			f.b >>= 5 | ||||
| 			f.nb -= 5 | ||||
| 		} else { | ||||
| 			sym, err := f.huffSym(f.hd) | ||||
| 			if err != nil { | ||||
| 				if debugDecode { | ||||
| 					fmt.Println("huffsym:", err) | ||||
| 			// Since a huffmanDecoder can be empty or be composed of a degenerate tree | ||||
| 			// with single element, huffSym must error on these two edge cases. In both | ||||
| 			// cases, the chunks slice will be 0 for the invalid sequence, leading it | ||||
| 			// satisfy the n == 0 check below. | ||||
| 			n := uint(f.hd.maxRead) | ||||
| 			// Optimization. Compiler isn't smart enough to keep f.b,f.nb in registers, | ||||
| 			// but is smart enough to keep local variables in registers, so use nb and b, | ||||
| 			// inline call to moreBits and reassign b,nb back to f on return. | ||||
| 			nb, b := f.nb, f.b | ||||
| 			for { | ||||
| 				for nb < n { | ||||
| 					c, err := fr.ReadByte() | ||||
| 					if err != nil { | ||||
| 						f.b = b | ||||
| 						f.nb = nb | ||||
| 						f.err = noEOF(err) | ||||
| 						return | ||||
| 					} | ||||
| 					f.roffset++ | ||||
| 					b |= uint32(c) << (nb & regSizeMaskUint32) | ||||
| 					nb += 8 | ||||
| 				} | ||||
| 				chunk := f.hd.chunks[b&(huffmanNumChunks-1)] | ||||
| 				n = uint(chunk & huffmanCountMask) | ||||
| 				if n > huffmanChunkBits { | ||||
| 					chunk = f.hd.links[chunk>>huffmanValueShift][(b>>huffmanChunkBits)&f.hd.linkMask] | ||||
| 					n = uint(chunk & huffmanCountMask) | ||||
| 				} | ||||
| 				if n <= nb { | ||||
| 					if n == 0 { | ||||
| 						f.b = b | ||||
| 						f.nb = nb | ||||
| 						if debugDecode { | ||||
| 							fmt.Println("huffsym: n==0") | ||||
| 						} | ||||
| 						f.err = CorruptInputError(f.roffset) | ||||
| 						return | ||||
| 					} | ||||
| 					f.b = b >> (n & regSizeMaskUint32) | ||||
| 					f.nb = nb - n | ||||
| 					dist = uint32(chunk >> huffmanValueShift) | ||||
| 					break | ||||
| 				} | ||||
| 				f.err = err | ||||
| 				return | ||||
| 			} | ||||
| 			dist = uint32(sym) | ||||
| 		} | ||||
|  | ||||
| 		switch { | ||||
| @@ -862,13 +930,17 @@ readLiteral: | ||||
| 			// have 1 bit in bottom of dist, need nb more. | ||||
| 			extra := (dist & 1) << (nb & regSizeMaskUint32) | ||||
| 			for f.nb < nb { | ||||
| 				if err = f.moreBits(); err != nil { | ||||
| 				c, err := fr.ReadByte() | ||||
| 				if err != nil { | ||||
| 					if debugDecode { | ||||
| 						fmt.Println("morebits f.nb<nb:", err) | ||||
| 					} | ||||
| 					f.err = err | ||||
| 					return | ||||
| 				} | ||||
| 				f.roffset++ | ||||
| 				f.b |= uint32(c) << f.nb | ||||
| 				f.nb += 8 | ||||
| 			} | ||||
| 			extra |= f.b & uint32(1<<(nb®SizeMaskUint32)-1) | ||||
| 			f.b >>= nb & regSizeMaskUint32 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user