diff options
author | Michal Krol <michal@vmware.com> | 2009-09-04 15:16:21 +0200 |
---|---|---|
committer | Michal Krol <michal@vmware.com> | 2009-09-07 10:12:07 +0200 |
commit | 4aa3222df315e3b36c73374e9000a6607c3b995c (patch) | |
tree | 6f8fd9d68f913fa9f15e954c7263580ccc164ddc /src/glsl/pp/sl_pp_process.c | |
parent | 0d9c5eafeb35fdd2e5009ba0b397d1acdfbd3205 (diff) |
glsl: Correctly handle line numbering.
Diffstat (limited to 'src/glsl/pp/sl_pp_process.c')
-rw-r--r-- | src/glsl/pp/sl_pp_process.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/glsl/pp/sl_pp_process.c b/src/glsl/pp/sl_pp_process.c index 5479e8a868..c4d6efaed3 100644 --- a/src/glsl/pp/sl_pp_process.c +++ b/src/glsl/pp/sl_pp_process.c @@ -75,6 +75,21 @@ sl_pp_process(struct sl_pp_context *context, memset(&state, 0, sizeof(state)); + if (context->line > 1) { + struct sl_pp_token_info ti; + + ti.token = SL_PP_LINE; + ti.data.line = context->line - 1; + if (sl_pp_process_out(&state, &ti)) { + return -1; + } + + ti.token = SL_PP_NEWLINE; + if (sl_pp_process_out(&state, &ti)) { + return -1; + } + } + while (!found_eof) { skip_whitespace(input, &i); if (input[i].token == SL_PP_HASH) { @@ -156,7 +171,7 @@ sl_pp_process(struct sl_pp_context *context, return -1; } } else if (!strcmp(name, "line")) { - if (sl_pp_process_line(context, input, first, last)) { + if (sl_pp_process_line(context, input, first, last, &state)) { return -1; } } else if (!strcmp(name, "pragma")) { @@ -176,6 +191,7 @@ sl_pp_process(struct sl_pp_context *context, if (sl_pp_process_out(&state, &endof)) { return -1; } + context->line++; } break; @@ -184,6 +200,7 @@ sl_pp_process(struct sl_pp_context *context, if (sl_pp_process_out(&state, &input[i])) { return -1; } + context->line++; i++; break; @@ -214,6 +231,7 @@ sl_pp_process(struct sl_pp_context *context, if (sl_pp_process_out(&state, &input[i])) { return -1; } + context->line++; i++; found_eol = 1; break; |