sbase

suckless unix tools
git clone git://git.suckless.org/sbase
Log | Files | Refs | README | LICENSE

commit 0850438f93155902b6a062c94786fa99e4269715
parent b39fe92a7ba9ec2ffbdeaced9398a7945de7d4cb
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date:   Sun, 23 Nov 2025 09:45:57 +0100

bc: set used = 0 in writeout

When we call writeou we do know that the temporary string built in
buff is not going to be used anymore, and it is a good moment to
reset it.

Diffstat:
Mbc.y | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/bc.y b/bc.y @@ -100,8 +100,8 @@ program : | item program ; -item : scolonlst '\n' {used = 0;} - | function {writeout($1); used = 0;} +item : scolonlst '\n' + | function {writeout($1);} ; scolonlst: @@ -245,6 +245,8 @@ writeout(char *s) goto err; if (write(1, (char[]){'\n'}, 1) < 0) goto err; + used = 0; + return; err: @@ -680,7 +682,8 @@ run(void) static void bc(char *fname) { - lineno = 0; + nested = lineno = 0; + if (fname) { filename = fname; if (!freopen(fname, "r", stdin)) @@ -689,7 +692,6 @@ bc(char *fname) for (init(); run(); init()) ; - nested = used = 0; } static void