projects
/
mesa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
glsl/apps: No need to purify source text for tokeniser.
[mesa.git]
/
src
/
glsl
/
apps
/
version.c
diff --git
a/src/glsl/apps/version.c
b/src/glsl/apps/version.c
index e774c4a8f163743b4327be64d10a7dd087b5af57..b1d0d6ff282d7e2ded065c474951d58143693357 100644
(file)
--- a/
src/glsl/apps/version.c
+++ b/
src/glsl/apps/version.c
@@
-27,9
+27,9
@@
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <assert.h>
#include <assert.h>
-#include "../pp/sl_pp_purify.h"
-#include "../pp/sl_pp_version.h"
+#include "../pp/sl_pp_public.h"
int
int
@@
-40,7
+40,9
@@
main(int argc,
long size;
char *inbuf;
struct sl_pp_purify_options options;
long size;
char *inbuf;
struct sl_pp_purify_options options;
- char *outbuf;
+ char errmsg[100] = "";
+ unsigned int errline = 0;
+ struct sl_pp_context *context;
struct sl_pp_token_info *tokens;
unsigned int version;
unsigned int tokens_eaten;
struct sl_pp_token_info *tokens;
unsigned int version;
unsigned int tokens_eaten;
@@
-59,14
+61,26
@@
main(int argc,
size = ftell(in);
fseek(in, 0, SEEK_SET);
size = ftell(in);
fseek(in, 0, SEEK_SET);
+ out = fopen(argv[2], "wb");
+ if (!out) {
+ fclose(in);
+ return 1;
+ }
+
inbuf = malloc(size + 1);
if (!inbuf) {
inbuf = malloc(size + 1);
if (!inbuf) {
+ fprintf(out, "$OOMERROR\n");
+
+ fclose(out);
fclose(in);
return 1;
}
if (fread(inbuf, 1, size, in) != size) {
fclose(in);
return 1;
}
if (fread(inbuf, 1, size, in) != size) {
+ fprintf(out, "$READERROR\n");
+
free(inbuf);
free(inbuf);
+ fclose(out);
fclose(in);
return 1;
}
fclose(in);
return 1;
}
@@
-76,33
+90,42
@@
main(int argc,
memset(&options, 0, sizeof(options));
memset(&options, 0, sizeof(options));
- if (sl_pp_purify(inbuf, &options, &outbuf)) {
+ context = sl_pp_context_create();
+ if (!context) {
+ fprintf(out, "$CONTEXERROR\n");
+
free(inbuf);
free(inbuf);
+ fclose(out);
return 1;
}
return 1;
}
- free(inbuf);
+ if (sl_pp_tokenise(context, inbuf, &options, &tokens)) {
+ fprintf(out, "$ERROR: `%s'\n", sl_pp_context_error_message(context));
- if (sl_pp_tokenise(outbuf, &tokens)) {
- free(outbuf);
+ sl_pp_context_destroy(context);
+ free(inbuf);
+ fclose(out);
return 1;
}
return 1;
}
- free(
out
buf);
+ free(
in
buf);
- if (sl_pp_version(tokens, &version, &tokens_eaten)) {
+ if (sl_pp_version(context, tokens, &version, &tokens_eaten)) {
+ fprintf(out, "$ERROR: `%s'\n", sl_pp_context_error_message(context));
+
+ sl_pp_context_destroy(context);
free(tokens);
free(tokens);
+ fclose(out);
return -1;
}
return -1;
}
+ sl_pp_context_destroy(context);
free(tokens);
free(tokens);
- out = fopen(argv[2], "wb");
- if (!out) {
- return 1;
- }
-
- fprintf(out, "%u\n", version);
+ fprintf(out,
+ "%u\n%u\n",
+ version,
+ tokens_eaten);
fclose(out);
fclose(out);