Propose to polish the consistency of case sensitivity in configurations

From: Tianyin Xu <tixu_at_cs.ucsd.edu>
Date: Tue, 29 Jan 2013 00:49:45 -0800

Hi, guys,

I would like to polish the consistency of the case sensitivity in
configuration options.
Currently in Squid, different configuration options follows different
rules, some are case sensitive but some are case insensitive.

For example, in the parsing function of "uri_whitespace", all the
options are case insensitive, as follows,

/* src/cache_cf.cc */
3167 static void
3168 parse_uri_whitespace(int *var)
......
3175 if (!strcasecmp(token, "strip"))
3176 *var = URI_WHITESPACE_STRIP;
3177 else if (!strcasecmp(token, "deny"))
3178 *var = URI_WHITESPACE_DENY;
3179 else if (!strcasecmp(token, "allow"))
3180 *var = URI_WHITESPACE_ALLOW;
3181 else if (!strcasecmp(token, "encode"))
3182 *var = URI_WHITESPACE_ENCODE;
3183 else if (!strcasecmp(token, "chop"))
3184 *var = URI_WHITESPACE_CHOP;
3185 else
3186 self_destruct();

Such case insensitivity applies for majority options including all the
boolean options (parse_onoff), tristate options (parse_tristate),
parse_peer, parse_cachedir, etc.

On the other hand, there're minority parsing functions using case
sensitive options, e.g., "wccp2_forwarding_method", as follows,

/* src/wccp2.cc */
2016 void
2017 parse_wccp2_method(int *method)
......
2028 if (strcmp(t, "gre") == 0 || strcmp(t, "1") == 0) {
2029 *method = WCCP2_METHOD_GRE;
2030 } else if (strcmp(t, "l2") == 0 || strcmp(t, "2") == 0) {
2031 *method = WCCP2_METHOD_L2;
2032 } else {
2033 debugs(80, DBG_CRITICAL, "wccp2_*_method: unknown
setting, got " << t );
2034 self_destruct();
2035 }

Other case-sensitive parsing functions include parse_wccp2_amethod,
parse_wccp2_service, "none" in parseBytesLine, parseBytesLine64, and
parseBytesLineSigned, etc.

I would like to make the case sensitivity consistent around the
system. The fixes are really simple -- changing the "strcmp" to
"strcasecmp". I plan to check all the use-site of these string
comparison and modify the inconsistent ones.

According to my experience of using Squid, the rule of case
sensitivity in Squid is summarized as follows,
1. Configuration directive is case sensitive, according to
parse_line() in "src/cf_parser.cci";
2. Options (especially enum options) should be case insensitive;
3. For configuration like A B=C, A and B should be sensitive while C
should be insensitive.
I don't know whether my understanding is correct.

How do you guys think? Let's me know you comments.

Thanks a lot!
Tianyin

--
Tianyin XU,
http://cseweb.ucsd.edu/~tixu/
Received on Tue Jan 29 2013 - 08:49:54 MST

This archive was generated by hypermail 2.2.0 : Wed Jan 30 2013 - 12:00:08 MST