Ensure that patterns like %d, %x, %o or %b properly truncate their
operands to whole integers.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
switch(pType) {
case 'b':
- subst = (+param || 0).toString(2);
+ subst = (~~param || 0).toString(2);
break;
case 'c':
break;
case 'd':
- subst = ~~(+param || 0);
+ subst = (~~param || 0);
break;
case 'u':
break;
case 'o':
- subst = (+param || 0).toString(8);
+ subst = (~~param || 0).toString(8);
break;
case 's':
break;
case 'x':
- subst = ('' + (+param || 0).toString(16)).toLowerCase();
+ subst = ('' + (~~param || 0).toString(16)).toLowerCase();
break;
case 'X':
- subst = ('' + (+param || 0).toString(16)).toUpperCase();
+ subst = ('' + (~~param || 0).toString(16)).toUpperCase();
break;
case 'h':