mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 04:38:03 +02:00
Change error/warning functions to print to the info log.
This commit is contained in:
parent
ca97bd395f
commit
b2ba6fac09
2 changed files with 31 additions and 29 deletions
|
|
@ -25,6 +25,10 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include <talloc.h>
|
||||||
|
}
|
||||||
|
|
||||||
#include "ast.h"
|
#include "ast.h"
|
||||||
#include "glsl_parser_extras.h"
|
#include "glsl_parser_extras.h"
|
||||||
#include "glsl_parser.h"
|
#include "glsl_parser.h"
|
||||||
|
|
@ -47,24 +51,20 @@ void
|
||||||
_mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state,
|
_mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state,
|
||||||
const char *fmt, ...)
|
const char *fmt, ...)
|
||||||
{
|
{
|
||||||
char buf[1024];
|
|
||||||
int len;
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
state->error = true;
|
state->error = true;
|
||||||
|
|
||||||
len = snprintf(buf, sizeof(buf), "%u:%u(%u): error: ",
|
assert(state->info_log != NULL);
|
||||||
locp->source, locp->first_line, locp->first_column);
|
state->info_log = talloc_asprintf_append(state->info_log,
|
||||||
|
"%u:%u(%u): error: ",
|
||||||
|
locp->source,
|
||||||
|
locp->first_line,
|
||||||
|
locp->first_column);
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vsnprintf(buf + len, sizeof(buf) - len, fmt, ap);
|
state->info_log = talloc_vasprintf_append(state->info_log, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
state->info_log = talloc_strdup_append(state->info_log, "\n");
|
||||||
printf("%s\n", buf);
|
|
||||||
|
|
||||||
if (state->info_log)
|
|
||||||
free(state->info_log);
|
|
||||||
state->info_log = strdup(buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -72,22 +72,18 @@ void
|
||||||
_mesa_glsl_warning(const YYLTYPE *locp, _mesa_glsl_parse_state *state,
|
_mesa_glsl_warning(const YYLTYPE *locp, _mesa_glsl_parse_state *state,
|
||||||
const char *fmt, ...)
|
const char *fmt, ...)
|
||||||
{
|
{
|
||||||
char buf[1024];
|
|
||||||
int len;
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
len = snprintf(buf, sizeof(buf), "%u:%u(%u): warning: ",
|
assert(state->info_log != NULL);
|
||||||
locp->source, locp->first_line, locp->first_column);
|
state->info_log = talloc_asprintf_append(state->info_log,
|
||||||
|
"%u:%u(%u): warning: ",
|
||||||
|
locp->source,
|
||||||
|
locp->first_line,
|
||||||
|
locp->first_column);
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vsnprintf(buf + len, sizeof(buf) - len, fmt, ap);
|
state->info_log = talloc_vasprintf_append(state->info_log, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
state->info_log = talloc_strdup_append(state->info_log, "\n");
|
||||||
printf("%s\n", buf);
|
|
||||||
|
|
||||||
if (!state->info_log) {
|
|
||||||
state->info_log = strdup(buf);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,11 @@
|
||||||
*/
|
*/
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include <talloc.h>
|
||||||
|
}
|
||||||
|
|
||||||
#include "ir_reader.h"
|
#include "ir_reader.h"
|
||||||
#include "glsl_parser_extras.h"
|
#include "glsl_parser_extras.h"
|
||||||
#include "glsl_types.h"
|
#include "glsl_types.h"
|
||||||
|
|
@ -86,17 +91,18 @@ ir_read_error(_mesa_glsl_parse_state *state, s_expression *expr,
|
||||||
|
|
||||||
state->error = true;
|
state->error = true;
|
||||||
|
|
||||||
printf("error: ");
|
state->info_log = talloc_strdup_append(state->info_log, "error: ");
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vprintf(fmt, ap);
|
state->info_log = talloc_vasprintf_append(state->info_log, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
printf("\n");
|
state->info_log = talloc_strdup_append(state->info_log, "\n");
|
||||||
|
|
||||||
if (expr != NULL) {
|
if (expr != NULL) {
|
||||||
printf("...in this context:\n ");
|
state->info_log = talloc_strdup_append(state->info_log,
|
||||||
|
"...in this context:\n ");
|
||||||
expr->print();
|
expr->print();
|
||||||
printf("\n\n");
|
state->info_log = talloc_strdup_append(state->info_log, "\n\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue