$NetBSD$

--- cmds.c.orig	1992-05-11 20:43:34.000000000 +0200
+++ cmds.c
@@ -28,6 +28,7 @@
 #include "sc.h"
 #include <signal.h>
 #include <errno.h>
+#include <limits.h>
 
 #ifdef SYSV3
 extern void exit();
@@ -39,8 +40,6 @@ void	openrow();
 void	syncref();
 void	unspecial();
 
-extern	int	errno;
-
 /* a linked list of free [struct ent]'s, uses .next as the pointer */
 extern	struct ent *freeents;
 
@@ -700,12 +699,18 @@ int r0, c0, rn, cn;
     int fieldlen, nextcol;
     register row, col;
     register struct ent **pp;
+    char fnbuf[PATH_MAX];
 
     if ((strcmp(fname, curfile) == 0) &&
 	!yn_ask("Confirm that you want to destroy the data base: (y,n)")) {
 	return;
     }
 
+    if (*fname == '\0') {
+	snprintf(fnbuf, sizeof fnbuf, "%s.asc", curfile);
+	fname = fnbuf;
+    }
+
     if (!pline && (pline = scxmalloc((unsigned)(FBUFLEN *
 					++fbufs_allocated))) == (char *)NULL)
     {   error("Malloc failed in printfile()");
