fix error output
This commit is contained in:
56
src/errors.c
56
src/errors.c
@@ -15,38 +15,38 @@ static void print_context_tokens()
|
|||||||
i = 0;
|
i = 0;
|
||||||
while (tokens_g_err[i].type != TOKEN_END)
|
while (tokens_g_err[i].type != TOKEN_END)
|
||||||
{
|
{
|
||||||
ft_printf("token %2i - type : ", i);
|
ft_dprintf(STDERR_FILENO, "token %2i - type : ", i);
|
||||||
|
|
||||||
if (tokens_g_err[i].type == TOKEN_VARIABLE)
|
if (tokens_g_err[i].type == TOKEN_VARIABLE)
|
||||||
ft_printf("%20s", "TOKEN_VARIABLE");
|
ft_dprintf(STDERR_FILENO, "%20s", "TOKEN_VARIABLE");
|
||||||
else if (tokens_g_err[i].type == TOKEN_NUMBER_INT)
|
else if (tokens_g_err[i].type == TOKEN_NUMBER_INT)
|
||||||
ft_printf("%20s", "TOKEN_NUMBER_INT");
|
ft_dprintf(STDERR_FILENO, "%20s", "TOKEN_NUMBER_INT");
|
||||||
else if (tokens_g_err[i].type == TOKEN_NUMBER_DOUBLE)
|
else if (tokens_g_err[i].type == TOKEN_NUMBER_DOUBLE)
|
||||||
ft_printf("%20s", "TOKEN_NUMBER_DOUBLE");
|
ft_dprintf(STDERR_FILENO, "%20s", "TOKEN_NUMBER_DOUBLE");
|
||||||
else if (tokens_g_err[i].type == TOKEN_POWER)
|
else if (tokens_g_err[i].type == TOKEN_POWER)
|
||||||
ft_printf("%20s", "TOKEN_POWER");
|
ft_dprintf(STDERR_FILENO, "%20s", "TOKEN_POWER");
|
||||||
else if (tokens_g_err[i].type == TOKEN_SIGN_PLUS)
|
else if (tokens_g_err[i].type == TOKEN_SIGN_PLUS)
|
||||||
ft_printf("%20s", "TOKEN_SIGN_PLUS");
|
ft_dprintf(STDERR_FILENO, "%20s", "TOKEN_SIGN_PLUS");
|
||||||
else if (tokens_g_err[i].type == TOKEN_SIGN_MINUS)
|
else if (tokens_g_err[i].type == TOKEN_SIGN_MINUS)
|
||||||
ft_printf("%20s", "TOKEN_SIGN_MINUS");
|
ft_dprintf(STDERR_FILENO, "%20s", "TOKEN_SIGN_MINUS");
|
||||||
else if (tokens_g_err[i].type == TOKEN_FACTOR_MULT)
|
else if (tokens_g_err[i].type == TOKEN_FACTOR_MULT)
|
||||||
ft_printf("%20s", "TOKEN_FACTOR_MULT");
|
ft_dprintf(STDERR_FILENO, "%20s", "TOKEN_FACTOR_MULT");
|
||||||
else if (tokens_g_err[i].type == TOKEN_FACTOR_DIV)
|
else if (tokens_g_err[i].type == TOKEN_FACTOR_DIV)
|
||||||
ft_printf("%20s", "TOKEN_FACTOR_DIV");
|
ft_dprintf(STDERR_FILENO, "%20s", "TOKEN_FACTOR_DIV");
|
||||||
else if (tokens_g_err[i].type == TOKEN_EQUAL)
|
else if (tokens_g_err[i].type == TOKEN_EQUAL)
|
||||||
ft_printf("%20s", "TOKEN_EQUAL");
|
ft_dprintf(STDERR_FILENO, "%20s", "TOKEN_EQUAL");
|
||||||
else if (tokens_g_err[i].type == TOKEN_END)
|
else if (tokens_g_err[i].type == TOKEN_END)
|
||||||
ft_printf("%20s", "TOKEN_END");
|
ft_dprintf(STDERR_FILENO, "%20s", "TOKEN_END");
|
||||||
|
|
||||||
ft_putstr(" - value : ");
|
ft_putstr(" - value : ");
|
||||||
|
|
||||||
if (tokens_g_err[i].tag == TOKEN_NUMBER)
|
if (tokens_g_err[i].tag == TOKEN_NUMBER)
|
||||||
{
|
{
|
||||||
printf("%g\n", tokens_g_err[i].value_double);
|
dprintf(STDERR_FILENO, "%g\n", tokens_g_err[i].value_double);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ft_printf("%c\n", tokens_g_err[i].value_char);
|
ft_dprintf(STDERR_FILENO, "%c\n", tokens_g_err[i].value_char);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@@ -61,23 +61,31 @@ static void print_context_terms()
|
|||||||
i = 0;
|
i = 0;
|
||||||
while (terms_g_err[i].position != TERM_END)
|
while (terms_g_err[i].position != TERM_END)
|
||||||
{
|
{
|
||||||
ft_printf("term %2i :\n", i);
|
ft_dprintf(STDERR_FILENO, "term %2i - ", i);
|
||||||
|
|
||||||
// position
|
// position
|
||||||
ft_printf(" position : ");
|
ft_dprintf(STDERR_FILENO, "%10s : ", "position");
|
||||||
if (terms_g_err[i].position == TERM_LEFT)
|
if (terms_g_err[i].position == TERM_LEFT)
|
||||||
ft_printf("%s\n", "TERM_LEFT");
|
ft_dprintf(STDERR_FILENO, "%10s", "TERM_LEFT");
|
||||||
if (terms_g_err[i].position == TERM_RIGHT)
|
else if (terms_g_err[i].position == TERM_RIGHT)
|
||||||
ft_printf("%s\n", "TERM_RIGHT");
|
ft_dprintf(STDERR_FILENO, "%10s", "TERM_RIGHT");
|
||||||
|
else
|
||||||
|
ft_dprintf(STDERR_FILENO, "%10s", "");
|
||||||
|
|
||||||
// sign
|
// sign
|
||||||
ft_printf(" sign : ");
|
ft_dprintf(STDERR_FILENO, " | %10s : ", "sign");
|
||||||
if (terms_g_err[i].sign == TERM_PLUS)
|
if (terms_g_err[i].sign == TERM_PLUS)
|
||||||
ft_printf("%s\n", "TERM_PLUS");
|
ft_dprintf(STDERR_FILENO, "%10s", "TERM_PLUS");
|
||||||
if (terms_g_err[i].sign == TERM_MINUS)
|
else if (terms_g_err[i].sign == TERM_MINUS)
|
||||||
ft_printf("%s\n", "TERM_MINUS");
|
ft_dprintf(STDERR_FILENO, "%10s", "TERM_MINUS");
|
||||||
|
else
|
||||||
|
ft_dprintf(STDERR_FILENO, "%10s", "");
|
||||||
|
|
||||||
// coefficient
|
// coefficient
|
||||||
printf(" coefficient : %g\n", terms_g_err[i].coefficient);
|
dprintf(STDERR_FILENO, " | %10s : %13g", "coefficient", terms_g_err[i].coefficient);
|
||||||
|
|
||||||
// exponent
|
// exponent
|
||||||
ft_printf(" exponent : %d\n", terms_g_err[i].exponent);
|
ft_dprintf(STDERR_FILENO, " | %10s : %d\n", "exponent", terms_g_err[i].exponent);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
ft_putchar('\n');
|
ft_putchar('\n');
|
||||||
|
|||||||
Reference in New Issue
Block a user