Commit 80e65e3b authored by Arnaud Blanchard's avatar Arnaud Blanchard
Browse files

Remove sscan_dims. Make fatal error use color only if the terminal is ANSI compatible

parent dddde12f
......@@ -196,7 +196,7 @@ MANY_REALLOCATIONS(&values, 7);
#define SPRINTF(buffer, ...) do{ if (snprintf(buffer, sizeof(buffer), __VA_ARGS__) >= (int)sizeof(buffer)) EXIT_ON_ERROR("The string is too long for the buffer of size '%ld'.", sizeof(buffer));}while(0)
///like strcpy but check that the buffer is big enough to contain the string. It only works with static buffer.
#define STRCPY(buffer, source) do {if (strlen(source)+1 > (int)sizeof(buffer)) EXIT_ON_ERROR("The length ('%d') of the your source ('%s') is longer than the receiving buffer: '%ld'.", strlen(source)+1, source, sizeof(buffer)); else strcpy(buffer, source);}while(0) //tricks to not have problem in a if
#define STRCPY(buffer, source) do {if (source==NULL) EXIT_ON_ERROR("source must not be NULL"); else if (buffer==NULL) EXIT_ON_ERROR("destination must not be NULL"); if (strlen(source)+1 > (int)sizeof(buffer)) EXIT_ON_ERROR("The length ('%d') of the your source ('%s') is longer than the receiving buffer: '%ld'.", strlen(source)+1, source, sizeof(buffer)); else strcpy(buffer, source);}while(0) //tricks to not have problem in a if
/// Do a fscanf checking than the number of interpreted arguments corresponds to the first parameter.
#define FSCANF(fields_nb, file, ... ) if (fscanf(file, __VA_ARGS__) != fields_nb) EXIT_ON_ERROR("Failed reading %d fields.", fields_nb)
......
......@@ -83,8 +83,8 @@ void fatal_error(const char *name_of_file, const char* name_of_function, int num
{
va_list arguments;
va_start(arguments, message);
color_fprintf(BLC_BRIGHT_RED, stderr, "\n%s: %s \t %s \t %i :\nError: ", blc_program_name, name_of_file, name_of_function, numero_of_line);
color_vfprintf(BLC_BRIGHT_RED, stderr, message, arguments);
color_eprintf(BLC_BRIGHT_RED, "\n%s: %s \t %s \t %i :\nError: ", blc_program_name, name_of_file, name_of_function, numero_of_line);
color_veprintf(BLC_BRIGHT_RED, message, arguments);
va_end(arguments);
fprintf(stderr, "\n\n");
fflush(stderr);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment