#define RETURN_STRING_TOKEN(token) \
do { \
if (! parser->skipping) { \
- yylval->str = linear_strdup(yyextra->linalloc, yytext); \
+ /* We're not doing linear_strdup here, to avoid \
+ * an implicit call on strlen() for the length \
+ * of the string, as this is already found by \
+ * flex and stored in yyleng */ \
+ void *mem_ctx = yyextra->linalloc; \
+ yylval->str = linear_alloc_child(mem_ctx, \
+ yyleng + 1); \
+ memcpy(yylval->str, yytext, yyleng + 1); \
RETURN_TOKEN_NEVER_SKIP (token); \
} \
} while(0)
"illegal use of reserved word `%s'", yytext); \
return ERROR_TOK; \
} else { \
- void *mem_ctx = yyextra->linalloc; \
- yylval->identifier = linear_strdup(mem_ctx, yytext); \
+ /* We're not doing linear_strdup here, to avoid an implicit \
+ * call on strlen() for the length of the string, as this is \
+ * already found by flex and stored in yyleng */ \
+ void *mem_ctx = yyextra->linalloc; \
+ char *id = (char *) linear_alloc_child(mem_ctx, yyleng + 1); \
+ memcpy(id, yytext, yyleng + 1); \
+ yylval->identifier = id; \
return classify_identifier(yyextra, yytext); \
} \
} while (0)
<PP>[ \t\r]* { }
<PP>: return COLON;
<PP>[_a-zA-Z][_a-zA-Z0-9]* {
- void *mem_ctx = yyextra->linalloc;
- yylval->identifier = linear_strdup(mem_ctx, yytext);
+ /* We're not doing linear_strdup here, to avoid an implicit call
+ * on strlen() for the length of the string, as this is already
+ * found by flex and stored in yyleng
+ */
+ void *mem_ctx = yyextra->linalloc;
+ char *id = (char *) linear_alloc_child(mem_ctx, yyleng + 1);
+ memcpy(id, yytext, yyleng + 1);
+ yylval->identifier = id;
return IDENTIFIER;
}
<PP>[1-9][0-9]* {
|| yyextra->ARB_tessellation_shader_enable) {
return LAYOUT_TOK;
} else {
- void *mem_ctx = yyextra->linalloc;
- yylval->identifier = linear_strdup(mem_ctx, yytext);
+ /* We're not doing linear_strdup here, to avoid an implicit call
+ * on strlen() for the length of the string, as this is already
+ * found by flex and stored in yyleng
+ */
+ void *mem_ctx = yyextra->linalloc;
+ char *id = (char *) linear_alloc_child(mem_ctx, yyleng + 1);
+ memcpy(id, yytext, yyleng + 1);
+ yylval->identifier = id;
return classify_identifier(yyextra, yytext);
}
}
[_a-zA-Z][_a-zA-Z0-9]* {
struct _mesa_glsl_parse_state *state = yyextra;
void *ctx = state->linalloc;
- if (state->es_shader && strlen(yytext) > 1024) {
+ if (state->es_shader && yyleng > 1024) {
_mesa_glsl_error(yylloc, state,
"Identifier `%s' exceeds 1024 characters",
yytext);
} else {
- yylval->identifier = linear_strdup(ctx, yytext);
+ /* We're not doing linear_strdup here, to avoid an implicit call
+ * on strlen() for the length of the string, as this is already
+ * found by flex and stored in yyleng
+ */
+ char *id = (char *) linear_alloc_child(ctx, yyleng + 1);
+ memcpy(id, yytext, yyleng + 1);
+ yylval->identifier = id;
}
return classify_identifier(state, yytext);
}