Article View: gnu.emacs.bug
Article #98748bug in cl.el (impacting conx.el)
From: Jamie Zawinski
Date: Thu, 04 Apr 1991 21:09
Date: Thu, 04 Apr 1991 21:09
68 lines
3345 bytes
3345 bytes
If you are using the conx.el program I posted a couple of days ago, replace
the call to `rem' in the function `conx-rand' with a call to `%'.
There are at least three versions of cl.el floating around, and two of them
have a bug that the other doesn't. Since cl.el does not have any kind of
changelog or version number, I don't know which of the versions of cl I have
come across is the most recent, so I don't know if these are bugs that have
recently been fixed, or have recently been introduced. So I'm reporting it.
After loading one version of cl.el, the form (rem 8286041 32) will
return 16572057 instead of 25.
The function `%', a subr, does the right thing, however. In our emacs,
(eq (symbol-function 'rem) '%) ==> t. I don't know if this is a standard
thing, or if it is done by some package we load, but it seems like a good
idea.
The difference between this bad version and the working version seems to be
in the function `safe-idiv'. In one version,
(multiple-value-list (safe-idiv 8286041 32)) returns (258938 16572057 -1)
instead of (258938 25 1).
Here is a diff between Bad CL #1 and the working cl:
-----------------------------------------------------------------------------
diff -c3 /gnuemacs/lisp/cl.el /tmp/bad-cl.el
*** /gnuemacs/lisp/cl.el Wed Jan 9 13:56:54 1991
--- /tmp/bad-cl.el Thu Apr 4 15:38:27 1991
***************
*** 1619,1625 ****
(let* ((absa (abs a))
(absb (abs b))
(q (/ absa absb))
! (s (* (signum a) (signum b)))
(r (- a (* (* s q) b))))
(values q r s)))
--- 1620,1626 ----
(let* ((absa (abs a))
(absb (abs b))
(q (/ absa absb))
! (s (signum (* a b)))
(r (- a (* (* s q) b))))
(values q r s)))
***************
-----------------------------------------------------------------------------
I don't have a copy of Bad CL #2, but I am told that the offending difference
(which causes `mod to not work) is this, in the function `floor':
-----------------------------------------------------------------------------
diff cl.el.~1~ cl.el
1520,1523c1520,1524
< (unless (zerop r) ; orig version
< (setq q (- 0 (+ q 1)))
< (setq r (- number (* q divisor))))
< (values q r)))))))
---
> (if (zerop r) ; our version
> (values (- 0 q) 0)
> (let ((q (- 0 (+ q 1))))
> (values q (- number (* q divisor))))
> )))))))
-----------------------------------------------------------------------------
What a nasty business!
-- Jamie
Technical Details
Message-ID:
<JWZ.91Apr4160946@thalidomide.lucid.com>Path:
arc1-ca.pugleaf.net!gmdzi!unido!fauern!ira.uka.de!sol.ctr.columbia.edu!emory!samsung!zaphod.mps.ohio-state.edu!usc!apple!agate!ucbvax!tut.cis.ohio-state.edu!unreplyable!garbageShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fb2f1,c9684e9f24dd7ff7,start X-Google-Attributes: gidfb2f1,public X-Google-ArrivalTime: 1991-04-04 13:09:46 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!fauern!ira.uka.de!sol.ctr.columbia.edu!emory!samsung!zaphod.mps.ohio-state.edu!usc!apple!agate!ucbvax!tut.cis.ohio-state.edu!unreplyable!garbage From: jwz@LUCID.COM (Jamie Zawinski) Newsgroups: gnu.emacs.bug Subject: bug in cl.el (impacting conx.el) Message-ID: <JWZ.91Apr4160946@thalidomide.lucid.com> Date: 4 Apr 91 21:09:46 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: Lucid Inc., Menlo Park, CA Lines: 68 Approved: bug-gnu-emacs@prep.ai.mit.edu