Skip to content

Commit

Permalink
LAGraph: Write files in binary mode to avoid different line endings o…
Browse files Browse the repository at this point in the history
…n Windows
  • Loading branch information
mmuetzel committed Oct 23, 2023
1 parent 26465ea commit 3145cde
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion LAGraph/experimental/test/test_SWrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ void test_SWrite_errors (void)
TEST_CHECK (result == GrB_INVALID_VALUE) ;
fclose (f) ;

f = fopen ("error.lagraph", "w") ;
f = fopen ("error.lagraph", "wb") ;
TEST_CHECK (f != NULL) ;

result = LAGraph_SWrite_HeaderStart (f, NULL, msg) ;
Expand Down
2 changes: 1 addition & 1 deletion LAGraph/experimental/utility/LAGraph_SSaveSet.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ int LAGraph_SSaveSet // save a set of matrices from a *.lagraph file
GRB_TRY (GxB_set (desc, GxB_COMPRESSION, GxB_COMPRESSION_LZ4HC + 9)) ;
#endif

f = fopen (filename, "w") ;
f = fopen (filename, "wb") ;
LG_ASSERT_MSG (f != NULL, -1001, "unable to create output file") ;

//--------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion LAGraph/src/test/include/acutest.h
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,7 @@ acutest_cmdline_callback_(int id, const char* arg)
acutest_worker_index_ = atoi(arg);
break;
case 'x':
acutest_xml_output_ = fopen(arg, "w");
acutest_xml_output_ = fopen(arg, "wb");
if (!acutest_xml_output_) {
fprintf(stderr, "Unable to open '%s': %s\n", arg, strerror(errno));
acutest_exit_(2);
Expand Down
8 changes: 4 additions & 4 deletions LAGraph/src/test/test_MMRead.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ void test_MMWrite (void)
// create a file for comments
//----------------------------------------------------------------------

FILE *fcomments = fopen (LG_DATA_DIR "comments.txt", "w") ;
FILE *fcomments = fopen (LG_DATA_DIR "comments.txt", "wb") ;
TEST_CHECK (fcomments != NULL) ;
fprintf (fcomments, " comments for %s\n", aname) ;
fprintf (fcomments, " this file was created by test_MMRead.c\n") ;
Expand All @@ -480,7 +480,7 @@ void test_MMWrite (void)

snprintf (filename, LEN, LG_DATA_DIR "comments_%s", aname) ;
fcomments = fopen (LG_DATA_DIR "comments.txt", "r") ;
FILE *foutput = fopen (filename, "w") ;
FILE *foutput = fopen (filename, "wb") ;
TEST_CHECK (foutput != NULL) ;
TEST_CHECK (fcomments != NULL) ;
OK (LAGraph_MMWrite (A, foutput, fcomments, msg)) ;
Expand Down Expand Up @@ -520,7 +520,7 @@ void test_MMWrite (void)
double a ;
OK (GrB_Matrix_extractElement (&a, A, 0, 0)) ;
TEST_CHECK (isnan (a)) ;
foutput = fopen (filename, "w") ;
foutput = fopen (filename, "wb") ;
fcomments = fopen (LG_DATA_DIR "comments.txt", "r") ;
TEST_CHECK (foutput != NULL) ;
OK (LAGraph_MMWrite (A, foutput, fcomments, msg)) ;
Expand Down Expand Up @@ -724,7 +724,7 @@ void test_array_pattern ( )
// write it to a temporary file
//--------------------------------------------------------------------------

FILE *f = tmpfile ( ) ; // fopen ("/tmp/mine.mtx", "w") ;
FILE *f = tmpfile ( ) ; // fopen ("/tmp/mine.mtx", "wb") ;
OK (LAGraph_MMWrite (A, f, NULL, msg)) ;
TEST_MSG ("Failed to write matrix to a temp file\n") ;
// OK (fclose (f)) ;
Expand Down

0 comments on commit 3145cde

Please sign in to comment.