diff options
author | marha <marha@users.sourceforge.net> | 2013-02-05 08:22:00 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2013-02-05 08:23:51 +0100 |
commit | 76c527be60066b647468ad66f8e4d7dd18fa1769 (patch) | |
tree | 2e4653dc3adf874409cf9baba399fd64537115d4 /mesalib/src/glsl/linker.cpp | |
parent | a6d5f8de1394c338d01b65be7dba3520bf8bdf4b (diff) | |
download | vcxsrv-76c527be60066b647468ad66f8e4d7dd18fa1769.tar.gz vcxsrv-76c527be60066b647468ad66f8e4d7dd18fa1769.tar.bz2 vcxsrv-76c527be60066b647468ad66f8e4d7dd18fa1769.zip |
fontconfig mesa xkeyboard-config git update 5 feb 2013
xkeyboard-config commit b4be67b48fb11989f1824dd0b1c8c399430162b0
fontconfig commit 95af7447dba7c54ed162b667c0bb2ea6500e8f32
mesa commit 86536a321d9d26137587affe687a07da71f0b526
Diffstat (limited to 'mesalib/src/glsl/linker.cpp')
-rw-r--r-- | mesalib/src/glsl/linker.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp index 63ce178f4..57e7a9ad3 100644 --- a/mesalib/src/glsl/linker.cpp +++ b/mesalib/src/glsl/linker.cpp @@ -200,6 +200,65 @@ linker_warning(gl_shader_program *prog, const char *fmt, ...) } +/** + * Given a string identifying a program resource, break it into a base name + * and an optional array index in square brackets. + * + * If an array index is present, \c out_base_name_end is set to point to the + * "[" that precedes the array index, and the array index itself is returned + * as a long. + * + * If no array index is present (or if the array index is negative or + * mal-formed), \c out_base_name_end, is set to point to the null terminator + * at the end of the input string, and -1 is returned. + * + * Only the final array index is parsed; if the string contains other array + * indices (or structure field accesses), they are left in the base name. + * + * No attempt is made to check that the base name is properly formed; + * typically the caller will look up the base name in a hash table, so + * ill-formed base names simply turn into hash table lookup failures. + */ +long +parse_program_resource_name(const GLchar *name, + const GLchar **out_base_name_end) +{ + /* Section 7.3.1 ("Program Interfaces") of the OpenGL 4.3 spec says: + * + * "When an integer array element or block instance number is part of + * the name string, it will be specified in decimal form without a "+" + * or "-" sign or any extra leading zeroes. Additionally, the name + * string will not include white space anywhere in the string." + */ + + const size_t len = strlen(name); + *out_base_name_end = name + len; + + if (len == 0 || name[len-1] != ']') + return -1; + + /* Walk backwards over the string looking for a non-digit character. This + * had better be the opening bracket for an array index. + * + * Initially, i specifies the location of the ']'. Since the string may + * contain only the ']' charcater, walk backwards very carefully. + */ + unsigned i; + for (i = len - 1; (i > 0) && isdigit(name[i-1]); --i) + /* empty */ ; + + if ((i == 0) || name[i-1] != '[') + return -1; + + long array_index = strtol(&name[i], NULL, 10); + if (array_index < 0) + return -1; + + *out_base_name_end = name + (i - 1); + return array_index; +} + + void link_invalidate_variable_locations(gl_shader *sh, int input_base, int output_base) |