aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl/glcpp
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-10-05 17:44:57 +0200
committermarha <marha@users.sourceforge.net>2011-10-05 17:44:57 +0200
commit8af87a5b60e37ae84fdd759e2c1602be38be4905 (patch)
tree2e621c7fbdc4dfe9eb8d733af4cc232bc03643d4 /mesalib/src/glsl/glcpp
parent8238de0fe0c28bd54b3e6cdd1fc94513cf21d3cc (diff)
parentf7025b4baa1ba35ee796785641f04eac5bedb0a6 (diff)
downloadvcxsrv-8af87a5b60e37ae84fdd759e2c1602be38be4905.tar.gz
vcxsrv-8af87a5b60e37ae84fdd759e2c1602be38be4905.tar.bz2
vcxsrv-8af87a5b60e37ae84fdd759e2c1602be38be4905.zip
Merge remote-tracking branch 'origin/released'
Conflicts: mesalib/src/mapi/glapi/glapi.h mesalib/src/mesa/main/syncobj.h xorg-server/dix/events.c xorg-server/dix/getevents.c xorg-server/include/misc.h
Diffstat (limited to 'mesalib/src/glsl/glcpp')
-rw-r--r--mesalib/src/glsl/glcpp/glcpp-parse.y89
1 files changed, 49 insertions, 40 deletions
diff --git a/mesalib/src/glsl/glcpp/glcpp-parse.y b/mesalib/src/glsl/glcpp/glcpp-parse.y
index 940830416..17941a9be 100644
--- a/mesalib/src/glsl/glcpp/glcpp-parse.y
+++ b/mesalib/src/glsl/glcpp/glcpp-parse.y
@@ -1275,6 +1275,48 @@ _glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list)
glcpp_parser_lex_from (parser, expanded);
}
+static void
+_glcpp_parser_apply_pastes (glcpp_parser_t *parser, token_list_t *list)
+{
+ token_node_t *node;
+
+ node = list->head;
+ while (node)
+ {
+ token_node_t *next_non_space;
+
+ /* Look ahead for a PASTE token, skipping space. */
+ next_non_space = node->next;
+ while (next_non_space && next_non_space->token->type == SPACE)
+ next_non_space = next_non_space->next;
+
+ if (next_non_space == NULL)
+ break;
+
+ if (next_non_space->token->type != PASTE) {
+ node = next_non_space;
+ continue;
+ }
+
+ /* Now find the next non-space token after the PASTE. */
+ next_non_space = next_non_space->next;
+ while (next_non_space && next_non_space->token->type == SPACE)
+ next_non_space = next_non_space->next;
+
+ if (next_non_space == NULL) {
+ yyerror (&node->token->location, parser, "'##' cannot appear at either end of a macro expansion\n");
+ return;
+ }
+
+ node->token = _token_paste (parser, node->token, next_non_space->token);
+ node->next = next_non_space->next;
+ if (next_non_space == list->tail)
+ list->tail = node;
+ }
+
+ list->non_space_tail = list->tail;
+}
+
/* This is a helper function that's essentially part of the
* implementation of _glcpp_parser_expand_node. It shouldn't be called
* except for by that function.
@@ -1386,43 +1428,7 @@ _glcpp_parser_expand_function (glcpp_parser_t *parser,
_token_list_trim_trailing_space (substituted);
- node = substituted->head;
- while (node)
- {
- token_node_t *next_non_space;
-
- /* Look ahead for a PASTE token, skipping space. */
- next_non_space = node->next;
- while (next_non_space && next_non_space->token->type == SPACE)
- next_non_space = next_non_space->next;
-
- if (next_non_space == NULL)
- break;
-
- if (next_non_space->token->type != PASTE) {
- node = next_non_space;
- continue;
- }
-
- /* Now find the next non-space token after the PASTE. */
- next_non_space = next_non_space->next;
- while (next_non_space && next_non_space->token->type == SPACE)
- next_non_space = next_non_space->next;
-
- if (next_non_space == NULL) {
- yyerror (&node->token->location, parser, "'##' cannot appear at either end of a macro expansion\n");
- return NULL;
- }
-
- node->token = _token_paste (parser, node->token, next_non_space->token);
- node->next = next_non_space->next;
- if (next_non_space == substituted->tail)
- substituted->tail = node;
-
- node = node->next;
- }
-
- substituted->non_space_tail = substituted->tail;
+ _glcpp_parser_apply_pastes (parser, substituted);
return substituted;
}
@@ -1492,13 +1498,16 @@ _glcpp_parser_expand_node (glcpp_parser_t *parser,
if (! macro->is_function)
{
+ token_list_t *replacement;
*last = node;
/* Replace a macro defined as empty with a SPACE token. */
if (macro->replacements == NULL)
return _token_list_create_with_one_space (parser);
- return _token_list_copy (parser, macro->replacements);
+ replacement = _token_list_copy (parser, macro->replacements);
+ _glcpp_parser_apply_pastes (parser, replacement);
+ return replacement;
}
return _glcpp_parser_expand_function (parser, node, last);
@@ -1654,8 +1663,8 @@ _check_for_reserved_macro_name (glcpp_parser_t *parser, YYLTYPE *loc,
/* According to the GLSL specification, macro names starting with "__"
* or "GL_" are reserved for future use. So, don't allow them.
*/
- if (strncmp(identifier, "__", 2) == 0) {
- glcpp_error (loc, parser, "Macro names starting with \"__\" are reserved.\n");
+ if (strstr(identifier, "__")) {
+ glcpp_error (loc, parser, "Macro names containing \"__\" are reserved.\n");
}
if (strncmp(identifier, "GL_", 3) == 0) {
glcpp_error (loc, parser, "Macro names starting with \"GL_\" are reserved.\n");