bc: Fix modulo operation - sbase - suckless unix tools
(HTM) git clone git://git.suckless.org/sbase
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 10ad90244eca21f033d59f808b45edf69060f5eb
(DIR) parent 974179ce006d118086cb91a4c3176d05a60daa60
(HTM) Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date: Tue, 25 Nov 2025 16:18:37 +0100
bc: Fix modulo operation
As we use % for the placeholders we have to protect it using two
of them in the case of the modulo operation that is implemented
in dc with %.
Diffstat:
M bc.y | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
---
(DIR) diff --git a/bc.y b/bc.y
@@ -219,7 +219,7 @@ nexpr : NUMBER {$$ = code(" %s", $1);}
| expr '-' expr {$$ = code("%s%s-", $1, $3);}
| expr '*' expr {$$ = code("%s%s*", $1, $3);}
| expr '/' expr {$$ = code("%s%s/", $1, $3);}
- | expr '%' expr {$$ = code("%s%s%", $1, $3);}
+ | expr '%' expr {$$ = code("%s%s%%", $1, $3);}
| expr '^' expr {$$ = code("%s%s^", $1, $3);}
| LENGTH '(' expr ')' {$$ = code("%sZ", $3);}
| SQRT '(' expr ')' {$$ = code("%sv", $3);}