Skip to content

Commit 88fac2f

Browse files
committed
The Stanford GraphBase — Release 2025-12-28.
1 parent c0943fd commit 88fac2f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

gb_save.w

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,15 +407,23 @@ corrective actions to be taken in each case, assuming that
407407
static long anomalies; /* problems accumulated by |save_graph| */
408408
static FILE *save_file; /* the file being written */
409409

410-
@ @<External f...@>=
410+
@ We open the file in binary mode. This makes no difference on
411+
UNIX-like operating systems; but it prevents Windows-like systems
412+
from converting the single internal character |'\n'| to the
413+
two external characters |'\r'| and |'\n'|.
414+
(Indeed, with text mode, a graph saved under Windows
415+
cannot be restored under Linux!
416+
But with binary mode that problem goes away.)
417+
418+
@<External f...@>=
411419
long save_graph(g,f)
412420
Graph *g; /* graph to be saved */
413421
char *f; /* name of the file to be created */
414422
{@+@<Local variables for |save_graph|@>@;@#
415423
if (g==NULL || g->vertices==NULL) return -1; /* where is |g|? */
416424
anomalies=0;
417425
@<Figure out the extent of |g|'s internal records@>;
418-
save_file=fopen(f,"w");
426+
save_file=fopen(f,"wb");
419427
if (!save_file) return -2; /* oops, the operating system won't cooperate */
420428
@<Translate |g| into external format@>;
421429
@<Make notes at the end of the file about any changes that were necessary@>;

0 commit comments

Comments
 (0)