summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien <bzg@gnu.org>2020-02-19 10:39:37 +0100
committerBastien <bzg@gnu.org>2020-02-19 10:39:37 +0100
commit6b2a7cb20b357e730de151522fe4204c96615f98 (patch)
tree8637a377eed99911501578f98450584b0300ddfb
parent7e52b7661249acf5167bc8d8d1562ac3fefc0cd6 (diff)
downloadorg-mode-6b2a7cb20b357e730de151522fe4204c96615f98.tar.gz
ob-core.el: Correctly interpret all numbers
* lisp/ob-core.el (org-babel--string-to-number): Correctly interpret all numbers. Thanks to Vladimir Nikishkin for reporting this.
-rw-r--r--lisp/ob-core.el5
1 files changed, 3 insertions, 2 deletions
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index a6368ad..7846474 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2932,8 +2932,9 @@ situations in which is it not appropriate."
(defun org-babel--string-to-number (string)
"If STRING represents a number return its value.
Otherwise return nil."
- (and (string-match-p "\\`-?\\([0-9]\\|\\([1-9]\\|[0-9]*\\.\\)[0-9]*\\)\\'" string)
- (string-to-number string)))
+ (let ((interned-string (ignore-errors (read string))))
+ (when (numberp interned-string)
+ interned-string)))
(defun org-babel-import-elisp-from-file (file-name &optional separator)
"Read the results located at FILE-NAME into an elisp table.