Within a single run, allow multiple plots with different names:

Add an increasing number to the id file name.
This commit is contained in:
Holger Vogt 2021-06-10 16:43:05 +02:00
parent 0f4d953950
commit 604c4624d1
3 changed files with 25 additions and 2 deletions

View File

@ -35,6 +35,8 @@ void com_hardcopy(wordlist *wl)
int hc_button; int hc_button;
int foundit; int foundit;
static int n;
if (!cp_getvar("hcopydev", CP_STRING, device, sizeof(device))) if (!cp_getvar("hcopydev", CP_STRING, device, sizeof(device)))
*device = '\0'; *device = '\0';
@ -53,7 +55,8 @@ void com_hardcopy(wordlist *wl)
} }
else { else {
hc_button = 1; hc_button = 1;
fname = smktemp("hc"); fname = smktemp2("hc", n);
n++;
tempf = TRUE; tempf = TRUE;
n_byte_fname = (strlen(fname) + 1) * sizeof *fname; n_byte_fname = (strlen(fname) + 1) * sizeof *fname;
if (!strcmp(devtype, "svg")) { if (!strcmp(devtype, "svg")) {

View File

@ -15,11 +15,12 @@ Copyright 1990 Regents of the University of California. All rights reserved.
#include <unistd.h> #include <unistd.h>
#endif #endif
#ifndef TEMPFORMAT #ifndef TEMPFORMAT
#define TEMPFORMAT "temp%s%d" #define TEMPFORMAT "temp%s%d"
#endif #endif
#define TEMPFORMAT2 "%s%d_%d.tmp"
char * char *
smktemp(char *id) smktemp(char *id)
{ {
@ -35,3 +36,21 @@ smktemp(char *id)
} }
return tprintf(TEMPFORMAT, id, getpid()); return tprintf(TEMPFORMAT, id, getpid());
} }
char*
smktemp2(char* id, int n)
{
if (!id)
id = "sp";
const char* const home = getenv("HOME");
if (home) {
return tprintf("%s"TEMPFORMAT2, home, id, getpid(), n);
}
const char* const usr = getenv("USERPROFILE");
if (usr) {
return tprintf("%s\\"TEMPFORMAT2, usr, id, getpid(), n);
}
return tprintf(TEMPFORMAT2, id, getpid(), n);
}

View File

@ -7,5 +7,6 @@
#define ngspice_MKTEMP_H #define ngspice_MKTEMP_H
char * smktemp(char *id); char * smktemp(char *id);
char * smktemp2(char *id, int n);
#endif #endif