ascii85_native 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9c131b0e45806651154e7787963fcf0b66caf3c0d178262fc23fc148bd8f5f8
4
- data.tar.gz: 824b411d00c8ef1f02d8cda1073f7f12c705599cd2280a60669f8cd268915cf7
3
+ metadata.gz: c5a51104b93e100797c8b06a127f666fa26aff4dfa5f6303430b382f1ca2fbff
4
+ data.tar.gz: 9e5ce38706d633a007ec233d43107b1b363b0b07ce63b0a0dc392a964f428e27
5
5
  SHA512:
6
- metadata.gz: b659d5d91700f63b9a04df578b8748047cca28a89a5d0105e781c8e0adb8d3f7838c139f394226dbd27612f97a8f2e2986851bcc639e7d2628f6d1883fa508f3
7
- data.tar.gz: e299f89e5df890f1294b6fc8d461a265a155f4285767f87e8cc51459003efc2543e73caf5a6260870df42f6e6322ce3da8ee47024fd4eed6a08eb97760d19070
6
+ metadata.gz: fdc7c43e274d698ea9e60089da2065a9aa63a98ac72ac0a3af2ecbc99e19bbb8d2e0499207e383c6bf9fe46557f38cfd983b1f1e371d06de4a246098048a4715
7
+ data.tar.gz: 01e94a7a9211549fa30bb5a396129743ce758bfa76d19d11d2371fe5063041dd10cc3260d825a8905b0fea4c78f6a6712da98c6c77b9799984e3516f3656864d
@@ -66,7 +66,7 @@ int a85_decoded_size(int input_length) {
66
66
  void a85_decode(const char* input, int input_length, u8* output) {
67
67
  while (input_length) {
68
68
 
69
- while ((*input >= 9 && *input <= 13) || *input == 32) { input++; input_length--;}
69
+ while ((*input >= 9 && *input <= 13) || *input == 32 || *input == 0) { input++; input_length--;}
70
70
 
71
71
  if (input_length < 5) {
72
72
  // Determine represented value in base 85
@@ -91,15 +91,15 @@ void a85_decode(const char* input, int input_length, u8* output) {
91
91
  }
92
92
 
93
93
  // Determine represented value in base 85 while throwing out invalid ascii85 characters
94
- while ((*input >= 9 && *input <= 13) || *input == 32) { input++; input_length--;}
94
+ while ((*input >= 9 && *input <= 13) || *input == 32 || *input == 0) { input++; input_length--;}
95
95
  u32 val = (*(input++) - 33) * 52200625; // 85^4
96
- while ((*input >= 9 && *input <= 13) || *input == 32) { input++; input_length--;}
96
+ while ((*input >= 9 && *input <= 13) || *input == 32 || *input == 0) { input++; input_length--;}
97
97
  val += (*(input++) - 33) * 614125; // 85^3
98
- while ((*input >= 9 && *input <= 13) || *input == 32) { input++; input_length--;}
98
+ while ((*input >= 9 && *input <= 13) || *input == 32 || *input == 0) { input++; input_length--;}
99
99
  val += (*(input++) - 33) * 7225; // 85^2
100
- while ((*input >= 9 && *input <= 13) || *input == 32) { input++; input_length--;}
100
+ while ((*input >= 9 && *input <= 13) || *input == 32 || *input == 0) { input++; input_length--;}
101
101
  val += (*(input++) - 33) * 85; // 85^1
102
- while ((*input >= 9 && *input <= 13) || *input == 32) { input++; input_length--;}
102
+ while ((*input >= 9 && *input <= 13) || *input == 32 || *input == 0) { input++; input_length--;}
103
103
  val += (*(input++) - 33); // 85^0
104
104
 
105
105
  // Write out in big-endian order
@@ -5,7 +5,6 @@ require 'ffi'
5
5
  module Ascii85Native
6
6
  extend FFI::Library
7
7
 
8
- ffi_lib 'c'
9
8
  ffi_lib File.join(File.dirname(__FILE__), 'ascii85_native.so')
10
9
 
11
10
  #void a85_encode(const u8* data, int binlen, char* text, bool append_null);
@@ -20,8 +19,6 @@ module Ascii85Native
20
19
  #void a85_decode(const char* text, int textlen, u8* data);
21
20
  attach_function :a85_decode, [:buffer_in, :int, :buffer_out], :void
22
21
 
23
- attach_function :strlen, [:buffer_in], :int
24
-
25
22
  def self.encode(input, include_delimiter=false)
26
23
  if input.nil? || input.size == 0
27
24
  return '<~~>' if include_delimiter
@@ -69,7 +66,7 @@ module Ascii85Native
69
66
  out_size = self.a85_decoded_size(input.size)
70
67
 
71
68
  FFI::MemoryPointer.new(:uint8, out_size) do |output|
72
- self.a85_decode(in_char, strlen(in_char), output)
69
+ self.a85_decode(in_char, input.size, output)
73
70
  return output.read_string()
74
71
  end
75
72
  end
@@ -80,7 +77,7 @@ module Ascii85Native
80
77
  cursor = 0
81
78
 
82
79
  input.size.times do |i|
83
- if ['\n', '\r', ' '].include?(input[cursor])
80
+ if ["\n", "\r", ' '].include?(input[cursor])
84
81
  cursor += 1
85
82
  next
86
83
  elsif input[cursor] == '<' && input[cursor+1] == '~'
@@ -99,7 +96,7 @@ module Ascii85Native
99
96
  cursor = -1
100
97
 
101
98
  input.size.times do |i|
102
- if ['\n', '\r', ' '].include?(input[cursor])
99
+ if ["\n", "\r", ' '].include?(input[cursor])
103
100
  cursor -= 1
104
101
  next
105
102
  elsif input[cursor] == '>' && input[cursor-1] == '~'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ascii85_native
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Crossfield
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-05 00:00:00.000000000 Z
11
+ date: 2021-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi