Skip to content
Snippets Groups Projects
Commit ac7acdc9 authored by Moritz Hanke's avatar Moritz Hanke
Browse files

improves error output in routine xfopen

parent f62bd9df
No related branches found
No related tags found
No related merge requests found
......@@ -51,8 +51,15 @@ SymPrefix(xfopen)(const char *path, const char *mode,
const char *source, int line)
{
FILE *fp;
if ((fp = fopen(path, mode)) == NULL)
SymPrefix(abort)(SymPrefix(default_comm), strerror(errno), source, line);
if ((fp = fopen(path, mode)) == NULL) {
char const format_string[] = "%s (path: \"%s\")";
char const * err_string = strerror(errno);
char * error_buffer =
xmalloc(strlen(format_string) + strlen(err_string) + strlen(path));
sprintf(error_buffer, "xfopen: %s (path: \"%s\")", err_string, path);
SymPrefix(abort)(SymPrefix(default_comm), error_buffer, source, line);
free(error_buffer);
}
return fp;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment