From 3def943d046ad03540dd188ab52c0eacaa021149 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 5 Mar 2013 20:04:53 +0000 Subject: users/17665: add FORCE_FLOAT option --- Src/math.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Src/math.c') diff --git a/Src/math.c b/Src/math.c index e90d6a59a..f8a4eefeb 100644 --- a/Src/math.c +++ b/Src/math.c @@ -456,6 +456,11 @@ lexconstant(void) yyval.u.l = zstrtol_underscore(ptr, &ptr, 0, 1); /* Should we set lastbase here? */ lastbase = 16; + if (isset(FORCEFLOAT)) + { + yyval.type = MN_FLOAT; + yyval.u.d = (double)yyval.u.l; + } return NUM; } else if (isset(OCTALZEROES)) @@ -475,6 +480,11 @@ lexconstant(void) { yyval.u.l = zstrtol_underscore(ptr, &ptr, 0, 1); lastbase = 8; + if (isset(FORCEFLOAT)) + { + yyval.type = MN_FLOAT; + yyval.u.d = (double)yyval.u.l; + } return NUM; } nptr = ptr2; @@ -537,6 +547,11 @@ lexconstant(void) lastbase = yyval.u.l; yyval.u.l = zstrtol_underscore(ptr, &ptr, lastbase, 1); } + if (isset(FORCEFLOAT)) + { + yyval.type = MN_FLOAT; + yyval.u.d = (double)yyval.u.l; + } } return NUM; } -- cgit v1.2.3 From 1d3d92a0c9a5e10228b42ce3a62e8de354748051 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Wed, 13 Mar 2013 19:54:20 +0000 Subject: 31140: avoid crash when hitting recursion limit --- ChangeLog | 7 ++++++- Src/math.c | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'Src/math.c') diff --git a/ChangeLog b/ChangeLog index f4f3a1990..21eaa18b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,11 @@ * unposted: Doc/Zsh/contrib.yo: Also adjust a mention of psvar in the vcs info documentation. + * 31140: Src/math.c: when the math recursion limit is hit, make + sure to not leave *ep pointing nowhere, which caused a crash + sometimes. Also print the token that we refused to evaluate + because of the limit. + 2013-03-13 Peter Stephenson * unposted, c.f. thread from 31144: Doc/Zsh/params.yo: all psvar @@ -593,5 +598,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5819 $ +* $Revision: 1.5820 $ ***************************************************** diff --git a/Src/math.c b/Src/math.c index f8a4eefeb..a2462a32e 100644 --- a/Src/math.c +++ b/Src/math.c @@ -362,8 +362,9 @@ mathevall(char *s, enum prec_type prec_tp, char **ep) if (mlevel >= MAX_MLEVEL) { xyyval.type = MN_INTEGER; xyyval.u.l = 0; + *ep = s; - zerr("math recursion limit exceeded"); + zerr("math recursion limit exceeded: %s", *ep); return xyyval; } -- cgit v1.2.3 From f4b083327064c122945901736c19f381d3f67499 Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Tue, 30 Apr 2013 00:18:13 -0700 Subject: 31353: fix handling of floating point in ternary --- ChangeLog | 2 ++ Src/math.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'Src/math.c') diff --git a/ChangeLog b/ChangeLog index b75195a5f..898aef16b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2013-04-29 Bart Schaefer + * 31353: Src/math.c: fix handling of floating point in ternary + * 31350: Src/init.c, Src/input.c, Src/signals.h, Src/utils.c, Src/Zle/zle_main.c: block SIGWINCH nearly all the time, except when about to calculate prompts or do synchronous read, so diff --git a/Src/math.c b/Src/math.c index a2462a32e..eae283d19 100644 --- a/Src/math.c +++ b/Src/math.c @@ -1459,7 +1459,8 @@ mathparse(int pc) case QUEST: if (stack[sp].val.type == MN_UNSET) stack[sp].val = getmathparam(stack + sp); - q = (stack[sp].val.type == MN_FLOAT) ? (zlong)stack[sp].val.u.d : + q = (stack[sp].val.type == MN_FLOAT) ? + (stack[sp].val.u.d == 0 ? 0 : 1) : stack[sp].val.u.l; if (!q) -- cgit v1.2.3