On 20 December 2011 06:56, Brian Paul <span dir="ltr">&lt;<a href="mailto:brianp@vmware.com">brianp@vmware.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On 12/19/2011 10:46 PM, Paul Berry wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
If piglit_is_extension_in_string(<u></u>) finds an extension whose name<br>
begins with the name it is searching for, but is not equal to the name<br>
it is searching for (e.g. it is searching for EXT_transform_feedback<br>
but it finds EXT_transform_feedback2), we need it to advance by one<br>
character before restarting the search, otherwise it will loop<br>
indefinitely.<br>
<br>
Prevents a hang when running some transform feedback tests on nVidia&#39;s<br>
proprietary Linux driver.<br>
---<br>
  tests/util/piglit-util.c |   16 ++++++++++++----<br>
  1 files changed, 12 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c<br>
index 65b02f5..3241528 100644<br>
--- a/tests/util/piglit-util.c<br>
+++ b/tests/util/piglit-util.c<br>
@@ -145,15 +145,23 @@ bool piglit_is_extension_in_string(<u></u>const char *haystack, const char *needle)<br>
        if (needle_len == 0)<br>
                return false;<br>
<br>
-       while (haystack != NULL) {<br>
+       while (true) {<br>
                const char *const s = strstr(haystack, needle);<br>
<br>
-               if (s != NULL<br>
-               &amp;&amp;  (s[needle_len] == &#39; &#39; || s[needle_len] == &#39;\0&#39;)) {<br>
+               if (s == NULL)<br>
+                       return false;<br>
+<br>
+               if (s[needle_len] == &#39; &#39; || s[needle_len] == &#39;\0&#39;) {<br>
                        return true;<br>
                }<br>
<br>
-               haystack = s;<br>
+               /* strstr found an extension whose name begins with<br>
+                * needle, but whose name is not equal to needle.<br>
+                * Restart the search at s + 1 so that we don&#39;t just<br>
+                * find the same extension again and go into an<br>
+                * infinite loop.<br>
+                */<br>
+               haystack = s + 1;<br>
</blockquote>
<br></div></div>
Actually, I think you could do &quot;haystack = s + needle_len&quot; but it&#39;s no big deal.<br></blockquote><div><br>Oh yeah.  That&#39;s a better idea.<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
        }<br>
<br>
        return false;<br>
</blockquote>
<br>
-Brian<br>
</blockquote></div><br>