diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2019-08-19 18:02:59 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2019-08-19 18:05:15 -0700 |
commit | 2197ea89bf5afabc4c52a6499b13e92ae6621554 (patch) | |
tree | 642c9ebf5c962305fedf69d4f14b95e3a8d8532d /src/timefns.c | |
parent | 50dc4ca8d02a466a7236765edf83ae7cfb02d74c (diff) | |
download | emacs-2197ea89bf5afabc4c52a6499b13e92ae6621554.tar.gz emacs-2197ea89bf5afabc4c52a6499b13e92ae6621554.tar.bz2 emacs-2197ea89bf5afabc4c52a6499b13e92ae6621554.zip |
Fix time-add/time-sub validity checking
* src/timefns.c (time_arith): Check the first arg for
validity even if the second arg is not finite.
* test/src/timefns-tests.el (time-arith-tests): Test this.
Diffstat (limited to 'src/timefns.c')
-rw-r--r-- | src/timefns.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/timefns.c b/src/timefns.c index 3948f873354..2d545a4f905 100644 --- a/src/timefns.c +++ b/src/timefns.c @@ -1035,12 +1035,12 @@ time_arith (Lisp_Object a, Lisp_Object b, bool subtract) double db = XFLOAT_DATA (Ffloat_time (b)); return make_float (subtract ? da - db : da + db); } - if (FLOATP (b) && !isfinite (XFLOAT_DATA (b))) - return subtract ? make_float (-XFLOAT_DATA (b)) : b; - enum timeform aform, bform; struct lisp_time ta = lisp_time_struct (a, &aform); + if (FLOATP (b) && !isfinite (XFLOAT_DATA (b))) + return subtract ? make_float (-XFLOAT_DATA (b)) : b; + /* Subtract nil from nil correctly, and handle other eq values quicker while we're at it. Compare here rather than earlier, to handle NaNs and check formats. */ |