From fbc47da5516220ce5022fa83f393c4dfd9f898de Mon Sep 17 00:00:00 2001 From: "Sergey V. Zhdanovskih" Date: Mon, 28 Aug 2023 21:16:21 +0300 Subject: [PATCH] Minor improvement --- .../GKCore/GDModel/Providers/GEDCOM/GEDCOMUtils.cs | 13 ++++++++++++- .../GDModel/Providers/GEDCOM/GEDCOMUtilsTests.cs | 4 ++++ projects/GKTests/Resources/test_aq.ged | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/projects/GKCore/GDModel/Providers/GEDCOM/GEDCOMUtils.cs b/projects/GKCore/GDModel/Providers/GEDCOM/GEDCOMUtils.cs index 40acad729..465f48b3b 100644 --- a/projects/GKCore/GDModel/Providers/GEDCOM/GEDCOMUtils.cs +++ b/projects/GKCore/GDModel/Providers/GEDCOM/GEDCOMUtils.cs @@ -300,7 +300,9 @@ public static string ParseXRefPointer(string str, out string xref) char chr = str[i]; if (chr == GEDCOMConsts.PointerDelimiter) { if (init == -1) { - init = i; + if (i == strBeg) { + init = i; + } } else { fin = i; xref = str.Substring(init + 1, fin - 1 - init); @@ -477,6 +479,9 @@ public static string ParseRangeDate(GDMDateRange date, string strValue) // Format: AFT DATE | BEF DATE | BET AFT_DATE AND BEF_DATE public static string ParseRangeDate(GDMTree owner, GDMDateRange date, GEDCOMParser strTok) { + /*GEDCOMFormat format = (owner == null) ? GEDCOMFormat.gf_Native : owner.Format; + bool isAQDeviance = (format == GEDCOMFormat.gf_AncestQuest);*/ + strTok.SkipWhitespaces(); var token = strTok.CurrentToken; @@ -494,10 +499,16 @@ public static string ParseRangeDate(GDMTree owner, GDMDateRange date, GEDCOMPars ParseDate(owner, date.Before, strTok); } else if (dateType == 2) { // "BET" strTok.Next(); + + /*if (isAQDeviance && strTok.RequireSymbol('.')) { + strTok.Next(); + }*/ + ParseDate(owner, date.After, strTok); strTok.SkipWhitespaces(); if (!strTok.RequireWord(GEDCOMConsts.GEDCOMDateRangeArray[3])) { // "AND" + //&& !(isAQDeviance && strTok.RequireSymbol('-'))) { throw new GEDCOMRangeDateException(strTok.GetFullStr()); } diff --git a/projects/GKTests/GDModel/Providers/GEDCOM/GEDCOMUtilsTests.cs b/projects/GKTests/GDModel/Providers/GEDCOM/GEDCOMUtilsTests.cs index e35632ec4..59846386b 100644 --- a/projects/GKTests/GDModel/Providers/GEDCOM/GEDCOMUtilsTests.cs +++ b/projects/GKTests/GDModel/Providers/GEDCOM/GEDCOMUtilsTests.cs @@ -519,6 +519,10 @@ public void Test_ParseXRefPointer() rest = GEDCOMUtils.ParseXRefPointer(null, out xref); Assert.AreEqual("", rest); Assert.AreEqual("", xref); + + rest = GEDCOMUtils.ParseXRefPointer(" ... sample@email.com ", out xref); + Assert.AreEqual("... sample@email.com ", rest); + Assert.AreEqual("", xref); } [Test] diff --git a/projects/GKTests/Resources/test_aq.ged b/projects/GKTests/Resources/test_aq.ged index 892c2ebcf..c735c75e1 100644 --- a/projects/GKTests/Resources/test_aq.ged +++ b/projects/GKTests/Resources/test_aq.ged @@ -79,7 +79,7 @@ 1 CHIL @I4@ 1 CHIL @I5@ 1 MARR -2 DATE 1 JAN 1920 +2 DATE BET 1 JAN 1920 AND 5 JAN 1920 0 @F2@ FAM 1 HUSB @I3@ 1 WIFE @I6@