Skip to content

Commit

Permalink
Don't change newline on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
nhz2 committed Jul 4, 2024
1 parent 30e3fe9 commit 69b0d41
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text=auto eol=lf
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf
12 changes: 2 additions & 10 deletions src/mmwrite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function mmwrite(filename::String, matrix::SparseMatrixCSC)
end

function mmwrite(stream::IO, matrix::SparseMatrixCSC)
nl = get_newline()
nl = "\n"
elem = generate_eltype(eltype(matrix))
sym = generate_symmetric(matrix)

Expand Down Expand Up @@ -62,7 +62,7 @@ function generate_symmetric(m::AbstractMatrix)
end

function generate_entity(i, j, rows, vals, kind::String)
nl = get_newline()
nl = "\n"
if kind == "pattern"
return "$(rows[j]) $i$nl"
elseif kind == "complex"
Expand All @@ -71,11 +71,3 @@ function generate_entity(i, j, rows, vals, kind::String)
return "$(rows[j]) $i $(vals[j])$nl"
end
end

function get_newline()
if Sys.iswindows()
return "\r\n"
else
return "\n"
end
end
3 changes: 1 addition & 2 deletions test/mtx.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@
mmwrite(newfilename, res)

stream = GzipDecompressorStream(open(gz_filename))
adjusted_content = replace(read(stream, String), "\n" => get_newline())
sha_test = bytes2hex(sha256(adjusted_content))
sha_test = bytes2hex(sha256(read(stream, String)))
close(stream)

stream = GzipDecompressorStream(open(newfilename))
Expand Down
8 changes: 0 additions & 8 deletions test/test_utils.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
function get_newline()
if Sys.iswindows()
return "\r\n"
else
return "\n"
end
end

function gunzip(fname)
destname, ext = splitext(fname)
if ext != ".gz"
Expand Down

0 comments on commit 69b0d41

Please sign in to comment.