extzstd 0.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +5 -5
  2. data/HISTORY.ja.md +39 -0
  3. data/README.md +38 -56
  4. data/contrib/zstd/CHANGELOG +613 -0
  5. data/contrib/zstd/CODE_OF_CONDUCT.md +5 -0
  6. data/contrib/zstd/CONTRIBUTING.md +406 -0
  7. data/contrib/zstd/COPYING +339 -0
  8. data/contrib/zstd/Makefile +420 -0
  9. data/contrib/zstd/README.md +179 -41
  10. data/contrib/zstd/TESTING.md +44 -0
  11. data/contrib/zstd/appveyor.yml +292 -0
  12. data/contrib/zstd/lib/BUCK +234 -0
  13. data/contrib/zstd/lib/Makefile +451 -0
  14. data/contrib/zstd/lib/README.md +207 -0
  15. data/contrib/zstd/{common → lib/common}/bitstream.h +187 -138
  16. data/contrib/zstd/lib/common/compiler.h +288 -0
  17. data/contrib/zstd/lib/common/cpu.h +213 -0
  18. data/contrib/zstd/lib/common/debug.c +24 -0
  19. data/contrib/zstd/lib/common/debug.h +107 -0
  20. data/contrib/zstd/lib/common/entropy_common.c +362 -0
  21. data/contrib/zstd/{common → lib/common}/error_private.c +25 -12
  22. data/contrib/zstd/{common → lib/common}/error_private.h +14 -10
  23. data/contrib/zstd/{common → lib/common}/fse.h +173 -92
  24. data/contrib/zstd/{common → lib/common}/fse_decompress.c +149 -85
  25. data/contrib/zstd/lib/common/huf.h +361 -0
  26. data/contrib/zstd/{common → lib/common}/mem.h +115 -59
  27. data/contrib/zstd/lib/common/pool.c +350 -0
  28. data/contrib/zstd/lib/common/pool.h +84 -0
  29. data/contrib/zstd/lib/common/threading.c +122 -0
  30. data/contrib/zstd/lib/common/threading.h +155 -0
  31. data/contrib/zstd/{common → lib/common}/xxhash.c +55 -96
  32. data/contrib/zstd/{common → lib/common}/xxhash.h +23 -47
  33. data/contrib/zstd/lib/common/zstd_common.c +83 -0
  34. data/contrib/zstd/lib/common/zstd_deps.h +111 -0
  35. data/contrib/zstd/lib/common/zstd_errors.h +95 -0
  36. data/contrib/zstd/lib/common/zstd_internal.h +478 -0
  37. data/contrib/zstd/{compress → lib/compress}/fse_compress.c +214 -319
  38. data/contrib/zstd/lib/compress/hist.c +181 -0
  39. data/contrib/zstd/lib/compress/hist.h +75 -0
  40. data/contrib/zstd/lib/compress/huf_compress.c +913 -0
  41. data/contrib/zstd/lib/compress/zstd_compress.c +5208 -0
  42. data/contrib/zstd/lib/compress/zstd_compress_internal.h +1203 -0
  43. data/contrib/zstd/lib/compress/zstd_compress_literals.c +158 -0
  44. data/contrib/zstd/lib/compress/zstd_compress_literals.h +29 -0
  45. data/contrib/zstd/lib/compress/zstd_compress_sequences.c +433 -0
  46. data/contrib/zstd/lib/compress/zstd_compress_sequences.h +54 -0
  47. data/contrib/zstd/lib/compress/zstd_compress_superblock.c +849 -0
  48. data/contrib/zstd/lib/compress/zstd_compress_superblock.h +32 -0
  49. data/contrib/zstd/lib/compress/zstd_cwksp.h +561 -0
  50. data/contrib/zstd/lib/compress/zstd_double_fast.c +521 -0
  51. data/contrib/zstd/lib/compress/zstd_double_fast.h +38 -0
  52. data/contrib/zstd/lib/compress/zstd_fast.c +496 -0
  53. data/contrib/zstd/lib/compress/zstd_fast.h +37 -0
  54. data/contrib/zstd/lib/compress/zstd_lazy.c +1412 -0
  55. data/contrib/zstd/lib/compress/zstd_lazy.h +87 -0
  56. data/contrib/zstd/lib/compress/zstd_ldm.c +660 -0
  57. data/contrib/zstd/lib/compress/zstd_ldm.h +116 -0
  58. data/contrib/zstd/lib/compress/zstd_opt.c +1345 -0
  59. data/contrib/zstd/lib/compress/zstd_opt.h +56 -0
  60. data/contrib/zstd/lib/compress/zstdmt_compress.c +1811 -0
  61. data/contrib/zstd/lib/compress/zstdmt_compress.h +110 -0
  62. data/contrib/zstd/lib/decompress/huf_decompress.c +1350 -0
  63. data/contrib/zstd/lib/decompress/zstd_ddict.c +244 -0
  64. data/contrib/zstd/lib/decompress/zstd_ddict.h +44 -0
  65. data/contrib/zstd/lib/decompress/zstd_decompress.c +1930 -0
  66. data/contrib/zstd/lib/decompress/zstd_decompress_block.c +1540 -0
  67. data/contrib/zstd/lib/decompress/zstd_decompress_block.h +62 -0
  68. data/contrib/zstd/lib/decompress/zstd_decompress_internal.h +190 -0
  69. data/contrib/zstd/{common → lib/deprecated}/zbuff.h +68 -45
  70. data/contrib/zstd/lib/deprecated/zbuff_common.c +26 -0
  71. data/contrib/zstd/lib/deprecated/zbuff_compress.c +147 -0
  72. data/contrib/zstd/lib/deprecated/zbuff_decompress.c +75 -0
  73. data/contrib/zstd/lib/dictBuilder/cover.c +1245 -0
  74. data/contrib/zstd/lib/dictBuilder/cover.h +157 -0
  75. data/contrib/zstd/{dictBuilder → lib/dictBuilder}/divsufsort.c +3 -3
  76. data/contrib/zstd/{dictBuilder → lib/dictBuilder}/divsufsort.h +0 -0
  77. data/contrib/zstd/lib/dictBuilder/fastcover.c +758 -0
  78. data/contrib/zstd/{dictBuilder → lib/dictBuilder}/zdict.c +318 -194
  79. data/contrib/zstd/lib/dictBuilder/zdict.h +305 -0
  80. data/contrib/zstd/{legacy → lib/legacy}/zstd_legacy.h +171 -15
  81. data/contrib/zstd/{legacy → lib/legacy}/zstd_v01.c +191 -124
  82. data/contrib/zstd/{legacy → lib/legacy}/zstd_v01.h +19 -5
  83. data/contrib/zstd/{legacy → lib/legacy}/zstd_v02.c +125 -125
  84. data/contrib/zstd/{legacy → lib/legacy}/zstd_v02.h +19 -5
  85. data/contrib/zstd/{legacy → lib/legacy}/zstd_v03.c +125 -124
  86. data/contrib/zstd/{legacy → lib/legacy}/zstd_v03.h +20 -6
  87. data/contrib/zstd/{legacy → lib/legacy}/zstd_v04.c +151 -299
  88. data/contrib/zstd/{legacy → lib/legacy}/zstd_v04.h +19 -5
  89. data/contrib/zstd/{legacy → lib/legacy}/zstd_v05.c +237 -243
  90. data/contrib/zstd/{legacy → lib/legacy}/zstd_v05.h +19 -6
  91. data/contrib/zstd/{legacy → lib/legacy}/zstd_v06.c +130 -143
  92. data/contrib/zstd/{legacy → lib/legacy}/zstd_v06.h +18 -5
  93. data/contrib/zstd/{legacy → lib/legacy}/zstd_v07.c +158 -157
  94. data/contrib/zstd/{legacy → lib/legacy}/zstd_v07.h +19 -5
  95. data/contrib/zstd/lib/libzstd.pc.in +15 -0
  96. data/contrib/zstd/lib/zstd.h +2391 -0
  97. data/ext/depend +2 -0
  98. data/ext/extconf.rb +15 -6
  99. data/ext/extzstd.c +76 -145
  100. data/ext/extzstd.h +80 -31
  101. data/ext/extzstd_stream.c +417 -142
  102. data/ext/libzstd_conf.h +8 -0
  103. data/ext/zstd_common.c +10 -7
  104. data/ext/zstd_compress.c +14 -5
  105. data/ext/zstd_decompress.c +5 -4
  106. data/ext/zstd_dictbuilder.c +9 -4
  107. data/ext/zstd_dictbuilder_fastcover.c +3 -0
  108. data/ext/zstd_legacy_v01.c +3 -1
  109. data/ext/zstd_legacy_v02.c +3 -1
  110. data/ext/zstd_legacy_v03.c +3 -1
  111. data/ext/zstd_legacy_v04.c +3 -1
  112. data/ext/zstd_legacy_v05.c +3 -1
  113. data/ext/zstd_legacy_v06.c +3 -1
  114. data/ext/zstd_legacy_v07.c +3 -1
  115. data/gemstub.rb +10 -24
  116. data/lib/extzstd.rb +64 -179
  117. data/lib/extzstd/version.rb +6 -1
  118. data/test/test_basic.rb +9 -6
  119. metadata +113 -57
  120. data/HISTORY.ja +0 -5
  121. data/contrib/zstd/common/entropy_common.c +0 -225
  122. data/contrib/zstd/common/huf.h +0 -228
  123. data/contrib/zstd/common/zstd_common.c +0 -83
  124. data/contrib/zstd/common/zstd_errors.h +0 -60
  125. data/contrib/zstd/common/zstd_internal.h +0 -267
  126. data/contrib/zstd/compress/huf_compress.c +0 -533
  127. data/contrib/zstd/compress/zbuff_compress.c +0 -319
  128. data/contrib/zstd/compress/zstd_compress.c +0 -3264
  129. data/contrib/zstd/compress/zstd_opt.h +0 -900
  130. data/contrib/zstd/decompress/huf_decompress.c +0 -883
  131. data/contrib/zstd/decompress/zbuff_decompress.c +0 -252
  132. data/contrib/zstd/decompress/zstd_decompress.c +0 -1842
  133. data/contrib/zstd/dictBuilder/zdict.h +0 -111
  134. data/contrib/zstd/zstd.h +0 -640
@@ -1,3 +1,8 @@
1
1
  module Zstd
2
- VERSION = "0.1"
2
+ verreg = /^\s*[\-\*]\s+version:\s*(\d+(?:\.\w+)+)\s*$/i
3
+ unless File.read("#{__dir__}/../../README.md", mode: "rt") =~ verreg
4
+ raise "``version'' is not defined or bad syntax in ``README.md''"
5
+ end
6
+
7
+ VERSION = String($1)
3
8
  end
data/test/test_basic.rb CHANGED
@@ -9,11 +9,6 @@ class TestZstd < Test::Unit::TestCase
9
9
  src = "ABCDEFGabcdefg" * 50
10
10
  assert_equal(src, Zstd.decode(Zstd.encode(src), src.bytesize))
11
11
  #assert_raise(Zstd::Error) { Zstd.decode("", 1111) }
12
- d1 = Zstd.encode(src)
13
- assert_same(src.tainted?, Zstd.encode(src).tainted?)
14
- src1 = src.dup
15
- src1.taint
16
- assert_same(src1.tainted?, Zstd.encode(src1).tainted?)
17
12
  end
18
13
 
19
14
  def test_huge
@@ -32,7 +27,15 @@ class TestZstd < Test::Unit::TestCase
32
27
  d.pos = 0
33
28
  size_b = 0
34
29
  md5b = Digest::MD5.new
35
- Zstd.decode(d) { |z| buf = ""; while z.read(654321, buf); size_b += buf.bytesize; md5b.update buf; end }
30
+ partial_list = [262144, 1, 262144, 262142, 524288, 524280, 99, 999, 9999, 99999, 999999, 9999999, nil]
31
+ Zstd.decode(d) do |z|
32
+ buf = ""
33
+ while z.read(s = partial_list.shift, buf)
34
+ assert_equal s, buf.bytesize if s
35
+ size_b += buf.bytesize
36
+ md5b.update buf
37
+ end
38
+ end
36
39
  assert_equal size_a, size_b
37
40
  assert_equal(md5a.hexdigest, md5b.hexdigest)
38
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: extzstd
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - dearblue
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-02 00:00:00.000000000 Z
11
+ date: 2021-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -16,35 +16,39 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '12.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
27
- description: 'unoficial ruby bindings for Zstandard (zstd) <https://github.com/Cyan4973/zstd>.
26
+ version: '12.0'
27
+ description: 'unoficial ruby bindings for Zstandard (zstd) <https://github.com/facebook/zstd>.
28
28
 
29
- '
29
+ '
30
30
  email: dearblue@users.osdn.me
31
31
  executables: []
32
32
  extensions:
33
33
  - ext/extconf.rb
34
34
  extra_rdoc_files:
35
- - HISTORY.ja
35
+ - HISTORY.ja.md
36
36
  - LICENSE
37
37
  - README.md
38
+ - contrib/zstd/CHANGELOG
38
39
  - contrib/zstd/LICENSE
39
40
  - contrib/zstd/README.md
41
+ - contrib/zstd/lib/README.md
40
42
  - ext/extzstd.c
41
43
  - ext/extzstd.h
42
44
  - ext/extzstd_nogvls.h
43
45
  - ext/extzstd_stream.c
46
+ - ext/libzstd_conf.h
44
47
  - ext/zstd_common.c
45
48
  - ext/zstd_compress.c
46
49
  - ext/zstd_decompress.c
47
50
  - ext/zstd_dictbuilder.c
51
+ - ext/zstd_dictbuilder_fastcover.c
48
52
  - ext/zstd_legacy_v01.c
49
53
  - ext/zstd_legacy_v02.c
50
54
  - ext/zstd_legacy_v03.c
@@ -55,63 +59,116 @@ extra_rdoc_files:
55
59
  - lib/extzstd.rb
56
60
  - lib/extzstd/version.rb
57
61
  files:
58
- - HISTORY.ja
62
+ - HISTORY.ja.md
59
63
  - LICENSE
60
64
  - README.md
61
65
  - Rakefile
66
+ - contrib/zstd/CHANGELOG
67
+ - contrib/zstd/CODE_OF_CONDUCT.md
68
+ - contrib/zstd/CONTRIBUTING.md
69
+ - contrib/zstd/COPYING
62
70
  - contrib/zstd/LICENSE
71
+ - contrib/zstd/Makefile
63
72
  - contrib/zstd/README.md
64
- - contrib/zstd/common/bitstream.h
65
- - contrib/zstd/common/entropy_common.c
66
- - contrib/zstd/common/error_private.c
67
- - contrib/zstd/common/error_private.h
68
- - contrib/zstd/common/fse.h
69
- - contrib/zstd/common/fse_decompress.c
70
- - contrib/zstd/common/huf.h
71
- - contrib/zstd/common/mem.h
72
- - contrib/zstd/common/xxhash.c
73
- - contrib/zstd/common/xxhash.h
74
- - contrib/zstd/common/zbuff.h
75
- - contrib/zstd/common/zstd_common.c
76
- - contrib/zstd/common/zstd_errors.h
77
- - contrib/zstd/common/zstd_internal.h
78
- - contrib/zstd/compress/fse_compress.c
79
- - contrib/zstd/compress/huf_compress.c
80
- - contrib/zstd/compress/zbuff_compress.c
81
- - contrib/zstd/compress/zstd_compress.c
82
- - contrib/zstd/compress/zstd_opt.h
83
- - contrib/zstd/decompress/huf_decompress.c
84
- - contrib/zstd/decompress/zbuff_decompress.c
85
- - contrib/zstd/decompress/zstd_decompress.c
86
- - contrib/zstd/dictBuilder/divsufsort.c
87
- - contrib/zstd/dictBuilder/divsufsort.h
88
- - contrib/zstd/dictBuilder/zdict.c
89
- - contrib/zstd/dictBuilder/zdict.h
90
- - contrib/zstd/legacy/zstd_legacy.h
91
- - contrib/zstd/legacy/zstd_v01.c
92
- - contrib/zstd/legacy/zstd_v01.h
93
- - contrib/zstd/legacy/zstd_v02.c
94
- - contrib/zstd/legacy/zstd_v02.h
95
- - contrib/zstd/legacy/zstd_v03.c
96
- - contrib/zstd/legacy/zstd_v03.h
97
- - contrib/zstd/legacy/zstd_v04.c
98
- - contrib/zstd/legacy/zstd_v04.h
99
- - contrib/zstd/legacy/zstd_v05.c
100
- - contrib/zstd/legacy/zstd_v05.h
101
- - contrib/zstd/legacy/zstd_v06.c
102
- - contrib/zstd/legacy/zstd_v06.h
103
- - contrib/zstd/legacy/zstd_v07.c
104
- - contrib/zstd/legacy/zstd_v07.h
105
- - contrib/zstd/zstd.h
73
+ - contrib/zstd/TESTING.md
74
+ - contrib/zstd/appveyor.yml
75
+ - contrib/zstd/lib/BUCK
76
+ - contrib/zstd/lib/Makefile
77
+ - contrib/zstd/lib/README.md
78
+ - contrib/zstd/lib/common/bitstream.h
79
+ - contrib/zstd/lib/common/compiler.h
80
+ - contrib/zstd/lib/common/cpu.h
81
+ - contrib/zstd/lib/common/debug.c
82
+ - contrib/zstd/lib/common/debug.h
83
+ - contrib/zstd/lib/common/entropy_common.c
84
+ - contrib/zstd/lib/common/error_private.c
85
+ - contrib/zstd/lib/common/error_private.h
86
+ - contrib/zstd/lib/common/fse.h
87
+ - contrib/zstd/lib/common/fse_decompress.c
88
+ - contrib/zstd/lib/common/huf.h
89
+ - contrib/zstd/lib/common/mem.h
90
+ - contrib/zstd/lib/common/pool.c
91
+ - contrib/zstd/lib/common/pool.h
92
+ - contrib/zstd/lib/common/threading.c
93
+ - contrib/zstd/lib/common/threading.h
94
+ - contrib/zstd/lib/common/xxhash.c
95
+ - contrib/zstd/lib/common/xxhash.h
96
+ - contrib/zstd/lib/common/zstd_common.c
97
+ - contrib/zstd/lib/common/zstd_deps.h
98
+ - contrib/zstd/lib/common/zstd_errors.h
99
+ - contrib/zstd/lib/common/zstd_internal.h
100
+ - contrib/zstd/lib/compress/fse_compress.c
101
+ - contrib/zstd/lib/compress/hist.c
102
+ - contrib/zstd/lib/compress/hist.h
103
+ - contrib/zstd/lib/compress/huf_compress.c
104
+ - contrib/zstd/lib/compress/zstd_compress.c
105
+ - contrib/zstd/lib/compress/zstd_compress_internal.h
106
+ - contrib/zstd/lib/compress/zstd_compress_literals.c
107
+ - contrib/zstd/lib/compress/zstd_compress_literals.h
108
+ - contrib/zstd/lib/compress/zstd_compress_sequences.c
109
+ - contrib/zstd/lib/compress/zstd_compress_sequences.h
110
+ - contrib/zstd/lib/compress/zstd_compress_superblock.c
111
+ - contrib/zstd/lib/compress/zstd_compress_superblock.h
112
+ - contrib/zstd/lib/compress/zstd_cwksp.h
113
+ - contrib/zstd/lib/compress/zstd_double_fast.c
114
+ - contrib/zstd/lib/compress/zstd_double_fast.h
115
+ - contrib/zstd/lib/compress/zstd_fast.c
116
+ - contrib/zstd/lib/compress/zstd_fast.h
117
+ - contrib/zstd/lib/compress/zstd_lazy.c
118
+ - contrib/zstd/lib/compress/zstd_lazy.h
119
+ - contrib/zstd/lib/compress/zstd_ldm.c
120
+ - contrib/zstd/lib/compress/zstd_ldm.h
121
+ - contrib/zstd/lib/compress/zstd_opt.c
122
+ - contrib/zstd/lib/compress/zstd_opt.h
123
+ - contrib/zstd/lib/compress/zstdmt_compress.c
124
+ - contrib/zstd/lib/compress/zstdmt_compress.h
125
+ - contrib/zstd/lib/decompress/huf_decompress.c
126
+ - contrib/zstd/lib/decompress/zstd_ddict.c
127
+ - contrib/zstd/lib/decompress/zstd_ddict.h
128
+ - contrib/zstd/lib/decompress/zstd_decompress.c
129
+ - contrib/zstd/lib/decompress/zstd_decompress_block.c
130
+ - contrib/zstd/lib/decompress/zstd_decompress_block.h
131
+ - contrib/zstd/lib/decompress/zstd_decompress_internal.h
132
+ - contrib/zstd/lib/deprecated/zbuff.h
133
+ - contrib/zstd/lib/deprecated/zbuff_common.c
134
+ - contrib/zstd/lib/deprecated/zbuff_compress.c
135
+ - contrib/zstd/lib/deprecated/zbuff_decompress.c
136
+ - contrib/zstd/lib/dictBuilder/cover.c
137
+ - contrib/zstd/lib/dictBuilder/cover.h
138
+ - contrib/zstd/lib/dictBuilder/divsufsort.c
139
+ - contrib/zstd/lib/dictBuilder/divsufsort.h
140
+ - contrib/zstd/lib/dictBuilder/fastcover.c
141
+ - contrib/zstd/lib/dictBuilder/zdict.c
142
+ - contrib/zstd/lib/dictBuilder/zdict.h
143
+ - contrib/zstd/lib/legacy/zstd_legacy.h
144
+ - contrib/zstd/lib/legacy/zstd_v01.c
145
+ - contrib/zstd/lib/legacy/zstd_v01.h
146
+ - contrib/zstd/lib/legacy/zstd_v02.c
147
+ - contrib/zstd/lib/legacy/zstd_v02.h
148
+ - contrib/zstd/lib/legacy/zstd_v03.c
149
+ - contrib/zstd/lib/legacy/zstd_v03.h
150
+ - contrib/zstd/lib/legacy/zstd_v04.c
151
+ - contrib/zstd/lib/legacy/zstd_v04.h
152
+ - contrib/zstd/lib/legacy/zstd_v05.c
153
+ - contrib/zstd/lib/legacy/zstd_v05.h
154
+ - contrib/zstd/lib/legacy/zstd_v06.c
155
+ - contrib/zstd/lib/legacy/zstd_v06.h
156
+ - contrib/zstd/lib/legacy/zstd_v07.c
157
+ - contrib/zstd/lib/legacy/zstd_v07.h
158
+ - contrib/zstd/lib/libzstd.pc.in
159
+ - contrib/zstd/lib/zstd.h
160
+ - ext/depend
106
161
  - ext/extconf.rb
107
162
  - ext/extzstd.c
108
163
  - ext/extzstd.h
109
164
  - ext/extzstd_nogvls.h
110
165
  - ext/extzstd_stream.c
166
+ - ext/libzstd_conf.h
111
167
  - ext/zstd_common.c
112
168
  - ext/zstd_compress.c
113
169
  - ext/zstd_decompress.c
114
170
  - ext/zstd_dictbuilder.c
171
+ - ext/zstd_dictbuilder_fastcover.c
115
172
  - ext/zstd_legacy_v01.c
116
173
  - ext/zstd_legacy_v02.c
117
174
  - ext/zstd_legacy_v03.c
@@ -123,11 +180,11 @@ files:
123
180
  - lib/extzstd.rb
124
181
  - lib/extzstd/version.rb
125
182
  - test/test_basic.rb
126
- homepage: https://osdn.jp/projects/rutsubo/
183
+ homepage: https://github.com/dearblue/ruby-extzstd/
127
184
  licenses:
128
- - 2-clause BSD License
185
+ - BSD-2-Clause
129
186
  metadata: {}
130
- post_install_message:
187
+ post_install_message:
131
188
  rdoc_options:
132
189
  - "--charset"
133
190
  - UTF-8
@@ -146,9 +203,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
203
  - !ruby/object:Gem::Version
147
204
  version: '0'
148
205
  requirements: []
149
- rubyforge_project:
150
- rubygems_version: 2.6.4
151
- signing_key:
206
+ rubygems_version: 3.2.14
207
+ signing_key:
152
208
  specification_version: 4
153
209
  summary: ruby bindings for Zstandard (zstd)
154
210
  test_files: []
data/HISTORY.ja DELETED
@@ -1,5 +0,0 @@
1
- # extzstd の更新履歴
2
-
3
- ## extzstd-0.1 (平成28年11月2日 (水曜日))
4
-
5
- 初版
@@ -1,225 +0,0 @@
1
- /*
2
- Common functions of New Generation Entropy library
3
- Copyright (C) 2016, Yann Collet.
4
-
5
- BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
6
-
7
- Redistribution and use in source and binary forms, with or without
8
- modification, are permitted provided that the following conditions are
9
- met:
10
-
11
- * Redistributions of source code must retain the above copyright
12
- notice, this list of conditions and the following disclaimer.
13
- * Redistributions in binary form must reproduce the above
14
- copyright notice, this list of conditions and the following disclaimer
15
- in the documentation and/or other materials provided with the
16
- distribution.
17
-
18
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
-
30
- You can contact the author at :
31
- - FSE+HUF source repository : https://github.com/Cyan4973/FiniteStateEntropy
32
- - Public forum : https://groups.google.com/forum/#!forum/lz4c
33
- *************************************************************************** */
34
-
35
- /* *************************************
36
- * Dependencies
37
- ***************************************/
38
- #include "mem.h"
39
- #include "error_private.h" /* ERR_*, ERROR */
40
- #define FSE_STATIC_LINKING_ONLY /* FSE_MIN_TABLELOG */
41
- #include "fse.h"
42
- #define HUF_STATIC_LINKING_ONLY /* HUF_TABLELOG_ABSOLUTEMAX */
43
- #include "huf.h"
44
-
45
-
46
- /*-****************************************
47
- * FSE Error Management
48
- ******************************************/
49
- unsigned FSE_isError(size_t code) { return ERR_isError(code); }
50
-
51
- const char* FSE_getErrorName(size_t code) { return ERR_getErrorName(code); }
52
-
53
-
54
- /* **************************************************************
55
- * HUF Error Management
56
- ****************************************************************/
57
- unsigned HUF_isError(size_t code) { return ERR_isError(code); }
58
-
59
- const char* HUF_getErrorName(size_t code) { return ERR_getErrorName(code); }
60
-
61
-
62
- /*-**************************************************************
63
- * FSE NCount encoding-decoding
64
- ****************************************************************/
65
- static short FSE_abs(short a) { return (short)(a<0 ? -a : a); }
66
-
67
- size_t FSE_readNCount (short* normalizedCounter, unsigned* maxSVPtr, unsigned* tableLogPtr,
68
- const void* headerBuffer, size_t hbSize)
69
- {
70
- const BYTE* const istart = (const BYTE*) headerBuffer;
71
- const BYTE* const iend = istart + hbSize;
72
- const BYTE* ip = istart;
73
- int nbBits;
74
- int remaining;
75
- int threshold;
76
- U32 bitStream;
77
- int bitCount;
78
- unsigned charnum = 0;
79
- int previous0 = 0;
80
-
81
- if (hbSize < 4) return ERROR(srcSize_wrong);
82
- bitStream = MEM_readLE32(ip);
83
- nbBits = (bitStream & 0xF) + FSE_MIN_TABLELOG; /* extract tableLog */
84
- if (nbBits > FSE_TABLELOG_ABSOLUTE_MAX) return ERROR(tableLog_tooLarge);
85
- bitStream >>= 4;
86
- bitCount = 4;
87
- *tableLogPtr = nbBits;
88
- remaining = (1<<nbBits)+1;
89
- threshold = 1<<nbBits;
90
- nbBits++;
91
-
92
- while ((remaining>1) & (charnum<=*maxSVPtr)) {
93
- if (previous0) {
94
- unsigned n0 = charnum;
95
- while ((bitStream & 0xFFFF) == 0xFFFF) {
96
- n0 += 24;
97
- if (ip < iend-5) {
98
- ip += 2;
99
- bitStream = MEM_readLE32(ip) >> bitCount;
100
- } else {
101
- bitStream >>= 16;
102
- bitCount += 16;
103
- } }
104
- while ((bitStream & 3) == 3) {
105
- n0 += 3;
106
- bitStream >>= 2;
107
- bitCount += 2;
108
- }
109
- n0 += bitStream & 3;
110
- bitCount += 2;
111
- if (n0 > *maxSVPtr) return ERROR(maxSymbolValue_tooSmall);
112
- while (charnum < n0) normalizedCounter[charnum++] = 0;
113
- if ((ip <= iend-7) || (ip + (bitCount>>3) <= iend-4)) {
114
- ip += bitCount>>3;
115
- bitCount &= 7;
116
- bitStream = MEM_readLE32(ip) >> bitCount;
117
- } else {
118
- bitStream >>= 2;
119
- } }
120
- { short const max = (short)((2*threshold-1)-remaining);
121
- short count;
122
-
123
- if ((bitStream & (threshold-1)) < (U32)max) {
124
- count = (short)(bitStream & (threshold-1));
125
- bitCount += nbBits-1;
126
- } else {
127
- count = (short)(bitStream & (2*threshold-1));
128
- if (count >= threshold) count -= max;
129
- bitCount += nbBits;
130
- }
131
-
132
- count--; /* extra accuracy */
133
- remaining -= FSE_abs(count);
134
- normalizedCounter[charnum++] = count;
135
- previous0 = !count;
136
- while (remaining < threshold) {
137
- nbBits--;
138
- threshold >>= 1;
139
- }
140
-
141
- if ((ip <= iend-7) || (ip + (bitCount>>3) <= iend-4)) {
142
- ip += bitCount>>3;
143
- bitCount &= 7;
144
- } else {
145
- bitCount -= (int)(8 * (iend - 4 - ip));
146
- ip = iend - 4;
147
- }
148
- bitStream = MEM_readLE32(ip) >> (bitCount & 31);
149
- } } /* while ((remaining>1) & (charnum<=*maxSVPtr)) */
150
- if (remaining != 1) return ERROR(corruption_detected);
151
- if (bitCount > 32) return ERROR(corruption_detected);
152
- *maxSVPtr = charnum-1;
153
-
154
- ip += (bitCount+7)>>3;
155
- return ip-istart;
156
- }
157
-
158
-
159
- /*! HUF_readStats() :
160
- Read compact Huffman tree, saved by HUF_writeCTable().
161
- `huffWeight` is destination buffer.
162
- @return : size read from `src` , or an error Code .
163
- Note : Needed by HUF_readCTable() and HUF_readDTableX?() .
164
- */
165
- size_t HUF_readStats(BYTE* huffWeight, size_t hwSize, U32* rankStats,
166
- U32* nbSymbolsPtr, U32* tableLogPtr,
167
- const void* src, size_t srcSize)
168
- {
169
- U32 weightTotal;
170
- const BYTE* ip = (const BYTE*) src;
171
- size_t iSize;
172
- size_t oSize;
173
-
174
- if (!srcSize) return ERROR(srcSize_wrong);
175
- iSize = ip[0];
176
- /* memset(huffWeight, 0, hwSize); *//* is not necessary, even though some analyzer complain ... */
177
-
178
- if (iSize >= 128) { /* special header */
179
- oSize = iSize - 127;
180
- iSize = ((oSize+1)/2);
181
- if (iSize+1 > srcSize) return ERROR(srcSize_wrong);
182
- if (oSize >= hwSize) return ERROR(corruption_detected);
183
- ip += 1;
184
- { U32 n;
185
- for (n=0; n<oSize; n+=2) {
186
- huffWeight[n] = ip[n/2] >> 4;
187
- huffWeight[n+1] = ip[n/2] & 15;
188
- } } }
189
- else { /* header compressed with FSE (normal case) */
190
- if (iSize+1 > srcSize) return ERROR(srcSize_wrong);
191
- oSize = FSE_decompress(huffWeight, hwSize-1, ip+1, iSize); /* max (hwSize-1) values decoded, as last one is implied */
192
- if (FSE_isError(oSize)) return oSize;
193
- }
194
-
195
- /* collect weight stats */
196
- memset(rankStats, 0, (HUF_TABLELOG_ABSOLUTEMAX + 1) * sizeof(U32));
197
- weightTotal = 0;
198
- { U32 n; for (n=0; n<oSize; n++) {
199
- if (huffWeight[n] >= HUF_TABLELOG_ABSOLUTEMAX) return ERROR(corruption_detected);
200
- rankStats[huffWeight[n]]++;
201
- weightTotal += (1 << huffWeight[n]) >> 1;
202
- } }
203
- if (weightTotal == 0) return ERROR(corruption_detected);
204
-
205
- /* get last non-null symbol weight (implied, total must be 2^n) */
206
- { U32 const tableLog = BIT_highbit32(weightTotal) + 1;
207
- if (tableLog > HUF_TABLELOG_ABSOLUTEMAX) return ERROR(corruption_detected);
208
- *tableLogPtr = tableLog;
209
- /* determine last weight */
210
- { U32 const total = 1 << tableLog;
211
- U32 const rest = total - weightTotal;
212
- U32 const verif = 1 << BIT_highbit32(rest);
213
- U32 const lastWeight = BIT_highbit32(rest) + 1;
214
- if (verif != rest) return ERROR(corruption_detected); /* last value must be a clean power of 2 */
215
- huffWeight[oSize] = (BYTE)lastWeight;
216
- rankStats[lastWeight]++;
217
- } }
218
-
219
- /* check tree construction validity */
220
- if ((rankStats[1] < 2) || (rankStats[1] & 1)) return ERROR(corruption_detected); /* by construction : at least 2 elts of rank 1, must be even */
221
-
222
- /* results */
223
- *nbSymbolsPtr = (U32)(oSize+1);
224
- return iSize+1;
225
- }