gnucap save prompt error

patrick <[email protected]>
Newsgroups gmane.comp.gnu.gnucap.devel
Message-ID <CAEx2pdf-8bDHkKnKVnvCFSQKafEUeLJ=C8bcRpv7KxNskHR2YA@mail.gmail.com>
Hi,

I am trying to save a circuit with interactive save prompt but get an
error as follows:

ore-lib version: cmake-4 2020.07.03
default plugins: cmake-4 2020.07.03
gnucap> save
file name?  abc.ckt
gnucap: /home/pmu/projects/gnucap/gnucap/lib/ap_construct.cc:125: CS&
CS::operator=(const string&): Assertion `!_file' failed.

The problem might be that getcmd is not writing the result from the
prompt into fname in lib/io_xopen.cc

I am trying to skip the prompt and save to a default file, the
functionality of save would change slightly but it would not give an
error.

0001-Save-to-default-file.patch

What do you think?
Also we might want to add a shortcut for save with "s" ?


Patrick
0001-Save-to-default-file.patch (text/x-patch, 2.4 KB)
From 2e90463cfcfde52331085defe5f76f16b15c1da7 Mon Sep 17 00:00:00 2001
From: "[email protected]" <[email protected]>
Date: Sun, 23 Aug 2020 12:14:56 +0200
Subject: [PATCH] Save to default file

---
 lib/io_xopen.cc | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/lib/io_xopen.cc b/lib/io_xopen.cc
index af4f4df..1636b18 100644
--- a/lib/io_xopen.cc
+++ b/lib/io_xopen.cc
@@ -48,32 +48,33 @@ void xclose(FILE **fn)
 FILE *xopen(CS& cmd, const char *ext, const char *how)
 {
   char fname[BIGBUFLEN];
-  
+
   cmd.skipbl();
   if (cmd.is_end()) {untested();
-    cmd = getcmd("file name?  ",fname, BIGBUFLEN);
-  }
-					/* copy the name		    */
+    //  cmd = getcmd("file name?  ", fname, BIGBUFLEN);
+    strncpy(fname, "snapshot.ckt\0", 100);
+  } else {
+  /* copy the name		    */
   cmd.skipbl();				/* and while we're at it ...	    */
-  {					/* find out if we want to add the   */
+   					/* find out if we want to add the   */
     bool defalt = true;			/* default extension		    */
     size_t i;
     for (i = 0;   i < BIGBUFLEN;   ) {
       char c = cmd.ctoc();
       if (!c || isspace(c)) {
-	break;
+        break;
       }
       if (c == '$') {untested(); 
-	sprintf(&(fname[i]), "%ld", static_cast<long>(time(0)));
-	i = strlen(fname);
+        sprintf(&(fname[i]), "%ld", static_cast<long>(time(0)));
+        i = strlen(fname);
       }else{				/* we want to add the extension	    */
-	fname[i++] = c;			/* if it doesn't already have one,  */
-	if (c == '.') {		/* as determined by a '.'	    */
-	  defalt = false;		/* not before the directory	    */
-	}else if (strchr(ENDDIR,c)) {	/* separator-terminator character   */
-	  itested();
-	  defalt = true;		/* '\' or '/' for msdos,	    */
-	}
+        fname[i++] = c;			/* if it doesn't already have one,  */
+        if (c == '.') {		/* as determined by a '.'	    */
+          defalt = false;		/* not before the directory	    */
+        }else if (strchr(ENDDIR,c)) {	/* separator-terminator character   */
+          itested();
+          defalt = true;		/* '\' or '/' for msdos,	    */
+        }
       }  				/* ']' or '/' for vms,		    */
     }					/* '/' for unix  (in ENDDIR)	    */
     cmd.skip(-1);
@@ -84,8 +85,9 @@ FILE *xopen(CS& cmd, const char *ext, const char *how)
       fname[i] = '\0';
     }
   }
-  
+
   trim(fname);
+  printf("Save session to %s \n", fname);
   if (strlen(fname)==0) {
     return NULL;
   }
-- 
2.16.4
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.