From 73651d9e697ef763a83282b5d0a2015574044a16 Mon Sep 17 00:00:00 2001 From: rpm-build Date: Dec 09 2020 13:45:17 +0000 Subject: assign-int.patch patch_name: assign-int.patch present_in_specfile: true location_in_specfile: 1 --- diff --git a/ChangeLog b/ChangeLog index b31740b..642e6c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2018-07-31 Arnold D. Robbins + + * interpret.h (unfield): Add a call to force_string() on + new value. See test/assignnumfield.awk. Thanks to + Ralph Corderoy for the bug report. + 2018-02-25 Arnold D. Robbins * 4.2.1: Release tar ball made. diff --git a/interpret.h b/interpret.h index 96e2c89..a86240b 100644 --- a/interpret.h +++ b/interpret.h @@ -32,16 +32,25 @@ * valref 1, that effectively means that this is an assignment like "$n = $n", * so a no-op, other than triggering $0 reconstitution. */ -#define UNFIELD(l, r) \ -{ \ - /* if was a field, turn it into a var */ \ - if ((r->flags & MALLOC) != 0 || r->valref == 1) { \ - l = r; \ - } else { \ - l = dupnode(r); \ - DEREF(r); \ - } \ +// not a macro so we can step into it with a debugger +#ifndef UNFIELD_DEFINED +#define UNFIELD_DEFINED 1 +static inline void +unfield(NODE **l, NODE **r) +{ + /* if was a field, turn it into a var */ + if (((*r)->flags & MALLOC) != 0 || (*r)->valref == 1) { + (*l) = (*r); + } else { + (*l) = dupnode(*r); + DEREF(*r); + } + force_string(*l); } + +#define UNFIELD(l, r) unfield(& (l), & (r)) +#endif + int r_interpret(INSTRUCTION *code) { diff --git a/test/ChangeLog b/test/ChangeLog index 65f01e6..0582ece 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2018-07-31 Arnold D. Robbins + + * Makefile.am (EXTRA_DIST): Add assignnumfield files. + * assignnumfield.awk, assignnumfield.in, assignnumfield.ok: New files. + 2018-02-25 Arnold D. Robbins * 4.2.1: Release tar ball made. diff --git a/test/Makefile.am b/test/Makefile.am index bf1dbd3..a617c47 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -120,6 +120,9 @@ EXTRA_DIST = \ asort.ok \ asorti.awk \ asorti.ok \ + assignnumfield.awk \ + assignnumfield.in \ + assignnumfield.ok \ awkpath.ok \ back89.awk \ back89.in \ @@ -1221,7 +1224,7 @@ BASIC_TESTS = \ addcomma anchgsub anchor argarray arrayind1 arrayind2 arrayind3 arrayparm \ arrayprm2 arrayprm3 arrayref arrymem1 arryref2 arryref3 arryref4 arryref5 \ arynasty arynocls aryprm1 aryprm2 aryprm3 aryprm4 aryprm5 aryprm6 aryprm7 \ - aryprm8 aryprm9 arysubnm aryunasgn asgext awkpath \ + aryprm8 aryprm9 arysubnm aryunasgn asgext awkpath assignnumfield \ back89 backgsub badassign1 badbuild \ callparam childin clobber closebad clsflnam compare compare2 \ concat1 concat2 concat3 concat4 concat5 convfmt \ diff --git a/test/Makefile.in b/test/Makefile.in index f96151b..6330083 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -378,6 +378,9 @@ EXTRA_DIST = \ asort.ok \ asorti.awk \ asorti.ok \ + assignnumfield.awk \ + assignnumfield.in \ + assignnumfield.ok \ awkpath.ok \ back89.awk \ back89.in \ @@ -1478,7 +1481,7 @@ BASIC_TESTS = \ addcomma anchgsub anchor argarray arrayind1 arrayind2 arrayind3 arrayparm \ arrayprm2 arrayprm3 arrayref arrymem1 arryref2 arryref3 arryref4 arryref5 \ arynasty arynocls aryprm1 aryprm2 aryprm3 aryprm4 aryprm5 aryprm6 aryprm7 \ - aryprm8 aryprm9 arysubnm aryunasgn asgext awkpath \ + aryprm8 aryprm9 arysubnm aryunasgn asgext awkpath assignnumfield \ back89 backgsub badassign1 badbuild \ callparam childin clobber closebad clsflnam compare compare2 \ concat1 concat2 concat3 concat4 concat5 convfmt \ @@ -3057,6 +3060,11 @@ asgext: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +assignnumfield: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + back89: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/Maketests b/test/Maketests index e449dd3..2fbf6e5 100644 --- a/test/Maketests +++ b/test/Maketests @@ -140,6 +140,11 @@ asgext: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +assignnumfield: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + back89: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/assignnumfield.awk b/test/assignnumfield.awk new file mode 100644 index 0000000..3a056cb --- /dev/null +++ b/test/assignnumfield.awk @@ -0,0 +1 @@ +{$0 = ++i} 1 diff --git a/test/assignnumfield.in b/test/assignnumfield.in new file mode 100644 index 0000000..b82c4b2 --- /dev/null +++ b/test/assignnumfield.in @@ -0,0 +1,5 @@ +a b c +a b c +a b c +a b c +a b c diff --git a/test/assignnumfield.ok b/test/assignnumfield.ok new file mode 100644 index 0000000..8a1218a --- /dev/null +++ b/test/assignnumfield.ok @@ -0,0 +1,5 @@ +1 +2 +3 +4 +5