branch: externals/yaml commit 20202d7c39f395533bf29ce884a52035916e81d0 Merge: 37a6b80ee3 5af0cd7c55 Author: Zachary Romero <zacrom...@posteo.net> Commit: GitHub <nore...@github.com>
Merge pull request #56 from zkry/fix-octal-hex-parsing Fix octal/hex parsing (#54) --- yaml-tests.el | 6 +++++- yaml.el | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/yaml-tests.el b/yaml-tests.el index acf56e5176..bfa70f3ac7 100644 --- a/yaml-tests.el +++ b/yaml-tests.el @@ -419,7 +419,11 @@ ship-to: "this is text")) (should (equal (yaml-parse-string "top: |1\n this is text" :object-type 'alist) - '((top . " this is text\n"))))) + '((top . " this is text\n")))) + (should (equal (yaml-parse-string "top: 0x10" :object-type 'alist) + '((top . 16)))) + (should (equal (yaml-parse-string "top: 0o10" :object-type 'alist) + '((top . 8))))) (ert-deftest yaml-parsing-completes () "Tests that the yaml parses." diff --git a/yaml.el b/yaml.el index 4b450434d6..bfa93cbdb0 100644 --- a/yaml.el +++ b/yaml.el @@ -305,9 +305,9 @@ This flag is intended for development purposes.") ((string-match "^[-+]?[0-9]+$" scalar) (string-to-number scalar)) ((string-match "^0o[0-7]+$" scalar) - (string-to-number scalar 8)) + (string-to-number (substring scalar 2) 8)) ((string-match "^0x[0-9a-fA-F]+$" scalar) - (string-to-number scalar 16)) + (string-to-number (substring scalar 2) 16)) ;; tag:yaml.org,2002:float ((string-match "^[-+]?\\(\\.[0-9]+\\|[0-9]+\\(\\.[0-9]*\\)?\\)\\([eE][-+]?[0-9]+\\)?$"