From: William Xu <william.xwl@gmail.com>
To: 17807@debbugs.gnu.org
Subject: bug#17807: 24.4.50; hif-string-to-number convert a hex(or any non-decial) integer as float
Date: Thu, 19 Jun 2014 14:26:59 +0800 [thread overview]
Message-ID: <CACzMC-A+_OK6C-_Q-sq2WxBnkQ_wbJ4uhSYe2Y2iAdegpc3a_Q@mail.gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 1438 bytes --]
(hif-string-to-number "0F" 16)
=> 15.0
It would fail hif-logand, like the one below, caught in cedet.
Is it really necessary to support non-decial floats? When is something
like "0xff.e9" useful?
Anyway, how about attached fix?
---------------------------------8<-------------------------------------
Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p 15.0)
logand(0 15.0)
hif-logand(0 15.0)
(hif-notequal (hif-logand (hif-lookup (quote SPURIOUS_APIC_VECTOR)) 15.0)
15.0)
eval((hif-notequal (hif-logand (hif-lookup (quote SPURIOUS_APIC_VECTOR))
15.0) 15.0))
semantic-c-do-lex-if()
semantic-c-lexer(1 4938 nil nil)
semantic-lex(1 4938 nil)
semantic-parse-region-default(1 4938 nil nil nil)
semantic-parse-region-c-mode(1 4938 nil nil nil)
semantic-parse-region(1 4938)
semantic-fetch-tags()
byte-code("\212\212\300 \210*\301\207" [semantic-fetch-tags nil] 1)
semantic-idle-scheduler-refresh-tags()
(and (semantic-idle-scheduler-enabled-p)
(semantic-idle-scheduler-refresh-tags))
...
---------------------------------8<-------------------------------------
In GNU Emacs 24.4.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.12.2)
of 2014-06-10 on linux-xwl
Windowing system distributor `The X.Org Foundation', version 11.0.11501000
System Description: Debian GNU/Linux unstable (sid)
Configured using:
`configure --with-x-toolkit=gtk3'
--
William
http://xwl.appspot.com
[-- Attachment #1.2: Type: text/html, Size: 1723 bytes --]
[-- Attachment #2: 0001-Convert-non-decimal-integer-string-still-as-an-integ.patch --]
[-- Type: text/x-patch, Size: 1283 bytes --]
From 83f61b25fe896112420e4b9d00b7db8c8b6d8bcf Mon Sep 17 00:00:00 2001
From: William Xu <william.1.xu@microsoft.com>
Date: Thu, 19 Jun 2014 14:18:36 +0800
Subject: [PATCH] Convert non-decimal integer string still as an integer.
(hif-string-to-number): e.g., Change (hif-string-to-number "0F" 16) to
return `15' instead of `15.0'.
---
lisp/progmodes/hideif.el | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/lisp/progmodes/hideif.el b/lisp/progmodes/hideif.el
index bcb4659..ee144df 100644
--- a/lisp/progmodes/hideif.el
+++ b/lisp/progmodes/hideif.el
@@ -412,9 +412,13 @@ that form should be displayed.")
(if (or (not base) (= base 10))
(string-to-number string base)
(let* ((parts (split-string string "\\." t "[ \t]+"))
- (frac (cadr parts))
- (quot (expt (* base 1.0) (length frac))))
- (/ (string-to-number (concat (car parts) frac) base) quot))))
+ (frac (cadr parts))
+ (quot (expt (* base 1.0) (length frac)))
+ (num (/ (string-to-number (concat (car parts) frac) base)
+ quot)))
+ (if (= num (truncate num))
+ (truncate num)
+ num))))
(defun hif-tokenize (start end)
"Separate string between START and END into a list of tokens."
--
2.0.0
next reply other threads:[~2014-06-19 6:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-19 6:26 William Xu [this message]
2014-06-19 21:09 ` bug#17807: 24.4.50; hif-string-to-number convert a hex(or any non-decial) integer as float Stefan Monnier
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CACzMC-A+_OK6C-_Q-sq2WxBnkQ_wbJ4uhSYe2Y2iAdegpc3a_Q@mail.gmail.com \
--to=william.xwl@gmail.com \
--cc=17807@debbugs.gnu.org \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.