diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | builtin.c | 8 | ||||
-rw-r--r-- | test/ChangeLog | 5 | ||||
-rw-r--r-- | test/Makefile.am | 5 | ||||
-rw-r--r-- | test/Makefile.in | 10 | ||||
-rw-r--r-- | test/Maketests | 5 | ||||
-rw-r--r-- | test/ofmtstrnum.awk | 7 | ||||
-rw-r--r-- | test/ofmtstrnum.ok | 2 |
8 files changed, 39 insertions, 8 deletions
@@ -1,3 +1,8 @@ +2016-07-23 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * builtin.c (do_print): Improve logic for formatting + numeric values. + 2016-07-19 Andrew J. Schorr <aschorr@telemetry-investments.com> * eval.c (set_LINT): Simplify the code considerably. @@ -2179,12 +2179,8 @@ do_print(int nargs, int redirtype) fatal(_("attempt to use array `%s' in a scalar context"), array_vname(tmp)); } - if ((tmp->flags & (NUMBER|STRING)) == NUMBER) { - if (OFMTidx == CONVFMTidx) - args_array[i] = force_string(tmp); - else - args_array[i] = format_val(OFMT, OFMTidx, tmp); - } + if ((tmp->flags & STRCUR) == 0 || (tmp->stfmt != -1 && tmp->stfmt != OFMTidx)) + args_array[i] = format_val(OFMT, OFMTidx, tmp); } if (redir_exp != NULL) { diff --git a/test/ChangeLog b/test/ChangeLog index f7c28922..8939b6f4 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2015-06-17 Arnold D. Robbins <arnold@skeeve.com> + + * Makefile.am (ofmtstrnum): New test. + * ofmtstrnu.awk, ofmtstrnum.ok: New files. + 2016-07-01 Arnold D. Robbins <arnold@skeeve.com> * arrayind1.awk, arrayind1.ok: Comment out prints to stderr to diff --git a/test/Makefile.am b/test/Makefile.am index 34cc954b..0bda377c 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -674,6 +674,8 @@ EXTRA_DIST = \ ofmts.awk \ ofmts.in \ ofmts.ok \ + ofmtstrnum.awk \ + ofmtstrnum.ok \ ofs1.awk \ ofs1.in \ ofs1.ok \ @@ -1080,7 +1082,8 @@ BASIC_TESTS = \ nasty nasty2 negexp negrange nested nfldstr nfloop nfneg nfset nlfldsep \ nlinstr nlstrina noeffect nofile nofmtch noloop1 noloop2 nonl \ noparms nors nulinsrc nulrsend numindex numsubstr \ - octsub ofmt ofmta ofmtbig ofmtfidl ofmts ofs1 onlynl opasnidx opasnslf \ + octsub ofmt ofmta ofmtbig ofmtfidl ofmts ofmtstrnum ofs1 onlynl \ + opasnidx opasnslf \ paramasfunc1 paramasfunc2 \ paramdup paramres paramtyp paramuninitglobal parse1 parsefld parseme \ pcntplus posix2008sub prdupval prec printf0 printf1 prmarscl prmreuse \ diff --git a/test/Makefile.in b/test/Makefile.in index 5baefb40..ff1d8e07 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -931,6 +931,8 @@ EXTRA_DIST = \ ofmts.awk \ ofmts.in \ ofmts.ok \ + ofmtstrnum.awk \ + ofmtstrnum.ok \ ofs1.awk \ ofs1.in \ ofs1.ok \ @@ -1336,7 +1338,8 @@ BASIC_TESTS = \ nasty nasty2 negexp negrange nested nfldstr nfloop nfneg nfset nlfldsep \ nlinstr nlstrina noeffect nofile nofmtch noloop1 noloop2 nonl \ noparms nors nulinsrc nulrsend numindex numsubstr \ - octsub ofmt ofmta ofmtbig ofmtfidl ofmts ofs1 onlynl opasnidx opasnslf \ + octsub ofmt ofmta ofmtbig ofmtfidl ofmts ofmtstrnum ofs1 onlynl \ + opasnidx opasnslf \ paramasfunc1 paramasfunc2 \ paramdup paramres paramtyp paramuninitglobal parse1 parsefld parseme \ pcntplus posix2008sub prdupval prec printf0 printf1 prmarscl prmreuse \ @@ -3233,6 +3236,11 @@ ofmts: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +ofmtstrnum: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + ofs1: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/Maketests b/test/Maketests index 57b5c5ad..7d50a4b3 100644 --- a/test/Maketests +++ b/test/Maketests @@ -620,6 +620,11 @@ ofmts: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +ofmtstrnum: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + ofs1: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/ofmtstrnum.awk b/test/ofmtstrnum.awk new file mode 100644 index 00000000..805dad73 --- /dev/null +++ b/test/ofmtstrnum.awk @@ -0,0 +1,7 @@ +BEGIN { + split(" 1", f, "|") + OFMT = "%.1f" + print f[1] + x = f[1] + 0 + print f[1] +} diff --git a/test/ofmtstrnum.ok b/test/ofmtstrnum.ok new file mode 100644 index 00000000..ae955868 --- /dev/null +++ b/test/ofmtstrnum.ok @@ -0,0 +1,2 @@ + 1 + 1 |