fix some intermediate file issues

This commit is contained in:
Bill Currie 2006-05-24 14:50:24 +00:00 committed by Jeff Teunissen
parent f7df6fea17
commit 130e6c1a3f
3 changed files with 14 additions and 12 deletions

View File

@ -38,7 +38,7 @@ void parse_cpp_name (void);
void add_cpp_def (const char *arg);
void intermediate_file (struct dstring_s *ifile, const char *filename,
const char *ext);
FILE * preprocess_file (const char *filename);
FILE * preprocess_file (const char *filename, const char *ext);
extern const char *cpp_name;
extern struct dstring_s *tempname;

View File

@ -150,14 +150,14 @@ build_cpp_args (const char *in_name, const char *out_name)
void
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) {
char *basename = strdup (filename);
char *temp;
temp = strrchr (basename, '.');
temp = strrchr (basename, '/');
if (!temp)
temp = basename;
temp = strrchr (temp, '.');
if (temp)
*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);
} else {
temp1 = getenv ("TMPDIR");
const char *temp1 = getenv ("TMPDIR");
char *temp2 = strrchr (this_program, PATH_SEPARATOR);
if ((!temp1) || (!temp1[0])) {
temp1 = getenv ("TEMP");
if ((!temp1) || (!temp1[0])) {
@ -189,7 +191,7 @@ intermediate_file (dstring_t *ifile, const char *filename, const char *ext)
}
FILE *
preprocess_file (const char *filename)
preprocess_file (const char *filename, const char *ext)
{
#ifndef _WIN32
pid_t pid;
@ -197,7 +199,7 @@ preprocess_file (const char *filename)
#endif
if (cpp_name) {
intermediate_file (tempname, filename, "p");
intermediate_file (tempname, filename, ext ? ext : "p");
build_cpp_args (filename, tempname->str);
#ifdef _WIN32

View File

@ -515,7 +515,7 @@ compile_to_obj (const char *file, const char *obj)
{
int err;
yyin = preprocess_file (file);
yyin = preprocess_file (file, 0);
if (!yyin)
return !options.preprocess_only;
@ -660,7 +660,7 @@ load_file (const char *fname)
QFile *file;
char *src;
file = Qfopen (preprocess_file (fname), "rt");
file = Qfopen (preprocess_file (fname, "i1"), "rt");
if (!file)
return 0;
src = malloc (Qfilesize (file) + 1);
@ -693,7 +693,7 @@ compile_file (const char *filename)
{
int err;
yyin = preprocess_file (filename);
yyin = preprocess_file (filename, 0);
if (!yyin)
return !options.preprocess_only;
@ -735,7 +735,7 @@ progs_src_compile (void)
dsprintf (filename, "%s", progs_src);
if (options.single_cpp) {
intermediate_file (single_name, filename->str, "i");
intermediate_file (single_name, filename->str, "i2");
if (!options.save_temps) {
#ifdef _WIN32
mktemp (single_name->str);