11 void nonfatal(const char *msg
, const char *errorstr
)
14 fprintf(stderr
, "%s: %s: %s\n" , program_name
, msg
, errorstr
);
16 fprintf(stderr
, "%s: %s\n" , program_name
, errorstr
);
19 void fatal(const char *msg
, const char *errorstr
)
21 nonfatal(msg
, errorstr
);
25 void set_compiler_path(void)
27 static int path_set
= 0;
31 char *compiler_path
= getenv("COMPILER_PATH");
32 char *path
= getenv("PATH");
34 if (compiler_path
&& path
)
37 size_t compiler_path_len
= strlen(compiler_path
);
38 size_t path_len
= strlen(path
);
40 new_path
= malloc(5 + compiler_path_len
+ 1 + path_len
+ 1);
43 memcpy(new_path
, "PATH=", 5);
44 memcpy(new_path
+ 5, compiler_path
, compiler_path_len
);
45 memcpy(new_path
+ 5 + compiler_path_len
, ":", 1);
46 memcpy(new_path
+ 5 + compiler_path_len
+ 1, path
, path_len
+ 1);
48 if (putenv(new_path
) == 0)
55 #ifndef _HAVE_LIBIBERTY_
57 void *xmalloc(size_t size
)
59 void *ret
= malloc(size
);
62 fatal("xmalloc", strerror(errno
));
68 char *make_temp_file(char *suffix
__attribute__((unused
)))
71 /* If you're unlucky enough to not have libiberty available, you'll have
72 to live with temporary files in /tmp and no suffix; it's ok for our own
74 char template[] = "/tmp/catmpXXXXXX";
76 fd
= mkstemp(template);
81 fatal("make_temp_file()/close()", strerror(errno
));
83 return strdup(template);