From a93abe1170a438d45d94b3a7f924553f5cf69cee Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Sun, 13 May 2018 10:13:42 +0200 Subject: 42488: test cases for 42369 and address some issues in the code --- Src/builtin.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'Src/builtin.c') diff --git a/Src/builtin.c b/Src/builtin.c index 73cfe7ad1..931605c6e 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -5234,8 +5234,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'; -- cgit v1.2.3 From ee7dda7806db51016f9fe8d84f7ac3edb594eff0 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 17 May 2018 09:32:26 +0100 Subject: 42785: Allow redefining math function to work silently. Previously it failed with an error message that the function was already defined. This is inconsistent with most other aspects of shell usage. --- ChangeLog | 5 +++++ Src/builtin.c | 13 ++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'Src/builtin.c') diff --git a/ChangeLog b/ChangeLog index deac58d68..e6e1427f0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2018-05-17 Peter Stephenson + + * 42785: Src/builtins.c: redefining a user math function should + silently work as with redefining other shell objects. + 2018-05-14 Peter Stephenson * 42297: dana: Src/params.c, Test/D06subscript.ztst: (e) diff --git a/Src/builtin.c b/Src/builtin.c index 931605c6e..1cba97dec 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; } } -- cgit v1.2.3 From eada7e1138a3fca90f085dd764ad86098e58c9ac Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 20 Jun 2018 12:09:43 +0100 Subject: 43077: Fix shift builtin status. If the math evaulation to get the shift count failed the status wasn't passed back from the builtin. --- ChangeLog | 5 +++++ Src/builtin.c | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'Src/builtin.c') diff --git a/ChangeLog b/ChangeLog index 526681632..fe91372f9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2018-06-20 Peter Stephenson + + * 43077: Src/builtin.c: failure of math evaluation didn't + propagate to status of shift builtin. + 2018-06-20 dana * 43061: Completion/Darwin/Command/_open, diff --git a/Src/builtin.c b/Src/builtin.c index 1cba97dec..93fa9112c 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -5318,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(); -- cgit v1.2.3