gnugo-devel
[Top][All Lists]
Advanced

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

Re: [gnugo-devel] trevor_1_18.5


From: Gunnar Farneback
Subject: Re: [gnugo-devel] trevor_1_18.5
Date: Thu, 03 Jan 2002 18:55:32 +0100
User-agent: EMH/1.14.1 SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.3 Emacs/20.7 (sparc-sun-solaris2.7) (with unibyte mode)

(Moved back to the list.)

Dan wrote:
> Trevor wrote:
> > I've been meaning to ask that that requirement be removed, at
> > least until my favorite SGF editor (non-free WinMGT) adds it.
> > 
> > Any reason why GNU Go requires that on the SGF files coming in?
> 
> I agree that the warning error is stupid. I think it's good
> practice to include the FF[4]GM[1] properties. Whether the
> standard mandates it I'm not sure. Anyway it wasn't too hard
> for me to add it to the whole collection of files using an
> emacs macro, which is what I did.

I don't think there's much point in GNU Go complaining about missing
GM or FF properties by default, but if those properties are present
with bad values it should warn.

The appended patch implements this behavior.

- checking of sgf GM and FF properties revised

/Gunnar

Index: sgf/sgfnode.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/sgf/sgfnode.c,v
retrieving revision 1.10
diff -u -r1.10 sgfnode.c
--- sgf/sgfnode.c       15 Dec 2001 14:35:27 -0000      1.10
+++ sgf/sgfnode.c       3 Jan 2002 17:12:39 -0000
@@ -50,6 +50,8 @@
 #define STRICT_SGF 's'
 #define LAX_SGF    'l'
 
+/* Set this to 1 if you want warnings for missing GM and FF properties. */
+#define VERBOSE_WARNINGS 0
 
 /* ================================================================ */
 /*                     Some utility functions.                      */
@@ -966,24 +968,20 @@
 
   /* perform some simple checks on the file */
   if (!sgfGetIntProperty(root, "GM", &tmpi)) {
-    fprintf(stderr, "Couldn't find the game type (GM) attribute!\n");
+    if (VERBOSE_WARNINGS)
+      fprintf(stderr, "Couldn't find the game type (GM) attribute!\n");
   }
-  if (tmpi != 1) {
+  else if (tmpi != 1) {
     fprintf(stderr, "SGF file might be for game other than go: %d\n", tmpi);
     fprintf(stderr, "Trying to load anyway.\n");
   }
 
-
-#if 0
-  if (debug & DEBUG_LOADSGF) {
-    if (!sgfGetIntProperty(root, "FF", &tmpi)) {
+  if (!sgfGetIntProperty(root, "FF", &tmpi)) {
+    if (VERBOSE_WARNINGS)
       fprintf(stderr, "Can not determine SGF spec version (FF)!\n");
-    }
-    if (tmpi < 3 || tmpi > 4) {
-      fprintf(stderr, "Unsupported SGF spec version: %d\n", tmpi);
-    }
   }
-#endif
+  else if (tmpi < 3 || tmpi > 4)
+    fprintf(stderr, "Unsupported SGF spec version: %d\n", tmpi);
 
   return root;
 }
@@ -1024,24 +1022,20 @@
 
   /* perform some simple checks on the file */
   if (!sgfGetIntProperty(root, "GM", &tmpi)) {
-    fprintf(stderr, "Couldn't find the game type (GM) attribute!\n");
+    if (VERBOSE_WARNINGS)
+      fprintf(stderr, "Couldn't find the game type (GM) attribute!\n");
   }
-  if (tmpi != 1) {
+  else if (tmpi != 1) {
     fprintf(stderr, "SGF file might be for game other than go: %d\n", tmpi);
     fprintf(stderr, "Trying to load anyway.\n");
   }
 
-
-#if 0
-  if (debug & DEBUG_LOADSGF) {
-    if (!sgfGetIntProperty(root, "FF", &tmpi)) {
+  if (!sgfGetIntProperty(root, "FF", &tmpi)) {
+    if (VERBOSE_WARNINGS)
       fprintf(stderr, "Can not determine SGF spec version (FF)!\n");
-    }
-    if (tmpi < 3 || tmpi > 4) {
-      fprintf(stderr, "Unsupported SGF spec version: %d\n", tmpi);
-    }
   }
-#endif
+  else if (tmpi < 3 || tmpi > 4)
+    fprintf(stderr, "Unsupported SGF spec version: %d\n", tmpi);
 
   return root;
 }



reply via email to

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