summaryrefslogtreecommitdiffstats
path: root/src/glsl/apps
diff options
context:
space:
mode:
Diffstat (limited to 'src/glsl/apps')
-rw-r--r--src/glsl/apps/process.c21
-rw-r--r--src/glsl/apps/tokenise.c15
-rw-r--r--src/glsl/apps/version.c10
3 files changed, 32 insertions, 14 deletions
diff --git a/src/glsl/apps/process.c b/src/glsl/apps/process.c
index 6e2828aa411..abcf1a92b83 100644
--- a/src/glsl/apps/process.c
+++ b/src/glsl/apps/process.c
@@ -28,6 +28,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
+#include "../pp/sl_pp_context.h"
#include "../pp/sl_pp_purify.h"
#include "../pp/sl_pp_version.h"
#include "../pp/sl_pp_process.h"
@@ -42,6 +43,7 @@ main(int argc,
char *inbuf;
struct sl_pp_purify_options options;
char *outbuf;
+ struct sl_pp_context context;
struct sl_pp_token_info *tokens;
unsigned int version;
unsigned int tokens_eaten;
@@ -86,19 +88,24 @@ main(int argc,
free(inbuf);
- if (sl_pp_tokenise(outbuf, &tokens)) {
+ sl_pp_context_init(&context);
+
+ if (sl_pp_tokenise(&context, outbuf, &tokens)) {
+ sl_pp_context_destroy(&context);
free(outbuf);
return 1;
}
free(outbuf);
- if (sl_pp_version(tokens, &version, &tokens_eaten)) {
+ if (sl_pp_version(&context, tokens, &version, &tokens_eaten)) {
+ sl_pp_context_destroy(&context);
free(tokens);
return -1;
}
- if (sl_pp_process(&tokens[tokens_eaten], &outtokens)) {
+ if (sl_pp_process(&context, &tokens[tokens_eaten], &outtokens)) {
+ sl_pp_context_destroy(&context);
free(tokens);
return -1;
}
@@ -107,6 +114,7 @@ main(int argc,
out = fopen(argv[2], "wb");
if (!out) {
+ sl_pp_context_destroy(&context);
free(outtokens);
return 1;
}
@@ -298,13 +306,11 @@ main(int argc,
break;
case SL_PP_IDENTIFIER:
- fprintf(out, "%s ", outtokens[i].data.identifier);
- free(outtokens[i].data.identifier);
+ fprintf(out, "%s ", sl_pp_context_cstr(&context, outtokens[i].data.identifier));
break;
case SL_PP_NUMBER:
- fprintf(out, "(%s) ", outtokens[i].data.number);
- free(outtokens[i].data.number);
+ fprintf(out, "%s ", sl_pp_context_cstr(&context, outtokens[i].data.number));
break;
case SL_PP_OTHER:
@@ -316,6 +322,7 @@ main(int argc,
}
}
+ sl_pp_context_destroy(&context);
free(outtokens);
fclose(out);
diff --git a/src/glsl/apps/tokenise.c b/src/glsl/apps/tokenise.c
index 2631b829986..b5092ba35f6 100644
--- a/src/glsl/apps/tokenise.c
+++ b/src/glsl/apps/tokenise.c
@@ -28,6 +28,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
+#include "../pp/sl_pp_context.h"
#include "../pp/sl_pp_purify.h"
#include "../pp/sl_pp_token.h"
@@ -41,6 +42,7 @@ main(int argc,
char *inbuf;
struct sl_pp_purify_options options;
char *outbuf;
+ struct sl_pp_context context;
struct sl_pp_token_info *tokens;
FILE *out;
unsigned int i;
@@ -82,7 +84,10 @@ main(int argc,
free(inbuf);
- if (sl_pp_tokenise(outbuf, &tokens)) {
+ sl_pp_context_init(&context);
+
+ if (sl_pp_tokenise(&context, outbuf, &tokens)) {
+ sl_pp_context_destroy(&context);
free(outbuf);
return 1;
}
@@ -91,6 +96,7 @@ main(int argc,
out = fopen(argv[2], "wb");
if (!out) {
+ sl_pp_context_destroy(&context);
free(tokens);
return 1;
}
@@ -289,13 +295,11 @@ main(int argc,
break;
case SL_PP_IDENTIFIER:
- fprintf(out, "%s ", tokens[i].data.identifier);
- free(tokens[i].data.identifier);
+ fprintf(out, "%s ", sl_pp_context_cstr(&context, tokens[i].data.identifier));
break;
case SL_PP_NUMBER:
- fprintf(out, "(%s) ", tokens[i].data.number);
- free(tokens[i].data.number);
+ fprintf(out, "(%s) ", sl_pp_context_cstr(&context, tokens[i].data.number));
break;
case SL_PP_OTHER:
@@ -311,6 +315,7 @@ main(int argc,
}
}
+ sl_pp_context_destroy(&context);
free(tokens);
fclose(out);
diff --git a/src/glsl/apps/version.c b/src/glsl/apps/version.c
index b49395ba97f..c56ae9dde9a 100644
--- a/src/glsl/apps/version.c
+++ b/src/glsl/apps/version.c
@@ -41,6 +41,7 @@ main(int argc,
char *inbuf;
struct sl_pp_purify_options options;
char *outbuf;
+ struct sl_pp_context context;
struct sl_pp_token_info *tokens;
unsigned int version;
unsigned int tokens_eaten;
@@ -83,18 +84,23 @@ main(int argc,
free(inbuf);
- if (sl_pp_tokenise(outbuf, &tokens)) {
+ sl_pp_context_init(&context);
+
+ if (sl_pp_tokenise(&context, outbuf, &tokens)) {
+ sl_pp_context_destroy(&context);
free(outbuf);
return 1;
}
free(outbuf);
- if (sl_pp_version(tokens, &version, &tokens_eaten)) {
+ if (sl_pp_version(&context, tokens, &version, &tokens_eaten)) {
+ sl_pp_context_destroy(&context);
free(tokens);
return -1;
}
+ sl_pp_context_destroy(&context);
free(tokens);
out = fopen(argv[2], "wb");