Merge branch 'hotfix-4.5.9'

This commit is contained in:
Timofey Solomko
2021-05-01 15:57:27 +03:00
22 changed files with 192 additions and 114 deletions
+2 -2
View File
@@ -3,11 +3,11 @@ sourcekitten_sourcefile: docs.json
clean: true
author: Timofey Solomko
module: SWCompression
module_version: 4.5.8
module_version: 4.5.9
copyright: '© 2021 Timofey Solomko'
readme: README.md
github_url: https://github.com/tsolomko/SWCompression
github_file_prefix: https://github.com/tsolomko/SWCompression/tree/4.5.7
github_file_prefix: https://github.com/tsolomko/SWCompression/tree/4.5.9
theme: fullwidth
custom_categories:
+59 -21
View File
@@ -4,13 +4,23 @@ git:
submodules: false
jobs:
include:
# We cannot test with Swift 4.2 on macOS since Carthage doesn't work with multiple Swift versions.
# We test only building using SPM with Swift 4.2 on macos since Carthage doesn't support multiple Swift language versions.
- stage: test
language: swift
os: osx
osx_image: xcode10.1 # Swift 4.2
script:
- swift --version
- swift build
- swift build -c release
- stage: test
language: swift
os: osx
osx_image: xcode10.3 # Swift 5.0
env:
- HOMEBREW_NO_INSTALL_CLEANUP=1
- WATCHOS_ACTIONS='clean build'
- WATCHOS_SIMULATOR='Apple Watch Series 4 - 44mm'
before_install:
- brew update
install:
@@ -25,6 +35,8 @@ jobs:
osx_image: xcode11.3 # Swift 5.1
env:
- HOMEBREW_NO_INSTALL_CLEANUP=1
- WATCHOS_ACTIONS='clean build'
- WATCHOS_SIMULATOR='Apple Watch Series 4 - 44mm'
before_install:
- brew update
install:
@@ -39,6 +51,8 @@ jobs:
osx_image: xcode11.4 # Swift 5.2
env:
- HOMEBREW_NO_INSTALL_CLEANUP=1
- WATCHOS_ACTIONS='clean build'
- WATCHOS_SIMULATOR='Apple Watch Series 4 - 44mm'
before_install:
- brew update
install:
@@ -54,6 +68,8 @@ jobs:
osx_image: xcode12 # Swift 5.3
env:
- HOMEBREW_NO_INSTALL_CLEANUP=1
- WATCHOS_ACTIONS='clean build'
- WATCHOS_SIMULATOR='Apple Watch Series 6 - 44mm'
before_install:
- brew update
install:
@@ -79,70 +95,90 @@ jobs:
osx_image: xcode12.4 # Swift 5.3.2
env:
- HOMEBREW_NO_INSTALL_CLEANUP=1
- WATCHOS_ACTIONS='clean build'
- WATCHOS_SIMULATOR='Apple Watch Series 6 - 44mm'
before_install:
- brew update
install:
- ./utils.py ci install-macos
before_script:
# TODO: Move this line into ./utils.py prepare-workspace macos when the old Swift versions and non-xcf installation
# method with Carthage are no longer supported.
- carthage bootstrap --use-xcframeworks --no-use-binaries
- git submodule update --init --recursive
- cp "Tests/Test Files/gitattributes-copy" "Tests/Test Files/.gitattributes"
- cd "Tests/Test Files/"
- git lfs pull
- git lfs checkout
- cd -
- ./utils.py prepare-workspace macos --xcf
script:
- ./utils.py ci script-macos
- stage: test
language: swift
os: osx
osx_image: xcode12.5 # Swift 5.4
env:
- HOMEBREW_NO_INSTALL_CLEANUP=1
- WATCHOS_ACTIONS='clean test'
- WATCHOS_SIMULATOR='Apple Watch Series 6 - 44mm'
before_install:
- brew update
install:
- ./utils.py ci install-macos
before_script:
- ./utils.py prepare-workspace macos --xcf
script:
- ./utils.py ci script-macos
- stage: test
language: generic
os: linux
dist: xenial
dist: bionic
env:
- SWIFT_VERSION=4.2.3
install:
- eval "$(curl -sL https://swiftenv.fuller.li/install.sh)"
- ./utils.py ci install-linux
script:
- ./utils.py ci script-linux
- stage: test
language: generic
os: linux
dist: xenial
dist: bionic
env:
- SWIFT_VERSION=5.0.3
install:
- eval "$(curl -sL https://swiftenv.fuller.li/install.sh)"
- ./utils.py ci install-linux
script:
- ./utils.py ci script-linux
- stage: test
language: generic
os: linux
dist: xenial
dist: bionic
env:
- SWIFT_VERSION=5.1.5
install:
- eval "$(curl -sL https://swiftenv.fuller.li/install.sh)"
- ./utils.py ci install-linux
script:
- ./utils.py ci script-linux
- stage: test
language: generic
os: linux
dist: xenial
dist: bionic
env:
- SWIFT_VERSION=5.2.5
install:
- eval "$(curl -sL https://swiftenv.fuller.li/install.sh)"
- ./utils.py ci install-linux
script:
- ./utils.py ci script-linux
- stage: test
language: generic
os: linux
dist: xenial
dist: bionic
env:
- SWIFT_VERSION=5.3.3
install:
- eval "$(curl -sL https://swiftenv.fuller.li/install.sh)"
- ./utils.py ci install-linux
script:
- ./utils.py ci script-linux
- stage: test
language: generic
os: linux
dist: bionic
env:
- SWIFT_VERSION=5.4
install:
- ./utils.py ci install-linux
script:
- ./utils.py ci script-linux
- stage: deploy
@@ -167,6 +203,8 @@ jobs:
- ./utils.py ci before-deploy
deploy:
- provider: pages
skip_cleanup: true
github_token: $GITHUB_TOKEN
local_dir: docs
skip_cleanup: true
on:
tags: true
+5
View File
@@ -1,5 +1,10 @@
# Changelog
## 4.5.9
- Improved performance of LZMA/LZMA2 and, consequently, of XZ.
- Fixed a rare crash when processing a BZip2 archive which uses non-standard (but allowed) run length values.
## 4.5.8
- Fixed incompatibility with Carthage `--use-xcframeworks` method of installation.
+1 -1
View File
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "SWCompression"
s.version = "4.5.8"
s.version = "4.5.9"
s.summary = "A framework with functions for working with compression, archives and containers."
s.description = "A framework with (de)compression algorithms and functions for processing various archives and containers."
+3 -3
View File
@@ -15,10 +15,10 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>4.5.8</string>
<string>4.5.9</string>
<key>CFBundleVersion</key>
<string>75</string>
<string>76</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2021 Timofey Solomko. All rights reserved.</string>
<string>Copyright © 2021 Timofey Solomko</string>
</dict>
</plist>
@@ -15,8 +15,8 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>4.5.8</string>
<string>4.5.9</string>
<key>CFBundleVersion</key>
<string>75</string>
<string>76</string>
</dict>
</plist>
+15 -7
View File
@@ -213,6 +213,8 @@
06F066771FFB763400312A82 /* test8.bz2 in Resources */ = {isa = PBXBuildFile; fileRef = 06F066111FFB763300312A82 /* test8.bz2 */; };
06F276DF1F2BAB4A00E67335 /* 7zEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06F276DE1F2BAB4900E67335 /* 7zEntry.swift */; };
06FEAD921F54B9CD00AD016E /* EncodingTree.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06FEAD911F54B9CD00AD016E /* EncodingTree.swift */; };
E652D8F3263D670900FC229B /* test_nonstandard_runlength.bz2 in Resources */ = {isa = PBXBuildFile; fileRef = E652D8F2263D670900FC229B /* test_nonstandard_runlength.bz2 */; };
E652D8F5263D678000FC229B /* test_nonstandard_runlength.answer in Resources */ = {isa = PBXBuildFile; fileRef = E652D8F4263D678000FC229B /* test_nonstandard_runlength.answer */; };
E66F36242538726E00076A6E /* test_empty.lzma in Resources */ = {isa = PBXBuildFile; fileRef = E66F36232538726E00076A6E /* test_empty.lzma */; };
E66F362C2538E2B700076A6E /* test_empty.zlib in Resources */ = {isa = PBXBuildFile; fileRef = E66F362B2538E2B700076A6E /* test_empty.zlib */; };
/* End PBXBuildFile section */
@@ -435,6 +437,8 @@
06F276DE1F2BAB4900E67335 /* 7zEntry.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = 7zEntry.swift; sourceTree = "<group>"; };
06FEAD911F54B9CD00AD016E /* EncodingTree.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = EncodingTree.swift; path = Sources/Common/CodingTree/EncodingTree.swift; sourceTree = SOURCE_ROOT; };
06FED40B1DD7717E0013DFB2 /* BZip2.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BZip2.swift; sourceTree = "<group>"; };
E652D8F2263D670900FC229B /* test_nonstandard_runlength.bz2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_nonstandard_runlength.bz2; sourceTree = "<group>"; };
E652D8F4263D678000FC229B /* test_nonstandard_runlength.answer */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_nonstandard_runlength.answer; sourceTree = "<group>"; };
E66F36232538726E00076A6E /* test_empty.lzma */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_empty.lzma; sourceTree = "<group>"; };
E66F362B2538E2B700076A6E /* test_empty.zlib */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_empty.zlib; sourceTree = "<group>"; };
/* End PBXFileReference section */
@@ -723,6 +727,7 @@
06F065B31FFB763300312A82 /* test7.answer */,
06F065B51FFB763300312A82 /* test8.answer */,
06F065B11FFB763300312A82 /* test9.answer */,
E652D8F4263D678000FC229B /* test_nonstandard_runlength.answer */,
);
path = Answers;
sourceTree = "<group>";
@@ -886,6 +891,7 @@
06F0660C1FFB763300312A82 /* test7.bz2 */,
06F066111FFB763300312A82 /* test8.bz2 */,
06F066101FFB763300312A82 /* test9.bz2 */,
E652D8F2263D670900FC229B /* test_nonstandard_runlength.bz2 */,
);
path = BZip2;
sourceTree = "<group>";
@@ -934,7 +940,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0920;
LastUpgradeCheck = 1240;
LastUpgradeCheck = 1250;
ORGANIZATIONNAME = "Timofey Solomko";
TargetAttributes = {
06BE1AC71DB410F100EE0F59 = {
@@ -980,6 +986,7 @@
06F066661FFB763400312A82 /* test3.7z in Resources */,
06F0664B1FFB763400312A82 /* test.tar in Resources */,
06F066501FFB763400312A82 /* test_gnu.tar in Resources */,
E652D8F5263D678000FC229B /* test_nonstandard_runlength.answer in Resources */,
06F066341FFB763400312A82 /* test1.xz in Resources */,
06F0665F1FFB763400312A82 /* test_multi_blocks.7z in Resources */,
068D070421368617002A6C3B /* test_delta_filter.7z in Resources */,
@@ -1051,6 +1058,7 @@
0698B10F2106344200A7C551 /* test_negative_mtime.tar in Resources */,
06F066561FFB763400312A82 /* SWCompressionSourceCode.tar in Resources */,
069864CA21403CE700755D9B /* test_sha256.xz in Resources */,
E652D8F3263D670900FC229B /* test_nonstandard_runlength.bz2 in Resources */,
06F0663D1FFB763400312A82 /* test2.xz in Resources */,
06F066351FFB763400312A82 /* test5.xz in Resources */,
06F066631FFB763400312A82 /* test_complicated_coding_scheme.7z in Resources */,
@@ -1090,7 +1098,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/bash;
shellScript = "if [[ ${SDK_NAME} == iphone* ]]; then\n if [[ ! -d ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/ ]]; then\n mkdir -p ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\n if [[ -d ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/ ]]; then\n if [[ ${SDK_NAME} == iphonesimulator* ]]; then\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/ios-*-simulator/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/ios-arm64_armv7/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/iOS/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\nelif [[ ${SDK_NAME} == appletv* ]]; then\n if [[ ! -d ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/ ]]; then\n mkdir -p ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\n if [[ -d ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/ ]]; then\n if [[ ${SDK_NAME} == appletvsimulator* ]]; then\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/tvos-*-simulator/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/tvos-arm64/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/tvOS/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\nelif [[ ${SDK_NAME} == watch* ]]; then\n if [[ ! -d ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/ ]]; then\n mkdir -p ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\n if [[ -d ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/ ]]; then\n if [[ ${SDK_NAME} == watchossimulator* ]]; then\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/watchos-*-simulator/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/watchos-arm64_32_armv7k/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/watchOS/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\nelif [[ ${SDK_NAME} == macos* ]]; then\n if [[ ! -d ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Contents/Frameworks/ ]]; then\n mkdir -p ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Contents/Frameworks/\n fi\n if [[ -d ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/ ]]; then\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/macos-*/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Contents/Frameworks/\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/Mac/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Contents/Frameworks/\n fi\nfi\n\nxattr -rc ${BUILT_PRODUCTS_DIR}\n";
shellScript = "if [[ ${SDK_NAME} == iphone* ]]; then\n if [[ ! -d ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/ ]]; then\n mkdir -p ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\n if [[ -d ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/ ]]; then\n if [[ ${SDK_NAME} == iphonesimulator* ]]; then\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/ios-*-simulator/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/ios-arm64_armv7/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/iOS/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\nelif [[ ${SDK_NAME} == appletv* ]]; then\n if [[ ! -d ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/ ]]; then\n mkdir -p ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\n if [[ -d ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/ ]]; then\n if [[ ${SDK_NAME} == appletvsimulator* ]]; then\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/tvos-*-simulator/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/tvos-arm64/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/tvOS/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\nelif [[ ${SDK_NAME} == watch* ]]; then\n if [[ ! -d ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/ ]]; then\n mkdir -p ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\n if [[ -d ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/ ]]; then\n if [[ ${SDK_NAME} == watchsimulator* ]]; then\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/watchos-*-simulator/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/watchos-arm64_32_armv7k/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/watchOS/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\nelif [[ ${SDK_NAME} == macos* ]]; then\n if [[ ! -d ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Contents/Frameworks/ ]]; then\n mkdir -p ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Contents/Frameworks/\n fi\n if [[ -d ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/ ]]; then\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/macos-*/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Contents/Frameworks/\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/Mac/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Contents/Frameworks/\n fi\nfi\n\nxattr -rc ${BUILT_PRODUCTS_DIR}\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
@@ -1250,7 +1258,7 @@
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CURRENT_PROJECT_VERSION = 75;
CURRENT_PROJECT_VERSION = 76;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
@@ -1331,7 +1339,7 @@
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CURRENT_PROJECT_VERSION = 75;
CURRENT_PROJECT_VERSION = 76;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_STRICT_OBJC_MSGSEND = YES;
"FRAMEWORK_SEARCH_PATHS[sdk=appletvos*]" = (
@@ -1377,7 +1385,7 @@
BitByteData,
);
SDKROOT = macosx;
SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator";
SUPPORTED_PLATFORMS = "macosx watchsimulator iphonesimulator appletvsimulator watchos appletvos iphoneos";
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_VERSION = 5.0;
TVOS_DEPLOYMENT_TARGET = 9.0;
@@ -1392,7 +1400,7 @@
APPLICATION_EXTENSION_API_ONLY = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 75;
DYLIB_CURRENT_VERSION = 76;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = SWCompression.xcodeproj/SWCompression.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
@@ -1419,7 +1427,7 @@
APPLICATION_EXTENSION_API_ONLY = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 75;
DYLIB_CURRENT_VERSION = 76;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = SWCompression.xcodeproj/SWCompression.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1240"
LastUpgradeVersion = "1250"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
+3 -1
View File
@@ -211,7 +211,9 @@ public class BZip2: DecompressionAlgorithm {
out.reserveCapacity(blockSize.sizeInKilobytes * 1000)
while i < nt.count {
if i < nt.count - 4 && nt[i] == nt[i + 1] && nt[i] == nt[i + 2] && nt[i] == nt[i + 3] {
let runLength = nt[i + 4] + 4
// While the reference implementation of BZip2 doesn't produce such output, the "specification"
// technically allows run lengths greater than 255. To allow this we have to convert to Int.
let runLength = nt[i + 4].toInt() + 4
for _ in 0..<runLength {
out.append(nt[i])
}
+1
View File
@@ -11,6 +11,7 @@ extension UnsignedInteger {
func toInt() -> Int {
return Int(truncatingIfNeeded: self)
}
}
extension Int {
+1 -1
View File
@@ -63,7 +63,7 @@ public class LZMA: DecompressionAlgorithm {
static func decompress(_ byteReader: ByteReader,
_ properties: LZMAProperties,
_ uncompSize: Int?) throws -> Data {
let decoder = LZMADecoder(byteReader)
var decoder = LZMADecoder(byteReader)
decoder.properties = properties
decoder.resetStateAndDecoders()
decoder.uncompressedSize = uncompSize ?? -1
+5 -5
View File
@@ -6,7 +6,7 @@
import Foundation
/// Used to decode symbols that need several bits for storing.
final class LZMABitTreeDecoder {
struct LZMABitTreeDecoder {
var probs: [Int]
let numBits: Int
@@ -17,7 +17,7 @@ final class LZMABitTreeDecoder {
self.numBits = numBits
}
func decode(with rangeDecoder: LZMARangeDecoder) -> Int {
mutating func decode(with rangeDecoder: inout LZMARangeDecoder) -> Int {
var m = 1
for _ in 0..<self.numBits {
m = (m << 1) + rangeDecoder.decode(bitWithProb: &self.probs[m])
@@ -25,14 +25,14 @@ final class LZMABitTreeDecoder {
return m - (1 << self.numBits)
}
func reverseDecode(with rangeDecoder: LZMARangeDecoder) -> Int {
mutating func reverseDecode(with rangeDecoder: inout LZMARangeDecoder) -> Int {
return LZMABitTreeDecoder.bitTreeReverseDecode(probs: &self.probs,
startIndex: 0,
bits: self.numBits, rangeDecoder)
bits: self.numBits, &rangeDecoder)
}
static func bitTreeReverseDecode(probs: inout [Int], startIndex: Int, bits: Int,
_ rangeDecoder: LZMARangeDecoder) -> Int {
_ rangeDecoder: inout LZMARangeDecoder) -> Int {
var m = 1
var symbol = 0
for i in 0..<bits {
+1 -1
View File
@@ -6,7 +6,7 @@
import Foundation
struct LZMAConstants {
static let topValue = 1 << 24
static let topValue: UInt32 = 1 << 24
static let numBitModelTotalBits = 11
static let numMoveBits = 5
static let probInitValue = (1 << numBitModelTotalBits) / 2
+14 -20
View File
@@ -6,7 +6,7 @@
import Foundation
import BitByteData
final class LZMADecoder {
struct LZMADecoder {
private let byteReader: ByteReader
@@ -76,10 +76,8 @@ final class LZMADecoder {
self.byteReader = byteReader
}
/**
Resets state properties and various sub-decoders of LZMA decoder.
*/
func resetStateAndDecoders() {
/// Resets state properties and various sub-decoders of LZMA decoder.
mutating func resetStateAndDecoders() {
self.state = 0
self.rep0 = 0
@@ -102,24 +100,20 @@ final class LZMADecoder {
self.repLenDecoder = LZMALenDecoder()
}
func resetDictionary() {
mutating func resetDictionary() {
self.dictStart = self.dictEnd
}
/// Main LZMA (algorithm) decoder function.
func decode() throws {
mutating func decode() throws {
// First, we need to initialize Rande Decoder.
guard let rD = LZMARangeDecoder(byteReader)
else { throw LZMAError.rangeDecoderInitError }
self.rangeDecoder = rD
self.rangeDecoder = try LZMARangeDecoder(byteReader)
// Main decoding cycle.
while true {
// If uncompressed size was defined and everything is unpacked then stop.
if uncompressedSize == 0 {
if rangeDecoder.isFinishedOK {
break
}
if uncompressedSize == 0 && rangeDecoder.isFinishedOK {
break
}
let posState = out.count & ((1 << pb) - 1)
@@ -218,14 +212,14 @@ final class LZMADecoder {
rep1 = rep0
rep0 = dist
}
len = repLenDecoder.decode(with: rangeDecoder, posState: posState)
len = repLenDecoder.decode(with: &rangeDecoder, posState: posState)
state = state < 7 ? 8 : 11
} else { // SIMPLE MATCH CASE
// First, we need to move history of distance values.
rep3 = rep2
rep2 = rep1
rep1 = rep0
len = lenDecoder.decode(with: rangeDecoder, posState: posState)
len = lenDecoder.decode(with: &rangeDecoder, posState: posState)
state = state < 7 ? 7 : 10
// DECODE DISTANCE:
@@ -236,7 +230,7 @@ final class LZMADecoder {
}
/// Defines decoding scheme for distance value.
let posSlot = posSlotDecoder[lenState].decode(with: rangeDecoder)
let posSlot = posSlotDecoder[lenState].decode(with: &rangeDecoder)
if posSlot < 4 {
// If `posSlot` is less than 4 then distance has defined value (no need to decode).
// And distance is actually equal to `posSlot`.
@@ -250,13 +244,13 @@ final class LZMADecoder {
// ...and 'Reverse' scheme to get distance value.
dist += LZMABitTreeDecoder.bitTreeReverseDecode(probs: &posDecoders,
startIndex: dist - posSlot,
bits: numDirectBits, rangeDecoder)
bits: numDirectBits, &rangeDecoder)
} else {
// Middle bits of distance are decoded as direct bits from RangeDecoder.
dist += rangeDecoder.decode(directBits: (numDirectBits - LZMAConstants.numAlignBits))
<< LZMAConstants.numAlignBits
// Low 4 bits are decoded with a bit tree decoder (called 'AlignDecoder') using "Reverse" scheme.
dist += alignDecoder.reverseDecode(with: rangeDecoder)
dist += alignDecoder.reverseDecode(with: &rangeDecoder)
}
rep0 = dist
}
@@ -292,7 +286,7 @@ final class LZMADecoder {
// MARK: Dictionary (out window) related functions.
func put(_ byte: UInt8) {
mutating func put(_ byte: UInt8) {
out.append(byte)
dictEnd += 1
if dictEnd - dictStart == dictSize {
+5 -5
View File
@@ -5,7 +5,7 @@
import Foundation
final class LZMALenDecoder {
struct LZMALenDecoder {
private var choice: Int = LZMAConstants.probInitValue
private var choice2: Int = LZMAConstants.probInitValue
@@ -22,21 +22,21 @@ final class LZMALenDecoder {
}
/// Decodes zero-based match length.
func decode(with rangeDecoder: LZMARangeDecoder, posState: Int) -> Int {
mutating func decode(with rangeDecoder: inout LZMARangeDecoder, posState: Int) -> Int {
// There can be one of three options.
// We need one or two bits to find out which decoding scheme to use.
// `choice` is used to decode first bit.
// `choice2` is used to decode second bit.
// If binary sequence starts with 0 then:
if rangeDecoder.decode(bitWithProb: &self.choice) == 0 {
return self.lowCoder[posState].decode(with: rangeDecoder)
return self.lowCoder[posState].decode(with: &rangeDecoder)
}
// If binary sequence starts with 1 0 then:
if rangeDecoder.decode(bitWithProb: &self.choice2) == 0 {
return 8 + self.midCoder[posState].decode(with: rangeDecoder)
return 8 + self.midCoder[posState].decode(with: &rangeDecoder)
}
// If binary sequence starts with 1 1 then:
return 16 + self.highCoder.decode(with: rangeDecoder)
return 16 + self.highCoder.decode(with: &rangeDecoder)
}
}
+10 -11
View File
@@ -6,9 +6,9 @@
import Foundation
import BitByteData
final class LZMARangeDecoder {
struct LZMARangeDecoder {
private var byteReader: ByteReader
private let byteReader: ByteReader
private var range = 0xFFFFFFFF as UInt32
private var code = 0 as UInt32
@@ -18,10 +18,10 @@ final class LZMARangeDecoder {
return self.code == 0
}
init?(_ byteReader: ByteReader) {
init(_ byteReader: ByteReader) throws {
// To initialize rande decoder at least 5 bytes are necessary.
guard byteReader.bytesLeft >= 5
else { return nil }
else { throw LZMAError.rangeDecoderInitError }
self.byteReader = byteReader
@@ -29,9 +29,8 @@ final class LZMARangeDecoder {
for _ in 0..<4 {
self.code = (self.code << 8) | UInt32(self.byteReader.byte())
}
if byte != 0 || self.code == self.range {
return nil
}
guard byte == 0 && self.code != self.range
else { throw LZMAError.rangeDecoderInitError }
}
init() {
@@ -39,15 +38,15 @@ final class LZMARangeDecoder {
}
/// `range` property cannot be smaller than `(1 << 24)`. This function keeps it bigger.
func normalize() {
if self.range < UInt32(LZMAConstants.topValue) {
mutating func normalize() {
if self.range < LZMAConstants.topValue {
self.range <<= 8
self.code = (self.code << 8) | UInt32(byteReader.byte())
}
}
/// Decodes sequence of direct bits (binary symbols with fixed and equal probabilities).
func decode(directBits: Int) -> Int {
mutating func decode(directBits: Int) -> Int {
var res: UInt32 = 0
var count = directBits
repeat {
@@ -70,7 +69,7 @@ final class LZMARangeDecoder {
}
/// Decodes binary symbol (bit) with predicted (estimated) probability.
func decode(bitWithProb prob: inout Int) -> Int {
mutating func decode(bitWithProb prob: inout Int) -> Int {
let bound = (self.range >> UInt32(LZMAConstants.numBitModelTotalBits)) * UInt32(prob)
let symbol: Int
if self.code < bound {
+1 -1
View File
@@ -28,7 +28,7 @@ public class LZMA2: DecompressionAlgorithm {
}
static func decompress(_ byteReader: ByteReader, _ dictSizeByte: UInt8) throws -> Data {
let decoder = try LZMA2Decoder(byteReader, dictSizeByte)
var decoder = try LZMA2Decoder(byteReader, dictSizeByte)
try decoder.decode()
return Data(decoder.out)
}
+6 -6
View File
@@ -6,10 +6,10 @@
import Foundation
import BitByteData
final class LZMA2Decoder {
struct LZMA2Decoder {
private let byteReader: ByteReader
private let decoder: LZMADecoder
private var decoder: LZMADecoder
var out: [UInt8] {
return self.decoder.out
@@ -32,7 +32,7 @@ final class LZMA2Decoder {
}
/// Main LZMA2 decoder function.
func decode() throws {
mutating func decode() throws {
mainLoop: while true {
let controlByte = byteReader.byte()
switch controlByte {
@@ -54,7 +54,7 @@ final class LZMA2Decoder {
}
/// Function which dispatches LZMA2 decoding process based on `controlByte`.
private func dispatch(_ controlByte: UInt8) throws {
private mutating func dispatch(_ controlByte: UInt8) throws {
let uncompressedSizeBits = controlByte & 0x1F
let reset = (controlByte & 0x60) >> 5
let unpackSize = (uncompressedSizeBits.toInt() << 16) +
@@ -82,7 +82,7 @@ final class LZMA2Decoder {
else { throw LZMA2Error.wrongSizes }
}
private func decodeUncompressed() {
private mutating func decodeUncompressed() {
let dataSize = self.byteReader.byte().toInt() << 8 + self.byteReader.byte().toInt() + 1
for _ in 0..<dataSize {
self.decoder.put(self.byteReader.byte())
@@ -93,7 +93,7 @@ final class LZMA2Decoder {
Sets `lc`, `pb` and `lp` properties of LZMA decoder with a single `byte` using standard LZMA properties encoding
scheme and resets decoder's state and sub-decoders.
*/
private func updateProperties() throws {
private mutating func updateProperties() throws {
self.decoder.properties = try LZMAProperties(lzmaByte: byteReader.byte(),
self.decoder.properties.dictionarySize)
self.decoder.resetStateAndDecoders()
+1 -1
View File
@@ -7,7 +7,7 @@ import Foundation
import SWCompression
import SwiftCLI
let cli = CLI(name: "swcomp", version: "4.5.8",
let cli = CLI(name: "swcomp", version: "4.5.9",
description: """
swcomp - small command-line client for SWCompression framework.
Serves as an example of SWCompression usage.
+4
View File
@@ -54,6 +54,10 @@ class BZip2Tests: XCTestCase {
try self.perform(test: "test9")
}
func testNonStandardRunLength() throws {
try self.perform(test: "test_nonstandard_runlength")
}
func testBadFile_short() {
XCTAssertThrowsError(try BZip2.decompress(data: Data([0])))
}
+51 -24
View File
@@ -1,13 +1,18 @@
#!/usr/bin/env python3
import argparse
import os
import subprocess
import sys
def _sprun(cmd, *args, **kwargs):
def _sprun(cmd: list, *args, **kwargs):
print("+ " + " ".join(cmd))
subprocess.run(cmd, check=True, *args, **kwargs)
def _sprun_shell(cmd: str, *args, **kwargs):
print("+ " + cmd)
subprocess.run(cmd, check=True, shell=True, *args, **kwargs)
def _ci_before_deploy():
docs_json_file = open("docs.json", "w")
_sprun(["sourcekitten", "doc", "--spm", "--module-name", "SWCompression"], stdout=docs_json_file)
@@ -15,37 +20,50 @@ def _ci_before_deploy():
_sprun(["jazzy"])
def _ci_install_macos():
_sprun(["brew", "install", "git-lfs"])
script = """if brew ls --versions "git-lfs" >/dev/null; then
HOMEBREW_NO_AUTO_UPDATE=1 brew upgrade "git-lfs"
else
HOMEBREW_NO_AUTO_UPDATE=1 brew install "git-lfs"
fi"""
_sprun_shell(script)
_sprun(["git", "lfs", "install"])
_sprun(["gem", "install", "-N", "xcpretty-travis-formatter"])
def _ci_script_linux():
_sprun(["swift", "build"])
_sprun(["swift", "build", "-c", "release"])
def _ci_install_linux():
_sprun_shell("eval \"$(curl -sL https://swiftenv.fuller.li/install.sh)\"")
def _ci_script_macos():
xcodebuild_command_parts = ["xcodebuild", "-project", "SWCompression.xcodeproj", "-scheme", "SWCompression"]
destinations_actions = [(["-destination 'platform=OS X'"], ["clean", "test"]),
(["-destination 'platform=iOS Simulator,name=iPhone 8'"], ["clean", "test"]),
(["-destination 'platform=watchOS Simulator,name=Apple Watch - 38mm'"], ["clean", "build"]),
_sprun_shell("xcodebuild -version")
_sprun(["swift", "--version"])
xcodebuild_command_parts = ["xcodebuild", "-quiet", "-project", "SWCompression.xcodeproj", "-scheme", "SWCompression"]
destinations_actions = [(["-destination 'platform=OS X'"], ["clean", "test"]),
(["-destination 'platform=iOS Simulator,name=iPhone 8'"], ["clean", "test"]),
(["-destination 'platform=watchOS Simulator,name=" + os.environ["WATCHOS_SIMULATOR"] + "'"], [os.environ["WATCHOS_ACTIONS"]]),
(["-destination 'platform=tvOS Simulator,name=Apple TV'"], ["clean", "test"])]
for destination, action in destinations_actions:
xcodebuild_command = xcodebuild_command_parts + destination + action
print("+ {0} | xcpretty -f `xcpretty-travis-formatter`".format(" ".join(xcodebuild_command)))
xcodebuild_process = subprocess.Popen(xcodebuild_command, stdout=subprocess.PIPE)
xcpretty_command = ["xcpretty", "-f", "`xcpretty-travis-formatter`"]
subprocess.run(xcpretty_command, stdin=xcodebuild_process.stdout, shell=True, check=True)
for destination, actions in destinations_actions:
xcodebuild_command = xcodebuild_command_parts + destination + actions
# If xcodebuild is not run inside shell, then destination parameters are ignored for some reason.
_sprun_shell(" ".join(xcodebuild_command))
def _ci_script_linux():
env = os.environ.copy()
env["SWIFTENV_ROOT"] = env["HOME"] +"/.swiftenv"
env["PATH"] = env["SWIFTENV_ROOT"] + "/bin:" + env["SWIFTENV_ROOT"] + "/shims:"+ env["PATH"]
_sprun(["swift", "--version"], env=env)
_sprun(["swift", "build"], env=env)
_sprun(["swift", "build", "-c", "release"], env=env)
def action_ci(args):
if args.cmd == "before-deploy":
_ci_before_deploy()
elif args.cmd == "install-macos":
_ci_install_macos()
elif args.cmd == "script-linux":
_ci_script_linux()
elif args.cmd == "install-linux":
_ci_install_linux()
elif args.cmd == "script-macos":
_ci_script_macos()
elif args.cmd == "script-linux":
_ci_script_linux()
else:
raise Exception("Unknown CI command")
@@ -60,13 +78,18 @@ def action_cw(args):
_sprun(["rm", "-f", "Package.resolved"])
_sprun(["rm", "-f", "SWCompression.framework.zip"])
def _pw_macos():
def _pw_macos(debug, xcf):
print("=> Downloading dependency (BitByteData) using Carthage")
_sprun(["carthage", "bootstrap", "--no-use-binaries"])
script = ["carthage", "bootstrap", "--no-use-binaries"]
if debug:
script += ["--configuration", "Debug"]
if xcf:
script += ["--use-xcframeworks"]
_sprun(script)
def action_pw(args):
if args.os == "macos":
_pw_macos()
_pw_macos(args.debug, args.xcf)
elif args.os == "other":
pass
else:
@@ -84,7 +107,7 @@ subparsers = parser.add_subparsers(title="commands", help="a command to perform"
# Parser for 'ci' command.
parser_ci = subparsers.add_parser("ci", help="a subset of commands used by CI",
description="a subset of commands used by CI")
parser_ci.add_argument("cmd", choices=["before-deploy", "install-macos", "script-linux", "script-macos"],
parser_ci.add_argument("cmd", choices=["before-deploy", "install-macos", "install-linux", "script-macos", "script-linux"],
help="a command to perform on CI", metavar="CI_CMD")
parser_ci.set_defaults(func=action_ci)
@@ -99,6 +122,10 @@ parser_pw = subparsers.add_parser("prepare-workspace", help="prepare workspace",
parser_pw.add_argument("os", choices=["macos", "other"], help="development operating system", metavar="OS")
parser_pw.add_argument("--no-test-files", "-T", action="store_true", dest="no_test_files",
help="don't download example files used for testing")
parser_pw.add_argument("--debug", "-d", action="store_true", dest="debug",
help="build BitByteData in Debug configuration")
parser_pw.add_argument("--xcf", action="store_true", dest="xcf",
help="build BitByteData as a XCFramework")
parser_pw.set_defaults(func=action_pw)
args = parser.parse_args()