diff --git a/Project.toml b/Project.toml index 2066dc9..c49cd23 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "FCSFiles" uuid = "d76558cf-badf-52d4-a17e-381ab0b0d937" -version = "0.1.1" +version = "0.1.2" [deps] FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" diff --git a/src/parse.jl b/src/parse.jl index 96da212..bc255ed 100644 --- a/src/parse.jl +++ b/src/parse.jl @@ -33,24 +33,21 @@ function parse_text(io, start_text::Int, end_text::Int) raw_btext = Array{UInt8}(undef, end_text - start_text + 1) read!(io, raw_btext) raw_text = String(raw_btext) - delimiter = raw_text[1] + # initialize iterator, save&skip the delimiter + delimiter, state = iterate(raw_text) + # container for the results text_mappings = Dict{String, String}() - # initialize iterator - iter_result = iterate(raw_text) - while iter_result !== nothing - i, state = iter_result - # found a new key, value pair - if i == '$' - # grab key and ignore escaped delimiters - key, state = grab_word(raw_text, state, delimiter) - # grab value and ignore escaped delimiters - value, state = grab_word(raw_text, state, delimiter) - # FCS keywords are case insensitive so force them uppercase - text_mappings["\$"*uppercase(key)] = value - end - iter_result = iterate(raw_text, state) + while iterate(raw_text, state) !== nothing + # grab key and ignore escaped delimiters + key, state = grab_word(raw_text, state, delimiter) + + # grab value and ignore escaped delimiters + value, state = grab_word(raw_text, state, delimiter) + + # FCS keywords are case insensitive so force everything to uppercase + text_mappings[uppercase(key)] = value end text_mappings end diff --git a/test/runtests.jl b/test/runtests.jl index 44d3d2b..e29ede7 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -24,7 +24,7 @@ using Test, HTTP # load the large file flowrun = load("testdata/testLargeFile.fcs") @test length(flowrun.data) == 50 - @test length(flowrun.params) == 262 + @test length(flowrun.params) == 268 # cleanup rm("testdata/testLargeFile.fcs", force=true)