URI:
       bc: Force a unwind string in every function - sbase - suckless unix tools
  HTML git clone git://git.suckless.org/sbase
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit c00921a3a3eabb3f908fc22eff9189c756274742
   DIR parent 1c79098178db0f6c26bf4459902000b81c098dd0
  HTML 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:
         M bc.y                                |       4 ++--
         A tests/0046-bc.sh                    |      19 +++++++++++++++++++
       
       2 files changed, 21 insertions(+), 2 deletions(-)
       ---
   DIR 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("");
        
   DIR 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