Commit 5ab50417 by Carlos Martín Nieto

Remove an unfortunate optimisation from cvar_match_section

The (rather late) early-exit code, which provides a negligible
optimisation causes cvar_match_section to return false negatives when
it's called with a section name instead of a full variable name.

Remove this optimisation.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
parent 340fc0d4
...@@ -130,7 +130,7 @@ static void cvar_list_free(cvar_t_list *list) ...@@ -130,7 +130,7 @@ static void cvar_list_free(cvar_t_list *list)
*/ */
static int cvar_match_section(const char *local, const char *input) static int cvar_match_section(const char *local, const char *input)
{ {
char *first_dot, *last_dot; char *first_dot;
char *local_sp = strchr(local, ' '); char *local_sp = strchr(local, ' ');
int comparison_len; int comparison_len;
...@@ -159,12 +159,8 @@ static int cvar_match_section(const char *local, const char *input) ...@@ -159,12 +159,8 @@ static int cvar_match_section(const char *local, const char *input)
*/ */
first_dot = strchr(input, '.'); first_dot = strchr(input, '.');
last_dot = strrchr(input, '.');
comparison_len = strlen(local_sp + 2) - 1; comparison_len = strlen(local_sp + 2) - 1;
if (last_dot == first_dot || last_dot - first_dot - 1 != comparison_len)
return 0;
return !strncmp(local_sp + 2, first_dot + 1, comparison_len); return !strncmp(local_sp + 2, first_dot + 1, comparison_len);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment