Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id E895C431FBC for ; Sat, 15 Dec 2012 07:54:29 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OPr4bmucks1v for ; Sat, 15 Dec 2012 07:54:27 -0800 (PST) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) by olra.theworths.org (Postfix) with ESMTP id 97A0E431FB6 for ; Sat, 15 Dec 2012 07:54:27 -0800 (PST) Received: from guru.guru-group.fi (localhost [IPv6:::1]) by guru.guru-group.fi (Postfix) with ESMTP id D30DD10007E; Sat, 15 Dec 2012 17:54:21 +0200 (EET) From: Tomi Ollila To: Austin Clements , notmuch@notmuchmail.org Subject: Re: [PATCH] emacs: Fix bug in resynchronizing after a JSON parse error In-Reply-To: <1355497655-9571-1-git-send-email-amdragon@mit.edu> References: <1355497655-9571-1-git-send-email-amdragon@mit.edu> User-Agent: Notmuch/0.14+116~g29fcdb5 (http://notmuchmail.org) Emacs/24.2.1 (x86_64-unknown-linux-gnu) X-Face: HhBM'cA~ MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Dec 2012 15:54:30 -0000 On Fri, Dec 14 2012, Austin Clements wrote: > Previously, if the input stream consisted only of an error message, > notmuch-json-begin-compound would signal a (wrong-type-argument > number-or-marker-p nil) error when reaching the end of the error > message. This happened because notmuch-json-scan-to-value would think > that it reached a value and put the parser into the 'value state. > Even after notmuch-json-begin-compound signaled the syntax error, the > parser would remain in this state and when the resynchronization logic > reached the end of the buffer, the parser would fail because the > 'value state indicates that characters are available. > > This fixes this problem by restoring the parser's previous state if it > encounters a syntax error. > --- I couldn't understand this (setf... even reading the docstring (and no time to experiment) anyway the code change is pretty trivial and i cannot see what it could break. I believe the code works as expected, so +1 Tomi > > This patch was already okayed by Mark Walters [0] in the context of a > larger series. Since it's independent of that larger series, I'm > re-sending it separately. > > [0] id:87hanxgczt.fsf@qmul.ac.uk > > emacs/notmuch-lib.el | 22 +++++++++++++--------- > 1 file changed, 13 insertions(+), 9 deletions(-) > > diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el > index 9c4ee71..fb6d3e7 100644 > --- a/emacs/notmuch-lib.el > +++ b/emacs/notmuch-lib.el > @@ -465,15 +465,19 @@ Entering JSON objects is currently unimplemented." > (with-current-buffer (notmuch-json-buffer jp) > ;; Disallow terminators > (setf (notmuch-json-allow-term jp) nil) > - (or (notmuch-json-scan-to-value jp) > - (if (/= (char-after) ?\[) > - (signal 'json-readtable-error (list "expected '['")) > - (forward-char) > - (push ?\] (notmuch-json-term-stack jp)) > - ;; Expect a value or terminator next > - (setf (notmuch-json-next jp) 'expect-value > - (notmuch-json-allow-term jp) t) > - t)))) > + ;; Save "next" so we can restore it if there's a syntax error > + (let ((saved-next (notmuch-json-next jp))) > + (or (notmuch-json-scan-to-value jp) > + (if (/= (char-after) ?\[) > + (progn > + (setf (notmuch-json-next jp) saved-next) > + (signal 'json-readtable-error (list "expected '['"))) > + (forward-char) > + (push ?\] (notmuch-json-term-stack jp)) > + ;; Expect a value or terminator next > + (setf (notmuch-json-next jp) 'expect-value > + (notmuch-json-allow-term jp) t) > + t))))) > > (defun notmuch-json-read (jp) > "Parse the value at point in JP's buffer. > -- > 1.7.10.4 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch