summaryrefslogtreecommitdiff
path: root/Src/builtin.c
diff options
context:
space:
mode:
authorAxel Beckert <abe@deuxchevaux.org>2018-08-27 13:31:04 +0200
committerAxel Beckert <abe@deuxchevaux.org>2018-08-27 13:31:04 +0200
commit719a715614f2182a76b30ad27a327d70a86f34f1 (patch)
treea437eb29da8035bf7c2e30506c08fe6f15719871 /Src/builtin.c
parent7da8d19c224860ae4d6aa3f077fca7f734f20d88 (diff)
parentef61918398517473b9b594690a3be375f607cebe (diff)
downloadzsh-719a715614f2182a76b30ad27a327d70a86f34f1.tar.gz
zsh-719a715614f2182a76b30ad27a327d70a86f34f1.zip
Merge tag 'zsh-5.5.1-test-2' into debian
Test release: 5.5.1-test-2.
Diffstat (limited to 'Src/builtin.c')
-rw-r--r--Src/builtin.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index 73cfe7ad1..93fa9112c 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3199,7 +3199,7 @@ bin_functions(char *name, char **argv, Options ops, int func)
pflags |= PRINT_NAMEONLY;
if (OPT_MINUS(ops,'M') || OPT_PLUS(ops,'M')) {
- MathFunc p, q;
+ MathFunc p, q, prev;
/*
* Add/remove/list function as mathematical.
*/
@@ -3331,15 +3331,10 @@ bin_functions(char *name, char **argv, Options ops, int func)
p->maxargs = maxargs;
queue_signals();
- for (q = mathfuncs; q; q = q->next) {
+ for (q = mathfuncs, prev = NULL; q; prev = q, q = q->next) {
if (!strcmp(q->name, funcname)) {
- unqueue_signals();
- zwarnnam(name, "-M %s: function already exists",
- funcname);
- zsfree(p->name);
- zsfree(p->module);
- zfree(p, sizeof(struct mathfunc));
- return 1;
+ removemathfunc(prev, q);
+ break;
}
}
@@ -5234,8 +5229,14 @@ bin_print(char *name, char **args, Options ops, int func)
errflag &= ~ERRFLAG_ERROR;
ret = 1;
}
- print_val(doubleval)
- break;
+ /* force consistent form for Inf/NaN output */
+ if (isnan(doubleval))
+ count += fputs("nan", fout);
+ else if (isinf(doubleval))
+ count += fputs((doubleval < 0.0) ? "-inf" : "inf", fout);
+ else
+ print_val(doubleval)
+ break;
case 3:
#ifdef ZSH_64_BIT_UTYPE
*d++ = 'l';
@@ -5317,8 +5318,13 @@ bin_shift(char *name, char **argv, Options ops, UNUSED(int func))
/* optional argument can be either numeric or an array */
queue_signals();
- if (*argv && !getaparam(*argv))
+ if (*argv && !getaparam(*argv)) {
num = mathevali(*argv++);
+ if (errflag) {
+ unqueue_signals();
+ return 1;
+ }
+ }
if (num < 0) {
unqueue_signals();