Skip to content

Commit

Permalink
Fix config file parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
tryone144 committed Feb 22, 2018
1 parent c2768ec commit ae9f27d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
17 changes: 2 additions & 15 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -1707,20 +1707,7 @@ parse_blur_method(session_t *ps, const char *str) {
* Parse a blur_strength option argument.
*/
static inline bool
parse_blur_strength(session_t *ps, const char *str) {
const char *endptr = NULL;
long level = strtol(str, (char **) &endptr, 0);
if (!endptr || endptr == str) {
printf_errf("(\"%s\"): Invalid number.", str);
return false;
}
while (isspace(*endptr))
++endptr;
if (*endptr) {
printf_errf("(\"%s\"): Trailing characters.", str);
return false;
}

parse_blur_strength(session_t *ps, const int level) {
switch (level) {
case 1:
ps->o.blur_strength_iterations = 1;
Expand Down Expand Up @@ -1783,7 +1770,7 @@ parse_blur_strength(session_t *ps, const char *str) {
ps->o.blur_strength_offset = 8.0;
break;
default:
printf_errf("(\"%s\"): Invalid blur_strength argument. Needs to be a number between 1 and 15.", str);
printf_errf("(\"%d\"): Invalid blur_strength argument. Needs to be a number between 1 and 15.", level);
return false;
}

Expand Down
7 changes: 3 additions & 4 deletions src/compton.c
Original file line number Diff line number Diff line change
Expand Up @@ -5645,9 +5645,8 @@ parse_config(session_t *ps, struct options_tmp *pcfgtmp) {
&& !parse_conv_kern_lst(ps, sval, ps->o.blur_kerns, MAX_BLUR_PASS))
exit(1);
// --blur-strength
//lcfg_lookup_int(&cfg, "blur-strength", &ps->o.blur_strength);
if (config_lookup_string(&cfg, "blur-strength", &sval)
&& !parse_blur_strength(ps, sval))
if (lcfg_lookup_int(&cfg, "blur-strength", &ival)
&& !parse_blur_strength(ps, ival))
exit(1);
// --resize-damage
lcfg_lookup_int(&cfg, "resize-damage", &ps->o.resize_damage);
Expand Down Expand Up @@ -6063,7 +6062,7 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
break;
case 322:
// --blur-strength
if (!parse_blur_strength(ps, optarg))
if (!parse_blur_strength(ps, strtol(optarg, NULL, 0)))
exit(1);
break;
P_CASEBOOL(731, reredir_on_root_change);
Expand Down

0 comments on commit ae9f27d

Please sign in to comment.