From: Kenneth Graunke Date: Mon, 21 Jun 2010 18:43:42 +0000 (-0700) Subject: Use yy_scan_string and stop caring about shader->SourceLen. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4a2bbdacfc29460de09e5f806fcc96040ad17dc4;p=mesa.git Use yy_scan_string and stop caring about shader->SourceLen. We had to call strlen on the preprocessed source, which seemed a bit pointless; also, we updated shader->SourceLen but not shader->Source, which was even more confusing. Just leave both untouched. --- diff --git a/glcpp/pp.c b/glcpp/pp.c index eaca4819ce5..e6921db46b5 100644 --- a/glcpp/pp.c +++ b/glcpp/pp.c @@ -57,7 +57,7 @@ glcpp_warning (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...) } extern int -preprocess(void *talloc_ctx, const char **shader, size_t *shader_len) +preprocess(void *talloc_ctx, const char **shader) { int errors; glcpp_parser_t *parser = glcpp_parser_create (); @@ -69,7 +69,6 @@ preprocess(void *talloc_ctx, const char **shader, size_t *shader_len) talloc_steal(talloc_ctx, parser->output); *shader = parser->output; - *shader_len = strlen(parser->output); errors = parser->error; glcpp_parser_destroy (parser); diff --git a/glsl_lexer.lpp b/glsl_lexer.lpp index cd150f81ca1..9a3037a8ff5 100644 --- a/glsl_lexer.lpp +++ b/glsl_lexer.lpp @@ -330,11 +330,10 @@ precision return PRECISION; %% void -_mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, - const char *string, size_t len) +_mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, const char *string) { yylex_init_extra(state, & state->scanner); - yy_scan_bytes(string, len, state->scanner); + yy_scan_string(string, state->scanner); } void diff --git a/glsl_parser_extras.h b/glsl_parser_extras.h index cad3424f6bd..1edd86bc6ea 100644 --- a/glsl_parser_extras.h +++ b/glsl_parser_extras.h @@ -102,11 +102,11 @@ extern void _mesa_glsl_warning(const YYLTYPE *locp, const char *fmt, ...); extern "C" { -extern int preprocess(void *ctx, const char **shader, size_t *shader_len); +extern int preprocess(void *ctx, const char **shader); } extern void _mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, - const char *string, size_t len); + const char *string); extern void _mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state); diff --git a/main.cpp b/main.cpp index 58657fe2012..25904380c95 100644 --- a/main.cpp +++ b/main.cpp @@ -128,10 +128,10 @@ compile_shader(struct glsl_shader *shader) * should probably be the parser context, but there isn't one yet. */ const char *source = shader->Source; - state.error = preprocess(shader, &source, &shader->SourceLen); + state.error = preprocess(shader, &source); if (!state.error) { - _mesa_glsl_lexer_ctor(& state, source, shader->SourceLen); + _mesa_glsl_lexer_ctor(& state, source); _mesa_glsl_parse(& state); _mesa_glsl_lexer_dtor(& state); }