[gnu.chess] Bug in SaveGame

eddins@eedsp.gatech.edu (Steve Eddins) (09/20/89)

If there's a gnu.chess.bugs newsgroup (mailing list), I couldn't find
it, so I'm posting here.

In gnuchess-1.52 and 1.53, the following lines appear in the
SaveGame() function in uxdsp.c:

>	ShowMessage("File name: ");
>	scanz("%s",fname);

>	if (fname[0] == '\0' || access(fname,W_OK) == -1) 
>		strcpy(fname,"chess.000");  
>	fd = fopen(fname,"w");

Note that if the file you want to save your game in does not already
exist, access(fname,W_OK) returns -1.  Therefore, unless you specify a
pre-existing file in the SaveGame function, all games get written to
chess.000.  I tried the following change, and it worked OK:

>	ShowMessage("File name: ");
>	scanz("%s",fname);
>
>	fd = fopen(fname,"w");
>	if (fd == NULL) 
>	  {
>	    ShowMessage("Cannot open file for writing.");
>	    return;
>	  }

Please mail any responses; I'll summarize if warranted.
-- 
Steve Eddins --- GRA
Georgia Tech, School of Electrical Engineering, Atlanta, GA  30332
uucp:  ...!{allegra,hplabs,ulysses}!gatech!gt-eedsp!eddins
internet: eddins@eedsp.gatech.edu