Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/FileFormats/MPS/MPS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,14 @@ function Headers(s::AbstractString)
end

function line_to_items(line)
items = split(line, " "; keepempty = false)
# Split on any whitespace characters. We can't split only on `' '` because
# at least one models in MIPLIB has `\t` as a separator.
#
# This decision assumes that we are parsing a free MPS file, where
# whitespace is disallowed in names. If this ever becomes a problem, we
# could change to the fixed MPS format, where the files are split at the
# usual offsets.
items = split(line, r"\s"; keepempty = false)
return String.(items)
end

Expand Down
10 changes: 10 additions & 0 deletions test/FileFormats/MPS/MPS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1703,6 +1703,16 @@ function test_issue_2792()
return
end

function test_issue_2797_tab()
@test MPS.line_to_items("a b") == ["a", "b"]
@test MPS.line_to_items(" a b") == ["a", "b"]
@test MPS.line_to_items("a\tb") == ["a", "b"]
@test MPS.line_to_items("a\tb") == ["a", "b"]
@test MPS.line_to_items("a\t b") == ["a", "b"]
@test MPS.line_to_items(" a \t b c ") == ["a", "b", "c"]
return
end

end # TestMPS

TestMPS.runtests()
Loading