From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: sand@blarg.net Newsgroups: gmane.emacs.bugs,gmane.emacs.pretest.bugs Subject: bug#679: 23.0.60; Function json-read-number does not handle complete Javascript spec Date: 9 Aug 2008 07:05:28 -0000 Message-ID: <20080809070528.26869.qmail@priss.frightenedpiglet.com> Reply-To: sand@blarg.net, 679@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1218271664 12063 80.91.229.12 (9 Aug 2008 08:47:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 9 Aug 2008 08:47:44 +0000 (UTC) Cc: rfrancoise@debian.org To: emacs-pretest-bug@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Aug 09 10:48:33 2008 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KRk7l-0005m6-4r for geb-bug-gnu-emacs@m.gmane.org; Sat, 09 Aug 2008 10:48:33 +0200 Original-Received: from localhost ([127.0.0.1]:56398 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KRk6p-0006s0-Eb for geb-bug-gnu-emacs@m.gmane.org; Sat, 09 Aug 2008 04:47:35 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KRk6k-0006qT-GS for bug-gnu-emacs@gnu.org; Sat, 09 Aug 2008 04:47:30 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KRk6h-0006kJ-GV for bug-gnu-emacs@gnu.org; Sat, 09 Aug 2008 04:47:29 -0400 Original-Received: from [199.232.76.173] (port=50837 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KRk6h-0006k1-AN for bug-gnu-emacs@gnu.org; Sat, 09 Aug 2008 04:47:27 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:55261) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KRk6g-0001JW-JC for bug-gnu-emacs@gnu.org; Sat, 09 Aug 2008 04:47:26 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m798lNsn029453; Sat, 9 Aug 2008 01:47:23 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id m798j4TV028287; Sat, 9 Aug 2008 01:45:04 -0700 X-Loop: don@donarmstrong.com Resent-From: sand@blarg.net Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Sat, 09 Aug 2008 08:45:04 +0000 Resent-Message-ID: Resent-Sender: don@donarmstrong.com X-Emacs-PR-Message: report 679 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by submit@emacsbugs.donarmstrong.com id=B.121827103726489 (code B ref -1); Sat, 09 Aug 2008 08:45:04 +0000 Original-Received: (at submit) by emacsbugs.donarmstrong.com; 9 Aug 2008 08:37:17 +0000 Original-Received: from fencepost.gnu.org (fencepost.gnu.org [140.186.70.10]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m798bDHO026483 for ; Sat, 9 Aug 2008 01:37:14 -0700 Original-Received: from mail.gnu.org ([199.232.76.166]:53052 helo=mx10.gnu.org) by fencepost.gnu.org with esmtp (Exim 4.67) (envelope-from ) id 1KRjvj-0003KO-4D for emacs-pretest-bug@gnu.org; Sat, 09 Aug 2008 04:36:07 -0400 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1KRjwk-000845-Qq for emacs-pretest-bug@gnu.org; Sat, 09 Aug 2008 04:37:12 -0400 Original-Received: from v-static-143-234.avvanta.com ([206.124.143.234]:47102 helo=priss.frightenedpiglet.com) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1KRjwk-0007xU-3O for emacs-pretest-bug@gnu.org; Sat, 09 Aug 2008 04:37:10 -0400 Original-Received: (qmail 26870 invoked by uid 1000); 9 Aug 2008 07:05:28 -0000 X-URL: http://home.blarg.net/~sand X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) X-Greylist: delayed 1951 seconds by postgrey-1.27 at monty-python; Sat, 09 Aug 2008 04:36:46 EDT X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) Resent-Date: Sat, 09 Aug 2008 04:47:29 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:19180 gmane.emacs.pretest.bugs:22806 Archived-At: ---- In json.el, the 'json-read-number' function is intended to read the textual representation of Javascript numbers. (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) ?-) (progn (json-advance) (- 0 (json-read-number))) (if (looking-at "[0-9]+\\([.][0-9]+\\)?\\([eE][+-]?[0-9]+\\)?") (progn (goto-char (match-end 0)) (string-to-number (match-string 0))) (signal 'json-number-format (list (point)))))) The Javascript spec (http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Literals#Floating-Point_Literals) 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 1. 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 .1 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. ---- In GNU Emacs 23.0.60.1 (i486-pc-linux-gnu, GTK+ Version 2.12.11) of 2008-07-27 on elegiac, modified by Debian (emacs-snapshot package, version 1:20080727-1) Windowing system distributor `The X.Org Foundation', version 11.0.10402000 configured using `configure '--build' 'i486-linux-gnu' '--host' 'i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/23.0.60/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.0.60/site-lisp:/usr/share/emacs/site-lisp' '--with-x=yes' '--with-x-toolkit=gtk' 'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu' 'CFLAGS=-DDEBIAN -DSITELOAD_PURESIZE_EXTRA=5000 -g -O2' 'LDFLAGS=-g -Wl,--as-needed' 'CPPFLAGS='' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: POSIX value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: en_US.UTF-8 value of $XMODIFIERS: nil locale-coding-system: utf-8-unix default-enable-multibyte-characters: t Major mode: VM Minor modes in effect: shell-dirtrack-mode: t auto-image-file-mode: t show-paren-mode: t icomplete-mode: t tooltip-mode: t mouse-wheel-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t global-auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t