<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 23, 2014 at 10:45 AM, George Joseph <span dir="ltr"><<a href="mailto:george.joseph@fairview5.com" target="_blank">george.joseph@fairview5.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I've been working on some changes for config.c and in the process I've found 5 instances of someone attempting to do "cat->name == category_name" instead of "strcmp(cat->name, category_name)". Example:<div><br></div><div><div><font size="1" face="courier new, monospace"><span style="white-space:pre-wrap"> </span>/* try exact match first, then case-insensitive match */</font></div><div><font size="1" face="courier new, monospace"><span style="white-space:pre-wrap"> </span>for (cat = config->root; cat; cat = cat->next) {</font></div><div><font size="1" face="courier new, monospace"><span style="white-space:pre-wrap"> </span>if (cat->name == category_name && (ignored || !cat->ignored))</font></div><div><font size="1" face="courier new, monospace"><span style="white-space:pre-wrap"> </span>return cat;</font></div><div><font size="1" face="courier new, monospace"><span style="white-space:pre-wrap"> </span>}</font></div><div><font size="1" face="courier new, monospace"><br></font></div><div><font size="1" face="courier new, monospace"><span style="white-space:pre-wrap"> </span>for (cat = config->root; cat; cat = cat->next) {</font></div><div><font size="1" face="courier new, monospace"><span style="white-space:pre-wrap"> </span>if (!strcasecmp(cat->name, category_name) && (ignored || !cat->ignored))</font></div><div><font size="1" face="courier new, monospace"><span style="white-space:pre-wrap"> </span>return cat;</font></div><div><font size="1" face="courier new, monospace"><span style="white-space:pre-wrap"> </span>}</font></div></div><div><font size="1" face="courier new, monospace"><br></font></div><div><font face="arial, helvetica, sans-serif">The result is that the case sensitive match never succeeds and it's always the case insensitive match that's run.</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">My question is... Should I fix these so the case sensitive match works and runs first or just remove the first loop so the match is always case-insensitive? I'm hoping the latter not only because it makes the code simpler but because that's how it's worked for years and suddenly making the match case sensitive might cause unexpected problems.</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><br clear="all"></div></blockquote></div><br></div><div class="gmail_extra">My vote is for case insensitive.<br><br></div><div class="gmail_extra">In fact, practically speaking, I'm not sure how this isn't always case insensitive.<br><br></div><div class="gmail_extra">Given contexts [foo] and [Foo], searching for "foo":<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">* If foo matches context foo directly, return foo.<br></div><div class="gmail_extra">* If foo matches context Foo, return Foo.<br><br>Either way, you'll end up matching on Foo eventually.<br><br></div><div class="gmail_extra">If there's a risk here that I'm missing, then I'd vote trunk only for changes.<br></div><div class="gmail_extra"><br>-- <br><div dir="ltr"><div>Matthew Jordan<br></div><div>Digium, Inc. | Engineering Manager</div><div>445 Jan Davis Drive NW - Huntsville, AL 35806 - USA</div><div>Check us out at: <a href="http://digium.com" target="_blank">http://digium.com</a> & <a href="http://asterisk.org" target="_blank">http://asterisk.org</a></div></div>
</div></div>