int _slang_preprocess_version (const char *text, unsigned int *version, unsigned int *eaten, slang_info_log *log) { grammar id; byte *prod, *I; unsigned int size; id = grammar_load_from_text ((const byte *) slang_version_syn); if (id == 0) { char buf[1024]; unsigned int pos; grammar_get_last_error ( (unsigned char*) buf, 1024, (int*) &pos); slang_info_log_error (log, buf); return 0; } if (!grammar_fast_check (id, (const byte *) text, &prod, &size, 8)) { char buf[1024]; unsigned int pos; grammar_get_last_error ( (unsigned char*) buf, 1024, (int*) &pos); slang_info_log_error (log, buf); grammar_destroy (id); return 0; } grammar_destroy (id); /* there can be multiple #version directives - grab the last one */ I = prod; while (I < prod + size) { *version = (unsigned int) I[0] + (unsigned int) I[1] * 100; *eaten = ((unsigned int) I[2]) + ((unsigned int) I[3] << 8) + ((unsigned int) I[4] << 16) + ((unsigned int) I[5] << 24); I += 6; } grammar_alloc_free (prod); return 1; }
static GLvoid grammar_error_to_log (slang_info_log *log) { char buf[1024]; GLint pos; grammar_get_last_error ((byte *) (buf), sizeof (buf), &pos); if (buf[0] == 0) { _mesa_snprintf(buf, sizeof(buf), "Preprocessor error"); } slang_info_log_error (log, buf); }