diff --git a/src/frontend/com_hardcopy.c b/src/frontend/com_hardcopy.c index 953ff01b4..16a5cbee3 100644 --- a/src/frontend/com_hardcopy.c +++ b/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")) { diff --git a/src/misc/mktemp.c b/src/misc/mktemp.c index 2fe4871f6..5b5b48f28 100644 --- a/src/misc/mktemp.c +++ b/src/misc/mktemp.c @@ -15,11 +15,12 @@ Copyright 1990 Regents of the University of California. All rights reserved. #include #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); +} + diff --git a/src/misc/mktemp.h b/src/misc/mktemp.h index 655e7344a..a1dcb34e0 100644 --- a/src/misc/mktemp.h +++ b/src/misc/mktemp.h @@ -7,5 +7,6 @@ #define ngspice_MKTEMP_H char * smktemp(char *id); +char * smktemp2(char *id, int n); #endif