Browse Source

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

Add an increasing number to the id file name.
pre-master-46
Holger Vogt 5 years ago
parent
commit
604c4624d1
  1. 5
      src/frontend/com_hardcopy.c
  2. 21
      src/misc/mktemp.c
  3. 1
      src/misc/mktemp.h

5
src/frontend/com_hardcopy.c

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

21
src/misc/mktemp.c

@ -15,11 +15,12 @@ Copyright 1990 Regents of the University of California. All rights reserved.
#include <unistd.h>
#endif
#ifndef TEMPFORMAT
#define TEMPFORMAT "temp%s%d"
#endif
#define TEMPFORMAT2 "%s%d_%d.tmp"
char *
smktemp(char *id)
{
@ -35,3 +36,21 @@ smktemp(char *id)
}
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);
}

1
src/misc/mktemp.h

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