mirror of
https://git.code.sf.net/p/ngspice/ngspice
synced 2026-08-22 05:47:42 +02:00
add *.cir file path as search path (MS Windows)
This commit is contained in:
+13
-1
@@ -997,7 +997,8 @@ bot:
|
||||
startup time. */
|
||||
FILE *tempfile;
|
||||
#ifdef HAS_WINDOWS
|
||||
char *tpf;
|
||||
char *tpf; /* temporary file */
|
||||
char *dname = NULL; /* directory of input file*/
|
||||
bool has_smk = FALSE;
|
||||
#endif
|
||||
tempfile = tmpfile();
|
||||
@@ -1030,13 +1031,24 @@ bot:
|
||||
err = 1;
|
||||
break;
|
||||
}
|
||||
#ifdef HAS_WINDOWS
|
||||
/* Copy the input file name which otherwise will be lost due to the
|
||||
temporary file */
|
||||
dname = copy(arg);
|
||||
#endif
|
||||
append_to_stream(tempfile, tp);
|
||||
fclose(tp);
|
||||
}
|
||||
fseek(tempfile, (long) 0, 0);
|
||||
|
||||
if (tempfile && (!err || !ft_batchmode)) {
|
||||
#ifdef HAS_WINDOWS
|
||||
/* Copy the input file name for adding another file search path */
|
||||
inp_spsource(tempfile, FALSE, dname);
|
||||
tfree(dname);
|
||||
#else
|
||||
inp_spsource(tempfile, FALSE, NULL);
|
||||
#endif
|
||||
gotone = TRUE;
|
||||
}
|
||||
#ifdef HAS_WINDOWS
|
||||
|
||||
@@ -188,6 +188,58 @@ basename(const char *name)
|
||||
return base;
|
||||
}
|
||||
|
||||
#ifdef HAS_WINDOWS
|
||||
/* allow back slashes \\ */
|
||||
char *
|
||||
dirname(const char *name)
|
||||
{
|
||||
static char *ret = NULL;
|
||||
int len;
|
||||
int size = 0;
|
||||
const char *p;
|
||||
|
||||
if (ret) {
|
||||
free(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
|
||||
if (!name || !strcmp(name, "") || (!strstr(name, "/") && !strstr(name, "\\")))
|
||||
return(".");
|
||||
|
||||
if (!strcmp(name, "/"))
|
||||
return(name);
|
||||
|
||||
if (!strcmp(name, "\\"))
|
||||
return(name);
|
||||
|
||||
// find the last slash in the string
|
||||
|
||||
len = strlen(name);
|
||||
p = &name[len - 1];
|
||||
|
||||
if (*p == '/') p--; // skip the trailing /
|
||||
|
||||
if (*p == '\\') p--; // skip the trailing \
|
||||
|
||||
while (p != name && *p != '/' && *p != '\\') p--;
|
||||
|
||||
size = p - name;
|
||||
if (size) {
|
||||
ret = malloc(size + 1);
|
||||
memcpy(ret, name, size);
|
||||
ret[size] = '\0';
|
||||
} else if (*p == '/')
|
||||
return "/";
|
||||
else if (*p == '\\')
|
||||
return "\\";
|
||||
else
|
||||
return "";
|
||||
|
||||
return (const char *) ret;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
char *
|
||||
dirname(const char *name)
|
||||
{
|
||||
@@ -228,5 +280,6 @@ dirname(const char *name)
|
||||
|
||||
return (const char *) ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user