tests: Read integer uniforms with strtol() and strtoul().
Because %i sscanf() converters are deprecated, and in practice clamp to [-2^31, 2^31) on 32 bit.
Merge request reports
Activity
added 1 commit
- b850db67 - tests: Read integer uniforms with strtol() and strtoul().
+static void read_int(const char **line, int *ptr)
I think "ptr" is a bit of an awkward name for this. Likewise for read_uint().
+static void read_int4(const char **line, int (*v)[4])
The "natural" type for "v" would seem struct ivec4. I imagine the choice of passing an array was largely dictated by the set_uniforms() interface, but perhaps it shouldn't be? Likewise for read_uint4().
added 1 commit
- 364adf49 - tests: Read integer uniforms with strtol() and strtoul().
I just noticed this, but:
+static void read_int(const char **line, int *i) +{ + char *rest; + long val; + + errno = 0; + val = strtol(*line, &rest, 0); + + if (errno != 0) + fatal_error("Malformed int constant '%s'.\n", *line); + + *i = val; + if (*i != val) + fatal_error("Out of range int constant '%s'.\n", *line);
Here and to some extent above, I don't think we can just print "*line"; there may be additional data beyond "rest" that we'd also output.
We may also want to make sure "*rest" is either '\0' or a whitespace character.
Here and to some extent above, I don't think we can just print "*line"; there may be additional data beyond "rest" that we'd also output.
This is already happening in various other places. See for example how the
probe
command is parsed. I guess the point of view is that the shader runner is a developer-facing tool, so we prefer a simpler code even if it results in somewhat less polished error messages.We may also want to make sure "*rest" is either '\0' or a whitespace character.
Ok, that makes sense.
added 1 commit
- 104a9429 - tests: Read integer uniforms with strtol() and strtoul().
Here and to some extent above, I don't think we can just print "*line"; there may be additional data beyond "rest" that we'd also output.
This is already happening in various other places. See for example how the
probe
command is parsed. I guess the point of view is that the shader runner is a developer-facing tool, so we prefer a simpler code even if it results in somewhat less polished error messages.I suppose, but I don't think it's that much more complicated to instead do something like
fatal_error("Out of range integer constant '%.*s'.\n", (int)(rest - *line), *line);
This is already happening in various other places. See for example how the
probe
command is parsed. I guess the point of view is that the shader runner is a developer-facing tool, so we prefer a simpler code even if it results in somewhat less polished error messages.In a sense, although it was less an intentional decision towards simplicity as a decision not to put in the effort to make it well-written.
added 1 commit
- d7616f87 - tests: Read integer uniforms with strtol() and strtoul().
added 13 commits
-
d7616f87...eb71c5f2 - 12 commits from branch
wine:master
- 9a27df3a - tests: Read integer uniforms with strtol() and strtoul().
-
d7616f87...eb71c5f2 - 12 commits from branch