REVISION 3.
[mesa.git] / src / mesa / shader / slang / slang_preprocess.c
index b9c7a9efceb0401febba446b417667243197e0c9..3601a384f7a379972093faf8859a4f1c7ce750ef 100644 (file)
@@ -1,8 +1,8 @@
 /*\r
  * Mesa 3-D graphics library\r
- * Version:  6.3\r
+ * Version:  6.5\r
  *\r
- * Copyright (C) 2005  Brian Paul   All Rights Reserved.\r
+ * Copyright (C) 2005-2006  Brian Paul   All Rights Reserved.\r
  *\r
  * Permission is hereby granted, free of charge, to any person obtaining a\r
  * copy of this software and associated documentation files (the "Software"),\r
  * \author Michal Krol\r
  */\r
 \r
-#include "imports.h" \r
-#include "slang_compile.h"\r
+#include "imports.h"\r
 #include "grammar_mesa.h"\r
+#include "slang_utility.h"\r
+#include "slang_compile.h"\r
 #include "slang_preprocess.h"\r
 \r
 static const char *slang_version_syn =\r
@@ -49,7 +50,7 @@ int _slang_preprocess_version (const char *text, unsigned int *version, unsigned
        {\r
                char buf[1024];\r
                unsigned int pos;\r
-               grammar_get_last_error (buf, 1024, &pos);\r
+               grammar_get_last_error ( (unsigned char*) buf, 1024, (int*) &pos);\r
                slang_info_log_error (log, buf);\r
                return 0;\r
        }\r
@@ -58,7 +59,7 @@ int _slang_preprocess_version (const char *text, unsigned int *version, unsigned
        {\r
                char buf[1024];\r
                unsigned int pos;\r
-               grammar_get_last_error (buf, 1024, &pos);\r
+               grammar_get_last_error ( (unsigned char*) buf, 1024, (int*) &pos);\r
                slang_info_log_error (log, buf);\r
                grammar_destroy (id);\r
                return 0;\r
@@ -66,12 +67,18 @@ int _slang_preprocess_version (const char *text, unsigned int *version, unsigned
 \r
        grammar_destroy (id);\r
 \r
+       /* there can be multiple #version directives - grab the last one */\r
        I = prod;\r
        while (I < prod + size)\r
        {\r
-               *version = (unsigned int) I[0] + (unsigned int) I[1] * 100;\r
-               *eaten = (unsigned int) I[2] + ((unsigned int) I[3] << 8) +\r
-                       ((unsigned int) I[4] << 16) + ((unsigned int) I[5] << 24);\r
+               *version =\r
+                       (unsigned int) I[0] +\r
+                       (unsigned int) I[1] * 100;\r
+               *eaten =\r
+                       ((unsigned int) I[2]) +\r
+                       ((unsigned int) I[3] << 8) +\r
+                       ((unsigned int) I[4] << 16) +\r
+                       ((unsigned int) I[5] << 24);\r
                I += 6;\r
        }\r
 \r