mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-01 17:24:50 +01:00
24068: attempt to make `printf "%g\n" -0 output "-0"
This commit is contained in:
parent
154ebe3e96
commit
b9f3fc7c81
2 changed files with 25 additions and 3 deletions
|
@ -1,3 +1,9 @@
|
|||
2007-11-06 Peter Stephenson <pws@csr.com>
|
||||
|
||||
* 24068: Src/builtin.c: attempt to make `printf "%g\n" -0'
|
||||
output "-0", although this depends on the vagaries of the
|
||||
library's strtod() (works on Solaris, doesn't on Fedora 7).
|
||||
|
||||
2007-11-04 Wayne Davison <wayned@users.sourceforge.net>
|
||||
|
||||
* unposted: Completion/Unix/Command/_rsync: Added new options
|
||||
|
|
|
@ -4162,9 +4162,25 @@ bin_print(char *name, char **args, Options ops, int func)
|
|||
break;
|
||||
case 2:
|
||||
if (curarg) {
|
||||
mnumval = matheval(curarg);
|
||||
doubleval = (mnumval.type & MN_FLOAT) ?
|
||||
mnumval.u.d : (double)mnumval.u.l;
|
||||
char *eptr;
|
||||
/*
|
||||
* First attempt to parse as a floating
|
||||
* point constant. If we go through
|
||||
* a math evaluation, we can lose
|
||||
* mostly unimportant information
|
||||
* that people in standards organizations
|
||||
* worry about.
|
||||
*/
|
||||
doubleval = strtod(curarg, &eptr);
|
||||
/*
|
||||
* If it didn't parse as a constant,
|
||||
* parse it as an expression.
|
||||
*/
|
||||
if (*eptr != '\0') {
|
||||
mnumval = matheval(curarg);
|
||||
doubleval = (mnumval.type & MN_FLOAT) ?
|
||||
mnumval.u.d : (double)mnumval.u.l;
|
||||
}
|
||||
} else doubleval = 0;
|
||||
if (errflag) {
|
||||
doubleval = 0;
|
||||
|
|
Loading…
Reference in a new issue