projects
/
mesa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge commit 'origin/gallium-0.1' into gallium-0.2
[mesa.git]
/
src
/
mesa
/
shader
/
grammar
/
grammar.c
diff --git
a/src/mesa/shader/grammar/grammar.c
b/src/mesa/shader/grammar/grammar.c
index 7f2ee42d21d7ba06ec26da8cbf955eff1822e8d5..a9775961d3a6577654cc072c8f3e423847e578e6 100644
(file)
--- a/
src/mesa/shader/grammar/grammar.c
+++ b/
src/mesa/shader/grammar/grammar.c
@@
-260,6
+260,8
@@
first).
*/
first).
*/
+#include <stdio.h>
+
static void mem_free (void **);
/*
static void mem_free (void **);
/*
@@
-2691,14
+2693,16
@@
fast_match (dict *di, const byte *text, int *index, rule *ru, int *_PP, bytepool
if (status == mr_matched)
{
if (status == mr_matched)
{
- if (sp->m_emits != NULL)
- if (emit_push (sp->m_emits, _BP->_F + _P, text[ind - 1], save_ind, &ctx))
+ if (sp->m_emits != NULL) {
+ const byte ch = (ind <= 0) ? 0 : text[ind - 1];
+ if (emit_push (sp->m_emits, _BP->_F + _P, ch, save_ind, &ctx))
{
free_regbyte_ctx_stack (ctx, *rbc);
return mr_internal_error;
}
{
free_regbyte_ctx_stack (ctx, *rbc);
return mr_internal_error;
}
- _P = _P2;
+ }
+ _P = _P2;
}
/* if the rule operator is a logical or, we pick up the first matching specifier */
}
/* if the rule operator is a logical or, we pick up the first matching specifier */
@@
-2797,10
+2801,16
@@
static void grammar_load_state_destroy (grammar_load_state **gr)
}
}
}
}
+
+static void error_msg(int line, const char *msg)
+{
+ fprintf(stderr, "Error in grammar_load_from_text() at line %d: %s\n", line, msg);
+}
+
+
/*
the API
*/
/*
the API
*/
-
grammar grammar_load_from_text (const byte *text)
{
grammar_load_state *g = NULL;
grammar grammar_load_from_text (const byte *text)
{
grammar_load_state *g = NULL;
@@
-2809,13
+2819,16
@@
grammar grammar_load_from_text (const byte *text)
clear_last_error ();
grammar_load_state_create (&g);
clear_last_error ();
grammar_load_state_create (&g);
- if (g == NULL)
+ if (g == NULL) {
+ error_msg(__LINE__, "");
return 0;
return 0;
+ }
dict_create (&g->di);
if (g->di == NULL)
{
grammar_load_state_destroy (&g);
dict_create (&g->di);
if (g->di == NULL)
{
grammar_load_state_destroy (&g);
+ error_msg(__LINE__, "");
return 0;
}
return 0;
}
@@
-2829,6
+2842,7
@@
grammar grammar_load_from_text (const byte *text)
if (get_identifier (&text, &g->syntax_symbol))
{
grammar_load_state_destroy (&g);
if (get_identifier (&text, &g->syntax_symbol))
{
grammar_load_state_destroy (&g);
+ error_msg(__LINE__, "");
return 0;
}
eat_spaces (&text);
return 0;
}
eat_spaces (&text);
@@
-2848,6
+2862,7
@@
grammar grammar_load_from_text (const byte *text)
if (get_identifier (&text, &symbol))
{
grammar_load_state_destroy (&g);
if (get_identifier (&text, &symbol))
{
grammar_load_state_destroy (&g);
+ error_msg(__LINE__, "");
return 0;
}
eat_spaces (&text);
return 0;
}
eat_spaces (&text);
@@
-2862,6
+2877,7
@@
grammar grammar_load_from_text (const byte *text)
if (get_emtcode (&text, &ma))
{
grammar_load_state_destroy (&g);
if (get_emtcode (&text, &ma))
{
grammar_load_state_destroy (&g);
+ error_msg(__LINE__, "");
return 0;
}
return 0;
}
@@
-2877,6
+2893,7
@@
grammar grammar_load_from_text (const byte *text)
if (get_regbyte (&text, &ma))
{
grammar_load_state_destroy (&g);
if (get_regbyte (&text, &ma))
{
grammar_load_state_destroy (&g);
+ error_msg(__LINE__, "");
return 0;
}
return 0;
}
@@
-2892,6
+2909,7
@@
grammar grammar_load_from_text (const byte *text)
if (get_errtext (&text, &ma))
{
grammar_load_state_destroy (&g);
if (get_errtext (&text, &ma))
{
grammar_load_state_destroy (&g);
+ error_msg(__LINE__, "");
return 0;
}
return 0;
}
@@
-2905,12
+2923,14
@@
grammar grammar_load_from_text (const byte *text)
if (g->di->m_string != NULL)
{
grammar_load_state_destroy (&g);
if (g->di->m_string != NULL)
{
grammar_load_state_destroy (&g);
+ error_msg(__LINE__, "");
return 0;
}
if (get_identifier (&text, &g->string_symbol))
{
grammar_load_state_destroy (&g);
return 0;
}
if (get_identifier (&text, &g->string_symbol))
{
grammar_load_state_destroy (&g);
+ error_msg(__LINE__, "");
return 0;
}
return 0;
}
@@
-2927,6
+2947,7
@@
grammar grammar_load_from_text (const byte *text)
if (get_rule (&text, &ru, g->maps, g->mapb))
{
grammar_load_state_destroy (&g);
if (get_rule (&text, &ru, g->maps, g->mapb))
{
grammar_load_state_destroy (&g);
+ error_msg(__LINE__, "");
return 0;
}
return 0;
}
@@
-2940,6
+2961,7
@@
grammar grammar_load_from_text (const byte *text)
if (ma == NULL)
{
grammar_load_state_destroy (&g);
if (ma == NULL)
{
grammar_load_state_destroy (&g);
+ error_msg(__LINE__, "");
return 0;
}
return 0;
}
@@
-2953,6
+2975,7
@@
grammar grammar_load_from_text (const byte *text)
g->di->m_regbytes))
{
grammar_load_state_destroy (&g);
g->di->m_regbytes))
{
grammar_load_state_destroy (&g);
+ error_msg(__LINE__, "update_dependencies() failed");
return 0;
}
return 0;
}