Browse Source

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.
Bastien 5 years ago
parent
commit
6b2a7cb20b
1 changed files with 3 additions and 2 deletions
  1. 3 2
      lisp/ob-core.el

+ 3 - 2
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.