From 3ce26af1676c6f9a71449300a60d35581bf7c37e Mon Sep 17 00:00:00 2001 From: gpmn Date: Fri, 22 Feb 2019 19:36:01 +0800 Subject: [PATCH 1/5] in progress --- datadictionary/datadictionary.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/datadictionary/datadictionary.go b/datadictionary/datadictionary.go index 410ca8ee1..d051d4810 100644 --- a/datadictionary/datadictionary.go +++ b/datadictionary/datadictionary.go @@ -3,6 +3,7 @@ package datadictionary import ( "encoding/xml" + "io" "os" ) @@ -326,6 +327,9 @@ func Parse(path string) (*DataDictionary, error) { doc := new(XMLDoc) decoder := xml.NewDecoder(xmlFile) + decoder.CharsetReader = func(encoding string, input io.Reader) (io.Reader, error) { + return input, nil + } if err := decoder.Decode(doc); err != nil { return nil, err } From 07bfa3c02bd94cdc0d9a0f52876ddfd10fe1fd42 Mon Sep 17 00:00:00 2001 From: gpmn Date: Sat, 2 Mar 2019 00:53:36 +0800 Subject: [PATCH 2/5] https://github.com/quickfixgo/quickfix/issues/366 for Incorrect NumInGroup --- validation.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/validation.go b/validation.go index 6e28b8cd0..0c2167b56 100644 --- a/validation.go +++ b/validation.go @@ -10,15 +10,14 @@ type validator interface { type validatorSettings struct { CheckFieldsOutOfOrder bool - RejectInvalidMessage bool - + RejectInvalidMessage bool } //Default configuration for message validation. //See http://www.quickfixengine.org/quickfix/doc/html/configuration.html. var defaultValidatorSettings = validatorSettings{ CheckFieldsOutOfOrder: true, - RejectInvalidMessage: true, + RejectInvalidMessage: true, } type fixValidator struct { @@ -87,8 +86,6 @@ func validateFIX(d *datadictionary.DataDictionary, settings validatorSettings, m } } - - return nil } @@ -212,6 +209,7 @@ func validateVisitGroupField(fieldDef *datadictionary.FieldDef, fieldStack []Tag return fieldStack, err } } else { + fieldStack = fieldStack[1:] if childDefs[0].Required() { return fieldStack, RequiredTagMissing(Tag(childDefs[0].Tag())) } From dbd1cd31486be22bc1cae2b61ae85155e2410c28 Mon Sep 17 00:00:00 2001 From: gpmn Date: Sat, 2 Mar 2019 11:03:37 +0800 Subject: [PATCH 3/5] move down iteration operation --- validation.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validation.go b/validation.go index 0c2167b56..7520d4b32 100644 --- a/validation.go +++ b/validation.go @@ -209,10 +209,10 @@ func validateVisitGroupField(fieldDef *datadictionary.FieldDef, fieldStack []Tag return fieldStack, err } } else { - fieldStack = fieldStack[1:] if childDefs[0].Required() { return fieldStack, RequiredTagMissing(Tag(childDefs[0].Tag())) } + fieldStack = fieldStack[1:] } childDefs = childDefs[1:] From 488335669d5ef8022b741f79903d414823b58aae Mon Sep 17 00:00:00 2001 From: Adam Krieg Date: Thu, 30 Sep 2021 16:03:21 -0400 Subject: [PATCH 4/5] Trim extra non-ascii characters that can arise from manually editing sequence number files --- filestore.go | 5 +++-- filestore_test.go | 13 +++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/filestore.go b/filestore.go index 120ba83c0..650bd388a 100644 --- a/filestore.go +++ b/filestore.go @@ -22,6 +22,7 @@ import ( "os" "path" "strconv" + "strings" "time" "github.com/pkg/errors" @@ -213,7 +214,7 @@ func (store *fileStore) populateCache() (creationTimePopulated bool, err error) } if senderSeqNumBytes, err := ioutil.ReadFile(store.senderSeqNumsFname); err == nil { - if senderSeqNum, err := strconv.Atoi(string(senderSeqNumBytes)); err == nil { + if senderSeqNum, err := strconv.Atoi(strings.Trim(string(senderSeqNumBytes), "\r\n")); err == nil { if err = store.cache.SetNextSenderMsgSeqNum(senderSeqNum); err != nil { return creationTimePopulated, errors.Wrap(err, "cache set next sender") } @@ -221,7 +222,7 @@ func (store *fileStore) populateCache() (creationTimePopulated bool, err error) } if targetSeqNumBytes, err := ioutil.ReadFile(store.targetSeqNumsFname); err == nil { - if targetSeqNum, err := strconv.Atoi(string(targetSeqNumBytes)); err == nil { + if targetSeqNum, err := strconv.Atoi(strings.Trim(string(targetSeqNumBytes),"\r\n")); err == nil { if err = store.cache.SetNextTargetMsgSeqNum(targetSeqNum); err != nil { return creationTimePopulated, errors.Wrap(err, "cache set next target") } diff --git a/filestore_test.go b/filestore_test.go index 3713ac8a9..efb6a9283 100644 --- a/filestore_test.go +++ b/filestore_test.go @@ -19,10 +19,12 @@ import ( "fmt" "os" "path" + "strconv" "strings" "testing" "time" + assert2 "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" ) @@ -62,3 +64,14 @@ func (suite *FileStoreTestSuite) TearDownTest() { func TestFileStoreTestSuite(t *testing.T) { suite.Run(t, new(FileStoreTestSuite)) } + +func TestStringParse(t *testing.T) { + assert := assert2.New(t) + i, err := strconv.Atoi(strings.Trim("00005\n", "\r\n")) + assert.Nil(err) + assert.Equal(5, i) + + i, err = strconv.Atoi(strings.Trim("00006\r", "\r\n")) + assert.Nil(err) + assert.Equal(6, i) +} From e161d08e7b04f38db5be92bd2db26a7f02b91bc9 Mon Sep 17 00:00:00 2001 From: Adam Krieg Date: Thu, 26 Oct 2023 22:37:45 -0400 Subject: [PATCH 5/5] Go fmt file --- filestore.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filestore.go b/filestore.go index 650bd388a..0d969a16e 100644 --- a/filestore.go +++ b/filestore.go @@ -222,7 +222,7 @@ func (store *fileStore) populateCache() (creationTimePopulated bool, err error) } if targetSeqNumBytes, err := ioutil.ReadFile(store.targetSeqNumsFname); err == nil { - if targetSeqNum, err := strconv.Atoi(strings.Trim(string(targetSeqNumBytes),"\r\n")); err == nil { + if targetSeqNum, err := strconv.Atoi(strings.Trim(string(targetSeqNumBytes), "\r\n")); err == nil { if err = store.cache.SetNextTargetMsgSeqNum(targetSeqNum); err != nil { return creationTimePopulated, errors.Wrap(err, "cache set next target") }