[hackers] [sbase] bc: set used = 0 in writeout || Roberto E. Vargas Caballero
commit 0850438f93155902b6a062c94786fa99e4269715
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.net>
AuthorDate: Sun Nov 23 09:45:57 2025 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.net>
CommitDate: Sun Nov 23 09:45:57 2025 +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.
diff --git a/bc.y b/bc.y
index 67eb74c..9f6f4e4 100644
--- a/bc.y
+++ b/bc.y
_AT_@ -100,8 +100,8 @@ program :
| item program
;
-item : scolonlst '\n' {used = 0;}
- | function {writeout($1); used = 0;}
+item : scolonlst '\n'
+ | function {writeout($1);}
;
scolonlst:
_AT_@ -245,6 +245,8 @@ writeout(char *s)
goto err;
if (write(1, (char[]){'\n'}, 1) < 0)
goto err;
+ used = 0;
+
return;
err:
_AT_@ -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))
_AT_@ -689,7 +692,6 @@ bc(char *fname)
for (init(); run(); init())
;
- nested = used = 0;
}
static void
Received on Sun Nov 23 2025 - 09:49:08 CET
This archive was generated by hypermail 2.3.0
: Sun Nov 23 2025 - 10:00:38 CET