lib/fossilize.rb in fossilize-1.0.0 vs lib/fossilize.rb in fossilize-1.1.0
- old
+ new
@@ -52,24 +52,18 @@
# Because this method can accept three different types of parameter (path, String or File)
# we need to do a sanity check on the input parameters.
source_string = check_input(source)
target_string = check_input(target)
- # Create native memory buffers for the input Strings.
- source_ptr = FFI::MemoryPointer.new(:char, source_string.size)
- source_ptr.put_bytes(0, source_string)
- target_ptr = FFI::MemoryPointer.new(:char, target_string.size)
- target_ptr.put_bytes(0, target_string)
-
# Create a bare string to hold to returning delta from the C function that's the
# size of the target + 60 (according to the Fossil source docs).
- delta = (' ' * (target_string.size + 60))
+ delta = ("\0" * (target_string.size + 60))
# create the delta, retaining the size of the delta output and return the delta,
# stripping out any excess left over (needs refinement...).
- delta_size = delta_create(source_ptr, source_ptr.size, target_ptr, target_ptr.size, delta)
- return delta.strip!
+ delta_size = delta_create(source_string, source_string.size, target_string, target_string.size, delta)
+ return delta.rstrip!
end
# Access
# Public Module Method
#
@@ -94,11 +88,10 @@
source_string = check_input(source)
delta_string = check_input(delta)
# Get the eventual size of the deltaed file and create a string to hold it
expected_output_size = delta_output_size(delta_string, delta_string.size)
- puts "expected = #{expected_output_size}"
# The algorithm will return -1 as the output size if there was an error
if expected_output_size == -1
raise MalformedDeltaError, "Was this delta intended for this string/file?"
return nil
@@ -114,10 +107,10 @@
raise DeltaApplicationError,
"Output was #{output_size}, but I expected #{expected_output_size}!"
return nil
end
- return output.strip!
+ return output
end
private
# Access