mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-19 07:20:50 +00:00
fix some intermediate file issues
This commit is contained in:
parent
f7df6fea17
commit
130e6c1a3f
3 changed files with 14 additions and 12 deletions
|
@ -38,7 +38,7 @@ void parse_cpp_name (void);
|
||||||
void add_cpp_def (const char *arg);
|
void add_cpp_def (const char *arg);
|
||||||
void intermediate_file (struct dstring_s *ifile, const char *filename,
|
void intermediate_file (struct dstring_s *ifile, const char *filename,
|
||||||
const char *ext);
|
const char *ext);
|
||||||
FILE * preprocess_file (const char *filename);
|
FILE * preprocess_file (const char *filename, const char *ext);
|
||||||
extern const char *cpp_name;
|
extern const char *cpp_name;
|
||||||
extern struct dstring_s *tempname;
|
extern struct dstring_s *tempname;
|
||||||
|
|
||||||
|
|
|
@ -150,14 +150,14 @@ build_cpp_args (const char *in_name, const char *out_name)
|
||||||
void
|
void
|
||||||
intermediate_file (dstring_t *ifile, const char *filename, const char *ext)
|
intermediate_file (dstring_t *ifile, const char *filename, const char *ext)
|
||||||
{
|
{
|
||||||
const char *temp1;
|
|
||||||
char *temp2 = strrchr (this_program, PATH_SEPARATOR);
|
|
||||||
|
|
||||||
if (options.save_temps) {
|
if (options.save_temps) {
|
||||||
char *basename = strdup (filename);
|
char *basename = strdup (filename);
|
||||||
char *temp;
|
char *temp;
|
||||||
|
|
||||||
temp = strrchr (basename, '.');
|
temp = strrchr (basename, '/');
|
||||||
|
if (!temp)
|
||||||
|
temp = basename;
|
||||||
|
temp = strrchr (temp, '.');
|
||||||
if (temp)
|
if (temp)
|
||||||
*temp = '\0'; // ignore the rest of the string
|
*temp = '\0'; // ignore the rest of the string
|
||||||
|
|
||||||
|
@ -175,7 +175,9 @@ intermediate_file (dstring_t *ifile, const char *filename, const char *ext)
|
||||||
}
|
}
|
||||||
free (basename);
|
free (basename);
|
||||||
} else {
|
} else {
|
||||||
temp1 = getenv ("TMPDIR");
|
const char *temp1 = getenv ("TMPDIR");
|
||||||
|
char *temp2 = strrchr (this_program, PATH_SEPARATOR);
|
||||||
|
|
||||||
if ((!temp1) || (!temp1[0])) {
|
if ((!temp1) || (!temp1[0])) {
|
||||||
temp1 = getenv ("TEMP");
|
temp1 = getenv ("TEMP");
|
||||||
if ((!temp1) || (!temp1[0])) {
|
if ((!temp1) || (!temp1[0])) {
|
||||||
|
@ -189,7 +191,7 @@ intermediate_file (dstring_t *ifile, const char *filename, const char *ext)
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *
|
FILE *
|
||||||
preprocess_file (const char *filename)
|
preprocess_file (const char *filename, const char *ext)
|
||||||
{
|
{
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
@ -197,7 +199,7 @@ preprocess_file (const char *filename)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (cpp_name) {
|
if (cpp_name) {
|
||||||
intermediate_file (tempname, filename, "p");
|
intermediate_file (tempname, filename, ext ? ext : "p");
|
||||||
build_cpp_args (filename, tempname->str);
|
build_cpp_args (filename, tempname->str);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
|
@ -515,7 +515,7 @@ compile_to_obj (const char *file, const char *obj)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
yyin = preprocess_file (file);
|
yyin = preprocess_file (file, 0);
|
||||||
if (!yyin)
|
if (!yyin)
|
||||||
return !options.preprocess_only;
|
return !options.preprocess_only;
|
||||||
|
|
||||||
|
@ -660,7 +660,7 @@ load_file (const char *fname)
|
||||||
QFile *file;
|
QFile *file;
|
||||||
char *src;
|
char *src;
|
||||||
|
|
||||||
file = Qfopen (preprocess_file (fname), "rt");
|
file = Qfopen (preprocess_file (fname, "i1"), "rt");
|
||||||
if (!file)
|
if (!file)
|
||||||
return 0;
|
return 0;
|
||||||
src = malloc (Qfilesize (file) + 1);
|
src = malloc (Qfilesize (file) + 1);
|
||||||
|
@ -693,7 +693,7 @@ compile_file (const char *filename)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
yyin = preprocess_file (filename);
|
yyin = preprocess_file (filename, 0);
|
||||||
if (!yyin)
|
if (!yyin)
|
||||||
return !options.preprocess_only;
|
return !options.preprocess_only;
|
||||||
|
|
||||||
|
@ -735,7 +735,7 @@ progs_src_compile (void)
|
||||||
dsprintf (filename, "%s", progs_src);
|
dsprintf (filename, "%s", progs_src);
|
||||||
|
|
||||||
if (options.single_cpp) {
|
if (options.single_cpp) {
|
||||||
intermediate_file (single_name, filename->str, "i");
|
intermediate_file (single_name, filename->str, "i2");
|
||||||
if (!options.save_temps) {
|
if (!options.save_temps) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
mktemp (single_name->str);
|
mktemp (single_name->str);
|
||||||
|
|
Loading…
Reference in a new issue