commit 10ad90244eca21f033d59f808b45edf69060f5eb
parent 974179ce006d118086cb91a4c3176d05a60daa60
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:
1 file changed, 1 insertion(+), 1 deletion(-)
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);}