URI:
       dc: Don't trash val next pointer - sbase - suckless unix tools
  HTML git clone git://git.suckless.org/sbase
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit a2940adeba5293032f6ceb7d218dc9f09d6de984
   DIR parent 40a4999b60355a8e498f1d228469aeca17f9a698
  HTML Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
       Date:   Mon, 19 Jan 2026 18:49:42 +0100
       
       dc: Don't trash val next pointer
       
       When a value was assigned to a register using the 's'
       command we were assigning the full value from execution
       stack, overwriting the next pointer of the register
       stack with the next pointer of the execution stack.
       
       Diffstat:
         M dc.c                                |       6 ++++--
         A tests/0048-dc.sh                    |      18 ++++++++++++++++++
       
       2 files changed, 22 insertions(+), 2 deletions(-)
       ---
   DIR diff --git a/dc.c b/dc.c
       @@ -1541,6 +1541,7 @@ dupval(Val v)
                        nv.u.n = copy(&zero);
                        break;
                }
       +        nv.next = NULL;
        
                return nv;
        }
       @@ -2057,9 +2058,10 @@ eval(void)
                        break;
                case 's':
                        rp = lookup(regname());
       +                v1 = pop();
                        freeval(rp->val);
       -                rp->val.type = NVAL;
       -                rp->val = pop();
       +                rp->val.u = v1.u;
       +                rp->val.type = v1.type;
                        break;
                case 'l':
                        rp = lookup(regname());
   DIR diff --git a/tests/0048-dc.sh b/tests/0048-dc.sh
       @@ -0,0 +1,18 @@
       +#!/bin/sh
       +
       +tmp=$$.tmp
       +
       +trap 'rm -f $tmp' EXIT
       +trap 'exit $?' HUP INT TERM
       +
       +cat <<'EOF' > $tmp
       +1
       +EOF
       +
       +$EXEC ../dc -i <<'EOF' | diff -u - $tmp
       +[Splp 1+dsps. 0 Lps. 1Q]s<1>
       +
       +1dsps.
       +lpl<1>xs.
       +lpps.
       +EOF