gnugo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnugo-devel] PATCH: avoid closing stdin when reading sgf file


From: Thien-Thi Nguyen
Subject: [gnugo-devel] PATCH: avoid closing stdin when reading sgf file
Date: Wed, 08 Sep 2004 15:23:59 +0200

hello,

here is a small patch that makes func `readsgffile' not close stdin
when given the input file "-".  caller can always do that afterwards
if desired.  this patch is made against the 3.3.15 distribution.

here is a suitable ChangeLog entry

2004-08-15  Thien-Thi Nguyen  <address@hidden>  (tiny change)

        * sgfnode.c (readsgffile): Do not fclose stdin.

i also added a small comment to better document the behavior.

thi

_________________________________________
diff -u sgfnode.c.ORIG sgfnode.c
--- sgfnode.c.ORIG      Wed Jan  1 16:48:51 2003
+++ sgfnode.c   Sun Aug 15 20:31:11 2004
@@ -1116,6 +1116,7 @@
 /*
  * Wrapper around readsgf which reads from a file rather than a string.
  * Returns NULL if file will not open, or some other parsing error.
+ * Filename "-" means read from stdin, and leave it open when done.
  */
 
 SGFNode *
@@ -1136,7 +1137,8 @@
   nexttoken();
   gametree(&root, NULL, LAX_SGF);
 
-  fclose(sgffile);
+  if (sgffile != stdin)
+    fclose(sgffile);
 
   if (sgferr) {
     fprintf(stderr, "Parse error: %s at position %d\n", sgferr, sgferrpos);






reply via email to

[Prev in Thread] Current Thread [Next in Thread]