[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#679: 23.0.60; Function json-read-number does not handle complete Jav
Tue, 12 Aug 2008 23:42:26 -0400
Could you take a look at this bug report?
In json.el, the 'json-read-number' function is intended to read the
(defun json-read-number ()
"Read the JSON number following point.
N.B.: Only numbers which can fit in Emacs Lisp's native number
representation will be parsed correctly."
(if (char-equal (json-peek) ?-)
(- 0 (json-read-number)))
(if (looking-at "[0-9]+\\([.][0-9]+\\)?\\([eE][+-]?[0-9]+\\)?")
(goto-char (match-end 0))
(string-to-number (match-string 0)))
(signal 'json-number-format (list (point))))))
says the following about floating-point numbers:
| A floating-point literal can have the following parts:
| * A decimal integer which can be signed (preceded by "+" or "-"),
| * A decimal point ("."),
| * A fraction (another decimal number),
| * An exponent.
| The exponent part is an "e" or "E" followed by an integer, which can
| be signed (preceded by "+" or "-"). A floating-point literal must have
| at least one digit and either a decimal point or "e" (or "E").
This means that
is a valid floating point-literal per the spec, but the regular
expression above does not match the complete text---the regular
expression requires digits after the decimal point. This ends up
matched as a simple integer, leaving the decimal point in the input
stream and causing a later syntax error. Similarly
is a valid floating point-literal illegal that Emacs rejects, because
the regular expression requires digits before the decimal point.
Testing with the error console in Firefox confirms that the two
examples above are valid syntax.
The parser function needs to be fixed to handle the complete syntax.
Chong Yidong <=