From 63efbff30c298d8684c0952b0a36c078c6aac60c Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Wed, 25 Jan 2012 23:00:34 -0700 Subject: [PATCH 1/3] add an EOF check, because this test would crash without it: ruby samples/birthdays.rb samples/royal.ged --- lib/gedcom.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gedcom.rb b/lib/gedcom.rb index 99a4508..33eeb52 100644 --- a/lib/gedcom.rb +++ b/lib/gedcom.rb @@ -167,7 +167,7 @@ def detect_rs io rs = "\x0d" mark = io.pos begin - while ch = io.readchar + while !io.eof && ch = io.readchar case ch when 0x0d ch2 = io.readchar From 6445a1b02b4759ded30a0c132628d786121bb4db Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Thu, 26 Jan 2012 21:47:23 -0700 Subject: [PATCH 2/3] fix infinite loop on error (eg. BIRT "DATE abt") --- lib/gedcom_date_parser.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/gedcom_date_parser.rb b/lib/gedcom_date_parser.rb index 6fecdd9..2d95056 100644 --- a/lib/gedcom_date_parser.rb +++ b/lib/gedcom_date_parser.rb @@ -733,7 +733,7 @@ def self.parse_date_part( parser, datePart, type ) end end - state = ST_DT_ERROR if( !transitionFound ) + state = ST_DT_ERROR if( transitionFound == 0 ) end raise DateParseException, "error parsing datepart, general" if( state == ST_DT_ERROR ) @@ -899,7 +899,7 @@ def self.parse_gedcom_date( dateString, date, type = GCTDEFAULT ) end end - state = ST_DV_ERROR if( !transitionFound ) + state = ST_DV_ERROR if( transitionFound == 0 ) end if( state == ST_DV_ERROR ) From ec8ad5b7362dc1adefa231fc2d2ec56b2dc0eec5 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Thu, 5 Jun 2014 14:58:26 -0600 Subject: [PATCH 3/3] avoid crashing with bank CONT or CONC lines --- lib/gedcom.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/gedcom.rb b/lib/gedcom.rb index 33eeb52..38359a5 100644 --- a/lib/gedcom.rb +++ b/lib/gedcom.rb @@ -132,10 +132,10 @@ def concat_data tag, rest @dataStack[-1] << rest else if tag == 'CONT' - @dataStack[-1] << "\n" + rest + @dataStack[-1] << "\n" + (rest || "") elsif tag == 'CONC' old = @dataStack[-1].chomp - @dataStack[-1] = old + rest + @dataStack[-1] = old + (rest || "") end end end