infused/dbf — Issue #35: Carriage return character does not terminate field descriptor parsing
Author: brenttheisen
Created: 2012-02-02 04:10:58+00:00
State: open

For whatever reason the DBF files I'm working with use a carriage return (\n) instead of a null terminator (\n) to indicate the end of the field descriptor section. So when I attempt to find a record I get something like this...

````irb
ruby-1.9.3-p0 :001 > DBF::Table.new('tkempsch.dbf')
=> #, @version="30", @record_count=3103, @header_length=1160, @record_length=192, @encoding_key="03", @encoding="cp1252", @memo=nil>
ruby-1.9.3-p0 :002 > DBF::Table.new(tkempsch.dbf').find :first
SyntaxError: (eval):1: syntax error, unexpected tDOT2
def ..\..\data.dbc
^
from /Users/brent/dbf/lib/dbf/record.rb:54:in `class_eval'
from /Users/brent/dbf/lib/dbf/record.rb:54:in `block in define_accessors'
from /Users/brent/dbf/lib/dbf/record.rb:52:in `each'
from /Users/brent/dbf/lib/dbf/record.rb:52:in `define_accessors'
from /Users/brent/dbf/lib/dbf/record.rb:14:in `initialize'
from /Users/brent/dbf/lib/dbf/table.rb:95:in `new'
from /Users/brent/dbf/lib/dbf/table.rb:95:in `record'
from /Users/brent/dbf/lib/dbf/table.rb:83:in `block in each'
from /Users/brent/dbf/lib/dbf/table.rb:83:in `times'
from /Users/brent/dbf/lib/dbf/table.rb:83:in `each'
from /Users/brent/dbf/lib/dbf/table.rb:264:in `detect'
from /Users/brent/dbf/lib/dbf/table.rb:264:in `find_first'
from /Users/brent/dbf/lib/dbf/table.rb:182:in `find'
from (irb):2
````

Because the carriage return is not terminating parsing of columns it tries to read the backlink section of the DBF file as a column and create a accessor method for it on the record. This fails because the file path it is trying to make a method name out of contains dots.