sbase

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

commit c00921a3a3eabb3f908fc22eff9189c756274742
parent 1c79098178db0f6c26bf4459902000b81c098dd0
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date:   Sun, 18 Jan 2026 11:26:26 +0100

bc: Force a unwind string in every function

The code in funcode() assumes that the string unwind has a
value but it didn't happen in the case of a function without
parameters or local variables.

Diffstat:
Mbc.y | 4++--
Atests/0046-bc.sh | 19+++++++++++++++++++
2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/bc.y b/bc.y @@ -356,6 +356,7 @@ macro(int op) inhome = 1; break; case DEF: + unwind = estrdup(""); inhome = 0; d->id = funid(yytext); d->flowid = macros[0].flowid; @@ -391,8 +392,7 @@ decl(int type, char *list, char *id) i2 = estrdup(id); free(id); - if (!unwind) - unwind = estrdup(""); + unwind = estrdup(""); if (!list) list = estrdup(""); diff --git a/tests/0046-bc.sh b/tests/0046-bc.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +tmp=$$.tmp + +trap 'rm -f $tmp' EXIT +trap 'exit $?' HUP INT TERM + +cat <<'EOF' > $tmp +0 +0 +EOF + +$EXEC ../bc -p ../dc <<'EOF' | diff -u - $tmp +define a() { +0 +} + +a() +EOF