From: Pip Cet <pipcet@gmail.com>
To: Andy Moreton <andrewjmoreton@gmail.com>
Cc: 36740@debbugs.gnu.org
Subject: bug#36740: 27.0.50; apparently buggy code in ccl.c (lookup-integer-constant)
Date: Sun, 21 Jul 2019 06:01:10 +0000 [thread overview]
Message-ID: <CAOqdjBeSrUuTsuDZYWVm_KKT8cWtw6Q3HB=oPMxV3Qeq-BeGcg@mail.gmail.com> (raw)
In-Reply-To: <86o91oxqyp.fsf@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 753 bytes --]
On Sat, Jul 20, 2019 at 10:49 PM Andy Moreton <andrewjmoreton@gmail.com> wrote:
> > (defun ccl-fixnum (code)
> > "Convert a CCL code word to a fixnum value."
> > - (- (logxor (logand code #x0fffffff) #x08000000) #x08000000))
> > + (if (integerp code)
> > + (- (logxor (logand code #x0fffffff) #x08000000) #x08000000)
> > + code))
>
> `ccl-fixnum' should only receive integer arguments, so perhaps this fix
> should go in the call in `ccl-embed-data' instead:
>
> (aset ccl-program-vector ccl-current-ic
> (if (numberp data) (ccl-fixnum data) data))
Agreed, revised patch attached.
Note that the test leaks entries in translation-hash-table-vector, but
I think it's cleaner to start with a new symbol each time we run the
test.
[-- Attachment #2: 0001-Fix-return-value-for-CCL-opcode-lookup-integer.patch --]
[-- Type: text/x-patch, Size: 3042 bytes --]
From 91383d6aa1900c426b0c876e2feef04269c2fd15 Mon Sep 17 00:00:00 2001
From: Pip Cet <pipcet@gmail.com>
Date: Sun, 21 Jul 2019 05:54:49 +0000
Subject: [PATCH] Fix return value for CCL opcode lookup-integer
* src/ccl.c (ccl_driver): Fix LookupIntConstTbl return value.
* test/lisp/international/ccl-tests.el (ccl-hash-table): Add test.
* lisp/international/ccl.el (ccl-embed-data): Don't pass non-numbers
to `ccl-fixnum'.
---
lisp/international/ccl.el | 8 ++++++--
src/ccl.c | 2 +-
test/lisp/international/ccl-tests.el | 14 ++++++++++++++
3 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/lisp/international/ccl.el b/lisp/international/ccl.el
index 51626f5161..db4f2462fe 100644
--- a/lisp/international/ccl.el
+++ b/lisp/international/ccl.el
@@ -196,7 +196,9 @@ ccl-embed-data
"Embed integer DATA in `ccl-program-vector' at `ccl-current-ic' and
increment it. If IC is specified, embed DATA at IC."
(if ic
- (aset ccl-program-vector ic (ccl-fixnum data))
+ (aset ccl-program-vector ic (if (numberp data)
+ (ccl-fixnum data)
+ data))
(let ((len (length ccl-program-vector)))
(if (>= ccl-current-ic len)
(let ((new (make-vector (* len 2) nil)))
@@ -204,7 +206,9 @@ ccl-embed-data
(setq len (1- len))
(aset new len (aref ccl-program-vector len)))
(setq ccl-program-vector new))))
- (aset ccl-program-vector ccl-current-ic (ccl-fixnum data))
+ (aset ccl-program-vector ccl-current-ic (if (numberp data)
+ (ccl-fixnum data)
+ data))
(setq ccl-current-ic (1+ ccl-current-ic))))
(defun ccl-embed-symbol (symbol prop)
diff --git a/src/ccl.c b/src/ccl.c
index ff42c6f25f..da2559e0b1 100644
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -1299,7 +1299,7 @@ #define EXCMD (field1 >> 6)
if (! (IN_INT_RANGE (eop) && CHARACTERP (opl)))
CCL_INVALID_CMD;
reg[RRR] = charset_unicode;
- reg[rrr] = eop;
+ reg[rrr] = XFIXNUM (opl);
reg[7] = 1; /* r7 true for success */
}
else
diff --git a/test/lisp/international/ccl-tests.el b/test/lisp/international/ccl-tests.el
index 69e3930d42..2de4d040c2 100644
--- a/test/lisp/international/ccl-tests.el
+++ b/test/lisp/international/ccl-tests.el
@@ -227,3 +227,17 @@ ccl-dump-midi
(with-temp-buffer
(ccl-dump prog-midi-code)
(should (equal (buffer-string) prog-midi-dump))))
+
+(ert-deftest ccl-hash-table ()
+ (let ((sym (gensym))
+ (table (make-hash-table :test 'eq)))
+ (puthash 16 17 table)
+ (puthash 17 16 table)
+ (define-translation-hash-table sym table)
+ (let* ((prog `(2
+ ((loop
+ (lookup-integer ,sym r0 r1)))))
+ (compiled (ccl-compile prog))
+ (registers [17 0 0 0 0 0 0 0]))
+ (ccl-execute compiled registers)
+ (should (equal registers [2 16 0 0 0 0 0 1])))))
--
2.22.0
next prev parent reply other threads:[~2019-07-21 6:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-20 12:29 bug#36740: 27.0.50; apparently buggy code in ccl.c (lookup-integer-constant) Pip Cet
2019-07-20 13:15 ` Eli Zaretskii
2019-07-20 13:23 ` Eli Zaretskii
2019-07-20 13:51 ` Eli Zaretskii
2019-07-20 14:58 ` Pip Cet
2019-07-20 18:59 ` Andy Moreton
2019-07-20 20:18 ` Pip Cet
2019-07-20 22:48 ` Andy Moreton
2019-07-21 6:01 ` Pip Cet [this message]
2019-08-01 17:14 ` Noam Postavsky
2020-08-21 12:48 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAOqdjBeSrUuTsuDZYWVm_KKT8cWtw6Q3HB=oPMxV3Qeq-BeGcg@mail.gmail.com' \
--to=pipcet@gmail.com \
--cc=36740@debbugs.gnu.org \
--cc=andrewjmoreton@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).