source file path as additional search path
This commit is contained in:
parent
b66562316d
commit
5571e9b9fa
|
|
@ -1,3 +1,7 @@
|
|||
2009-12-19 Holger Vogt
|
||||
* main.c, inpcom.c: source file path added as additional search path for
|
||||
opening .include files (MS Windows only).
|
||||
|
||||
2009-12-17 Dietmar Warning
|
||||
* devices/bsim3/b3set.c: add the ngspice specific copyNodesets approach and remove
|
||||
the tnom celsius -> kelvin transformation
|
||||
|
|
|
|||
|
|
@ -163,16 +163,39 @@ readline(FILE *fd)
|
|||
|
||||
|
||||
/*-------------------------------------------------------------------------*
|
||||
* Look up the variable sourcepath and try everything in the list in order *
|
||||
* if the file isn't in . and it isn't an abs path name. *
|
||||
Look up the variable sourcepath and try everything in the list in order
|
||||
if the file isn't in . and it isn't an abs path name.
|
||||
For MS Windows: First try the path of the source file.
|
||||
*-------------------------------------------------------------------------*/
|
||||
FILE *
|
||||
inp_pathopen(char *name, char *mode)
|
||||
{
|
||||
FILE *fp;
|
||||
char buf[BSIZE_SP];
|
||||
char buf[BSIZE_SP], buf2[BSIZE_SP];
|
||||
struct variable *v;
|
||||
|
||||
#if defined(HAS_WINDOWS)
|
||||
/* search in the path where the source (input) file has been found,
|
||||
but only if "name" is just a file name */
|
||||
if (!(index(name, DIR_TERM)) && cp_getvar("sourcefile", VT_STRING, buf2)) {
|
||||
/* If pathname is found, get path.
|
||||
(char *dirname(const char *name) might have been used here) */
|
||||
if (substring(DIR_PATHSEP, buf2)) {
|
||||
int i,j=0;
|
||||
for (i=0; i<BSIZE_SP-1; i++) {
|
||||
if (buf2[i] == '\0') break;
|
||||
if (buf2[i] == DIR_TERM) j=i;
|
||||
}
|
||||
buf2[j+1] = '\0'; /* include path separator */
|
||||
}
|
||||
/* add file name */
|
||||
strcat(buf2, name);
|
||||
/* try to open file */
|
||||
if ((fp = fopen(buf2, mode)))
|
||||
return (fp);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If this is an abs pathname, or there is no sourcepath var, just
|
||||
* do an fopen.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1044,7 +1044,7 @@ bot:
|
|||
FILE *tempfile;
|
||||
#if defined(HAS_WINDOWS) || defined(_MSC_VER) || defined(__MINGW32__)
|
||||
char *tpf = NULL; /* temporary file */
|
||||
char *dname = NULL; /* directory of input file*/
|
||||
char *dname = NULL; /* input file*/
|
||||
bool has_smk = FALSE;
|
||||
#endif
|
||||
tempfile = tmpfile();
|
||||
|
|
@ -1086,6 +1086,8 @@ bot:
|
|||
#if defined(HAS_WINDOWS)
|
||||
/* write source file name into source window */
|
||||
SetSource(dname);
|
||||
/* write source file name into a variable */
|
||||
cp_vset("sourcefile", VT_STRING, dname);
|
||||
#endif
|
||||
append_to_stream(tempfile, tp);
|
||||
fclose(tp);
|
||||
|
|
|
|||
Loading…
Reference in New Issue