lib/dbf/table.rb in dbf-2.0.12 vs lib/dbf/table.rb in dbf-2.0.13
- old
+ new
@@ -227,15 +227,22 @@
private
def build_columns # nodoc
columns = []
@data.seek(DBF_HEADER_SIZE)
- until ["\0", "\r"].include?(first_byte = @data.read(1))
- column_data = first_byte + @data.read(DBF_HEADER_SIZE - 1)
+ while !end_of_record?
+ column_data = @data.read(DBF_HEADER_SIZE)
name, type, length, decimal = column_data.unpack('a10 x a x4 C2')
columns << column_class.new(self, name, type, length, decimal)
end
columns
+ end
+
+ def end_of_record? # nodoc
+ pos = @data.pos
+ byte = @data.read(1)
+ @data.seek(pos)
+ byte[0].ord == 13
end
def foxpro? # nodoc
FOXPRO_VERSIONS.keys.include? version
end