<div dir="ltr">On 21 January 2014 04:19, Timothy Arceri <span dir="ltr"><<a href="mailto:t_arceri@yahoo.com.au" target="_blank">t_arceri@yahoo.com.au</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">We need to insert outermost dimensions in the correct spot otherwise<br>
the dimension order will be backwards<br>
<br>
Signed-off-by: Timothy Arceri <<a href="mailto:t_arceri@yahoo.com.au">t_arceri@yahoo.com.au</a>><br>
---<br>
src/glsl/glsl_types.cpp | 14 ++++++++++++--<br>
1 file changed, 12 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp<br>
index 12d4ac0..f7f3117 100644<br>
--- a/src/glsl/glsl_types.cpp<br>
+++ b/src/glsl/glsl_types.cpp<br>
@@ -300,8 +300,18 @@ glsl_type::glsl_type(const glsl_type *array, unsigned length) :<br>
<br>
if (length == 0)<br>
snprintf(n, name_length, "%s[]", array->name);<br>
- else<br>
- snprintf(n, name_length, "%s[%u]", array->name, length);<br>
+ else {<br>
+ /* insert outermost dimensions in the correct spot */<br>
+ const char *pos = strchr(array->name, '[');<br>
+ if (pos) {<br>
+ int idx = pos - array->name;<br>
+ snprintf(n, idx+1, "%s", array->name);<br>
+ snprintf(n + idx, name_length, "[%u]", length);<br>
+ snprintf(n + strlen(n), name_length, "%s", array->name + idx);<br></blockquote><div><br></div><div>Technically the last two snprintf's are unsafe, since the second argument is a length, so we need to subtract the offset we supplied to the first argument.<br>
<br>Also, there's no need to split the second snprintf from the third; both of them can be combined to:<br><br></div><div>snprintf(n + idx, name_length - idx, "[%u]%s", length, array->name + idx);<br><br>
</div><div>Good catch on noticing that it's necessary to reverse the order of the dimensions. With that fixed, this patch is:<br><br></div><div>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ } else {<br>
+ snprintf(n, name_length, "%s[%u]", array->name, length);<br>
+ }<br>
+ }<br>
<br>
this->name = n;<br>
}<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.3.1<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>