add *.cir file path as search path (MS Windows)
This commit is contained in:
parent
73e581f015
commit
cdcf63aa46
14
src/main.c
14
src/main.c
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue