11 #define PATH_SEPARATOR ';'
13 /* If we're running on MinGW, PATH is in native Windows form while
14 COMPILER_PATH has ';' as entries separator but still has '/' as directory
15 separator, so we have to convert it. This is what this magic for. */
17 void copy_path(char *to
, char *from
)
28 #define PATH_SEPARATOR ':'
29 #define copy_path strcpy
33 void nonfatal(const char *msg
, const char *errorstr
)
36 fprintf(stderr
, "%s: %s: %s\n" , program_name
, msg
, errorstr
);
38 fprintf(stderr
, "%s: %s\n" , program_name
, errorstr
);
41 void fatal(const char *msg
, const char *errorstr
)
43 nonfatal(msg
, errorstr
);
47 void set_compiler_path(void)
49 static int path_set
= 0;
53 char *compiler_path
= getenv("COMPILER_PATH");
54 char *path
= getenv("PATH");
56 if (compiler_path
&& path
)
59 size_t compiler_path_len
= strlen(compiler_path
);
60 size_t path_len
= strlen(path
);
62 new_path
= malloc(5 + compiler_path_len
+ 1 + path_len
+ 1);
65 strcpy(new_path
, "PATH=");
66 copy_path(new_path
+ 5, compiler_path
);
67 new_path
[5 + compiler_path_len
] = PATH_SEPARATOR
;
68 strcpy(new_path
+ 5 + compiler_path_len
+ 1, path
);
70 if (putenv(new_path
) == 0)
77 #ifndef _HAVE_LIBIBERTY_
79 void *xmalloc(size_t size
)
81 void *ret
= malloc(size
);
84 fatal("xmalloc", strerror(errno
));
90 char *make_temp_file(char *suffix
__attribute__((unused
)))
93 /* If you're unlucky enough to not have libiberty available, you'll have
94 to live with temporary files in /tmp and no suffix; it's ok for our own
96 char template[] = "/tmp/catmpXXXXXX";
98 fd
= mkstemp(template);
103 fatal("make_temp_file()/close()", strerror(errno
));
105 return strdup(template);