@@ -956,6 +956,9 @@ function Base.read!(io::IO, model::Model)
956956 _set_objective_sense (section, model, lower_line)
957957 continue
958958 end
959+ while _line_continues (section, peeked_line)
960+ line, peeked_line = _readline (io, string (line, ' ' , peeked_line))
961+ end
959962 _parse_section (section, model, cache, line)
960963 end
961964 obj = if isempty (cache. quad_obj_terms)
@@ -971,18 +974,32 @@ function Base.read!(io::IO, model::Model)
971974 return
972975end
973976
977+ function _line_continues (
978+ :: Union{typeof(_KW_OBJECTIVE),typeof(_KW_CONSTRAINTS)} ,
979+ peeked_line:: AbstractString ,
980+ )
981+ return any (Base. Fix1 (startswith, peeked_line), (' +' , ' -' ))
982+ end
983+
984+ _line_continues (:: Any , :: Any ) = false
985+
974986function _readline (io:: IO , line:: AbstractString )
975987 if eof (io)
976988 return line, nothing
977989 end
978990 peeked_line = _strip_comment (string (readline (io)))
979991 if isempty (line)
992+ # If the line is empty, go to the next
980993 return _readline (io, peeked_line)
981994 elseif isempty (peeked_line)
995+ # If the peeked line is empty, get another
982996 return _readline (io, line)
983- elseif any (c -> endswith (line, c), (' +' , ' -' , ' [' , ' =' ))
997+ elseif any (Base. Fix1 (endswith, line), (' +' , ' -' , ' [' , ' =' ))
998+ # If the line ends with a continuation character, read in the next line.
984999 return _readline (io, string (line, ' ' , peeked_line))
985- elseif startswith (peeked_line, ' ]' ) || startswith (peeked_line, ' /' )
1000+ elseif any (Base. Fix1 (startswith, peeked_line), (' ]' , ' /' ))
1001+ # Always read in the next line if it starts with ] or /, which are used
1002+ # in quadratic functions.
9861003 return _readline (io, string (line, ' ' , peeked_line))
9871004 end
9881005 return line, peeked_line
0 commit comments