[asterisk-dev] Opinions Needed: Case sensitivity in config file section names

Matthew Jordan mjordan at digium.com
Tue Sep 23 10:52:51 CDT 2014


On Tue, Sep 23, 2014 at 10:45 AM, George Joseph <george.joseph at fairview5.com
> wrote:

> 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:
>
> /* try exact match first, then case-insensitive match */
> for (cat = config->root; cat; cat = cat->next) {
> if (cat->name == category_name && (ignored || !cat->ignored))
> return cat;
> }
>
> for (cat = config->root; cat; cat = cat->next) {
> if (!strcasecmp(cat->name, category_name) && (ignored || !cat->ignored))
> return cat;
> }
>
> The result is that the case sensitive match never succeeds and it's always
> the case insensitive match that's run.
>
> 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.
>
>
>
My vote is for case insensitive.

In fact, practically speaking, I'm not sure how this isn't always case
insensitive.

Given contexts [foo] and [Foo], searching for "foo":

* If foo matches context foo directly, return foo.
* If foo matches context Foo, return Foo.

Either way, you'll end up matching on Foo eventually.

If there's a risk here that I'm missing, then I'd vote trunk only for
changes.

-- 
Matthew Jordan
Digium, Inc. | Engineering Manager
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: http://digium.com & http://asterisk.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20140923/526b3cb5/attachment.html>


More information about the asterisk-dev mailing list