From 32bf274f78920c24ea213452bdaa4d8b2b2a029c Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Sun, 30 Jul 2006 14:48:01 +0000 Subject: Program to convert .syn file to .h headers. --- src/mesa/shader/slang/library/syn_to_c.c | 72 ++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/mesa/shader/slang/library/syn_to_c.c diff --git a/src/mesa/shader/slang/library/syn_to_c.c b/src/mesa/shader/slang/library/syn_to_c.c new file mode 100644 index 00000000000..f997edfd8b5 --- /dev/null +++ b/src/mesa/shader/slang/library/syn_to_c.c @@ -0,0 +1,72 @@ +#include + +static int was_space = 0; +static int first_char = 1; + +static void put_char (int c) +{ + if (c == '\n') { + if (!first_char) { + fputs ("\\n\"\n\"", stdout); + first_char = 1; + } + } + else { + first_char = 0; + if (c == '\\') + fputs ("\\\\", stdout); + else if (c == '\"') + fputs ("\\\"", stdout); + else if (!was_space || !(c == ' ' || c == '\t')) + fputc (c, stdout); + was_space = (c == ' ' || c == '\t'); + } +} + +int main (int argc, char *argv[]) +{ + int c; + FILE *f; + + if (argc == 1) + return 1; + f = fopen (argv[1], "r"); + if (f == NULL) + return 1; + + fputs ("\n", stdout); + fputs ("/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE .syn FILE */\n", stdout); + fputs ("\n", stdout); + fputs ("\"", stdout); + c = getc (f); + while (c != EOF) { + if (c == '/') { + int c2 = getc (f); + if (c2 == '*') { + was_space = 0; + c = getc (f); + for (;;) { + if (c == '*') { + c2 = getc (f); + if (c2 == '/') + break; + } + c = getc (f); + } + } + else { + put_char (c); + put_char (c2); + } + } + else { + put_char (c); + } + c = getc (f); + } + fputs ("\"\n", stdout); + + fclose (f); + return 0; +} + -- cgit v1.2.3