On Tuesday 15 December 2009 09:21:05 michal wrote: > Zack Rusin pisze: > > The attached patch makes the tgsi assembly parser report, in an > > admittedly rather crude way, the line number at which a syntax error was > > detected. What do you think about that? > > I agree, that's a bit invasive. > > What about saving the starting pointer and, on error, scanning it again > and counting newlines up to the current position?
yea, good idea. also ugly but a lot less code =)
From 3ebf748f2c8de718df51fc62a385c5613a7e46f3 Mon Sep 17 00:00:00 2001 From: Zack Rusin <za...@vmware.com> Date: Tue, 15 Dec 2009 09:26:51 -0500 Subject: [PATCH 2/2] tgsi: make the tgsi assembly parser report line/column on error --- src/gallium/auxiliary/tgsi/tgsi_text.c | 15 ++++++++++++++- 1 files changed, 14 insertions(+), 1 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c index b47daa5..62e2e29 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_text.c +++ b/src/gallium/auxiliary/tgsi/tgsi_text.c @@ -182,7 +182,20 @@ struct translate_ctx static void report_error( struct translate_ctx *ctx, const char *msg ) { - debug_printf( "\nError: %s", msg ); + int line = 0; + int column = 0; + const char *itr = ctx->text; + + while (itr != ctx->cur) { + if (*itr == '\n') { + column = 0; + ++line; + } + ++column; + ++itr; + } + + debug_printf( "\nTGSI asm error: %s [%d : %d] \n", msg, line, column ); } /* Parse shader header. -- 1.6.5.4
------------------------------------------------------------------------------ Return on Information: Google Enterprise Search pays you back Get the facts. http://p.sf.net/sfu/google-dev2dev
_______________________________________________ Mesa3d-dev mailing list Mesa3d-dev@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mesa3d-dev